From cf4d0e0ddd6d9d8808bde59d8b62acb4ff7f1750 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:36:24 +0000 Subject: [PATCH 1/3] feat: [Many APIs] Add support for opt-in debug logging (#13348) BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: https://github.com/googleapis/googleapis/commit/f9b8b9150f7fcd600b0acaeef91236b1843f5e49 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca1e0a1e472d6e6f5de883a5cb54724f112ce348 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRwdS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRyYWNlLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRyYW5zbGF0ZS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpZGVvLWxpdmUtc3RyZWFtLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpZGVvLXN0aXRjaGVyLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpZGVvLXRyYW5zY29kZXIvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpZGVvaW50ZWxsaWdlbmNlLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpc2lvbi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpc2lvbmFpLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZtLW1pZ3JhdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZtd2FyZWVuZ2luZS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZwYy1hY2Nlc3MvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXdlYnJpc2svLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXdlYnNlY3VyaXR5c2Nhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXdvcmtmbG93cy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXdvcmtzdGF0aW9ucy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtYWRkcmVzc3ZhbGlkYXRpb24vLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtYXJlYWluc2lnaHRzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtZmxlZXRlbmdpbmUtZGVsaXZlcnkvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtZmxlZXRlbmdpbmUvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/tpu/gapic_version.py | 2 +- .../google/cloud/tpu_v1/gapic_version.py | 2 +- .../cloud/tpu_v1/services/tpu/async_client.py | 168 +- .../cloud/tpu_v1/services/tpu/client.py | 173 +- .../cloud/tpu_v1/services/tpu/pagers.py | 48 +- .../tpu_v1/services/tpu/transports/grpc.py | 128 +- .../services/tpu/transports/grpc_asyncio.py | 125 +- .../google/cloud/tpu_v2/gapic_version.py | 2 +- .../cloud/tpu_v2/services/tpu/async_client.py | 184 +- .../cloud/tpu_v2/services/tpu/client.py | 189 +- .../cloud/tpu_v2/services/tpu/pagers.py | 48 +- .../tpu_v2/services/tpu/transports/grpc.py | 132 +- .../services/tpu/transports/grpc_asyncio.py | 129 +- .../tpu_v2/services/tpu/transports/rest.py | 1187 +++- .../cloud/tpu_v2alpha1/gapic_version.py | 2 +- .../tpu_v2alpha1/services/tpu/async_client.py | 232 +- .../cloud/tpu_v2alpha1/services/tpu/client.py | 237 +- .../cloud/tpu_v2alpha1/services/tpu/pagers.py | 64 +- .../services/tpu/transports/grpc.py | 146 +- .../services/tpu/transports/grpc_asyncio.py | 143 +- .../snippet_metadata_google.cloud.tpu.v1.json | 46 +- .../snippet_metadata_google.cloud.tpu.v2.json | 54 +- ...et_metadata_google.cloud.tpu.v2alpha1.json | 78 +- .../tests/unit/gapic/tpu_v2/test_tpu.py | 73 + .../google/cloud/trace/gapic_version.py | 2 +- .../google/cloud/trace_v1/gapic_version.py | 2 +- .../services/trace_service/async_client.py | 56 +- .../trace_v1/services/trace_service/client.py | 61 +- .../trace_v1/services/trace_service/pagers.py | 16 +- .../services/trace_service/transports/grpc.py | 96 +- .../trace_service/transports/grpc_asyncio.py | 95 +- .../services/trace_service/transports/rest.py | 180 +- .../google/cloud/trace_v2/gapic_version.py | 2 +- .../services/trace_service/async_client.py | 48 +- .../trace_v2/services/trace_service/client.py | 53 +- .../services/trace_service/transports/grpc.py | 94 +- .../trace_service/transports/grpc_asyncio.py | 93 +- .../services/trace_service/transports/rest.py | 112 +- ...etadata_google.devtools.cloudtrace.v1.json | 14 +- ...etadata_google.devtools.cloudtrace.v2.json | 10 +- .../unit/gapic/trace_v1/test_trace_service.py | 15 + .../unit/gapic/trace_v2/test_trace_service.py | 9 + .../google/cloud/translate/gapic_version.py | 2 +- .../cloud/translate_v3/gapic_version.py | 2 +- .../translation_service/async_client.py | 392 +- .../services/translation_service/client.py | 397 +- .../services/translation_service/pagers.py | 128 +- .../translation_service/transports/grpc.py | 190 +- .../transports/grpc_asyncio.py | 187 +- .../translation_service/transports/rest.py | 2812 ++++++++- .../cloud/translate_v3beta1/gapic_version.py | 2 +- .../translation_service/async_client.py | 112 +- .../services/translation_service/client.py | 117 +- .../services/translation_service/pagers.py | 16 +- .../translation_service/transports/grpc.py | 114 +- .../transports/grpc_asyncio.py | 111 +- .../translation_service/transports/rest.py | 663 ++- ..._metadata_google.cloud.translation.v3.json | 154 +- ...data_google.cloud.translation.v3beta1.json | 42 +- .../translate_v3/test_translation_service.py | 202 + .../test_translation_service.py | 47 + .../cloud/video/live_stream/gapic_version.py | 2 +- .../video/live_stream_v1/gapic_version.py | 2 +- .../livestream_service/async_client.py | 288 +- .../services/livestream_service/client.py | 293 +- .../services/livestream_service/pagers.py | 80 +- .../livestream_service/transports/grpc.py | 158 +- .../transports/grpc_asyncio.py | 155 +- .../livestream_service/transports/rest.py | 1988 +++++- ...data_google.cloud.video.livestream.v1.json | 106 +- .../live_stream_v1/test_livestream_service.py | 142 + .../cloud/video/stitcher/gapic_version.py | 2 +- .../cloud/video/stitcher_v1/gapic_version.py | 2 +- .../video_stitcher_service/async_client.py | 304 +- .../services/video_stitcher_service/client.py | 309 +- .../services/video_stitcher_service/pagers.py | 112 +- .../video_stitcher_service/transports/grpc.py | 162 +- .../transports/grpc_asyncio.py | 159 +- ...tadata_google.cloud.video.stitcher.v1.json | 122 +- .../cloud/video/transcoder/gapic_version.py | 2 +- .../video/transcoder_v1/gapic_version.py | 2 +- .../transcoder_service/async_client.py | 96 +- .../services/transcoder_service/client.py | 101 +- .../services/transcoder_service/pagers.py | 32 +- .../transcoder_service/transports/grpc.py | 106 +- .../transports/grpc_asyncio.py | 105 +- .../transcoder_service/transports/rest.py | 478 +- ...data_google.cloud.video.transcoder.v1.json | 34 +- .../transcoder_v1/test_transcoder_service.py | 40 + .../cloud/videointelligence/gapic_version.py | 2 +- .../videointelligence_v1/gapic_version.py | 2 +- .../async_client.py | 40 +- .../video_intelligence_service/client.py | 45 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- .../gapic_version.py | 2 +- .../async_client.py | 40 +- .../video_intelligence_service/client.py | 45 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- .../gapic_version.py | 2 +- .../async_client.py | 40 +- .../video_intelligence_service/client.py | 45 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- .../gapic_version.py | 2 +- .../async_client.py | 40 +- .../video_intelligence_service/client.py | 45 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- .../gapic_version.py | 2 +- .../async_client.py | 40 +- .../client.py | 45 +- .../transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../async_client.py | 40 +- .../video_intelligence_service/client.py | 45 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 93 +- ...ata_google.cloud.videointelligence.v1.json | 6 +- ...oogle.cloud.videointelligence.v1beta2.json | 6 +- ...gle.cloud.videointelligence.v1p1beta1.json | 6 +- ...gle.cloud.videointelligence.v1p2beta1.json | 6 +- ...gle.cloud.videointelligence.v1p3beta1.json | 10 +- .../test_video_intelligence_service.py | 5 + .../test_video_intelligence_service.py | 5 + .../test_video_intelligence_service.py | 5 + .../test_video_intelligence_service.py | 5 + .../google/cloud/vision/gapic_version.py | 2 +- .../google/cloud/vision_v1/gapic_version.py | 2 +- .../services/image_annotator/async_client.py | 72 +- .../services/image_annotator/client.py | 77 +- .../image_annotator/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 105 +- .../image_annotator/transports/rest.py | 333 +- .../services/product_search/async_client.py | 192 +- .../services/product_search/client.py | 197 +- .../services/product_search/pagers.py | 64 +- .../product_search/transports/grpc.py | 138 +- .../product_search/transports/grpc_asyncio.py | 135 +- .../product_search/transports/rest.py | 1194 +++- .../cloud/vision_v1p1beta1/gapic_version.py | 2 +- .../services/image_annotator/async_client.py | 40 +- .../services/image_annotator/client.py | 45 +- .../image_annotator/transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../image_annotator/transports/rest.py | 77 +- .../cloud/vision_v1p2beta1/gapic_version.py | 2 +- .../services/image_annotator/async_client.py | 48 +- .../services/image_annotator/client.py | 53 +- .../image_annotator/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../image_annotator/transports/rest.py | 140 +- .../cloud/vision_v1p3beta1/gapic_version.py | 2 +- .../services/image_annotator/async_client.py | 48 +- .../services/image_annotator/client.py | 53 +- .../image_annotator/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../image_annotator/transports/rest.py | 140 +- .../services/product_search/async_client.py | 176 +- .../services/product_search/client.py | 181 +- .../services/product_search/pagers.py | 64 +- .../product_search/transports/grpc.py | 134 +- .../product_search/transports/grpc_asyncio.py | 131 +- .../product_search/transports/rest.py | 1066 +++- .../cloud/vision_v1p4beta1/gapic_version.py | 2 +- .../services/image_annotator/async_client.py | 64 +- .../services/image_annotator/client.py | 69 +- .../image_annotator/transports/grpc.py | 106 +- .../transports/grpc_asyncio.py | 103 +- .../image_annotator/transports/rest.py | 270 +- .../services/product_search/async_client.py | 184 +- .../services/product_search/client.py | 189 +- .../services/product_search/pagers.py | 64 +- .../product_search/transports/grpc.py | 136 +- .../product_search/transports/grpc_asyncio.py | 133 +- .../product_search/transports/rest.py | 1131 +++- ...ippet_metadata_google.cloud.vision.v1.json | 94 +- ...etadata_google.cloud.vision.v1p1beta1.json | 6 +- ...etadata_google.cloud.vision.v1p2beta1.json | 10 +- ...etadata_google.cloud.vision.v1p3beta1.json | 82 +- ...etadata_google.cloud.vision.v1p4beta1.json | 94 +- .../gapic/vision_v1/test_image_annotator.py | 22 + .../gapic/vision_v1/test_product_search.py | 97 + .../vision_v1p1beta1/test_image_annotator.py | 5 + .../vision_v1p2beta1/test_image_annotator.py | 10 + .../vision_v1p3beta1/test_image_annotator.py | 10 + .../vision_v1p3beta1/test_product_search.py | 90 + .../vision_v1p4beta1/test_image_annotator.py | 20 + .../vision_v1p4beta1/test_product_search.py | 95 + .../google/cloud/visionai/gapic_version.py | 2 +- .../google/cloud/visionai_v1/gapic_version.py | 2 +- .../services/app_platform/async_client.py | 272 +- .../services/app_platform/client.py | 277 +- .../services/app_platform/pagers.py | 64 +- .../services/app_platform/transports/grpc.py | 162 +- .../app_platform/transports/grpc_asyncio.py | 159 +- .../services/app_platform/transports/rest.py | 1888 +++++- .../health_check_service/async_client.py | 72 +- .../services/health_check_service/client.py | 77 +- .../health_check_service/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 99 +- .../health_check_service/transports/rest.py | 286 +- .../live_video_analytics/async_client.py | 208 +- .../services/live_video_analytics/client.py | 213 +- .../services/live_video_analytics/pagers.py | 64 +- .../live_video_analytics/transports/grpc.py | 138 +- .../transports/grpc_asyncio.py | 135 +- .../live_video_analytics/transports/rest.py | 1376 ++++- .../streaming_service/async_client.py | 112 +- .../services/streaming_service/client.py | 117 +- .../streaming_service/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../streaming_service/transports/rest.py | 420 +- .../services/streams_service/async_client.py | 248 +- .../services/streams_service/client.py | 253 +- .../services/streams_service/pagers.py | 64 +- .../streams_service/transports/grpc.py | 148 +- .../transports/grpc_asyncio.py | 145 +- .../streams_service/transports/rest.py | 1703 +++++- .../services/warehouse/async_client.py | 568 +- .../visionai_v1/services/warehouse/client.py | 573 +- .../visionai_v1/services/warehouse/pagers.py | 208 +- .../services/warehouse/transports/grpc.py | 228 +- .../warehouse/transports/grpc_asyncio.py | 225 +- .../services/warehouse/transports/rest.py | 4090 +++++++++++-- .../cloud/visionai_v1alpha1/gapic_version.py | 2 +- .../services/app_platform/async_client.py | 312 +- .../services/app_platform/client.py | 317 +- .../services/app_platform/pagers.py | 64 +- .../services/app_platform/transports/grpc.py | 172 +- .../app_platform/transports/grpc_asyncio.py | 169 +- .../services/app_platform/transports/rest.py | 2204 ++++++- .../live_video_analytics/async_client.py | 144 +- .../services/live_video_analytics/client.py | 149 +- .../services/live_video_analytics/pagers.py | 16 +- .../live_video_analytics/transports/grpc.py | 122 +- .../transports/grpc_asyncio.py | 119 +- .../live_video_analytics/transports/rest.py | 856 ++- .../streaming_service/async_client.py | 152 +- .../services/streaming_service/client.py | 157 +- .../streaming_service/transports/grpc.py | 120 +- .../transports/grpc_asyncio.py | 119 +- .../streaming_service/transports/rest.py | 736 ++- .../services/streams_service/async_client.py | 280 +- .../services/streams_service/client.py | 285 +- .../services/streams_service/pagers.py | 64 +- .../streams_service/transports/grpc.py | 156 +- .../transports/grpc_asyncio.py | 153 +- .../streams_service/transports/rest.py | 1954 +++++- .../services/warehouse/async_client.py | 336 +- .../services/warehouse/client.py | 341 +- .../services/warehouse/pagers.py | 96 +- .../services/warehouse/transports/grpc.py | 170 +- .../warehouse/transports/grpc_asyncio.py | 167 +- .../services/warehouse/transports/rest.py | 2238 ++++++- ...pet_metadata_google.cloud.visionai.v1.json | 550 +- ...tadata_google.cloud.visionai.v1alpha1.json | 354 +- .../gapic/visionai_v1/test_app_platform.py | 138 + .../visionai_v1/test_health_check_service.py | 11 + .../visionai_v1/test_live_video_analytics.py | 98 + .../visionai_v1/test_streaming_service.py | 17 + .../gapic/visionai_v1/test_streams_service.py | 123 + .../unit/gapic/visionai_v1/test_warehouse.py | 304 + .../visionai_v1alpha1/test_app_platform.py | 148 + .../test_live_video_analytics.py | 43 + .../test_streaming_service.py | 27 + .../visionai_v1alpha1/test_streams_service.py | 128 + .../gapic/visionai_v1alpha1/test_warehouse.py | 154 + .../google/cloud/vmmigration/gapic_version.py | 2 +- .../cloud/vmmigration_v1/gapic_version.py | 2 +- .../services/vm_migration/async_client.py | 448 +- .../services/vm_migration/client.py | 453 +- .../services/vm_migration/pagers.py | 144 +- .../services/vm_migration/transports/grpc.py | 204 +- .../vm_migration/transports/grpc_asyncio.py | 201 +- .../services/vm_migration/transports/rest.py | 3302 +++++++++- ..._metadata_google.cloud.vmmigration.v1.json | 186 +- .../gapic/vmmigration_v1/test_vm_migration.py | 239 + .../vmmigration-v1-py.tar.gz | Bin 65536 -> 0 bytes .../cloud/vmwareengine/gapic_version.py | 2 +- .../cloud/vmwareengine_v1/gapic_version.py | 2 +- .../services/vmware_engine/async_client.py | 688 ++- .../services/vmware_engine/client.py | 693 ++- .../services/vmware_engine/pagers.py | 272 +- .../services/vmware_engine/transports/grpc.py | 276 +- .../vmware_engine/transports/grpc_asyncio.py | 273 +- .../services/vmware_engine/transports/rest.py | 5304 +++++++++++++++-- ...metadata_google.cloud.vmwareengine.v1.json | 298 +- .../vmwareengine_v1/test_vmware_engine.py | 386 ++ .../google/cloud/vpcaccess/gapic_version.py | 2 +- .../cloud/vpcaccess_v1/gapic_version.py | 2 +- .../vpc_access_service/async_client.py | 88 +- .../services/vpc_access_service/client.py | 93 +- .../services/vpc_access_service/pagers.py | 16 +- .../vpc_access_service/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 105 +- .../vpc_access_service/transports/rest.py | 455 +- ...et_metadata_google.cloud.vpcaccess.v1.json | 18 +- .../vpcaccess_v1/test_vpc_access_service.py | 26 + .../google/cloud/webrisk/gapic_version.py | 2 +- .../google/cloud/webrisk_v1/gapic_version.py | 2 +- .../services/web_risk_service/async_client.py | 104 +- .../services/web_risk_service/client.py | 109 +- .../web_risk_service/transports/grpc.py | 112 +- .../transports/grpc_asyncio.py | 109 +- .../web_risk_service/transports/rest.py | 542 +- .../cloud/webrisk_v1beta1/gapic_version.py | 2 +- .../web_risk_service_v1_beta1/async_client.py | 56 +- .../web_risk_service_v1_beta1/client.py | 61 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../transports/rest.py | 204 +- ...ppet_metadata_google.cloud.webrisk.v1.json | 22 +- ...metadata_google.cloud.webrisk.v1beta1.json | 14 +- .../gapic/webrisk_v1/test_web_risk_service.py | 32 + .../test_web_risk_service_v1_beta1.py | 15 + .../webrisk-v1beta1-py.tar.gz | 0 .../cloud/websecurityscanner/gapic_version.py | 2 +- .../websecurityscanner_v1/gapic_version.py | 2 +- .../web_security_scanner/async_client.py | 136 +- .../services/web_security_scanner/client.py | 141 +- .../services/web_security_scanner/pagers.py | 64 +- .../web_security_scanner/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../web_security_scanner/transports/rest.py | 840 ++- .../gapic_version.py | 2 +- .../web_security_scanner/async_client.py | 136 +- .../services/web_security_scanner/client.py | 141 +- .../services/web_security_scanner/pagers.py | 64 +- .../web_security_scanner/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../web_security_scanner/transports/rest.py | 840 ++- .../gapic_version.py | 2 +- .../web_security_scanner/async_client.py | 136 +- .../services/web_security_scanner/client.py | 141 +- .../services/web_security_scanner/pagers.py | 64 +- .../web_security_scanner/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../web_security_scanner/transports/rest.py | 840 ++- ...ta_google.cloud.websecurityscanner.v1.json | 54 +- ...ogle.cloud.websecurityscanner.v1alpha.json | 54 +- ...oogle.cloud.websecurityscanner.v1beta.json | 54 +- .../test_web_security_scanner.py | 39 + .../test_web_security_scanner.py | 65 + .../test_web_security_scanner.py | 65 + .../workflows/executions/gapic_version.py | 2 +- .../workflows/executions_v1/gapic_version.py | 2 +- .../services/executions/async_client.py | 64 +- .../services/executions/client.py | 69 +- .../services/executions/pagers.py | 16 +- .../services/executions/transports/grpc.py | 98 +- .../executions/transports/grpc_asyncio.py | 97 +- .../executions_v1beta/gapic_version.py | 2 +- .../services/executions/async_client.py | 64 +- .../services/executions/client.py | 69 +- .../services/executions/pagers.py | 16 +- .../services/executions/transports/grpc.py | 98 +- .../executions/transports/grpc_asyncio.py | 97 +- .../google/cloud/workflows/gapic_version.py | 2 +- .../cloud/workflows_v1/gapic_version.py | 2 +- .../services/workflows/async_client.py | 112 +- .../workflows_v1/services/workflows/client.py | 117 +- .../workflows_v1/services/workflows/pagers.py | 16 +- .../services/workflows/transports/grpc.py | 114 +- .../workflows/transports/grpc_asyncio.py | 111 +- .../services/workflows/transports/rest.py | 622 +- .../cloud/workflows_v1beta/gapic_version.py | 2 +- .../services/workflows/async_client.py | 72 +- .../services/workflows/client.py | 77 +- .../services/workflows/pagers.py | 16 +- .../services/workflows/transports/grpc.py | 104 +- .../workflows/transports/grpc_asyncio.py | 101 +- .../services/workflows/transports/rest.py | 328 +- ..._google.cloud.workflows.executions.v1.json | 18 +- ...gle.cloud.workflows.executions.v1beta.json | 18 +- ...et_metadata_google.cloud.workflows.v1.json | 22 +- ...etadata_google.cloud.workflows.v1beta.json | 22 +- .../unit/gapic/workflows_v1/test_workflows.py | 35 + .../gapic/workflows_v1beta/test_workflows.py | 25 + .../cloud/workstations/gapic_version.py | 2 +- .../cloud/workstations_v1/gapic_version.py | 2 +- .../services/workstations/async_client.py | 248 +- .../services/workstations/client.py | 253 +- .../services/workstations/pagers.py | 80 +- .../services/workstations/transports/grpc.py | 154 +- .../workstations/transports/grpc_asyncio.py | 151 +- .../services/workstations/transports/rest.py | 1714 +++++- .../workstations_v1beta/gapic_version.py | 2 +- .../services/workstations/async_client.py | 248 +- .../services/workstations/client.py | 253 +- .../services/workstations/pagers.py | 80 +- .../services/workstations/transports/grpc.py | 154 +- .../workstations/transports/grpc_asyncio.py | 151 +- .../services/workstations/transports/rest.py | 1714 +++++- ...metadata_google.cloud.workstations.v1.json | 82 +- ...data_google.cloud.workstations.v1beta.json | 82 +- .../workstations_v1/test_workstations.py | 114 + .../workstations_v1beta/test_workstations.py | 114 + .../maps/addressvalidation/gapic_version.py | 2 +- .../addressvalidation_v1/gapic_version.py | 2 +- .../address_validation/async_client.py | 48 +- .../services/address_validation/client.py | 53 +- .../address_validation/transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../address_validation/transports/rest.py | 141 +- ...data_google.maps.addressvalidation.v1.json | 10 +- .../test_address_validation.py | 8 + .../google/maps/areainsights/gapic_version.py | 2 +- .../maps/areainsights_v1/gapic_version.py | 2 +- .../services/area_insights/async_client.py | 40 +- .../services/area_insights/client.py | 45 +- .../services/area_insights/transports/grpc.py | 92 +- .../area_insights/transports/grpc_asyncio.py | 91 +- .../services/area_insights/transports/rest.py | 77 +- ..._metadata_google.maps.areainsights.v1.json | 6 +- .../areainsights_v1/test_area_insights.py | 4 + .../fleetengine_delivery/gapic_version.py | 2 +- .../fleetengine_delivery_v1/gapic_version.py | 2 +- .../services/delivery_service/async_client.py | 112 +- .../services/delivery_service/client.py | 117 +- .../services/delivery_service/pagers.py | 32 +- .../delivery_service/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../delivery_service/transports/rest.py | 659 +- ...metadata_maps.fleetengine.delivery.v1.json | 42 +- .../test_delivery_service.py | 49 + .../services/trip_service/async_client.py | 72 +- .../services/trip_service/client.py | 77 +- .../services/trip_service/pagers.py | 16 +- .../services/trip_service/transports/grpc.py | 100 +- .../trip_service/transports/grpc_asyncio.py | 99 +- .../services/vehicle_service/async_client.py | 80 +- .../services/vehicle_service/client.py | 85 +- .../services/vehicle_service/pagers.py | 16 +- .../vehicle_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 101 +- .../snippet_metadata_maps.fleetengine.v1.json | 44 +- 442 files changed, 73632 insertions(+), 13366 deletions(-) create mode 100644 packages/google-cloud-webrisk/webrisk-v1beta1-py.tar.gz diff --git a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py index f42787b20d66..ca6a215bb069 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tpu_v1.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes. @@ -309,8 +341,10 @@ async def sample_list_nodes(): 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, 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: google.cloud.tpu_v1.services.tpu.pagers.ListNodesAsyncPager: @@ -385,7 +419,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -426,8 +460,10 @@ async def sample_get_node(): 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, 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: google.cloud.tpu_v1.types.Node: @@ -486,7 +522,7 @@ async def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a node. @@ -547,8 +583,10 @@ async def sample_create_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -623,7 +661,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a node. @@ -669,8 +707,10 @@ async def sample_delete_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -740,7 +780,7 @@ async def reimage_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Reimages a node's OS. @@ -780,8 +820,10 @@ async def sample_reimage_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -837,7 +879,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops a node, this operation is only available with single TPU nodes. @@ -878,8 +920,10 @@ async def sample_stop_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -935,7 +979,7 @@ async def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a node. @@ -975,8 +1019,10 @@ async def sample_start_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1033,7 +1079,7 @@ async def list_tensor_flow_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTensorFlowVersionsAsyncPager: r"""List TensorFlow versions supported by this API. @@ -1076,8 +1122,10 @@ async def sample_list_tensor_flow_versions(): 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, 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: google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsAsyncPager: @@ -1152,7 +1200,7 @@ async def get_tensor_flow_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1194,8 +1242,10 @@ async def sample_get_tensor_flow_version(): 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, 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: google.cloud.tpu_v1.types.TensorFlowVersion: @@ -1256,7 +1306,7 @@ async def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1299,8 +1349,10 @@ async def sample_list_accelerator_types(): 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, 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: google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1375,7 +1427,7 @@ async def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1417,8 +1469,10 @@ async def sample_get_accelerator_type(): 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, 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: google.cloud.tpu_v1.types.AcceleratorType: @@ -1478,7 +1532,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1489,8 +1543,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1531,7 +1587,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1542,8 +1598,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1584,7 +1642,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1600,8 +1658,10 @@ async def delete_operation( 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, 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: None """ @@ -1638,7 +1698,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1653,8 +1713,10 @@ async def cancel_operation( 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, 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: None """ @@ -1691,7 +1753,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1702,8 +1764,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1744,7 +1808,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1755,8 +1819,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py index 8bf1b851b3bb..95e06b1d5f5a 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -627,6 +637,10 @@ def __init__( # 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( @@ -687,6 +701,29 @@ def __init__( 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.tpu_v1.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -694,7 +731,7 @@ def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes. @@ -737,8 +774,10 @@ def sample_list_nodes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.services.tpu.pagers.ListNodesPager: @@ -810,7 +849,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -851,8 +890,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.types.Node: @@ -910,7 +951,7 @@ def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a node. @@ -971,8 +1012,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1044,7 +1087,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a node. @@ -1090,8 +1133,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1158,7 +1203,7 @@ def reimage_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Reimages a node's OS. @@ -1198,8 +1243,10 @@ def sample_reimage_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1253,7 +1300,7 @@ def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops a node, this operation is only available with single TPU nodes. @@ -1294,8 +1341,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1349,7 +1398,7 @@ def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a node. @@ -1389,8 +1438,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1445,7 +1496,7 @@ def list_tensor_flow_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTensorFlowVersionsPager: r"""List TensorFlow versions supported by this API. @@ -1488,8 +1539,10 @@ def sample_list_tensor_flow_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsPager: @@ -1563,7 +1616,7 @@ def get_tensor_flow_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1605,8 +1658,10 @@ def sample_get_tensor_flow_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.types.TensorFlowVersion: @@ -1664,7 +1719,7 @@ def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1707,8 +1762,10 @@ def sample_list_accelerator_types(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesPager: @@ -1780,7 +1837,7 @@ def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1822,8 +1879,10 @@ def sample_get_accelerator_type(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v1.types.AcceleratorType: @@ -1893,7 +1952,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1904,8 +1963,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1946,7 +2007,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1957,8 +2018,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1999,7 +2062,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2015,8 +2078,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2053,7 +2118,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2068,8 +2133,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2106,7 +2173,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2117,8 +2184,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2159,7 +2228,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2170,8 +2239,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py index 5e1edf534b06..9f25db672583 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListTensorFlowVersionsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListTensorFlowVersionsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py index a48eb87a4628..03c0452af25d 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tpu_v1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +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.tpu.v1.Tpu", + "rpcName": 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.tpu.v1.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -374,7 +462,7 @@ def reimage_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reimage_node" not in self._stubs: - self._stubs["reimage_node"] = self.grpc_channel.unary_unary( + self._stubs["reimage_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ReimageNode", request_serializer=cloud_tpu.ReimageNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -456,7 +544,7 @@ def list_tensor_flow_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tensor_flow_versions" not in self._stubs: - self._stubs["list_tensor_flow_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_tensor_flow_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListTensorFlowVersions", request_serializer=cloud_tpu.ListTensorFlowVersionsRequest.serialize, response_deserializer=cloud_tpu.ListTensorFlowVersionsResponse.deserialize, @@ -482,7 +570,7 @@ def get_tensor_flow_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tensor_flow_version" not in self._stubs: - self._stubs["get_tensor_flow_version"] = self.grpc_channel.unary_unary( + self._stubs["get_tensor_flow_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetTensorFlowVersion", request_serializer=cloud_tpu.GetTensorFlowVersionRequest.serialize, response_deserializer=cloud_tpu.TensorFlowVersion.deserialize, @@ -510,7 +598,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -536,7 +624,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -544,7 +632,7 @@ def get_accelerator_type( return self._stubs["get_accelerator_type"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -556,7 +644,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -573,7 +661,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -590,7 +678,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -609,7 +697,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -628,7 +716,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -645,7 +733,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py index 1437d0ebc801..17f4b939c3b1 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tpu_v1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +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.tpu.v1.Tpu", + "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.tpu.v1.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def reimage_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reimage_node" not in self._stubs: - self._stubs["reimage_node"] = self.grpc_channel.unary_unary( + self._stubs["reimage_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ReimageNode", request_serializer=cloud_tpu.ReimageNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -468,7 +553,7 @@ def list_tensor_flow_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tensor_flow_versions" not in self._stubs: - self._stubs["list_tensor_flow_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_tensor_flow_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListTensorFlowVersions", request_serializer=cloud_tpu.ListTensorFlowVersionsRequest.serialize, response_deserializer=cloud_tpu.ListTensorFlowVersionsResponse.deserialize, @@ -496,7 +581,7 @@ def get_tensor_flow_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tensor_flow_version" not in self._stubs: - self._stubs["get_tensor_flow_version"] = self.grpc_channel.unary_unary( + self._stubs["get_tensor_flow_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetTensorFlowVersion", request_serializer=cloud_tpu.GetTensorFlowVersionRequest.serialize, response_deserializer=cloud_tpu.TensorFlowVersion.deserialize, @@ -525,7 +610,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -553,7 +638,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -656,7 +741,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -672,7 +757,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -689,7 +774,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -706,7 +791,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -725,7 +810,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -744,7 +829,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -761,7 +846,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py index e2fa90a9e7ce..fc86217c4265 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tpu_v2.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes. @@ -309,8 +341,10 @@ async def sample_list_nodes(): 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, 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: google.cloud.tpu_v2.services.tpu.pagers.ListNodesAsyncPager: @@ -385,7 +419,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -426,8 +460,10 @@ async def sample_get_node(): 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, 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: google.cloud.tpu_v2.types.Node: @@ -486,7 +522,7 @@ async def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a node. @@ -546,8 +582,10 @@ async def sample_create_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -622,7 +660,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a node. @@ -668,8 +706,10 @@ async def sample_delete_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -747,7 +787,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops a node. This operation is only available with single TPU nodes. @@ -789,8 +829,10 @@ async def sample_stop_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -846,7 +888,7 @@ async def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a node. @@ -887,8 +929,10 @@ async def sample_start_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -946,7 +990,7 @@ async def update_node( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the configurations of a node. @@ -1005,8 +1049,10 @@ async def sample_update_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1080,7 +1126,7 @@ async def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1118,8 +1164,10 @@ async def sample_generate_service_identity(): 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, 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: google.cloud.tpu_v2.types.GenerateServiceIdentityResponse: @@ -1166,7 +1214,7 @@ async def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1209,8 +1257,10 @@ async def sample_list_accelerator_types(): 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, 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: google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1285,7 +1335,7 @@ async def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1327,8 +1377,10 @@ async def sample_get_accelerator_type(): 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, 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: google.cloud.tpu_v2.types.AcceleratorType: @@ -1389,7 +1441,7 @@ async def list_runtime_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRuntimeVersionsAsyncPager: r"""Lists runtime versions supported by this API. @@ -1432,8 +1484,10 @@ async def sample_list_runtime_versions(): 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, 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: google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsAsyncPager: @@ -1508,7 +1562,7 @@ async def get_runtime_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1550,8 +1604,10 @@ async def sample_get_runtime_version(): 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, 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: google.cloud.tpu_v2.types.RuntimeVersion: @@ -1611,7 +1667,7 @@ async def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -1648,8 +1704,10 @@ async def sample_get_guest_attributes(): 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, 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: google.cloud.tpu_v2.types.GetGuestAttributesResponse: @@ -1695,7 +1753,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1706,8 +1764,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1748,7 +1808,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1759,8 +1819,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1801,7 +1863,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1817,8 +1879,10 @@ async def delete_operation( 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, 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: None """ @@ -1855,7 +1919,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1870,8 +1934,10 @@ async def cancel_operation( 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, 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: None """ @@ -1908,7 +1974,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1919,8 +1985,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1961,7 +2029,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1972,8 +2040,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py index 6a8b54f73ce8..67b951a51ffa 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -631,6 +641,10 @@ def __init__( # 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( @@ -691,6 +705,29 @@ def __init__( 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.tpu_v2.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -698,7 +735,7 @@ def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes. @@ -741,8 +778,10 @@ def sample_list_nodes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.services.tpu.pagers.ListNodesPager: @@ -814,7 +853,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -855,8 +894,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.types.Node: @@ -914,7 +955,7 @@ def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a node. @@ -974,8 +1015,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1047,7 +1090,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a node. @@ -1093,8 +1136,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1169,7 +1214,7 @@ def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops a node. This operation is only available with single TPU nodes. @@ -1211,8 +1256,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1266,7 +1313,7 @@ def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a node. @@ -1307,8 +1354,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1364,7 +1413,7 @@ def update_node( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the configurations of a node. @@ -1423,8 +1472,10 @@ def sample_update_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1495,7 +1546,7 @@ def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1533,8 +1584,10 @@ def sample_generate_service_identity(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.types.GenerateServiceIdentityResponse: @@ -1581,7 +1634,7 @@ def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1624,8 +1677,10 @@ def sample_list_accelerator_types(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesPager: @@ -1697,7 +1752,7 @@ def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1739,8 +1794,10 @@ def sample_get_accelerator_type(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.types.AcceleratorType: @@ -1798,7 +1855,7 @@ def list_runtime_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRuntimeVersionsPager: r"""Lists runtime versions supported by this API. @@ -1841,8 +1898,10 @@ def sample_list_runtime_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsPager: @@ -1914,7 +1973,7 @@ def get_runtime_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1956,8 +2015,10 @@ def sample_get_runtime_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.types.RuntimeVersion: @@ -2014,7 +2075,7 @@ def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2051,8 +2112,10 @@ def sample_get_guest_attributes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2.types.GetGuestAttributesResponse: @@ -2109,7 +2172,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2120,8 +2183,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2162,7 +2227,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2173,8 +2238,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2215,7 +2282,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2231,8 +2298,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2269,7 +2338,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2284,8 +2353,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2322,7 +2393,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2333,8 +2404,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2375,7 +2448,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2386,8 +2459,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py index 62884a98b75c..bb2fa56c220a 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListRuntimeVersionsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListRuntimeVersionsRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py index b7022b377222..6c57707898ab 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tpu_v2.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +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.tpu.v2.Tpu", + "rpcName": 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.tpu.v2.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +545,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -485,7 +573,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -511,7 +599,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -539,7 +627,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -565,7 +653,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -593,7 +681,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -601,7 +689,7 @@ def get_guest_attributes( return self._stubs["get_guest_attributes"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -613,7 +701,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -630,7 +718,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -647,7 +735,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -666,7 +754,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -685,7 +773,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -702,7 +790,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py index 36ca488a5cf5..ae51d9091420 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tpu_v2.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +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.tpu.v2.Tpu", + "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.tpu.v2.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,7 +554,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -498,7 +583,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -526,7 +611,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -555,7 +640,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -583,7 +668,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -612,7 +697,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -725,7 +810,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -741,7 +826,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -758,7 +843,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -775,7 +860,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -794,7 +879,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -813,7 +898,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -830,7 +915,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py index 98acc2888356..d503b356ff39 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/services/tpu/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -173,8 +181,10 @@ def post_update_node(self, response): """ def pre_create_node( - self, request: cloud_tpu.CreateNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.CreateNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.CreateNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.CreateNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_node Override in a subclass to manipulate the request or metadata @@ -194,8 +204,10 @@ def post_create_node( return response def pre_delete_node( - self, request: cloud_tpu.DeleteNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.DeleteNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.DeleteNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.DeleteNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_node Override in a subclass to manipulate the request or metadata @@ -217,8 +229,11 @@ def post_delete_node( def pre_generate_service_identity( self, request: cloud_tpu.GenerateServiceIdentityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GenerateServiceIdentityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GenerateServiceIdentityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_service_identity Override in a subclass to manipulate the request or metadata @@ -240,8 +255,10 @@ def post_generate_service_identity( def pre_get_accelerator_type( self, request: cloud_tpu.GetAcceleratorTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetAcceleratorTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetAcceleratorTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_accelerator_type Override in a subclass to manipulate the request or metadata @@ -263,8 +280,10 @@ def post_get_accelerator_type( def pre_get_guest_attributes( self, request: cloud_tpu.GetGuestAttributesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetGuestAttributesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetGuestAttributesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_guest_attributes Override in a subclass to manipulate the request or metadata @@ -284,8 +303,10 @@ def post_get_guest_attributes( return response def pre_get_node( - self, request: cloud_tpu.GetNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.GetNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.GetNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.GetNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_node Override in a subclass to manipulate the request or metadata @@ -305,8 +326,10 @@ def post_get_node(self, response: cloud_tpu.Node) -> cloud_tpu.Node: def pre_get_runtime_version( self, request: cloud_tpu.GetRuntimeVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.GetRuntimeVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.GetRuntimeVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_runtime_version Override in a subclass to manipulate the request or metadata @@ -328,8 +351,10 @@ def post_get_runtime_version( def pre_list_accelerator_types( self, request: cloud_tpu.ListAcceleratorTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.ListAcceleratorTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.ListAcceleratorTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_accelerator_types Override in a subclass to manipulate the request or metadata @@ -349,8 +374,10 @@ def post_list_accelerator_types( return response def pre_list_nodes( - self, request: cloud_tpu.ListNodesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.ListNodesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.ListNodesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.ListNodesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_nodes Override in a subclass to manipulate the request or metadata @@ -372,8 +399,10 @@ def post_list_nodes( def pre_list_runtime_versions( self, request: cloud_tpu.ListRuntimeVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tpu.ListRuntimeVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tpu.ListRuntimeVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_runtime_versions Override in a subclass to manipulate the request or metadata @@ -393,8 +422,10 @@ def post_list_runtime_versions( return response def pre_start_node( - self, request: cloud_tpu.StartNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.StartNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.StartNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.StartNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start_node Override in a subclass to manipulate the request or metadata @@ -414,8 +445,10 @@ def post_start_node( return response def pre_stop_node( - self, request: cloud_tpu.StopNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.StopNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.StopNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.StopNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop_node Override in a subclass to manipulate the request or metadata @@ -435,8 +468,10 @@ def post_stop_node( return response def pre_update_node( - self, request: cloud_tpu.UpdateNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tpu.UpdateNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tpu.UpdateNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tpu.UpdateNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_node Override in a subclass to manipulate the request or metadata @@ -458,8 +493,10 @@ def post_update_node( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -481,8 +518,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -504,8 +543,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -525,8 +566,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -546,8 +589,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -569,8 +614,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -764,7 +811,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create node method over HTTP. @@ -775,8 +822,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -787,6 +836,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseCreateNode._get_http_options() + request, metadata = self._interceptor.pre_create_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseCreateNode._get_transcoded_request( @@ -803,6 +853,33 @@ def __call__( 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.tpu_v2.TpuClient.CreateNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CreateNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._CreateNode._get_response( self._host, @@ -822,7 +899,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_node(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.tpu_v2.TpuClient.create_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CreateNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNode(_BaseTpuRestTransport._BaseDeleteNode, TpuRestStub): @@ -857,7 +956,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete node method over HTTP. @@ -868,8 +967,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -880,6 +981,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseDeleteNode._get_http_options() + request, metadata = self._interceptor.pre_delete_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseDeleteNode._get_transcoded_request( @@ -892,6 +994,33 @@ def __call__( 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.tpu_v2.TpuClient.DeleteNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._DeleteNode._get_response( self._host, @@ -910,7 +1039,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_node(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.tpu_v2.TpuClient.delete_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateServiceIdentity( @@ -948,7 +1099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Call the generate service identity method over HTTP. @@ -959,8 +1110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.GenerateServiceIdentityResponse: @@ -972,6 +1125,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGenerateServiceIdentity._get_http_options() ) + request, metadata = self._interceptor.pre_generate_service_identity( request, metadata ) @@ -988,6 +1142,33 @@ def __call__( 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.tpu_v2.TpuClient.GenerateServiceIdentity", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GenerateServiceIdentity", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GenerateServiceIdentity._get_response( self._host, @@ -1009,7 +1190,31 @@ def __call__( pb_resp = cloud_tpu.GenerateServiceIdentityResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_service_identity(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_tpu.GenerateServiceIdentityResponse.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.tpu_v2.TpuClient.generate_service_identity", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GenerateServiceIdentity", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAcceleratorType( @@ -1046,7 +1251,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Call the get accelerator type method over HTTP. @@ -1057,8 +1262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.AcceleratorType: @@ -1070,6 +1277,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetAcceleratorType._get_http_options() ) + request, metadata = self._interceptor.pre_get_accelerator_type( request, metadata ) @@ -1086,6 +1294,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.GetAcceleratorType", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetAcceleratorType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetAcceleratorType._get_response( self._host, @@ -1106,7 +1341,29 @@ def __call__( pb_resp = cloud_tpu.AcceleratorType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_accelerator_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.AcceleratorType.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.tpu_v2.TpuClient.get_accelerator_type", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetAcceleratorType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGuestAttributes( @@ -1144,7 +1401,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Call the get guest attributes method over HTTP. @@ -1155,8 +1412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.GetGuestAttributesResponse: @@ -1168,6 +1427,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetGuestAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_get_guest_attributes( request, metadata ) @@ -1188,6 +1448,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.GetGuestAttributes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetGuestAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetGuestAttributes._get_response( self._host, @@ -1209,7 +1496,31 @@ def __call__( pb_resp = cloud_tpu.GetGuestAttributesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_guest_attributes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.GetGuestAttributesResponse.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.tpu_v2.TpuClient.get_guest_attributes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetGuestAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNode(_BaseTpuRestTransport._BaseGetNode, TpuRestStub): @@ -1244,7 +1555,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Call the get node method over HTTP. @@ -1254,8 +1565,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.Node: @@ -1263,6 +1576,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseGetNode._get_http_options() + request, metadata = self._interceptor.pre_get_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetNode._get_transcoded_request( @@ -1275,6 +1589,33 @@ def __call__( 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.tpu_v2.TpuClient.GetNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetNode._get_response( self._host, @@ -1295,7 +1636,29 @@ def __call__( pb_resp = cloud_tpu.Node.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.Node.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.tpu_v2.TpuClient.get_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRuntimeVersion(_BaseTpuRestTransport._BaseGetRuntimeVersion, TpuRestStub): @@ -1330,7 +1693,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Call the get runtime version method over HTTP. @@ -1341,8 +1704,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.RuntimeVersion: @@ -1354,6 +1719,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseGetRuntimeVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_runtime_version( request, metadata ) @@ -1370,6 +1736,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.GetRuntimeVersion", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetRuntimeVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetRuntimeVersion._get_response( self._host, @@ -1390,7 +1783,29 @@ def __call__( pb_resp = cloud_tpu.RuntimeVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_runtime_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.RuntimeVersion.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.tpu_v2.TpuClient.get_runtime_version", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetRuntimeVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAcceleratorTypes( @@ -1427,7 +1842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.ListAcceleratorTypesResponse: r"""Call the list accelerator types method over HTTP. @@ -1438,8 +1853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.ListAcceleratorTypesResponse: @@ -1451,6 +1868,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseListAcceleratorTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_accelerator_types( request, metadata ) @@ -1467,6 +1885,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.ListAcceleratorTypes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListAcceleratorTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListAcceleratorTypes._get_response( self._host, @@ -1487,7 +1932,31 @@ def __call__( pb_resp = cloud_tpu.ListAcceleratorTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_accelerator_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.ListAcceleratorTypesResponse.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.tpu_v2.TpuClient.list_accelerator_types", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListAcceleratorTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodes(_BaseTpuRestTransport._BaseListNodes, TpuRestStub): @@ -1522,7 +1991,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.ListNodesResponse: r"""Call the list nodes method over HTTP. @@ -1533,8 +2002,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.ListNodesResponse: @@ -1544,6 +2015,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseListNodes._get_http_options() + request, metadata = self._interceptor.pre_list_nodes(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListNodes._get_transcoded_request( @@ -1556,6 +2028,33 @@ def __call__( 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.tpu_v2.TpuClient.ListNodes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListNodes._get_response( self._host, @@ -1576,7 +2075,29 @@ def __call__( pb_resp = cloud_tpu.ListNodesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.ListNodesResponse.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.tpu_v2.TpuClient.list_nodes", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRuntimeVersions( @@ -1613,7 +2134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.ListRuntimeVersionsResponse: r"""Call the list runtime versions method over HTTP. @@ -1624,8 +2145,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tpu.ListRuntimeVersionsResponse: @@ -1637,6 +2160,7 @@ def __call__( http_options = ( _BaseTpuRestTransport._BaseListRuntimeVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_runtime_versions( request, metadata ) @@ -1653,6 +2177,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.ListRuntimeVersions", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListRuntimeVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListRuntimeVersions._get_response( self._host, @@ -1673,7 +2224,31 @@ def __call__( pb_resp = cloud_tpu.ListRuntimeVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_runtime_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tpu.ListRuntimeVersionsResponse.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.tpu_v2.TpuClient.list_runtime_versions", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListRuntimeVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartNode(_BaseTpuRestTransport._BaseStartNode, TpuRestStub): @@ -1709,7 +2284,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start node method over HTTP. @@ -1720,8 +2295,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1732,6 +2309,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseStartNode._get_http_options() + request, metadata = self._interceptor.pre_start_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseStartNode._get_transcoded_request( @@ -1748,6 +2326,33 @@ def __call__( 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.tpu_v2.TpuClient.StartNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StartNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._StartNode._get_response( self._host, @@ -1767,7 +2372,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_node(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.tpu_v2.TpuClient.start_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StartNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopNode(_BaseTpuRestTransport._BaseStopNode, TpuRestStub): @@ -1803,7 +2430,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the stop node method over HTTP. @@ -1814,8 +2441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1826,6 +2455,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseStopNode._get_http_options() + request, metadata = self._interceptor.pre_stop_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseStopNode._get_transcoded_request( @@ -1842,6 +2472,33 @@ def __call__( 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.tpu_v2.TpuClient.StopNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StopNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._StopNode._get_response( self._host, @@ -1861,7 +2518,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_node(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.tpu_v2.TpuClient.stop_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "StopNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNode(_BaseTpuRestTransport._BaseUpdateNode, TpuRestStub): @@ -1897,7 +2576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update node method over HTTP. @@ -1908,8 +2587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1920,6 +2601,7 @@ def __call__( """ http_options = _BaseTpuRestTransport._BaseUpdateNode._get_http_options() + request, metadata = self._interceptor.pre_update_node(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseUpdateNode._get_transcoded_request( @@ -1936,6 +2618,33 @@ def __call__( 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.tpu_v2.TpuClient.UpdateNode", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "UpdateNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._UpdateNode._get_response( self._host, @@ -1955,7 +2664,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_node(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.tpu_v2.TpuClient.update_node", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "UpdateNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2105,7 +2836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2115,14 +2846,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. """ http_options = _BaseTpuRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetLocation._get_transcoded_request( @@ -2137,6 +2871,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.GetLocation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetLocation._get_response( self._host, @@ -2156,6 +2917,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.tpu_v2.TpuAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2194,7 +2976,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2204,14 +2986,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. """ http_options = _BaseTpuRestTransport._BaseListLocations._get_http_options() + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListLocations._get_transcoded_request( @@ -2226,6 +3011,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.ListLocations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListLocations._get_response( self._host, @@ -2245,6 +3057,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.tpu_v2.TpuAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2283,7 +3116,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2293,13 +3126,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTpuRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2316,6 +3152,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.CancelOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._CancelOperation._get_response( self._host, @@ -2369,7 +3232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2379,13 +3242,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTpuRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2402,6 +3268,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._DeleteOperation._get_response( self._host, @@ -2455,7 +3348,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2465,14 +3358,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. """ http_options = _BaseTpuRestTransport._BaseGetOperation._get_http_options() + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseGetOperation._get_transcoded_request( @@ -2487,6 +3383,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.GetOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._GetOperation._get_response( self._host, @@ -2506,6 +3429,27 @@ def __call__( 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.tpu_v2.TpuAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2544,7 +3488,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2554,14 +3498,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. """ http_options = _BaseTpuRestTransport._BaseListOperations._get_http_options() + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseTpuRestTransport._BaseListOperations._get_transcoded_request( @@ -2576,6 +3523,33 @@ def __call__( ) ) + 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.tpu_v2.TpuClient.ListOperations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TpuRestTransport._ListOperations._get_response( self._host, @@ -2595,6 +3569,27 @@ def __call__( 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.tpu_v2.TpuAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.tpu.v2.Tpu", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py index 68899264edad..558c8aab67c5 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.19.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py index 61e18600e7a2..131504f9fccd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TpuTransport from .transports.grpc_asyncio import TpuGrpcAsyncIOTransport +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 TpuAsyncClient: """Manages TPU nodes and other resources @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tpu_v2alpha1.TpuAsyncClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "credentialsType": None, + }, + ) + async def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes. @@ -311,8 +343,10 @@ async def sample_list_nodes(): 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, 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesAsyncPager: @@ -387,7 +421,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -429,8 +463,10 @@ async def sample_get_node(): 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, 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: google.cloud.tpu_v2alpha1.types.Node: @@ -489,7 +525,7 @@ async def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a node. @@ -549,8 +585,10 @@ async def sample_create_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -626,7 +664,7 @@ async def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a node. @@ -672,8 +710,10 @@ async def sample_delete_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -751,7 +791,7 @@ async def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops a node. This operation is only available with single TPU nodes. @@ -793,8 +833,10 @@ async def sample_stop_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -851,7 +893,7 @@ async def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a node. @@ -892,8 +934,10 @@ async def sample_start_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -952,7 +996,7 @@ async def update_node( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the configurations of a node. @@ -1011,8 +1055,10 @@ async def sample_update_node(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1088,7 +1134,7 @@ async def list_queued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuedResourcesAsyncPager: r"""Lists queued resources. @@ -1131,8 +1177,10 @@ async def sample_list_queued_resources(): 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, 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesAsyncPager: @@ -1207,7 +1255,7 @@ async def get_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.QueuedResource: r"""Gets details of a queued resource. @@ -1249,8 +1297,10 @@ async def sample_get_queued_resource(): 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, 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: google.cloud.tpu_v2alpha1.types.QueuedResource: @@ -1315,7 +1365,7 @@ async def create_queued_resource( queued_resource_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a QueuedResource TPU instance. @@ -1373,8 +1423,10 @@ async def sample_create_queued_resource(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1450,7 +1502,7 @@ async def delete_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a QueuedResource TPU instance. @@ -1496,8 +1548,10 @@ async def sample_delete_queued_resource(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1569,7 +1623,7 @@ async def reset_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Resets a QueuedResource TPU instance @@ -1617,8 +1671,10 @@ async def sample_reset_queued_resource(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1689,7 +1745,7 @@ async def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -1727,8 +1783,10 @@ async def sample_generate_service_identity(): 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, 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: google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse: @@ -1775,7 +1833,7 @@ async def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1818,8 +1876,10 @@ async def sample_list_accelerator_types(): 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, 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesAsyncPager: @@ -1894,7 +1954,7 @@ async def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1936,8 +1996,10 @@ async def sample_get_accelerator_type(): 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, 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: google.cloud.tpu_v2alpha1.types.AcceleratorType: @@ -1998,7 +2060,7 @@ async def list_runtime_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRuntimeVersionsAsyncPager: r"""Lists runtime versions supported by this API. @@ -2041,8 +2103,10 @@ async def sample_list_runtime_versions(): 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, 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsAsyncPager: @@ -2117,7 +2181,7 @@ async def get_runtime_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -2159,8 +2223,10 @@ async def sample_get_runtime_version(): 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, 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: google.cloud.tpu_v2alpha1.types.RuntimeVersion: @@ -2220,7 +2286,7 @@ async def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2257,8 +2323,10 @@ async def sample_get_guest_attributes(): 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, 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: google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse: @@ -2306,7 +2374,7 @@ async def simulate_maintenance_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Simulates a maintenance event. @@ -2347,8 +2415,10 @@ async def sample_simulate_maintenance_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2405,7 +2475,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2416,8 +2486,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2458,7 +2530,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2469,8 +2541,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2511,7 +2585,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2527,8 +2601,10 @@ async def delete_operation( 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, 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: None """ @@ -2565,7 +2641,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2580,8 +2656,10 @@ async def cancel_operation( 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, 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: None """ @@ -2618,7 +2696,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2629,8 +2707,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2671,7 +2751,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2682,8 +2762,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py index 23ed6f5401f7..49fd1a0bdf62 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -651,6 +661,10 @@ def __init__( # 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( @@ -711,6 +725,29 @@ def __init__( 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.tpu_v2alpha1.TpuClient`.", + extra={ + "serviceName": "google.cloud.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "credentialsType": None, + }, + ) + def list_nodes( self, request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, @@ -718,7 +755,7 @@ def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes. @@ -761,8 +798,10 @@ def sample_list_nodes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesPager: @@ -834,7 +873,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -876,8 +915,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.Node: @@ -935,7 +976,7 @@ def create_node( node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a node. @@ -995,8 +1036,10 @@ def sample_create_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1069,7 +1112,7 @@ def delete_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a node. @@ -1115,8 +1158,10 @@ def sample_delete_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1191,7 +1236,7 @@ def stop_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops a node. This operation is only available with single TPU nodes. @@ -1233,8 +1278,10 @@ def sample_stop_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1289,7 +1336,7 @@ def start_node( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a node. @@ -1330,8 +1377,10 @@ def sample_start_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1388,7 +1437,7 @@ def update_node( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the configurations of a node. @@ -1447,8 +1496,10 @@ def sample_update_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1521,7 +1572,7 @@ def list_queued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuedResourcesPager: r"""Lists queued resources. @@ -1564,8 +1615,10 @@ def sample_list_queued_resources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesPager: @@ -1637,7 +1690,7 @@ def get_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.QueuedResource: r"""Gets details of a queued resource. @@ -1679,8 +1732,10 @@ def sample_get_queued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.QueuedResource: @@ -1742,7 +1797,7 @@ def create_queued_resource( queued_resource_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a QueuedResource TPU instance. @@ -1800,8 +1855,10 @@ def sample_create_queued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1874,7 +1931,7 @@ def delete_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a QueuedResource TPU instance. @@ -1920,8 +1977,10 @@ def sample_delete_queued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1990,7 +2049,7 @@ def reset_queued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Resets a QueuedResource TPU instance @@ -2038,8 +2097,10 @@ def sample_reset_queued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2107,7 +2168,7 @@ def generate_service_identity( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the project. @@ -2145,8 +2206,10 @@ def sample_generate_service_identity(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse: @@ -2193,7 +2256,7 @@ def list_accelerator_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -2236,8 +2299,10 @@ def sample_list_accelerator_types(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesPager: @@ -2309,7 +2374,7 @@ def get_accelerator_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -2351,8 +2416,10 @@ def sample_get_accelerator_type(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.AcceleratorType: @@ -2410,7 +2477,7 @@ def list_runtime_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRuntimeVersionsPager: r"""Lists runtime versions supported by this API. @@ -2453,8 +2520,10 @@ def sample_list_runtime_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsPager: @@ -2526,7 +2595,7 @@ def get_runtime_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -2568,8 +2637,10 @@ def sample_get_runtime_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.RuntimeVersion: @@ -2626,7 +2697,7 @@ def get_guest_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -2663,8 +2734,10 @@ def sample_get_guest_attributes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse: @@ -2710,7 +2783,7 @@ def simulate_maintenance_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Simulates a maintenance event. @@ -2751,8 +2824,10 @@ def sample_simulate_maintenance_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2822,7 +2897,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2833,8 +2908,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2875,7 +2952,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2886,8 +2963,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2928,7 +3007,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2944,8 +3023,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2982,7 +3063,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2997,8 +3078,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3035,7 +3118,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3046,8 +3129,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -3088,7 +3173,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3099,8 +3184,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py index 05da2e89ee66..c82a208419fb 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListNodesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListQueuedResourcesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListQueuedResourcesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListAcceleratorTypesRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_tpu.ListRuntimeVersionsRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_tpu.ListRuntimeVersionsRequest(request) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py index fd9f0f854c8d..dc4cebdab2a1 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tpu_v2alpha1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport +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.tpu.v2alpha1.Tpu", + "rpcName": 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.tpu.v2alpha1.Tpu", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcTransport(TpuTransport): """gRPC backend transport for Tpu. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -296,7 +384,7 @@ def get_node(self) -> Callable[[cloud_tpu.GetNodeRequest], cloud_tpu.Node]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -322,7 +410,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -455,7 +543,7 @@ def list_queued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queued_resources" not in self._stubs: - self._stubs["list_queued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_queued_resources"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListQueuedResources", request_serializer=cloud_tpu.ListQueuedResourcesRequest.serialize, response_deserializer=cloud_tpu.ListQueuedResourcesResponse.deserialize, @@ -481,7 +569,7 @@ def get_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queued_resource" not in self._stubs: - self._stubs["get_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetQueuedResource", request_serializer=cloud_tpu.GetQueuedResourceRequest.serialize, response_deserializer=cloud_tpu.QueuedResource.deserialize, @@ -507,7 +595,7 @@ def create_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queued_resource" not in self._stubs: - self._stubs["create_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["create_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateQueuedResource", request_serializer=cloud_tpu.CreateQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -533,7 +621,7 @@ def delete_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queued_resource" not in self._stubs: - self._stubs["delete_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["delete_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteQueuedResource", request_serializer=cloud_tpu.DeleteQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -559,7 +647,7 @@ def reset_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["reset_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -589,7 +677,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -617,7 +705,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -643,7 +731,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -671,7 +759,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -697,7 +785,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -725,7 +813,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -753,7 +841,9 @@ def simulate_maintenance_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "simulate_maintenance_event" not in self._stubs: - self._stubs["simulate_maintenance_event"] = self.grpc_channel.unary_unary( + self._stubs[ + "simulate_maintenance_event" + ] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/SimulateMaintenanceEvent", request_serializer=cloud_tpu.SimulateMaintenanceEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -761,7 +851,7 @@ def simulate_maintenance_event( return self._stubs["simulate_maintenance_event"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -773,7 +863,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -790,7 +880,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -807,7 +897,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -826,7 +916,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -845,7 +935,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -862,7 +952,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py index bbe88dcfc3f7..400b04a64928 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tpu_v2alpha1.types import cloud_tpu from .base import DEFAULT_CLIENT_INFO, TpuTransport from .grpc import TpuGrpcTransport +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.tpu.v2alpha1.Tpu", + "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.tpu.v2alpha1.Tpu", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TpuGrpcAsyncIOTransport(TpuTransport): """gRPC AsyncIO backend transport for Tpu. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListNodes", request_serializer=cloud_tpu.ListNodesRequest.serialize, response_deserializer=cloud_tpu.ListNodesResponse.deserialize, @@ -308,7 +393,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetNode", request_serializer=cloud_tpu.GetNodeRequest.serialize, response_deserializer=cloud_tpu.Node.deserialize, @@ -334,7 +419,7 @@ def create_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_node" not in self._stubs: - self._stubs["create_node"] = self.grpc_channel.unary_unary( + self._stubs["create_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateNode", request_serializer=cloud_tpu.CreateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +445,7 @@ def delete_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_node" not in self._stubs: - self._stubs["delete_node"] = self.grpc_channel.unary_unary( + self._stubs["delete_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteNode", request_serializer=cloud_tpu.DeleteNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def stop_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_node" not in self._stubs: - self._stubs["stop_node"] = self.grpc_channel.unary_unary( + self._stubs["stop_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StopNode", request_serializer=cloud_tpu.StopNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -413,7 +498,7 @@ def start_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_node" not in self._stubs: - self._stubs["start_node"] = self.grpc_channel.unary_unary( + self._stubs["start_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/StartNode", request_serializer=cloud_tpu.StartNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +524,7 @@ def update_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_node" not in self._stubs: - self._stubs["update_node"] = self.grpc_channel.unary_unary( + self._stubs["update_node"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/UpdateNode", request_serializer=cloud_tpu.UpdateNodeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -468,7 +553,7 @@ def list_queued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queued_resources" not in self._stubs: - self._stubs["list_queued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_queued_resources"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListQueuedResources", request_serializer=cloud_tpu.ListQueuedResourcesRequest.serialize, response_deserializer=cloud_tpu.ListQueuedResourcesResponse.deserialize, @@ -496,7 +581,7 @@ def get_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queued_resource" not in self._stubs: - self._stubs["get_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetQueuedResource", request_serializer=cloud_tpu.GetQueuedResourceRequest.serialize, response_deserializer=cloud_tpu.QueuedResource.deserialize, @@ -524,7 +609,7 @@ def create_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queued_resource" not in self._stubs: - self._stubs["create_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["create_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/CreateQueuedResource", request_serializer=cloud_tpu.CreateQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +637,7 @@ def delete_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queued_resource" not in self._stubs: - self._stubs["delete_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["delete_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/DeleteQueuedResource", request_serializer=cloud_tpu.DeleteQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +665,7 @@ def reset_queued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( + self._stubs["reset_queued_resource"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +695,7 @@ def generate_service_identity( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_service_identity" not in self._stubs: - self._stubs["generate_service_identity"] = self.grpc_channel.unary_unary( + self._stubs["generate_service_identity"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GenerateServiceIdentity", request_serializer=cloud_tpu.GenerateServiceIdentityRequest.serialize, response_deserializer=cloud_tpu.GenerateServiceIdentityResponse.deserialize, @@ -639,7 +724,7 @@ def list_accelerator_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accelerator_types" not in self._stubs: - self._stubs["list_accelerator_types"] = self.grpc_channel.unary_unary( + self._stubs["list_accelerator_types"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListAcceleratorTypes", request_serializer=cloud_tpu.ListAcceleratorTypesRequest.serialize, response_deserializer=cloud_tpu.ListAcceleratorTypesResponse.deserialize, @@ -667,7 +752,7 @@ def get_accelerator_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_accelerator_type" not in self._stubs: - self._stubs["get_accelerator_type"] = self.grpc_channel.unary_unary( + self._stubs["get_accelerator_type"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetAcceleratorType", request_serializer=cloud_tpu.GetAcceleratorTypeRequest.serialize, response_deserializer=cloud_tpu.AcceleratorType.deserialize, @@ -696,7 +781,7 @@ def list_runtime_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_runtime_versions" not in self._stubs: - self._stubs["list_runtime_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_runtime_versions"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/ListRuntimeVersions", request_serializer=cloud_tpu.ListRuntimeVersionsRequest.serialize, response_deserializer=cloud_tpu.ListRuntimeVersionsResponse.deserialize, @@ -724,7 +809,7 @@ def get_runtime_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_runtime_version" not in self._stubs: - self._stubs["get_runtime_version"] = self.grpc_channel.unary_unary( + self._stubs["get_runtime_version"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetRuntimeVersion", request_serializer=cloud_tpu.GetRuntimeVersionRequest.serialize, response_deserializer=cloud_tpu.RuntimeVersion.deserialize, @@ -753,7 +838,7 @@ def get_guest_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_guest_attributes" not in self._stubs: - self._stubs["get_guest_attributes"] = self.grpc_channel.unary_unary( + self._stubs["get_guest_attributes"] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/GetGuestAttributes", request_serializer=cloud_tpu.GetGuestAttributesRequest.serialize, response_deserializer=cloud_tpu.GetGuestAttributesResponse.deserialize, @@ -781,7 +866,9 @@ def simulate_maintenance_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "simulate_maintenance_event" not in self._stubs: - self._stubs["simulate_maintenance_event"] = self.grpc_channel.unary_unary( + self._stubs[ + "simulate_maintenance_event" + ] = self._logged_channel.unary_unary( "/google.cloud.tpu.v2alpha1.Tpu/SimulateMaintenanceEvent", request_serializer=cloud_tpu.SimulateMaintenanceEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -924,7 +1011,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -940,7 +1027,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -957,7 +1044,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -974,7 +1061,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -993,7 +1080,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1012,7 +1099,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1029,7 +1116,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json index 91c5476e75e7..0c1dfa7ef851 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.AcceleratorType", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.AcceleratorType", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.Node", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.Node", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.TensorFlowVersion", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.types.TensorFlowVersion", @@ -868,7 +868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -948,7 +948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1029,7 +1029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListNodesAsyncPager", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListNodesPager", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsAsyncPager", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v1.services.tpu.pagers.ListTensorFlowVersionsPager", @@ -1347,7 +1347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1500,7 +1500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json index 6087881385a7..f887178885e7 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -381,7 +381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GenerateServiceIdentityResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GenerateServiceIdentityResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.AcceleratorType", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.AcceleratorType", @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GetGuestAttributesResponse", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.GetGuestAttributesResponse", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.Node", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.Node", @@ -1013,7 +1013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.RuntimeVersion", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.types.RuntimeVersion", @@ -1174,7 +1174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1335,7 +1335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListNodesAsyncPager", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListNodesPager", @@ -1496,7 +1496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsAsyncPager", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2.services.tpu.pagers.ListRuntimeVersionsPager", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1806,7 +1806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1967,7 +1967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2051,7 +2051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json index fb9e919e65c6..5b36366634f6 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.19.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -719,7 +719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityResponse", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.AcceleratorType", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.AcceleratorType", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.GetGuestAttributesResponse", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.Node", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.Node", @@ -1351,7 +1351,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.QueuedResource", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.QueuedResource", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.RuntimeVersion", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.types.RuntimeVersion", @@ -1673,7 +1673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesAsyncPager", @@ -1753,7 +1753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListAcceleratorTypesPager", @@ -1834,7 +1834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesAsyncPager", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListNodesPager", @@ -1995,7 +1995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesAsyncPager", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListQueuedResourcesPager", @@ -2156,7 +2156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsAsyncPager", @@ -2236,7 +2236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tpu_v2alpha1.services.tpu.pagers.ListRuntimeVersionsPager", @@ -2317,7 +2317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2397,7 +2397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2474,7 +2474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2550,7 +2550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2627,7 +2627,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2703,7 +2703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2780,7 +2780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2856,7 +2856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2941,7 +2941,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3025,7 +3025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py index d7c7d4977604..f46c89530ed1 100644 --- a/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py +++ b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py @@ -5765,6 +5765,7 @@ def test_list_nodes_rest_required_fields(request_type=cloud_tpu.ListNodesRequest response_value._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_nodes(request) @@ -5818,6 +5819,7 @@ def test_list_nodes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_nodes(**mock_args) @@ -6007,6 +6009,7 @@ def test_get_node_rest_required_fields(request_type=cloud_tpu.GetNodeRequest): response_value._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_node(request) @@ -6052,6 +6055,7 @@ def test_get_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node(**mock_args) @@ -6184,6 +6188,7 @@ def test_create_node_rest_required_fields(request_type=cloud_tpu.CreateNodeReque response_value._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_node(request) @@ -6237,6 +6242,7 @@ def test_create_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node(**mock_args) @@ -6368,6 +6374,7 @@ def test_delete_node_rest_required_fields(request_type=cloud_tpu.DeleteNodeReque response_value._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_node(request) @@ -6411,6 +6418,7 @@ def test_delete_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node(**mock_args) @@ -6541,6 +6549,7 @@ def test_stop_node_rest_required_fields(request_type=cloud_tpu.StopNodeRequest): response_value._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.stop_node(request) @@ -6660,6 +6669,7 @@ def test_start_node_rest_required_fields(request_type=cloud_tpu.StartNodeRequest response_value._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.start_node(request) @@ -6776,6 +6786,7 @@ def test_update_node_rest_required_fields(request_type=cloud_tpu.UpdateNodeReque response_value._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_node(request) @@ -6830,6 +6841,7 @@ def test_update_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node(**mock_args) @@ -6967,6 +6979,7 @@ def test_generate_service_identity_rest_required_fields( response_value._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.generate_service_identity(request) @@ -7100,6 +7113,7 @@ def test_list_accelerator_types_rest_required_fields( response_value._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_accelerator_types(request) @@ -7155,6 +7169,7 @@ def test_list_accelerator_types_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_accelerator_types(**mock_args) @@ -7353,6 +7368,7 @@ def test_get_accelerator_type_rest_required_fields( response_value._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_accelerator_type(request) @@ -7400,6 +7416,7 @@ def test_get_accelerator_type_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_accelerator_type(**mock_args) @@ -7545,6 +7562,7 @@ def test_list_runtime_versions_rest_required_fields( response_value._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_runtime_versions(request) @@ -7600,6 +7618,7 @@ def test_list_runtime_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_runtime_versions(**mock_args) @@ -7798,6 +7817,7 @@ def test_get_runtime_version_rest_required_fields( response_value._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_runtime_version(request) @@ -7845,6 +7865,7 @@ def test_get_runtime_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_runtime_version(**mock_args) @@ -7981,6 +8002,7 @@ def test_get_guest_attributes_rest_required_fields( response_value._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_guest_attributes(request) @@ -8795,6 +8817,7 @@ def test_list_nodes_rest_bad_request(request_type=cloud_tpu.ListNodesRequest): 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_nodes(request) @@ -8831,6 +8854,7 @@ def test_list_nodes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_nodes(request) # Establish that the response is the type that we expect. @@ -8868,6 +8892,7 @@ def test_list_nodes_rest_interceptors(null_interceptor): 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 = cloud_tpu.ListNodesResponse.to_json( cloud_tpu.ListNodesResponse() ) @@ -8912,6 +8937,7 @@ def test_get_node_rest_bad_request(request_type=cloud_tpu.GetNodeRequest): 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_node(request) @@ -8959,6 +8985,7 @@ def test_get_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_node(request) # Establish that the response is the type that we expect. @@ -9007,6 +9034,7 @@ def test_get_node_rest_interceptors(null_interceptor): 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 = cloud_tpu.Node.to_json(cloud_tpu.Node()) req.return_value.content = return_value @@ -9049,6 +9077,7 @@ def test_create_node_rest_bad_request(request_type=cloud_tpu.CreateNodeRequest): 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_node(request) @@ -9193,6 +9222,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_node(request) # Establish that the response is the type that we expect. @@ -9230,6 +9260,7 @@ def test_create_node_rest_interceptors(null_interceptor): 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 @@ -9272,6 +9303,7 @@ def test_delete_node_rest_bad_request(request_type=cloud_tpu.DeleteNodeRequest): 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_node(request) @@ -9302,6 +9334,7 @@ def test_delete_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_node(request) # Establish that the response is the type that we expect. @@ -9339,6 +9372,7 @@ def test_delete_node_rest_interceptors(null_interceptor): 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 @@ -9381,6 +9415,7 @@ def test_stop_node_rest_bad_request(request_type=cloud_tpu.StopNodeRequest): 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.stop_node(request) @@ -9411,6 +9446,7 @@ def test_stop_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_node(request) # Establish that the response is the type that we expect. @@ -9448,6 +9484,7 @@ def test_stop_node_rest_interceptors(null_interceptor): 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 @@ -9490,6 +9527,7 @@ def test_start_node_rest_bad_request(request_type=cloud_tpu.StartNodeRequest): 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.start_node(request) @@ -9520,6 +9558,7 @@ def test_start_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_node(request) # Establish that the response is the type that we expect. @@ -9557,6 +9596,7 @@ def test_start_node_rest_interceptors(null_interceptor): 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 @@ -9601,6 +9641,7 @@ def test_update_node_rest_bad_request(request_type=cloud_tpu.UpdateNodeRequest): 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_node(request) @@ -9747,6 +9788,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_node(request) # Establish that the response is the type that we expect. @@ -9784,6 +9826,7 @@ def test_update_node_rest_interceptors(null_interceptor): 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 @@ -9828,6 +9871,7 @@ def test_generate_service_identity_rest_bad_request( 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.generate_service_identity(request) @@ -9861,6 +9905,7 @@ def test_generate_service_identity_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_service_identity(request) # Establish that the response is the type that we expect. @@ -9898,6 +9943,7 @@ def test_generate_service_identity_rest_interceptors(null_interceptor): 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 = cloud_tpu.GenerateServiceIdentityResponse.to_json( cloud_tpu.GenerateServiceIdentityResponse() ) @@ -9944,6 +9990,7 @@ def test_list_accelerator_types_rest_bad_request( 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_accelerator_types(request) @@ -9980,6 +10027,7 @@ def test_list_accelerator_types_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_accelerator_types(request) # Establish that the response is the type that we expect. @@ -10019,6 +10067,7 @@ def test_list_accelerator_types_rest_interceptors(null_interceptor): 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 = cloud_tpu.ListAcceleratorTypesResponse.to_json( cloud_tpu.ListAcceleratorTypesResponse() ) @@ -10067,6 +10116,7 @@ def test_get_accelerator_type_rest_bad_request( 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_accelerator_type(request) @@ -10105,6 +10155,7 @@ def test_get_accelerator_type_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_accelerator_type(request) # Establish that the response is the type that we expect. @@ -10144,6 +10195,7 @@ def test_get_accelerator_type_rest_interceptors(null_interceptor): 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 = cloud_tpu.AcceleratorType.to_json(cloud_tpu.AcceleratorType()) req.return_value.content = return_value @@ -10188,6 +10240,7 @@ def test_list_runtime_versions_rest_bad_request( 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_runtime_versions(request) @@ -10224,6 +10277,7 @@ def test_list_runtime_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_runtime_versions(request) # Establish that the response is the type that we expect. @@ -10263,6 +10317,7 @@ def test_list_runtime_versions_rest_interceptors(null_interceptor): 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 = cloud_tpu.ListRuntimeVersionsResponse.to_json( cloud_tpu.ListRuntimeVersionsResponse() ) @@ -10311,6 +10366,7 @@ def test_get_runtime_version_rest_bad_request( 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_runtime_version(request) @@ -10349,6 +10405,7 @@ def test_get_runtime_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_runtime_version(request) # Establish that the response is the type that we expect. @@ -10388,6 +10445,7 @@ def test_get_runtime_version_rest_interceptors(null_interceptor): 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 = cloud_tpu.RuntimeVersion.to_json(cloud_tpu.RuntimeVersion()) req.return_value.content = return_value @@ -10432,6 +10490,7 @@ def test_get_guest_attributes_rest_bad_request( 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_guest_attributes(request) @@ -10465,6 +10524,7 @@ def test_get_guest_attributes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_guest_attributes(request) # Establish that the response is the type that we expect. @@ -10502,6 +10562,7 @@ def test_get_guest_attributes_rest_interceptors(null_interceptor): 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 = cloud_tpu.GetGuestAttributesResponse.to_json( cloud_tpu.GetGuestAttributesResponse() ) @@ -10548,6 +10609,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -10578,6 +10640,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -10606,6 +10669,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -10636,6 +10700,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -10666,6 +10731,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -10696,6 +10762,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -10726,6 +10793,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -10756,6 +10824,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -10786,6 +10855,7 @@ def test_get_operation_rest_bad_request( 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) @@ -10816,6 +10886,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -10846,6 +10917,7 @@ def test_list_operations_rest_bad_request( 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) @@ -10876,6 +10948,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-trace/google/cloud/trace/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py index 6ed28847cbe8..31976891eef0 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .transports.grpc_asyncio import TraceServiceGrpcAsyncIOTransport +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 TraceServiceAsyncClient: """This file describes an API for collecting and viewing traces @@ -254,6 +264,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.devtools.cloudtrace_v1.TraceServiceAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "credentialsType": None, + }, + ) + async def list_traces( self, request: Optional[Union[trace.ListTracesRequest, dict]] = None, @@ -261,7 +293,7 @@ async def list_traces( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTracesAsyncPager: r"""Returns of a list of traces that match the specified filter conditions. @@ -307,8 +339,10 @@ async def sample_list_traces(): 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, 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: google.cloud.trace_v1.services.trace_service.pagers.ListTracesAsyncPager: @@ -385,7 +419,7 @@ async def get_trace( trace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Trace: r"""Gets a single trace by its ID. @@ -434,8 +468,10 @@ async def sample_get_trace(): 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, 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: google.cloud.trace_v1.types.Trace: @@ -507,7 +543,7 @@ async def patch_traces( traces: Optional[trace.Traces] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send @@ -558,8 +594,10 @@ async def sample_patch_traces(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py index 88b9461c2edb..41d1ed054d6a 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.trace_v1.services.trace_service import pagers from google.cloud.trace_v1.types import trace @@ -560,6 +570,10 @@ def __init__( # 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( @@ -622,6 +636,29 @@ def __init__( 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.devtools.cloudtrace_v1.TraceServiceClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "credentialsType": None, + }, + ) + def list_traces( self, request: Optional[Union[trace.ListTracesRequest, dict]] = None, @@ -629,7 +666,7 @@ def list_traces( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTracesPager: r"""Returns of a list of traces that match the specified filter conditions. @@ -675,8 +712,10 @@ def sample_list_traces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.trace_v1.services.trace_service.pagers.ListTracesPager: @@ -750,7 +789,7 @@ def get_trace( trace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Trace: r"""Gets a single trace by its ID. @@ -799,8 +838,10 @@ def sample_get_trace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.trace_v1.types.Trace: @@ -869,7 +910,7 @@ def patch_traces( traces: Optional[trace.Traces] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send @@ -920,8 +961,10 @@ def sample_patch_traces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py index 7713f73b2374..fcc3ddb83eb9 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = trace.ListTracesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = trace.ListTracesRequest(request) diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py index 68bbf4c3d2ff..c500d6d69f80 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.trace_v1.types import trace from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport +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.devtools.cloudtrace.v1.TraceService", + "rpcName": 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.devtools.cloudtrace.v1.TraceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcTransport(TraceServiceTransport): """gRPC backend transport for TraceService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def list_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_traces" not in self._stubs: - self._stubs["list_traces"] = self.grpc_channel.unary_unary( + self._stubs["list_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/ListTraces", request_serializer=trace.ListTracesRequest.serialize, response_deserializer=trace.ListTracesResponse.deserialize, @@ -284,7 +370,7 @@ def get_trace(self) -> Callable[[trace.GetTraceRequest], trace.Trace]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trace" not in self._stubs: - self._stubs["get_trace"] = self.grpc_channel.unary_unary( + self._stubs["get_trace"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/GetTrace", request_serializer=trace.GetTraceRequest.serialize, response_deserializer=trace.Trace.deserialize, @@ -314,7 +400,7 @@ def patch_traces(self) -> Callable[[trace.PatchTracesRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "patch_traces" not in self._stubs: - self._stubs["patch_traces"] = self.grpc_channel.unary_unary( + self._stubs["patch_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/PatchTraces", request_serializer=trace.PatchTracesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -322,7 +408,7 @@ def patch_traces(self) -> Callable[[trace.PatchTracesRequest], empty_pb2.Empty]: return self._stubs["patch_traces"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py index 5f1e5e1a17fb..1e7200ddebe6 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.trace_v1.types import trace from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .grpc import TraceServiceGrpcTransport +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.devtools.cloudtrace.v1.TraceService", + "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.devtools.cloudtrace.v1.TraceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcAsyncIOTransport(TraceServiceTransport): """gRPC AsyncIO backend transport for TraceService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def list_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_traces" not in self._stubs: - self._stubs["list_traces"] = self.grpc_channel.unary_unary( + self._stubs["list_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/ListTraces", request_serializer=trace.ListTracesRequest.serialize, response_deserializer=trace.ListTracesResponse.deserialize, @@ -292,7 +377,7 @@ def get_trace(self) -> Callable[[trace.GetTraceRequest], Awaitable[trace.Trace]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trace" not in self._stubs: - self._stubs["get_trace"] = self.grpc_channel.unary_unary( + self._stubs["get_trace"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/GetTrace", request_serializer=trace.GetTraceRequest.serialize, response_deserializer=trace.Trace.deserialize, @@ -324,7 +409,7 @@ def patch_traces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "patch_traces" not in self._stubs: - self._stubs["patch_traces"] = self.grpc_channel.unary_unary( + self._stubs["patch_traces"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v1.TraceService/PatchTraces", request_serializer=trace.PatchTracesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -387,7 +472,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py index 2744481b0daf..aa9d715a6019 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -88,8 +96,10 @@ def pre_patch_traces(self, request, metadata): """ def pre_get_trace( - self, request: trace.GetTraceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.GetTraceRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.GetTraceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.GetTraceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_trace Override in a subclass to manipulate the request or metadata @@ -107,8 +117,10 @@ def post_get_trace(self, response: trace.Trace) -> trace.Trace: return response def pre_list_traces( - self, request: trace.ListTracesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.ListTracesRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.ListTracesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.ListTracesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_traces Override in a subclass to manipulate the request or metadata @@ -128,8 +140,10 @@ def post_list_traces( return response def pre_patch_traces( - self, request: trace.PatchTracesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.PatchTracesRequest, Sequence[Tuple[str, str]]]: + self, + request: trace.PatchTracesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[trace.PatchTracesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch_traces Override in a subclass to manipulate the request or metadata @@ -261,7 +275,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Trace: r"""Call the get trace method over HTTP. @@ -271,8 +285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.trace.Trace: @@ -287,6 +303,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseGetTrace._get_http_options() ) + request, metadata = self._interceptor.pre_get_trace(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseGetTrace._get_transcoded_request( @@ -301,6 +318,33 @@ def __call__( ) ) + 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.devtools.cloudtrace_v1.TraceServiceClient.GetTrace", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "GetTrace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._GetTrace._get_response( self._host, @@ -321,7 +365,29 @@ def __call__( pb_resp = trace.Trace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_trace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.Trace.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.devtools.cloudtrace_v1.TraceServiceClient.get_trace", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "GetTrace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTraces( @@ -358,7 +424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.ListTracesResponse: r"""Call the list traces method over HTTP. @@ -369,8 +435,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.trace.ListTracesResponse: @@ -380,6 +448,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseListTraces._get_http_options() ) + request, metadata = self._interceptor.pre_list_traces(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseListTraces._get_transcoded_request( @@ -394,6 +463,33 @@ def __call__( ) ) + 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.devtools.cloudtrace_v1.TraceServiceClient.ListTraces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "ListTraces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._ListTraces._get_response( self._host, @@ -414,7 +510,29 @@ def __call__( pb_resp = trace.ListTracesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_traces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.ListTracesResponse.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.devtools.cloudtrace_v1.TraceServiceClient.list_traces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "ListTraces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchTraces( @@ -452,7 +570,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the patch traces method over HTTP. @@ -462,13 +580,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTraceServiceRestTransport._BasePatchTraces._get_http_options() ) + request, metadata = self._interceptor.pre_patch_traces(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BasePatchTraces._get_transcoded_request( @@ -489,6 +610,33 @@ def __call__( ) ) + 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.devtools.cloudtrace_v1.TraceServiceClient.PatchTraces", + extra={ + "serviceName": "google.devtools.cloudtrace.v1.TraceService", + "rpcName": "PatchTraces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._PatchTraces._get_response( self._host, diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py b/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py index 2eb82e7b7427..d398284fb2fd 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .transports.grpc_asyncio import TraceServiceGrpcAsyncIOTransport +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 TraceServiceAsyncClient: """Service for collecting and viewing traces and spans within a @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.devtools.cloudtrace_v2.TraceServiceAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "credentialsType": None, + }, + ) + async def batch_write_spans( self, request: Optional[Union[tracing.BatchWriteSpansRequest, dict]] = None, @@ -269,7 +301,7 @@ async def batch_write_spans( spans: Optional[MutableSequence[trace.Span]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Batch writes new spans to new or existing traces. You cannot update existing spans. @@ -324,8 +356,10 @@ async def sample_batch_write_spans(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -378,7 +412,7 @@ async def create_span( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Span: r"""Creates a new span. @@ -425,8 +459,10 @@ async def sample_create_span(): 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, 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: google.cloud.trace_v2.types.Span: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py index 51b81b2f7017..06424cdf1fd6 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -587,6 +597,10 @@ def __init__( # 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( @@ -649,6 +663,29 @@ def __init__( 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.devtools.cloudtrace_v2.TraceServiceClient`.", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "credentialsType": None, + }, + ) + def batch_write_spans( self, request: Optional[Union[tracing.BatchWriteSpansRequest, dict]] = None, @@ -657,7 +694,7 @@ def batch_write_spans( spans: Optional[MutableSequence[trace.Span]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Batch writes new spans to new or existing traces. You cannot update existing spans. @@ -712,8 +749,10 @@ def sample_batch_write_spans(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -763,7 +802,7 @@ def create_span( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Span: r"""Creates a new span. @@ -810,8 +849,10 @@ def sample_create_span(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.trace_v2.types.Span: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py index ea932ffe20b3..6a41fb389670 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.trace_v2.types import trace, tracing from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport +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.devtools.cloudtrace.v2.TraceService", + "rpcName": 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.devtools.cloudtrace.v2.TraceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcTransport(TraceServiceTransport): """gRPC backend transport for TraceService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -262,7 +348,7 @@ def batch_write_spans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_write_spans" not in self._stubs: - self._stubs["batch_write_spans"] = self.grpc_channel.unary_unary( + self._stubs["batch_write_spans"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans", request_serializer=tracing.BatchWriteSpansRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -286,7 +372,7 @@ def create_span(self) -> Callable[[trace.Span], trace.Span]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_span" not in self._stubs: - self._stubs["create_span"] = self.grpc_channel.unary_unary( + self._stubs["create_span"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/CreateSpan", request_serializer=trace.Span.serialize, response_deserializer=trace.Span.deserialize, @@ -294,7 +380,7 @@ def create_span(self) -> Callable[[trace.Span], trace.Span]: return self._stubs["create_span"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py index 492d02f2b9f0..deafca3ddf29 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.trace_v2.types import trace, tracing from .base import DEFAULT_CLIENT_INFO, TraceServiceTransport from .grpc import TraceServiceGrpcTransport +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.devtools.cloudtrace.v2.TraceService", + "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.devtools.cloudtrace.v2.TraceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TraceServiceGrpcAsyncIOTransport(TraceServiceTransport): """gRPC AsyncIO backend transport for TraceService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def batch_write_spans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_write_spans" not in self._stubs: - self._stubs["batch_write_spans"] = self.grpc_channel.unary_unary( + self._stubs["batch_write_spans"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans", request_serializer=tracing.BatchWriteSpansRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -294,7 +379,7 @@ def create_span(self) -> Callable[[trace.Span], Awaitable[trace.Span]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_span" not in self._stubs: - self._stubs["create_span"] = self.grpc_channel.unary_unary( + self._stubs["create_span"] = self._logged_channel.unary_unary( "/google.devtools.cloudtrace.v2.TraceService/CreateSpan", request_serializer=trace.Span.serialize, response_deserializer=trace.Span.deserialize, @@ -342,7 +427,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py index 898fa25a0814..7bf5d092ee99 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -82,8 +90,8 @@ def post_create_span(self, response): def pre_batch_write_spans( self, request: tracing.BatchWriteSpansRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tracing.BatchWriteSpansRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tracing.BatchWriteSpansRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_write_spans Override in a subclass to manipulate the request or metadata @@ -92,8 +100,8 @@ def pre_batch_write_spans( return request, metadata def pre_create_span( - self, request: trace.Span, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[trace.Span, Sequence[Tuple[str, str]]]: + self, request: trace.Span, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[trace.Span, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_span Override in a subclass to manipulate the request or metadata @@ -239,7 +247,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the batch write spans method over HTTP. @@ -249,13 +257,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTraceServiceRestTransport._BaseBatchWriteSpans._get_http_options() ) + request, metadata = self._interceptor.pre_batch_write_spans( request, metadata ) @@ -272,6 +283,33 @@ def __call__( 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.devtools.cloudtrace_v2.TraceServiceClient.BatchWriteSpans", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "BatchWriteSpans", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._BatchWriteSpans._get_response( self._host, @@ -323,7 +361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trace.Span: r"""Call the create span method over HTTP. @@ -343,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.trace.Span: @@ -365,6 +405,7 @@ def __call__( http_options = ( _BaseTraceServiceRestTransport._BaseCreateSpan._get_http_options() ) + request, metadata = self._interceptor.pre_create_span(request, metadata) transcoded_request = ( _BaseTraceServiceRestTransport._BaseCreateSpan._get_transcoded_request( @@ -385,6 +426,33 @@ def __call__( ) ) + 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.devtools.cloudtrace_v2.TraceServiceClient.CreateSpan", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "CreateSpan", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TraceServiceRestTransport._CreateSpan._get_response( self._host, @@ -406,7 +474,29 @@ def __call__( pb_resp = trace.Span.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_span(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trace.Span.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.devtools.cloudtrace_v2.TraceServiceClient.create_span", + extra={ + "serviceName": "google.devtools.cloudtrace.v2.TraceService", + "rpcName": "CreateSpan", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json index 7c1dfd761136..a4f20614ce5b 100644 --- a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json +++ b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-trace", - "version": "1.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.types.Trace", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.types.Trace", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.services.trace_service.pagers.ListTracesAsyncPager", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v1.services.trace_service.pagers.ListTracesPager", @@ -381,7 +381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "patch_traces" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "patch_traces" diff --git a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json index 6b5b5d92f372..b7d6fcf9f839 100644 --- a/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json +++ b/packages/google-cloud-trace/samples/generated_samples/snippet_metadata_google.devtools.cloudtrace.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-trace", - "version": "1.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_write_spans" @@ -132,7 +132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_write_spans" @@ -206,7 +206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v2.types.Span", @@ -282,7 +282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.trace_v2.types.Span", diff --git a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py index f408bb6c6666..0edd38cff7b2 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py @@ -2333,6 +2333,7 @@ def test_list_traces_rest_required_fields(request_type=trace.ListTracesRequest): response_value._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_traces(request) @@ -2391,6 +2392,7 @@ def test_list_traces_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_traces(**mock_args) @@ -2583,6 +2585,7 @@ def test_get_trace_rest_required_fields(request_type=trace.GetTraceRequest): response_value._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_trace(request) @@ -2637,6 +2640,7 @@ def test_get_trace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_trace(**mock_args) @@ -2764,6 +2768,7 @@ def test_patch_traces_rest_required_fields(request_type=trace.PatchTracesRequest response_value._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.patch_traces(request) @@ -2816,6 +2821,7 @@ def test_patch_traces_rest_flattened(): 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"} client.patch_traces(**mock_args) @@ -3131,6 +3137,7 @@ def test_list_traces_rest_bad_request(request_type=trace.ListTracesRequest): 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_traces(request) @@ -3166,6 +3173,7 @@ def test_list_traces_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_traces(request) # Establish that the response is the type that we expect. @@ -3204,6 +3212,7 @@ def test_list_traces_rest_interceptors(null_interceptor): 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 = trace.ListTracesResponse.to_json(trace.ListTracesResponse()) req.return_value.content = return_value @@ -3246,6 +3255,7 @@ def test_get_trace_rest_bad_request(request_type=trace.GetTraceRequest): 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_trace(request) @@ -3282,6 +3292,7 @@ def test_get_trace_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_trace(request) # Establish that the response is the type that we expect. @@ -3321,6 +3332,7 @@ def test_get_trace_rest_interceptors(null_interceptor): 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 = trace.Trace.to_json(trace.Trace()) req.return_value.content = return_value @@ -3363,6 +3375,7 @@ def test_patch_traces_rest_bad_request(request_type=trace.PatchTracesRequest): 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.patch_traces(request) @@ -3479,6 +3492,7 @@ def get_message_fields(field): 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.patch_traces(request) # Establish that the response is the type that we expect. @@ -3513,6 +3527,7 @@ def test_patch_traces_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = trace.PatchTracesRequest() metadata = [ diff --git a/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py index 43f62175b138..58b8e3ab660b 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py @@ -1737,6 +1737,7 @@ def test_batch_write_spans_rest_required_fields( response_value._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.batch_write_spans(request) @@ -1789,6 +1790,7 @@ def test_batch_write_spans_rest_flattened(): 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"} client.batch_write_spans(**mock_args) @@ -1923,6 +1925,7 @@ def test_create_span_rest_required_fields(request_type=trace.Span): response_value._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_span(request) @@ -2198,6 +2201,7 @@ def test_batch_write_spans_rest_bad_request( 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.batch_write_spans(request) @@ -2228,6 +2232,7 @@ def test_batch_write_spans_rest_call_success(request_type): 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.batch_write_spans(request) # Establish that the response is the type that we expect. @@ -2262,6 +2267,7 @@ def test_batch_write_spans_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = tracing.BatchWriteSpansRequest() metadata = [ @@ -2300,6 +2306,7 @@ def test_create_span_rest_bad_request(request_type=trace.Span): 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_span(request) @@ -2338,6 +2345,7 @@ def test_create_span_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_span(request) # Establish that the response is the type that we expect. @@ -2379,6 +2387,7 @@ def test_create_span_rest_interceptors(null_interceptor): 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 = trace.Span.to_json(trace.Span()) req.return_value.content = return_value diff --git a/packages/google-cloud-translate/google/cloud/translate/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py index be93575f07a6..480dde1e4f0b 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport +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 TranslationServiceAsyncClient: """Provides natural language translation operations.""" @@ -299,6 +309,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.translation_v3.TranslationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "credentialsType": None, + }, + ) + async def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, @@ -311,7 +343,7 @@ async def translate_text( source_language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -437,8 +469,10 @@ async def sample_translate_text(): 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, 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: google.cloud.translate_v3.types.TranslateTextResponse: @@ -517,7 +551,7 @@ async def romanize_text( contents: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Romanize input text written in non-Latin scripts to Latin text. @@ -578,8 +612,10 @@ async def sample_romanize_text(): 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, 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: google.cloud.translate_v3.types.RomanizeTextResponse: @@ -647,7 +683,7 @@ async def detect_language( content: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -735,8 +771,10 @@ async def sample_detect_language(): 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, 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: google.cloud.translate_v3.types.DetectLanguageResponse: @@ -807,7 +845,7 @@ async def get_supported_languages( display_language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -893,8 +931,10 @@ async def sample_get_supported_languages(): 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, 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: google.cloud.translate_v3.types.SupportedLanguages: @@ -960,7 +1000,7 @@ async def translate_document( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1001,8 +1041,10 @@ async def sample_translate_document(): 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, 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: google.cloud.translate_v3.types.TranslateDocumentResponse: @@ -1050,7 +1092,7 @@ async def batch_translate_text( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1109,8 +1151,10 @@ async def sample_batch_translate_text(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1177,7 +1221,7 @@ async def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1291,8 +1335,10 @@ async def sample_batch_translate_document(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1384,7 +1430,7 @@ async def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1439,8 +1485,10 @@ async def sample_create_glossary(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1517,7 +1565,7 @@ async def update_glossary( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a glossary. A LRO is used since the update can be async if the glossary's entry file is updated. @@ -1576,8 +1624,10 @@ async def sample_update_glossary(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1655,7 +1705,7 @@ async def list_glossaries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossariesAsyncPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1701,8 +1751,10 @@ async def sample_list_glossaries(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesAsyncPager: @@ -1777,7 +1829,7 @@ async def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1821,8 +1873,10 @@ async def sample_get_glossary(): 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, 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: google.cloud.translate_v3.types.Glossary: @@ -1885,7 +1939,7 @@ async def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1934,8 +1988,10 @@ async def sample_delete_glossary(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2009,7 +2065,7 @@ async def get_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Gets a single glossary entry by the given id. @@ -2053,8 +2109,10 @@ async def sample_get_glossary_entry(): 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, 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2117,7 +2175,7 @@ async def list_glossary_entries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossaryEntriesAsyncPager: r"""List the entries for the glossary. @@ -2163,8 +2221,10 @@ async def sample_list_glossary_entries(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesAsyncPager: @@ -2242,7 +2302,7 @@ async def create_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Creates a glossary entry. @@ -2293,8 +2353,10 @@ async def sample_create_glossary_entry(): 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, 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2359,7 +2421,7 @@ async def update_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Updates a glossary entry. @@ -2402,8 +2464,10 @@ async def sample_update_glossary_entry(): 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, 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2468,7 +2532,7 @@ async def delete_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a single entry from the glossary @@ -2509,8 +2573,10 @@ async def sample_delete_glossary_entry(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2563,7 +2629,7 @@ async def create_dataset( dataset: Optional[automl_translation.Dataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Dataset. @@ -2613,8 +2679,10 @@ async def sample_create_dataset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2687,7 +2755,7 @@ async def get_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Dataset: r"""Gets a Dataset. @@ -2730,8 +2798,10 @@ async def sample_get_dataset(): 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, 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: google.cloud.translate_v3.types.Dataset: @@ -2793,7 +2863,7 @@ async def list_datasets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatasetsAsyncPager: r"""Lists datasets. @@ -2837,8 +2907,10 @@ async def sample_list_datasets(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsAsyncPager: @@ -2913,7 +2985,7 @@ async def delete_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a dataset and all of its contents. @@ -2960,8 +3032,10 @@ async def sample_delete_dataset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3043,7 +3117,7 @@ async def create_adaptive_mt_dataset( adaptive_mt_dataset: Optional[adaptive_mt.AdaptiveMtDataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Creates an Adaptive MT dataset. @@ -3098,8 +3172,10 @@ async def sample_create_adaptive_mt_dataset(): 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, 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: google.cloud.translate_v3.types.AdaptiveMtDataset: @@ -3162,7 +3238,7 @@ async def delete_adaptive_mt_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an Adaptive MT dataset, including all its entries and associated metadata. @@ -3204,8 +3280,10 @@ async def sample_delete_adaptive_mt_dataset(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3257,7 +3335,7 @@ async def get_adaptive_mt_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Gets the Adaptive MT dataset. @@ -3301,8 +3379,10 @@ async def sample_get_adaptive_mt_dataset(): 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, 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: google.cloud.translate_v3.types.AdaptiveMtDataset: @@ -3363,7 +3443,7 @@ async def list_adaptive_mt_datasets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtDatasetsAsyncPager: r"""Lists all Adaptive MT datasets for which the caller has read permission. @@ -3411,8 +3491,10 @@ async def sample_list_adaptive_mt_datasets(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsAsyncPager: @@ -3488,7 +3570,7 @@ async def adaptive_mt_translate( content: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Translate text using Adaptive MT. @@ -3543,8 +3625,10 @@ async def sample_adaptive_mt_translate(): 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, 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: google.cloud.translate_v3.types.AdaptiveMtTranslateResponse: @@ -3605,7 +3689,7 @@ async def get_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Gets and AdaptiveMtFile @@ -3649,8 +3733,10 @@ async def sample_get_adaptive_mt_file(): 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, 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: google.cloud.translate_v3.types.AdaptiveMtFile: @@ -3709,7 +3795,7 @@ async def delete_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an AdaptiveMtFile along with its sentences. @@ -3751,8 +3837,10 @@ async def sample_delete_adaptive_mt_file(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3804,7 +3892,7 @@ async def import_adaptive_mt_file( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset. @@ -3856,8 +3944,10 @@ async def sample_import_adaptive_mt_file(): 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, 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: google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse: @@ -3918,7 +4008,7 @@ async def list_adaptive_mt_files( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtFilesAsyncPager: r"""Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset. @@ -3965,8 +4055,10 @@ async def sample_list_adaptive_mt_files(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesAsyncPager: @@ -4043,7 +4135,7 @@ async def list_adaptive_mt_sentences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtSentencesAsyncPager: r"""Lists all AdaptiveMtSentences under a given file/dataset. @@ -4094,8 +4186,10 @@ async def sample_list_adaptive_mt_sentences(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesAsyncPager: @@ -4171,7 +4265,7 @@ async def import_data( input_config: Optional[automl_translation.DatasetInputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Import sentence pairs into translation Dataset. @@ -4225,8 +4319,10 @@ async def sample_import_data(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4308,7 +4404,7 @@ async def export_data( output_config: Optional[automl_translation.DatasetOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports dataset's data to the provided output location. @@ -4367,8 +4463,10 @@ async def sample_export_data(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4449,7 +4547,7 @@ async def list_examples( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExamplesAsyncPager: r"""Lists sentence pairs in the dataset. @@ -4493,8 +4591,10 @@ async def sample_list_examples(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListExamplesAsyncPager: @@ -4570,7 +4670,7 @@ async def create_model( model: Optional[automl_translation.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Model. @@ -4622,8 +4722,10 @@ async def sample_create_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4697,7 +4799,7 @@ async def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsAsyncPager: r"""Lists models. @@ -4741,8 +4843,10 @@ async def sample_list_models(): 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, 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: google.cloud.translate_v3.services.translation_service.pagers.ListModelsAsyncPager: @@ -4817,7 +4921,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Model: r"""Gets a model. @@ -4860,8 +4964,10 @@ async def sample_get_model(): 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, 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: google.cloud.translate_v3.types.Model: @@ -4920,7 +5026,7 @@ async def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a model. @@ -4967,8 +5073,10 @@ async def sample_delete_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5046,7 +5154,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5057,8 +5165,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -5099,7 +5209,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -5110,8 +5220,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5152,7 +5264,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -5168,8 +5280,10 @@ async def delete_operation( 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, 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: None """ @@ -5206,7 +5320,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -5221,8 +5335,10 @@ async def cancel_operation( 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, 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: None """ @@ -5259,7 +5375,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -5276,8 +5392,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5318,7 +5436,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -5329,8 +5447,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -5371,7 +5491,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -5382,8 +5502,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py index 4cd600ec7dc1..f42d0570a00a 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -761,6 +771,10 @@ def __init__( # 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( @@ -827,6 +841,29 @@ def __init__( 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.translation_v3.TranslationServiceClient`.", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "credentialsType": None, + }, + ) + def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, @@ -839,7 +876,7 @@ def translate_text( source_language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -965,8 +1002,10 @@ def sample_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.TranslateTextResponse: @@ -1042,7 +1081,7 @@ def romanize_text( contents: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Romanize input text written in non-Latin scripts to Latin text. @@ -1103,8 +1142,10 @@ def sample_romanize_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.RomanizeTextResponse: @@ -1169,7 +1210,7 @@ def detect_language( content: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -1257,8 +1298,10 @@ def sample_detect_language(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.DetectLanguageResponse: @@ -1326,7 +1369,7 @@ def get_supported_languages( display_language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -1412,8 +1455,10 @@ def sample_get_supported_languages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.SupportedLanguages: @@ -1476,7 +1521,7 @@ def translate_document( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1517,8 +1562,10 @@ def sample_translate_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.TranslateDocumentResponse: @@ -1564,7 +1611,7 @@ def batch_translate_text( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1623,8 +1670,10 @@ def sample_batch_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1689,7 +1738,7 @@ def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1803,8 +1852,10 @@ def sample_batch_translate_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1893,7 +1944,7 @@ def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1948,8 +1999,10 @@ def sample_create_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2023,7 +2076,7 @@ def update_glossary( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a glossary. A LRO is used since the update can be async if the glossary's entry file is updated. @@ -2082,8 +2135,10 @@ def sample_update_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2158,7 +2213,7 @@ def list_glossaries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossariesPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -2204,8 +2259,10 @@ def sample_list_glossaries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager: @@ -2277,7 +2334,7 @@ def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -2321,8 +2378,10 @@ def sample_get_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.Glossary: @@ -2382,7 +2441,7 @@ def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -2431,8 +2490,10 @@ def sample_delete_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2503,7 +2564,7 @@ def get_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Gets a single glossary entry by the given id. @@ -2547,8 +2608,10 @@ def sample_get_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2608,7 +2671,7 @@ def list_glossary_entries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossaryEntriesPager: r"""List the entries for the glossary. @@ -2654,8 +2717,10 @@ def sample_list_glossary_entries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesPager: @@ -2730,7 +2795,7 @@ def create_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Creates a glossary entry. @@ -2781,8 +2846,10 @@ def sample_create_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2844,7 +2911,7 @@ def update_glossary_entry( glossary_entry: Optional[common.GlossaryEntry] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Updates a glossary entry. @@ -2887,8 +2954,10 @@ def sample_update_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.GlossaryEntry: @@ -2950,7 +3019,7 @@ def delete_glossary_entry( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a single entry from the glossary @@ -2991,8 +3060,10 @@ def sample_delete_glossary_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3042,7 +3113,7 @@ def create_dataset( dataset: Optional[automl_translation.Dataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Dataset. @@ -3092,8 +3163,10 @@ def sample_create_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3163,7 +3236,7 @@ def get_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Dataset: r"""Gets a Dataset. @@ -3206,8 +3279,10 @@ def sample_get_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.Dataset: @@ -3266,7 +3341,7 @@ def list_datasets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatasetsPager: r"""Lists datasets. @@ -3310,8 +3385,10 @@ def sample_list_datasets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsPager: @@ -3383,7 +3460,7 @@ def delete_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a dataset and all of its contents. @@ -3430,8 +3507,10 @@ def sample_delete_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3510,7 +3589,7 @@ def create_adaptive_mt_dataset( adaptive_mt_dataset: Optional[adaptive_mt.AdaptiveMtDataset] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Creates an Adaptive MT dataset. @@ -3565,8 +3644,10 @@ def sample_create_adaptive_mt_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.AdaptiveMtDataset: @@ -3628,7 +3709,7 @@ def delete_adaptive_mt_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an Adaptive MT dataset, including all its entries and associated metadata. @@ -3670,8 +3751,10 @@ def sample_delete_adaptive_mt_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3722,7 +3805,7 @@ def get_adaptive_mt_dataset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Gets the Adaptive MT dataset. @@ -3766,8 +3849,10 @@ def sample_get_adaptive_mt_dataset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.AdaptiveMtDataset: @@ -3825,7 +3910,7 @@ def list_adaptive_mt_datasets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtDatasetsPager: r"""Lists all Adaptive MT datasets for which the caller has read permission. @@ -3873,8 +3958,10 @@ def sample_list_adaptive_mt_datasets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsPager: @@ -3949,7 +4036,7 @@ def adaptive_mt_translate( content: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Translate text using Adaptive MT. @@ -4004,8 +4091,10 @@ def sample_adaptive_mt_translate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.AdaptiveMtTranslateResponse: @@ -4063,7 +4152,7 @@ def get_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Gets and AdaptiveMtFile @@ -4107,8 +4196,10 @@ def sample_get_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.AdaptiveMtFile: @@ -4164,7 +4255,7 @@ def delete_adaptive_mt_file( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an AdaptiveMtFile along with its sentences. @@ -4206,8 +4297,10 @@ def sample_delete_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4256,7 +4349,7 @@ def import_adaptive_mt_file( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset. @@ -4308,8 +4401,10 @@ def sample_import_adaptive_mt_file(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse: @@ -4367,7 +4462,7 @@ def list_adaptive_mt_files( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtFilesPager: r"""Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset. @@ -4414,8 +4509,10 @@ def sample_list_adaptive_mt_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesPager: @@ -4489,7 +4586,7 @@ def list_adaptive_mt_sentences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdaptiveMtSentencesPager: r"""Lists all AdaptiveMtSentences under a given file/dataset. @@ -4540,8 +4637,10 @@ def sample_list_adaptive_mt_sentences(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesPager: @@ -4616,7 +4715,7 @@ def import_data( input_config: Optional[automl_translation.DatasetInputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Import sentence pairs into translation Dataset. @@ -4670,8 +4769,10 @@ def sample_import_data(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4750,7 +4851,7 @@ def export_data( output_config: Optional[automl_translation.DatasetOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports dataset's data to the provided output location. @@ -4809,8 +4910,10 @@ def sample_export_data(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4888,7 +4991,7 @@ def list_examples( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExamplesPager: r"""Lists sentence pairs in the dataset. @@ -4932,8 +5035,10 @@ def sample_list_examples(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3.services.translation_service.pagers.ListExamplesPager: @@ -5006,7 +5111,7 @@ def create_model( model: Optional[automl_translation.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Model. @@ -5058,8 +5163,10 @@ def sample_create_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -5130,7 +5237,7 @@ def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsPager: r"""Lists models. @@ -5174,8 +5281,10 @@ def sample_list_models(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.translate_v3.services.translation_service.pagers.ListModelsPager: @@ -5247,7 +5356,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Model: r"""Gets a model. @@ -5290,8 +5399,10 @@ def sample_get_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.translate_v3.types.Model: @@ -5347,7 +5458,7 @@ def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a model. @@ -5394,8 +5505,10 @@ def sample_delete_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -5483,7 +5596,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5494,8 +5607,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -5536,7 +5651,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -5547,8 +5662,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5589,7 +5706,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -5605,8 +5722,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5643,7 +5762,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -5658,8 +5777,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5696,7 +5817,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -5713,8 +5834,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5755,7 +5878,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -5766,8 +5889,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -5808,7 +5933,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -5819,8 +5944,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py index dffa95ae680c..27bb1887dbbf 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = translation_service.ListGlossariesRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( 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, 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`. """ self._method = method self._request = translation_service.ListGlossariesRequest(request) @@ -224,7 +228,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -238,8 +242,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = translation_service.ListGlossaryEntriesRequest(request) @@ -300,7 +306,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -314,8 +320,10 @@ def __init__( 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, 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`. """ self._method = method self._request = translation_service.ListGlossaryEntriesRequest(request) @@ -380,7 +388,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -394,8 +402,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = automl_translation.ListDatasetsRequest(request) @@ -454,7 +464,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -468,8 +478,10 @@ def __init__( 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, 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`. """ self._method = method self._request = automl_translation.ListDatasetsRequest(request) @@ -532,7 +544,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -546,8 +558,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtDatasetsRequest(request) @@ -606,7 +620,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -620,8 +634,10 @@ def __init__( 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, 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtDatasetsRequest(request) @@ -684,7 +700,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -698,8 +714,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtFilesRequest(request) @@ -758,7 +776,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -772,8 +790,10 @@ def __init__( 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, 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtFilesRequest(request) @@ -836,7 +856,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -850,8 +870,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtSentencesRequest(request) @@ -910,7 +932,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -924,8 +946,10 @@ def __init__( 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, 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`. """ self._method = method self._request = adaptive_mt.ListAdaptiveMtSentencesRequest(request) @@ -988,7 +1012,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1002,8 +1026,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = automl_translation.ListExamplesRequest(request) @@ -1062,7 +1088,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1076,8 +1102,10 @@ def __init__( 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, 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`. """ self._method = method self._request = automl_translation.ListExamplesRequest(request) @@ -1140,7 +1168,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1154,8 +1182,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = automl_translation.ListModelsRequest(request) @@ -1214,7 +1244,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1228,8 +1258,10 @@ def __init__( 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, 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`. """ self._method = method self._request = automl_translation.ListModelsRequest(request) diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py index f2effd13612c..7187ff19bb97 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,7 +28,10 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.translate_v3.types import ( adaptive_mt, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport +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.translation.v3.TranslationService", + "rpcName": 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.translation.v3.TranslationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcTransport(TranslationServiceTransport): """gRPC backend transport for TranslationService. @@ -190,7 +271,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -311,7 +399,7 @@ def romanize_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "romanize_text" not in self._stubs: - self._stubs["romanize_text"] = self.grpc_channel.unary_unary( + self._stubs["romanize_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/RomanizeText", request_serializer=translation_service.RomanizeTextRequest.serialize, response_deserializer=translation_service.RomanizeTextResponse.deserialize, @@ -340,7 +428,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -370,7 +458,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -399,7 +487,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -436,7 +524,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -473,7 +561,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -502,7 +590,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +619,7 @@ def update_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary" not in self._stubs: - self._stubs["update_glossary"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossary", request_serializer=translation_service.UpdateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -561,7 +649,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -590,7 +678,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -620,7 +708,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -646,7 +734,7 @@ def get_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary_entry" not in self._stubs: - self._stubs["get_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossaryEntry", request_serializer=translation_service.GetGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -675,7 +763,7 @@ def list_glossary_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossary_entries" not in self._stubs: - self._stubs["list_glossary_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossary_entries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaryEntries", request_serializer=translation_service.ListGlossaryEntriesRequest.serialize, response_deserializer=translation_service.ListGlossaryEntriesResponse.deserialize, @@ -703,7 +791,7 @@ def create_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary_entry" not in self._stubs: - self._stubs["create_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossaryEntry", request_serializer=translation_service.CreateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -731,7 +819,7 @@ def update_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary_entry" not in self._stubs: - self._stubs["update_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossaryEntry", request_serializer=translation_service.UpdateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -757,7 +845,7 @@ def delete_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary_entry" not in self._stubs: - self._stubs["delete_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossaryEntry", request_serializer=translation_service.DeleteGlossaryEntryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -783,7 +871,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateDataset", request_serializer=automl_translation.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -809,7 +897,7 @@ def get_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetDataset", request_serializer=automl_translation.GetDatasetRequest.serialize, response_deserializer=automl_translation.Dataset.deserialize, @@ -838,7 +926,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListDatasets", request_serializer=automl_translation.ListDatasetsRequest.serialize, response_deserializer=automl_translation.ListDatasetsResponse.deserialize, @@ -864,7 +952,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteDataset", request_serializer=automl_translation.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -892,7 +980,9 @@ def create_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_adaptive_mt_dataset" not in self._stubs: - self._stubs["create_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset", request_serializer=adaptive_mt.CreateAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -919,7 +1009,9 @@ def delete_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_dataset" not in self._stubs: - self._stubs["delete_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset", request_serializer=adaptive_mt.DeleteAdaptiveMtDatasetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -947,7 +1039,7 @@ def get_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_dataset" not in self._stubs: - self._stubs["get_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset", request_serializer=adaptive_mt.GetAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -977,7 +1069,7 @@ def list_adaptive_mt_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_datasets" not in self._stubs: - self._stubs["list_adaptive_mt_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets", request_serializer=adaptive_mt.ListAdaptiveMtDatasetsRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtDatasetsResponse.deserialize, @@ -1006,7 +1098,7 @@ def adaptive_mt_translate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "adaptive_mt_translate" not in self._stubs: - self._stubs["adaptive_mt_translate"] = self.grpc_channel.unary_unary( + self._stubs["adaptive_mt_translate"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate", request_serializer=adaptive_mt.AdaptiveMtTranslateRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtTranslateResponse.deserialize, @@ -1032,7 +1124,7 @@ def get_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_file" not in self._stubs: - self._stubs["get_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile", request_serializer=adaptive_mt.GetAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtFile.deserialize, @@ -1058,7 +1150,7 @@ def delete_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_file" not in self._stubs: - self._stubs["delete_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile", request_serializer=adaptive_mt.DeleteAdaptiveMtFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1088,7 +1180,7 @@ def import_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_adaptive_mt_file" not in self._stubs: - self._stubs["import_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["import_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile", request_serializer=adaptive_mt.ImportAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.ImportAdaptiveMtFileResponse.deserialize, @@ -1118,7 +1210,7 @@ def list_adaptive_mt_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_files" not in self._stubs: - self._stubs["list_adaptive_mt_files"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_files"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles", request_serializer=adaptive_mt.ListAdaptiveMtFilesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtFilesResponse.deserialize, @@ -1148,7 +1240,9 @@ def list_adaptive_mt_sentences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_sentences" not in self._stubs: - self._stubs["list_adaptive_mt_sentences"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_adaptive_mt_sentences" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences", request_serializer=adaptive_mt.ListAdaptiveMtSentencesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtSentencesResponse.deserialize, @@ -1174,7 +1268,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportData", request_serializer=automl_translation.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1201,7 +1295,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ExportData", request_serializer=automl_translation.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1230,7 +1324,7 @@ def list_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_examples" not in self._stubs: - self._stubs["list_examples"] = self.grpc_channel.unary_unary( + self._stubs["list_examples"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListExamples", request_serializer=automl_translation.ListExamplesRequest.serialize, response_deserializer=automl_translation.ListExamplesResponse.deserialize, @@ -1256,7 +1350,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateModel", request_serializer=automl_translation.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1284,7 +1378,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListModels", request_serializer=automl_translation.ListModelsRequest.serialize, response_deserializer=automl_translation.ListModelsResponse.deserialize, @@ -1310,7 +1404,7 @@ def get_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetModel", request_serializer=automl_translation.GetModelRequest.serialize, response_deserializer=automl_translation.Model.deserialize, @@ -1336,7 +1430,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteModel", request_serializer=automl_translation.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1344,7 +1438,7 @@ def delete_model( return self._stubs["delete_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1356,7 +1450,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1373,7 +1467,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1390,7 +1484,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -1407,7 +1501,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1426,7 +1520,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1445,7 +1539,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1462,7 +1556,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py index 7a7dcffd0ad2..1712f606af99 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -27,8 +30,11 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.translate_v3.types import ( adaptive_mt, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .grpc import TranslationServiceGrpcTransport +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.translation.v3.TranslationService", + "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.translation.v3.TranslationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcAsyncIOTransport(TranslationServiceTransport): """gRPC AsyncIO backend transport for TranslationService. @@ -237,10 +319,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -321,7 +406,7 @@ def romanize_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "romanize_text" not in self._stubs: - self._stubs["romanize_text"] = self.grpc_channel.unary_unary( + self._stubs["romanize_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/RomanizeText", request_serializer=translation_service.RomanizeTextRequest.serialize, response_deserializer=translation_service.RomanizeTextResponse.deserialize, @@ -350,7 +435,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -380,7 +465,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -409,7 +494,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -447,7 +532,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -514,7 +599,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +628,7 @@ def update_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary" not in self._stubs: - self._stubs["update_glossary"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossary", request_serializer=translation_service.UpdateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -573,7 +658,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -603,7 +688,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -633,7 +718,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +746,7 @@ def get_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary_entry" not in self._stubs: - self._stubs["get_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetGlossaryEntry", request_serializer=translation_service.GetGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -690,7 +775,7 @@ def list_glossary_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossary_entries" not in self._stubs: - self._stubs["list_glossary_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossary_entries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListGlossaryEntries", request_serializer=translation_service.ListGlossaryEntriesRequest.serialize, response_deserializer=translation_service.ListGlossaryEntriesResponse.deserialize, @@ -719,7 +804,7 @@ def create_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary_entry" not in self._stubs: - self._stubs["create_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateGlossaryEntry", request_serializer=translation_service.CreateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -748,7 +833,7 @@ def update_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_glossary_entry" not in self._stubs: - self._stubs["update_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["update_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/UpdateGlossaryEntry", request_serializer=translation_service.UpdateGlossaryEntryRequest.serialize, response_deserializer=common.GlossaryEntry.deserialize, @@ -776,7 +861,7 @@ def delete_glossary_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary_entry" not in self._stubs: - self._stubs["delete_glossary_entry"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary_entry"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteGlossaryEntry", request_serializer=translation_service.DeleteGlossaryEntryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -804,7 +889,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateDataset", request_serializer=automl_translation.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +917,7 @@ def get_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetDataset", request_serializer=automl_translation.GetDatasetRequest.serialize, response_deserializer=automl_translation.Dataset.deserialize, @@ -861,7 +946,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListDatasets", request_serializer=automl_translation.ListDatasetsRequest.serialize, response_deserializer=automl_translation.ListDatasetsResponse.deserialize, @@ -889,7 +974,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteDataset", request_serializer=automl_translation.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -918,7 +1003,9 @@ def create_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_adaptive_mt_dataset" not in self._stubs: - self._stubs["create_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset", request_serializer=adaptive_mt.CreateAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -947,7 +1034,9 @@ def delete_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_dataset" not in self._stubs: - self._stubs["delete_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_adaptive_mt_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset", request_serializer=adaptive_mt.DeleteAdaptiveMtDatasetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -976,7 +1065,7 @@ def get_adaptive_mt_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_dataset" not in self._stubs: - self._stubs["get_adaptive_mt_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_dataset"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset", request_serializer=adaptive_mt.GetAdaptiveMtDatasetRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtDataset.deserialize, @@ -1006,7 +1095,7 @@ def list_adaptive_mt_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_datasets" not in self._stubs: - self._stubs["list_adaptive_mt_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_datasets"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets", request_serializer=adaptive_mt.ListAdaptiveMtDatasetsRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtDatasetsResponse.deserialize, @@ -1035,7 +1124,7 @@ def adaptive_mt_translate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "adaptive_mt_translate" not in self._stubs: - self._stubs["adaptive_mt_translate"] = self.grpc_channel.unary_unary( + self._stubs["adaptive_mt_translate"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate", request_serializer=adaptive_mt.AdaptiveMtTranslateRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtTranslateResponse.deserialize, @@ -1063,7 +1152,7 @@ def get_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_adaptive_mt_file" not in self._stubs: - self._stubs["get_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["get_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile", request_serializer=adaptive_mt.GetAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.AdaptiveMtFile.deserialize, @@ -1091,7 +1180,7 @@ def delete_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_adaptive_mt_file" not in self._stubs: - self._stubs["delete_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile", request_serializer=adaptive_mt.DeleteAdaptiveMtFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1121,7 +1210,7 @@ def import_adaptive_mt_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_adaptive_mt_file" not in self._stubs: - self._stubs["import_adaptive_mt_file"] = self.grpc_channel.unary_unary( + self._stubs["import_adaptive_mt_file"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile", request_serializer=adaptive_mt.ImportAdaptiveMtFileRequest.serialize, response_deserializer=adaptive_mt.ImportAdaptiveMtFileResponse.deserialize, @@ -1151,7 +1240,7 @@ def list_adaptive_mt_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_files" not in self._stubs: - self._stubs["list_adaptive_mt_files"] = self.grpc_channel.unary_unary( + self._stubs["list_adaptive_mt_files"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles", request_serializer=adaptive_mt.ListAdaptiveMtFilesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtFilesResponse.deserialize, @@ -1181,7 +1270,9 @@ def list_adaptive_mt_sentences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_adaptive_mt_sentences" not in self._stubs: - self._stubs["list_adaptive_mt_sentences"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_adaptive_mt_sentences" + ] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences", request_serializer=adaptive_mt.ListAdaptiveMtSentencesRequest.serialize, response_deserializer=adaptive_mt.ListAdaptiveMtSentencesResponse.deserialize, @@ -1209,7 +1300,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ImportData", request_serializer=automl_translation.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1238,7 +1329,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ExportData", request_serializer=automl_translation.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1267,7 +1358,7 @@ def list_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_examples" not in self._stubs: - self._stubs["list_examples"] = self.grpc_channel.unary_unary( + self._stubs["list_examples"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListExamples", request_serializer=automl_translation.ListExamplesRequest.serialize, response_deserializer=automl_translation.ListExamplesResponse.deserialize, @@ -1295,7 +1386,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/CreateModel", request_serializer=automl_translation.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1324,7 +1415,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/ListModels", request_serializer=automl_translation.ListModelsRequest.serialize, response_deserializer=automl_translation.ListModelsResponse.deserialize, @@ -1352,7 +1443,7 @@ def get_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/GetModel", request_serializer=automl_translation.GetModelRequest.serialize, response_deserializer=automl_translation.Model.deserialize, @@ -1380,7 +1471,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3.TranslationService/DeleteModel", request_serializer=automl_translation.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1663,7 +1754,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1679,7 +1770,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1696,7 +1787,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1713,7 +1804,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -1730,7 +1821,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1749,7 +1840,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1768,7 +1859,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1785,7 +1876,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py index a97c73752636..06abe7a126fb 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3/services/translation_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -47,6 +47,14 @@ 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, @@ -371,8 +379,10 @@ def post_update_glossary_entry(self, response): def pre_adaptive_mt_translate( self, request: adaptive_mt.AdaptiveMtTranslateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.AdaptiveMtTranslateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.AdaptiveMtTranslateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for adaptive_mt_translate Override in a subclass to manipulate the request or metadata @@ -394,9 +404,10 @@ def post_adaptive_mt_translate( def pre_batch_translate_document( self, request: translation_service.BatchTranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateDocumentRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_document @@ -419,9 +430,10 @@ def post_batch_translate_document( def pre_batch_translate_text( self, request: translation_service.BatchTranslateTextRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateTextRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_text @@ -444,8 +456,11 @@ def post_batch_translate_text( def pre_create_adaptive_mt_dataset( self, request: adaptive_mt.CreateAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.CreateAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.CreateAdaptiveMtDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -467,8 +482,10 @@ def post_create_adaptive_mt_dataset( def pre_create_dataset( self, request: automl_translation.CreateDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.CreateDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.CreateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_dataset Override in a subclass to manipulate the request or metadata @@ -490,8 +507,11 @@ def post_create_dataset( def pre_create_glossary( self, request: translation_service.CreateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.CreateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.CreateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_glossary Override in a subclass to manipulate the request or metadata @@ -513,9 +533,10 @@ def post_create_glossary( def pre_create_glossary_entry( self, request: translation_service.CreateGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.CreateGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.CreateGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_glossary_entry @@ -538,8 +559,10 @@ def post_create_glossary_entry( def pre_create_model( self, request: automl_translation.CreateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.CreateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -561,8 +584,11 @@ def post_create_model( def pre_delete_adaptive_mt_dataset( self, request: adaptive_mt.DeleteAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.DeleteAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.DeleteAdaptiveMtDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -573,8 +599,10 @@ def pre_delete_adaptive_mt_dataset( def pre_delete_adaptive_mt_file( self, request: adaptive_mt.DeleteAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.DeleteAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.DeleteAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -585,8 +613,10 @@ def pre_delete_adaptive_mt_file( def pre_delete_dataset( self, request: automl_translation.DeleteDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.DeleteDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.DeleteDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_dataset Override in a subclass to manipulate the request or metadata @@ -608,8 +638,11 @@ def post_delete_dataset( def pre_delete_glossary( self, request: translation_service.DeleteGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DeleteGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DeleteGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_glossary Override in a subclass to manipulate the request or metadata @@ -631,9 +664,10 @@ def post_delete_glossary( def pre_delete_glossary_entry( self, request: translation_service.DeleteGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.DeleteGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.DeleteGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_glossary_entry @@ -645,8 +679,10 @@ def pre_delete_glossary_entry( def pre_delete_model( self, request: automl_translation.DeleteModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.DeleteModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -668,8 +704,11 @@ def post_delete_model( def pre_detect_language( self, request: translation_service.DetectLanguageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DetectLanguageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DetectLanguageRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for detect_language Override in a subclass to manipulate the request or metadata @@ -691,8 +730,10 @@ def post_detect_language( def pre_export_data( self, request: automl_translation.ExportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ExportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -714,8 +755,10 @@ def post_export_data( def pre_get_adaptive_mt_dataset( self, request: adaptive_mt.GetAdaptiveMtDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.GetAdaptiveMtDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.GetAdaptiveMtDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_adaptive_mt_dataset Override in a subclass to manipulate the request or metadata @@ -737,8 +780,10 @@ def post_get_adaptive_mt_dataset( def pre_get_adaptive_mt_file( self, request: adaptive_mt.GetAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.GetAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.GetAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -760,8 +805,10 @@ def post_get_adaptive_mt_file( def pre_get_dataset( self, request: automl_translation.GetDatasetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.GetDatasetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.GetDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_dataset Override in a subclass to manipulate the request or metadata @@ -783,8 +830,10 @@ def post_get_dataset( def pre_get_glossary( self, request: translation_service.GetGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_glossary Override in a subclass to manipulate the request or metadata @@ -806,8 +855,11 @@ def post_get_glossary( def pre_get_glossary_entry( self, request: translation_service.GetGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryEntryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_glossary_entry Override in a subclass to manipulate the request or metadata @@ -829,8 +881,10 @@ def post_get_glossary_entry( def pre_get_model( self, request: automl_translation.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -852,9 +906,10 @@ def post_get_model( def pre_get_supported_languages( self, request: translation_service.GetSupportedLanguagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.GetSupportedLanguagesRequest, Sequence[Tuple[str, str]] + translation_service.GetSupportedLanguagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_supported_languages @@ -877,8 +932,10 @@ def post_get_supported_languages( def pre_import_adaptive_mt_file( self, request: adaptive_mt.ImportAdaptiveMtFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ImportAdaptiveMtFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ImportAdaptiveMtFileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_adaptive_mt_file Override in a subclass to manipulate the request or metadata @@ -900,8 +957,10 @@ def post_import_adaptive_mt_file( def pre_import_data( self, request: automl_translation.ImportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ImportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -923,8 +982,11 @@ def post_import_data( def pre_list_adaptive_mt_datasets( self, request: adaptive_mt.ListAdaptiveMtDatasetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtDatasetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtDatasetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_adaptive_mt_datasets Override in a subclass to manipulate the request or metadata @@ -946,8 +1008,10 @@ def post_list_adaptive_mt_datasets( def pre_list_adaptive_mt_files( self, request: adaptive_mt.ListAdaptiveMtFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtFilesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_adaptive_mt_files Override in a subclass to manipulate the request or metadata @@ -969,8 +1033,11 @@ def post_list_adaptive_mt_files( def pre_list_adaptive_mt_sentences( self, request: adaptive_mt.ListAdaptiveMtSentencesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[adaptive_mt.ListAdaptiveMtSentencesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + adaptive_mt.ListAdaptiveMtSentencesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_adaptive_mt_sentences Override in a subclass to manipulate the request or metadata @@ -992,8 +1059,10 @@ def post_list_adaptive_mt_sentences( def pre_list_datasets( self, request: automl_translation.ListDatasetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListDatasetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListDatasetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_datasets Override in a subclass to manipulate the request or metadata @@ -1015,8 +1084,10 @@ def post_list_datasets( def pre_list_examples( self, request: automl_translation.ListExamplesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListExamplesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListExamplesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_examples Override in a subclass to manipulate the request or metadata @@ -1038,8 +1109,11 @@ def post_list_examples( def pre_list_glossaries( self, request: translation_service.ListGlossariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.ListGlossariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.ListGlossariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_glossaries Override in a subclass to manipulate the request or metadata @@ -1061,9 +1135,10 @@ def post_list_glossaries( def pre_list_glossary_entries( self, request: translation_service.ListGlossaryEntriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.ListGlossaryEntriesRequest, Sequence[Tuple[str, str]] + translation_service.ListGlossaryEntriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_glossary_entries @@ -1086,8 +1161,10 @@ def post_list_glossary_entries( def pre_list_models( self, request: automl_translation.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[automl_translation.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + automl_translation.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -1109,8 +1186,10 @@ def post_list_models( def pre_romanize_text( self, request: translation_service.RomanizeTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.RomanizeTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.RomanizeTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for romanize_text Override in a subclass to manipulate the request or metadata @@ -1132,8 +1211,11 @@ def post_romanize_text( def pre_translate_document( self, request: translation_service.TranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_document Override in a subclass to manipulate the request or metadata @@ -1155,8 +1237,11 @@ def post_translate_document( def pre_translate_text( self, request: translation_service.TranslateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_text Override in a subclass to manipulate the request or metadata @@ -1178,8 +1263,11 @@ def post_translate_text( def pre_update_glossary( self, request: translation_service.UpdateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.UpdateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.UpdateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_glossary Override in a subclass to manipulate the request or metadata @@ -1201,9 +1289,10 @@ def post_update_glossary( def pre_update_glossary_entry( self, request: translation_service.UpdateGlossaryEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.UpdateGlossaryEntryRequest, Sequence[Tuple[str, str]] + translation_service.UpdateGlossaryEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_glossary_entry @@ -1226,8 +1315,10 @@ def post_update_glossary_entry( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -1249,8 +1340,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -1272,8 +1365,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1293,8 +1388,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1314,8 +1411,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1337,8 +1436,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1360,8 +1461,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -1564,7 +1667,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtTranslateResponse: r"""Call the adaptive mt translate method over HTTP. @@ -1575,8 +1678,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.AdaptiveMtTranslateResponse: @@ -1586,6 +1691,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseAdaptiveMtTranslate._get_http_options() ) + request, metadata = self._interceptor.pre_adaptive_mt_translate( request, metadata ) @@ -1602,6 +1708,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.AdaptiveMtTranslate", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "AdaptiveMtTranslate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._AdaptiveMtTranslate._get_response( @@ -1625,7 +1758,31 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtTranslateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_adaptive_mt_translate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtTranslateResponse.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.translation_v3.TranslationServiceClient.adaptive_mt_translate", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "AdaptiveMtTranslate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateDocument( @@ -1664,7 +1821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch translate document method over HTTP. @@ -1674,8 +1831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1688,6 +1847,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_document( request, metadata ) @@ -1704,6 +1864,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.BatchTranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateDocument._get_response( @@ -1725,7 +1912,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_translate_document(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.translation_v3.TranslationServiceClient.batch_translate_document", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateText( @@ -1764,7 +1973,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch translate text method over HTTP. @@ -1774,8 +1983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1788,6 +1999,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_text( request, metadata ) @@ -1804,6 +2016,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.BatchTranslateText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateText._get_response( @@ -1825,7 +2064,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_translate_text(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.translation_v3.TranslationServiceClient.batch_translate_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "BatchTranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAdaptiveMtDataset( @@ -1864,7 +2125,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Call the create adaptive mt dataset method over HTTP. @@ -1876,8 +2137,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.AdaptiveMtDataset: @@ -1887,6 +2150,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_adaptive_mt_dataset( request, metadata ) @@ -1903,6 +2167,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CreateAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._CreateAdaptiveMtDataset._get_response( @@ -1926,7 +2217,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtDataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_adaptive_mt_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtDataset.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.translation_v3.TranslationServiceClient.create_adaptive_mt_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateAdaptiveMtDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataset( @@ -1965,7 +2278,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create dataset method over HTTP. @@ -1975,8 +2288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1989,6 +2304,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateDataset._get_transcoded_request( http_options, request @@ -2003,6 +2319,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CreateDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateDataset._get_response( self._host, @@ -2022,7 +2365,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_dataset(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.translation_v3.TranslationServiceClient.create_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossary( @@ -2061,7 +2426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create glossary method over HTTP. @@ -2071,8 +2436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2085,6 +2452,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_transcoded_request( http_options, request @@ -2099,6 +2467,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CreateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateGlossary._get_response( self._host, @@ -2118,7 +2513,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_glossary(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.translation_v3.TranslationServiceClient.create_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossaryEntry( @@ -2157,7 +2574,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Call the create glossary entry method over HTTP. @@ -2168,8 +2585,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.GlossaryEntry: @@ -2181,6 +2600,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary_entry( request, metadata ) @@ -2197,6 +2617,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CreateGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._CreateGlossaryEntry._get_response( @@ -2220,7 +2667,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.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.translation_v3.TranslationServiceClient.create_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateModel( @@ -2259,7 +2728,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -2269,8 +2738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2283,6 +2754,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateModel._get_transcoded_request( http_options, request @@ -2297,6 +2769,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CreateModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateModel._get_response( self._host, @@ -2316,7 +2815,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.translation_v3.TranslationServiceClient.create_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAdaptiveMtDataset( @@ -2354,7 +2875,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete adaptive mt dataset method over HTTP. @@ -2366,13 +2887,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_adaptive_mt_dataset( request, metadata ) @@ -2385,6 +2909,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteAdaptiveMtDataset._get_response( @@ -2437,7 +2988,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete adaptive mt file method over HTTP. @@ -2448,13 +2999,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_adaptive_mt_file( request, metadata ) @@ -2467,6 +3021,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteAdaptiveMtFile._get_response( @@ -2519,7 +3100,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete dataset method over HTTP. @@ -2529,8 +3110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2543,6 +3126,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteDataset._get_transcoded_request( http_options, request @@ -2553,6 +3137,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteDataset._get_response( self._host, @@ -2571,7 +3182,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_dataset(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.translation_v3.TranslationServiceClient.delete_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossary( @@ -2609,7 +3242,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete glossary method over HTTP. @@ -2619,8 +3252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2633,6 +3268,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_transcoded_request( http_options, request @@ -2643,6 +3279,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteGlossary._get_response( self._host, @@ -2661,7 +3324,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_glossary(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.translation_v3.TranslationServiceClient.delete_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossaryEntry( @@ -2699,7 +3384,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete glossary entry method over HTTP. @@ -2710,13 +3395,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary_entry( request, metadata ) @@ -2729,6 +3417,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._DeleteGlossaryEntry._get_response( @@ -2781,7 +3496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete model method over HTTP. @@ -2791,8 +3506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2805,6 +3522,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteModel._get_transcoded_request( http_options, request @@ -2815,6 +3533,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteModel._get_response( self._host, @@ -2833,7 +3578,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_model(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.translation_v3.TranslationServiceClient.delete_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetectLanguage( @@ -2872,7 +3639,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Call the detect language method over HTTP. @@ -2883,8 +3650,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.DetectLanguageResponse: @@ -2896,6 +3665,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_http_options() ) + request, metadata = self._interceptor.pre_detect_language(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_transcoded_request( http_options, request @@ -2910,6 +3680,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DetectLanguage", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DetectLanguage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DetectLanguage._get_response( self._host, @@ -2931,7 +3728,31 @@ def __call__( pb_resp = translation_service.DetectLanguageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_language(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.DetectLanguageResponse.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.translation_v3.TranslationServiceClient.detect_language", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DetectLanguage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData( @@ -2969,7 +3790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export data method over HTTP. @@ -2979,8 +3800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2993,6 +3816,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseExportData._get_http_options() ) + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseExportData._get_transcoded_request( http_options, request @@ -3007,6 +3831,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ExportData", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ExportData._get_response( self._host, @@ -3026,7 +3877,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_data(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.translation_v3.TranslationServiceClient.export_data", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAdaptiveMtDataset( @@ -3064,7 +3937,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtDataset: r"""Call the get adaptive mt dataset method over HTTP. @@ -3075,8 +3948,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.AdaptiveMtDataset: @@ -3086,6 +3961,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetAdaptiveMtDataset._get_http_options() ) + request, metadata = self._interceptor.pre_get_adaptive_mt_dataset( request, metadata ) @@ -3098,6 +3974,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetAdaptiveMtDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetAdaptiveMtDataset._get_response( @@ -3120,7 +4023,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtDataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_adaptive_mt_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtDataset.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.translation_v3.TranslationServiceClient.get_adaptive_mt_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAdaptiveMtFile( @@ -3158,7 +4083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.AdaptiveMtFile: r"""Call the get adaptive mt file method over HTTP. @@ -3169,8 +4094,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.AdaptiveMtFile: @@ -3180,6 +4107,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_get_adaptive_mt_file( request, metadata ) @@ -3192,6 +4120,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetAdaptiveMtFile._get_response( self._host, @@ -3212,7 +4167,29 @@ def __call__( pb_resp = adaptive_mt.AdaptiveMtFile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_adaptive_mt_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.AdaptiveMtFile.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.translation_v3.TranslationServiceClient.get_adaptive_mt_file", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetAdaptiveMtFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataset( @@ -3249,7 +4226,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Dataset: r"""Call the get dataset method over HTTP. @@ -3259,8 +4236,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.automl_translation.Dataset: @@ -3273,6 +4252,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetDataset._get_http_options() ) + request, metadata = self._interceptor.pre_get_dataset(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetDataset._get_transcoded_request( http_options, request @@ -3283,6 +4263,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetDataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetDataset._get_response( self._host, @@ -3303,7 +4310,29 @@ def __call__( pb_resp = automl_translation.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.Dataset.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.translation_v3.TranslationServiceClient.get_dataset", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossary( @@ -3341,7 +4370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Call the get glossary method over HTTP. @@ -3351,8 +4380,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.Glossary: @@ -3364,6 +4395,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetGlossary._get_transcoded_request( http_options, request @@ -3374,6 +4406,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossary._get_response( self._host, @@ -3394,7 +4453,29 @@ def __call__( pb_resp = translation_service.Glossary.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.Glossary.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.translation_v3.TranslationServiceClient.get_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossaryEntry( @@ -3432,7 +4513,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Call the get glossary entry method over HTTP. @@ -3443,8 +4524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.GlossaryEntry: @@ -3456,6 +4539,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary_entry( request, metadata ) @@ -3468,6 +4552,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossaryEntry._get_response( self._host, @@ -3488,7 +4599,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.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.translation_v3.TranslationServiceClient.get_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModel( @@ -3525,7 +4658,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.Model: r"""Call the get model method over HTTP. @@ -3535,8 +4668,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.automl_translation.Model: @@ -3546,6 +4681,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetModel._get_transcoded_request( http_options, request @@ -3556,6 +4692,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetModel", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetModel._get_response( self._host, @@ -3576,7 +4739,29 @@ def __call__( pb_resp = automl_translation.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.Model.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.translation_v3.TranslationServiceClient.get_model", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSupportedLanguages( @@ -3614,7 +4799,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Call the get supported languages method over HTTP. @@ -3625,8 +4810,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.SupportedLanguages: @@ -3638,6 +4825,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetSupportedLanguages._get_http_options() ) + request, metadata = self._interceptor.pre_get_supported_languages( request, metadata ) @@ -3650,6 +4838,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetSupportedLanguages", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetSupportedLanguages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetSupportedLanguages._get_response( @@ -3672,7 +4887,31 @@ def __call__( pb_resp = translation_service.SupportedLanguages.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_supported_languages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.SupportedLanguages.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.translation_v3.TranslationServiceClient.get_supported_languages", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetSupportedLanguages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAdaptiveMtFile( @@ -3711,7 +4950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ImportAdaptiveMtFileResponse: r"""Call the import adaptive mt file method over HTTP. @@ -3723,8 +4962,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.ImportAdaptiveMtFileResponse: @@ -3736,6 +4977,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseImportAdaptiveMtFile._get_http_options() ) + request, metadata = self._interceptor.pre_import_adaptive_mt_file( request, metadata ) @@ -3752,6 +4994,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ImportAdaptiveMtFile", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportAdaptiveMtFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ImportAdaptiveMtFile._get_response( @@ -3775,7 +5044,31 @@ def __call__( pb_resp = adaptive_mt.ImportAdaptiveMtFileResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_adaptive_mt_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.ImportAdaptiveMtFileResponse.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.translation_v3.TranslationServiceClient.import_adaptive_mt_file", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportAdaptiveMtFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData( @@ -3813,7 +5106,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import data method over HTTP. @@ -3823,8 +5116,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3837,6 +5132,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseImportData._get_http_options() ) + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseImportData._get_transcoded_request( http_options, request @@ -3851,6 +5147,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ImportData", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ImportData._get_response( self._host, @@ -3870,7 +5193,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_data(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.translation_v3.TranslationServiceClient.import_data", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtDatasets( @@ -3908,7 +5253,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtDatasetsResponse: r"""Call the list adaptive mt datasets method over HTTP. @@ -3920,8 +5265,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.ListAdaptiveMtDatasetsResponse: @@ -3931,6 +5278,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_datasets( request, metadata ) @@ -3943,6 +5291,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListAdaptiveMtDatasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtDatasets._get_response( @@ -3965,7 +5340,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + adaptive_mt.ListAdaptiveMtDatasetsResponse.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.translation_v3.TranslationServiceClient.list_adaptive_mt_datasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtFiles( @@ -4003,7 +5402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtFilesResponse: r"""Call the list adaptive mt files method over HTTP. @@ -4014,8 +5413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.ListAdaptiveMtFilesResponse: @@ -4027,6 +5428,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtFiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_files( request, metadata ) @@ -4039,6 +5441,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListAdaptiveMtFiles", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtFiles._get_response( @@ -4061,7 +5490,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = adaptive_mt.ListAdaptiveMtFilesResponse.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.translation_v3.TranslationServiceClient.list_adaptive_mt_files", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdaptiveMtSentences( @@ -4099,7 +5552,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> adaptive_mt.ListAdaptiveMtSentencesResponse: r"""Call the list adaptive mt sentences method over HTTP. @@ -4111,8 +5564,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.adaptive_mt.ListAdaptiveMtSentencesResponse: @@ -4122,6 +5577,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListAdaptiveMtSentences._get_http_options() ) + request, metadata = self._interceptor.pre_list_adaptive_mt_sentences( request, metadata ) @@ -4134,6 +5590,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListAdaptiveMtSentences", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtSentences", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListAdaptiveMtSentences._get_response( @@ -4156,7 +5639,31 @@ def __call__( pb_resp = adaptive_mt.ListAdaptiveMtSentencesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_adaptive_mt_sentences(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + adaptive_mt.ListAdaptiveMtSentencesResponse.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.translation_v3.TranslationServiceClient.list_adaptive_mt_sentences", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListAdaptiveMtSentences", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatasets( @@ -4194,7 +5701,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListDatasetsResponse: r"""Call the list datasets method over HTTP. @@ -4204,8 +5711,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.automl_translation.ListDatasetsResponse: @@ -4215,6 +5724,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_datasets(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListDatasets._get_transcoded_request( http_options, request @@ -4225,6 +5735,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListDatasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListDatasets._get_response( self._host, @@ -4245,7 +5782,31 @@ def __call__( pb_resp = automl_translation.ListDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.ListDatasetsResponse.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.translation_v3.TranslationServiceClient.list_datasets", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExamples( @@ -4283,7 +5844,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListExamplesResponse: r"""Call the list examples method over HTTP. @@ -4293,8 +5854,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.automl_translation.ListExamplesResponse: @@ -4304,6 +5867,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListExamples._get_http_options() ) + request, metadata = self._interceptor.pre_list_examples(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListExamples._get_transcoded_request( http_options, request @@ -4314,6 +5878,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListExamples", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListExamples", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListExamples._get_response( self._host, @@ -4334,7 +5925,31 @@ def __call__( pb_resp = automl_translation.ListExamplesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_examples(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.ListExamplesResponse.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.translation_v3.TranslationServiceClient.list_examples", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListExamples", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaries( @@ -4372,7 +5987,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossariesResponse: r"""Call the list glossaries method over HTTP. @@ -4382,8 +5997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.ListGlossariesResponse: @@ -4393,6 +6010,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossaries(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListGlossaries._get_transcoded_request( http_options, request @@ -4403,6 +6021,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListGlossaries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListGlossaries._get_response( self._host, @@ -4423,7 +6068,31 @@ def __call__( pb_resp = translation_service.ListGlossariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossariesResponse.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.translation_v3.TranslationServiceClient.list_glossaries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaryEntries( @@ -4461,7 +6130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossaryEntriesResponse: r"""Call the list glossary entries method over HTTP. @@ -4472,8 +6141,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.ListGlossaryEntriesResponse: @@ -4485,6 +6156,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaryEntries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossary_entries( request, metadata ) @@ -4497,6 +6169,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListGlossaryEntries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaryEntries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._ListGlossaryEntries._get_response( @@ -4519,7 +6218,33 @@ def __call__( pb_resp = translation_service.ListGlossaryEntriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossary_entries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossaryEntriesResponse.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.translation_v3.TranslationServiceClient.list_glossary_entries", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListGlossaryEntries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -4556,7 +6281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> automl_translation.ListModelsResponse: r"""Call the list models method over HTTP. @@ -4566,8 +6291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.automl_translation.ListModelsResponse: @@ -4577,6 +6304,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListModels._get_transcoded_request( http_options, request @@ -4587,6 +6315,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListModels", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListModels._get_response( self._host, @@ -4607,7 +6362,31 @@ def __call__( pb_resp = automl_translation.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = automl_translation.ListModelsResponse.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.translation_v3.TranslationServiceClient.list_models", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RomanizeText( @@ -4646,7 +6425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.RomanizeTextResponse: r"""Call the romanize text method over HTTP. @@ -4657,8 +6436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.RomanizeTextResponse: @@ -4670,6 +6451,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseRomanizeText._get_http_options() ) + request, metadata = self._interceptor.pre_romanize_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseRomanizeText._get_transcoded_request( http_options, request @@ -4684,6 +6466,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.RomanizeText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "RomanizeText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._RomanizeText._get_response( self._host, @@ -4705,7 +6514,31 @@ def __call__( pb_resp = translation_service.RomanizeTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_romanize_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.RomanizeTextResponse.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.translation_v3.TranslationServiceClient.romanize_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "RomanizeText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateDocument( @@ -4744,7 +6577,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Call the translate document method over HTTP. @@ -4754,8 +6587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.TranslateDocumentResponse: @@ -4767,6 +6602,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_translate_document( request, metadata ) @@ -4783,6 +6619,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.TranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateDocument._get_response( self._host, @@ -4804,7 +6667,31 @@ def __call__( pb_resp = translation_service.TranslateDocumentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateDocumentResponse.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.translation_v3.TranslationServiceClient.translate_document", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateText( @@ -4843,7 +6730,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Call the translate text method over HTTP. @@ -4854,8 +6741,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.TranslateTextResponse: @@ -4865,6 +6754,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_translate_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseTranslateText._get_transcoded_request( http_options, request @@ -4879,6 +6769,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.TranslateText", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateText._get_response( self._host, @@ -4900,7 +6817,31 @@ def __call__( pb_resp = translation_service.TranslateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateTextResponse.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.translation_v3.TranslationServiceClient.translate_text", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "TranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGlossary( @@ -4939,7 +6880,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update glossary method over HTTP. @@ -4950,8 +6891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4964,6 +6907,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseUpdateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_update_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseUpdateGlossary._get_transcoded_request( http_options, request @@ -4978,6 +6922,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.UpdateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._UpdateGlossary._get_response( self._host, @@ -4997,7 +6968,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_glossary(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.translation_v3.TranslationServiceClient.update_glossary", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGlossaryEntry( @@ -5036,7 +7029,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.GlossaryEntry: r"""Call the update glossary entry method over HTTP. @@ -5047,8 +7040,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.GlossaryEntry: @@ -5060,6 +7055,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseUpdateGlossaryEntry._get_http_options() ) + request, metadata = self._interceptor.pre_update_glossary_entry( request, metadata ) @@ -5076,6 +7072,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.UpdateGlossaryEntry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossaryEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._UpdateGlossaryEntry._get_response( @@ -5099,7 +7122,29 @@ def __call__( pb_resp = common.GlossaryEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_glossary_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.GlossaryEntry.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.translation_v3.TranslationServiceClient.update_glossary_entry", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "UpdateGlossaryEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5509,7 +7554,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -5519,8 +7564,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -5529,6 +7576,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -5539,6 +7587,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetLocation._get_response( self._host, @@ -5558,6 +7633,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.translation_v3.TranslationServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5599,7 +7695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -5609,8 +7705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -5619,6 +7717,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5629,6 +7728,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListLocations._get_response( self._host, @@ -5648,6 +7774,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.translation_v3.TranslationServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5690,7 +7837,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -5700,13 +7847,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranslationServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5723,6 +7873,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CancelOperation._get_response( self._host, @@ -5780,7 +7957,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -5790,13 +7967,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5809,6 +7989,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteOperation._get_response( self._host, @@ -5865,7 +8072,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -5875,8 +8082,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -5885,6 +8094,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5895,6 +8105,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetOperation._get_response( self._host, @@ -5914,6 +8151,27 @@ def __call__( 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.translation_v3.TranslationServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5955,7 +8213,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -5965,8 +8223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -5975,6 +8235,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5985,6 +8246,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListOperations._get_response( self._host, @@ -6004,6 +8292,27 @@ def __call__( 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.translation_v3.TranslationServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6046,7 +8355,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -6056,8 +8365,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -6066,6 +8377,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseWaitOperation._get_transcoded_request( http_options, request @@ -6080,6 +8392,33 @@ def __call__( 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.translation_v3.TranslationServiceClient.WaitOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._WaitOperation._get_response( self._host, @@ -6100,6 +8439,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.translation_v3.TranslationServiceAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.translation.v3.TranslationService", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py index 4138c894ea3a..558c8aab67c5 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.18.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py index 90e6d6aedc1b..87ea8f693701 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport +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 TranslationServiceAsyncClient: """Provides natural language translation operations.""" @@ -262,13 +272,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.translation_v3beta1.TranslationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "credentialsType": None, + }, + ) + async def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -307,8 +339,10 @@ async def sample_translate_text(): 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, 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: google.cloud.translate_v3beta1.types.TranslateTextResponse: @@ -357,7 +391,7 @@ async def detect_language( mime_type: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -438,8 +472,10 @@ async def sample_detect_language(): 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, 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: google.cloud.translate_v3beta1.types.DetectLanguageResponse: @@ -508,7 +544,7 @@ async def get_supported_languages( model: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -594,8 +630,10 @@ async def sample_get_supported_languages(): 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, 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: google.cloud.translate_v3beta1.types.SupportedLanguages: @@ -661,7 +699,7 @@ async def translate_document( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -702,8 +740,10 @@ async def sample_translate_document(): 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, 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: google.cloud.translate_v3beta1.types.TranslateDocumentResponse: @@ -751,7 +791,7 @@ async def batch_translate_text( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -810,8 +850,10 @@ async def sample_batch_translate_text(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -878,7 +920,7 @@ async def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -992,8 +1034,10 @@ async def sample_batch_translate_document(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1085,7 +1129,7 @@ async def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1140,8 +1184,10 @@ async def sample_create_glossary(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1218,7 +1264,7 @@ async def list_glossaries( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossariesAsyncPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1298,8 +1344,10 @@ async def sample_list_glossaries(): 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, 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: google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesAsyncPager: @@ -1376,7 +1424,7 @@ async def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1420,8 +1468,10 @@ async def sample_get_glossary(): 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, 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: google.cloud.translate_v3beta1.types.Glossary: @@ -1484,7 +1534,7 @@ async def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1533,8 +1583,10 @@ async def sample_delete_glossary(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py index a82059655567..fcbb0db03671 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore @@ -586,6 +596,10 @@ def __init__( # 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( @@ -652,13 +666,36 @@ def __init__( 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.translation_v3beta1.TranslationServiceClient`.", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "credentialsType": None, + }, + ) + def translate_text( self, request: Optional[Union[translation_service.TranslateTextRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Translates input text and returns translated text. @@ -697,8 +734,10 @@ def sample_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.types.TranslateTextResponse: @@ -745,7 +784,7 @@ def detect_language( mime_type: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Detects the language of text within a request. @@ -826,8 +865,10 @@ def sample_detect_language(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.types.DetectLanguageResponse: @@ -893,7 +934,7 @@ def get_supported_languages( model: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Returns a list of supported languages for translation. @@ -979,8 +1020,10 @@ def sample_get_supported_languages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.types.SupportedLanguages: @@ -1043,7 +1086,7 @@ def translate_document( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Translates documents in synchronous mode. @@ -1084,8 +1127,10 @@ def sample_translate_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.types.TranslateDocumentResponse: @@ -1131,7 +1176,7 @@ def batch_translate_text( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Translates a large volume of text in asynchronous batch mode. This function provides real-time output as @@ -1190,8 +1235,10 @@ def sample_batch_translate_text(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1256,7 +1303,7 @@ def batch_translate_document( output_config: Optional[translation_service.BatchDocumentOutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Translates a large volume of document in asynchronous batch mode. This function provides real-time output as @@ -1370,8 +1417,10 @@ def sample_batch_translate_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1460,7 +1509,7 @@ def create_glossary( glossary: Optional[translation_service.Glossary] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. @@ -1515,8 +1564,10 @@ def sample_create_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1590,7 +1641,7 @@ def list_glossaries( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGlossariesPager: r"""Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. @@ -1670,8 +1721,10 @@ def sample_list_glossaries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesPager: @@ -1745,7 +1798,7 @@ def get_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. @@ -1789,8 +1842,10 @@ def sample_get_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.translate_v3beta1.types.Glossary: @@ -1850,7 +1905,7 @@ def delete_glossary( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary @@ -1899,8 +1954,10 @@ def sample_delete_glossary(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py index c342b99c761f..e84e8513b2ab 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = translation_service.ListGlossariesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = translation_service.ListGlossariesRequest(request) diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py index c6e97a27fbbb..2bc75b6443a7 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.translate_v3beta1.types import translation_service from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport +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.translation.v3beta1.TranslationService", + "rpcName": 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.translation.v3beta1.TranslationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcTransport(TranslationServiceTransport): """gRPC backend transport for TranslationService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -301,7 +389,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -331,7 +419,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -360,7 +448,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -397,7 +485,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +522,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +551,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -522,7 +610,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -552,7 +640,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -560,7 +648,7 @@ def delete_glossary( return self._stubs["delete_glossary"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py index 61c06d644a1e..1550048e656b 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.translate_v3beta1.types import translation_service from .base import DEFAULT_CLIENT_INFO, TranslationServiceTransport from .grpc import TranslationServiceGrpcTransport +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.translation.v3beta1.TranslationService", + "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.translation.v3beta1.TranslationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranslationServiceGrpcAsyncIOTransport(TranslationServiceTransport): """gRPC AsyncIO backend transport for TranslationService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_text" not in self._stubs: - self._stubs["translate_text"] = self.grpc_channel.unary_unary( + self._stubs["translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateText", request_serializer=translation_service.TranslateTextRequest.serialize, response_deserializer=translation_service.TranslateTextResponse.deserialize, @@ -311,7 +396,7 @@ def detect_language( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_language" not in self._stubs: - self._stubs["detect_language"] = self.grpc_channel.unary_unary( + self._stubs["detect_language"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DetectLanguage", request_serializer=translation_service.DetectLanguageRequest.serialize, response_deserializer=translation_service.DetectLanguageResponse.deserialize, @@ -341,7 +426,7 @@ def get_supported_languages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_supported_languages" not in self._stubs: - self._stubs["get_supported_languages"] = self.grpc_channel.unary_unary( + self._stubs["get_supported_languages"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetSupportedLanguages", request_serializer=translation_service.GetSupportedLanguagesRequest.serialize, response_deserializer=translation_service.SupportedLanguages.deserialize, @@ -370,7 +455,7 @@ def translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_document" not in self._stubs: - self._stubs["translate_document"] = self.grpc_channel.unary_unary( + self._stubs["translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/TranslateDocument", request_serializer=translation_service.TranslateDocumentRequest.serialize, response_deserializer=translation_service.TranslateDocumentResponse.deserialize, @@ -408,7 +493,7 @@ def batch_translate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_text" not in self._stubs: - self._stubs["batch_translate_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_text"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateText", request_serializer=translation_service.BatchTranslateTextRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def batch_translate_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_translate_document" not in self._stubs: - self._stubs["batch_translate_document"] = self.grpc_channel.unary_unary( + self._stubs["batch_translate_document"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/BatchTranslateDocument", request_serializer=translation_service.BatchTranslateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -475,7 +560,7 @@ def create_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_glossary" not in self._stubs: - self._stubs["create_glossary"] = self.grpc_channel.unary_unary( + self._stubs["create_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/CreateGlossary", request_serializer=translation_service.CreateGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -505,7 +590,7 @@ def list_glossaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_glossaries" not in self._stubs: - self._stubs["list_glossaries"] = self.grpc_channel.unary_unary( + self._stubs["list_glossaries"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/ListGlossaries", request_serializer=translation_service.ListGlossariesRequest.serialize, response_deserializer=translation_service.ListGlossariesResponse.deserialize, @@ -535,7 +620,7 @@ def get_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_glossary" not in self._stubs: - self._stubs["get_glossary"] = self.grpc_channel.unary_unary( + self._stubs["get_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/GetGlossary", request_serializer=translation_service.GetGlossaryRequest.serialize, response_deserializer=translation_service.Glossary.deserialize, @@ -565,7 +650,7 @@ def delete_glossary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_glossary" not in self._stubs: - self._stubs["delete_glossary"] = self.grpc_channel.unary_unary( + self._stubs["delete_glossary"] = self._logged_channel.unary_unary( "/google.cloud.translation.v3beta1.TranslationService/DeleteGlossary", request_serializer=translation_service.DeleteGlossaryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -673,7 +758,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py index 3e82d1fbd473..c50e7729fd8d 100644 --- a/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py +++ b/packages/google-cloud-translate/google/cloud/translate_v3beta1/services/translation_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -150,9 +158,10 @@ def post_translate_text(self, response): def pre_batch_translate_document( self, request: translation_service.BatchTranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateDocumentRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_document @@ -175,9 +184,10 @@ def post_batch_translate_document( def pre_batch_translate_text( self, request: translation_service.BatchTranslateTextRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.BatchTranslateTextRequest, Sequence[Tuple[str, str]] + translation_service.BatchTranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_translate_text @@ -200,8 +210,11 @@ def post_batch_translate_text( def pre_create_glossary( self, request: translation_service.CreateGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.CreateGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.CreateGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_glossary Override in a subclass to manipulate the request or metadata @@ -223,8 +236,11 @@ def post_create_glossary( def pre_delete_glossary( self, request: translation_service.DeleteGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DeleteGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DeleteGlossaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_glossary Override in a subclass to manipulate the request or metadata @@ -246,8 +262,11 @@ def post_delete_glossary( def pre_detect_language( self, request: translation_service.DetectLanguageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.DetectLanguageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.DetectLanguageRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for detect_language Override in a subclass to manipulate the request or metadata @@ -269,8 +288,10 @@ def post_detect_language( def pre_get_glossary( self, request: translation_service.GetGlossaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.GetGlossaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.GetGlossaryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_glossary Override in a subclass to manipulate the request or metadata @@ -292,9 +313,10 @@ def post_get_glossary( def pre_get_supported_languages( self, request: translation_service.GetSupportedLanguagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - translation_service.GetSupportedLanguagesRequest, Sequence[Tuple[str, str]] + translation_service.GetSupportedLanguagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_supported_languages @@ -317,8 +339,11 @@ def post_get_supported_languages( def pre_list_glossaries( self, request: translation_service.ListGlossariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.ListGlossariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.ListGlossariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_glossaries Override in a subclass to manipulate the request or metadata @@ -340,8 +365,11 @@ def post_list_glossaries( def pre_translate_document( self, request: translation_service.TranslateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateDocumentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_document Override in a subclass to manipulate the request or metadata @@ -363,8 +391,11 @@ def post_translate_document( def pre_translate_text( self, request: translation_service.TranslateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[translation_service.TranslateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + translation_service.TranslateTextRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for translate_text Override in a subclass to manipulate the request or metadata @@ -567,7 +598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch translate document method over HTTP. @@ -577,8 +608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -591,6 +624,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_document( request, metadata ) @@ -607,6 +641,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.BatchTranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateDocument._get_response( @@ -628,7 +689,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_translate_document(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.translation_v3beta1.TranslationServiceClient.batch_translate_document", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchTranslateText( @@ -667,7 +750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch translate text method over HTTP. @@ -677,8 +760,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -691,6 +776,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseBatchTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_translate_text( request, metadata ) @@ -707,6 +793,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.BatchTranslateText", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._BatchTranslateText._get_response( @@ -728,7 +841,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_translate_text(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.translation_v3beta1.TranslationServiceClient.batch_translate_text", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "BatchTranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGlossary( @@ -767,7 +902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create glossary method over HTTP. @@ -777,8 +912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -791,6 +928,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_create_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseCreateGlossary._get_transcoded_request( http_options, request @@ -805,6 +943,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.CreateGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "CreateGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._CreateGlossary._get_response( self._host, @@ -824,7 +989,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_glossary(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.translation_v3beta1.TranslationServiceClient.create_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "CreateGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGlossary( @@ -862,7 +1049,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete glossary method over HTTP. @@ -872,8 +1059,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -886,6 +1075,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_delete_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDeleteGlossary._get_transcoded_request( http_options, request @@ -896,6 +1086,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.DeleteGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DeleteGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DeleteGlossary._get_response( self._host, @@ -914,7 +1131,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_glossary(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.translation_v3beta1.TranslationServiceClient.delete_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DeleteGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetectLanguage( @@ -953,7 +1192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.DetectLanguageResponse: r"""Call the detect language method over HTTP. @@ -964,8 +1203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.DetectLanguageResponse: @@ -977,6 +1218,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_http_options() ) + request, metadata = self._interceptor.pre_detect_language(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseDetectLanguage._get_transcoded_request( http_options, request @@ -991,6 +1233,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.DetectLanguage", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DetectLanguage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._DetectLanguage._get_response( self._host, @@ -1012,7 +1281,31 @@ def __call__( pb_resp = translation_service.DetectLanguageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_language(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.DetectLanguageResponse.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.translation_v3beta1.TranslationServiceClient.detect_language", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "DetectLanguage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlossary( @@ -1050,7 +1343,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.Glossary: r"""Call the get glossary method over HTTP. @@ -1060,8 +1353,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.Glossary: @@ -1073,6 +1368,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetGlossary._get_http_options() ) + request, metadata = self._interceptor.pre_get_glossary(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseGetGlossary._get_transcoded_request( http_options, request @@ -1083,6 +1379,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.GetGlossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetGlossary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._GetGlossary._get_response( self._host, @@ -1103,7 +1426,29 @@ def __call__( pb_resp = translation_service.Glossary.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_glossary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.Glossary.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.translation_v3beta1.TranslationServiceClient.get_glossary", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetGlossary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSupportedLanguages( @@ -1141,7 +1486,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.SupportedLanguages: r"""Call the get supported languages method over HTTP. @@ -1152,8 +1497,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.SupportedLanguages: @@ -1165,6 +1512,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseGetSupportedLanguages._get_http_options() ) + request, metadata = self._interceptor.pre_get_supported_languages( request, metadata ) @@ -1177,6 +1525,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.GetSupportedLanguages", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetSupportedLanguages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TranslationServiceRestTransport._GetSupportedLanguages._get_response( @@ -1199,7 +1574,31 @@ def __call__( pb_resp = translation_service.SupportedLanguages.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_supported_languages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = translation_service.SupportedLanguages.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.translation_v3beta1.TranslationServiceClient.get_supported_languages", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "GetSupportedLanguages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGlossaries( @@ -1237,7 +1636,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.ListGlossariesResponse: r"""Call the list glossaries method over HTTP. @@ -1247,8 +1646,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.ListGlossariesResponse: @@ -1258,6 +1659,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseListGlossaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_glossaries(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseListGlossaries._get_transcoded_request( http_options, request @@ -1268,6 +1670,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.ListGlossaries", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "ListGlossaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._ListGlossaries._get_response( self._host, @@ -1288,7 +1717,31 @@ def __call__( pb_resp = translation_service.ListGlossariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_glossaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.ListGlossariesResponse.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.translation_v3beta1.TranslationServiceClient.list_glossaries", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "ListGlossaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateDocument( @@ -1327,7 +1780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateDocumentResponse: r"""Call the translate document method over HTTP. @@ -1337,8 +1790,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.TranslateDocumentResponse: @@ -1350,6 +1805,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_translate_document( request, metadata ) @@ -1366,6 +1822,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.TranslateDocument", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateDocument._get_response( self._host, @@ -1387,7 +1870,31 @@ def __call__( pb_resp = translation_service.TranslateDocumentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateDocumentResponse.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.translation_v3beta1.TranslationServiceClient.translate_document", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TranslateText( @@ -1426,7 +1933,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> translation_service.TranslateTextResponse: r"""Call the translate text method over HTTP. @@ -1437,8 +1944,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.translation_service.TranslateTextResponse: @@ -1448,6 +1957,7 @@ def __call__( http_options = ( _BaseTranslationServiceRestTransport._BaseTranslateText._get_http_options() ) + request, metadata = self._interceptor.pre_translate_text(request, metadata) transcoded_request = _BaseTranslationServiceRestTransport._BaseTranslateText._get_transcoded_request( http_options, request @@ -1462,6 +1972,33 @@ def __call__( 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.translation_v3beta1.TranslationServiceClient.TranslateText", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranslationServiceRestTransport._TranslateText._get_response( self._host, @@ -1483,7 +2020,31 @@ def __call__( pb_resp = translation_service.TranslateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_translate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + translation_service.TranslateTextResponse.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.translation_v3beta1.TranslationServiceClient.translate_text", + extra={ + "serviceName": "google.cloud.translation.v3beta1.TranslationService", + "rpcName": "TranslateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json index f8751bf48e01..de406536e428 100644 --- a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json +++ b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-translate", - "version": "3.18.0" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtTranslateResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtTranslateResponse", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -328,7 +328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -405,7 +405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -735,7 +735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -904,7 +904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -988,7 +988,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -1073,7 +1073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1242,7 +1242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1326,7 +1326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1407,7 +1407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_dataset" @@ -1484,7 +1484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_dataset" @@ -1562,7 +1562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_file" @@ -1639,7 +1639,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_adaptive_mt_file" @@ -1717,7 +1717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1797,7 +1797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1878,7 +1878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_glossary_entry" @@ -1955,7 +1955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_glossary_entry" @@ -2033,7 +2033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2113,7 +2113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2194,7 +2194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2274,7 +2274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.DetectLanguageResponse", @@ -2459,7 +2459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.DetectLanguageResponse", @@ -2544,7 +2544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2628,7 +2628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2709,7 +2709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -2789,7 +2789,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtDataset", @@ -2870,7 +2870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtFile", @@ -2950,7 +2950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.AdaptiveMtFile", @@ -3031,7 +3031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Dataset", @@ -3111,7 +3111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Dataset", @@ -3192,7 +3192,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -3272,7 +3272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -3353,7 +3353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Glossary", @@ -3433,7 +3433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Glossary", @@ -3514,7 +3514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Model", @@ -3594,7 +3594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.Model", @@ -3683,7 +3683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.SupportedLanguages", @@ -3771,7 +3771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.SupportedLanguages", @@ -3852,7 +3852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse", @@ -3932,7 +3932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.ImportAdaptiveMtFileResponse", @@ -4017,7 +4017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4101,7 +4101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4182,7 +4182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsAsyncPager", @@ -4262,7 +4262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtDatasetsPager", @@ -4343,7 +4343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesAsyncPager", @@ -4423,7 +4423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtFilesPager", @@ -4504,7 +4504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesAsyncPager", @@ -4584,7 +4584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListAdaptiveMtSentencesPager", @@ -4665,7 +4665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsAsyncPager", @@ -4745,7 +4745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListDatasetsPager", @@ -4826,7 +4826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListExamplesAsyncPager", @@ -4906,7 +4906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListExamplesPager", @@ -4987,7 +4987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesAsyncPager", @@ -5067,7 +5067,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager", @@ -5148,7 +5148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesAsyncPager", @@ -5228,7 +5228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListGlossaryEntriesPager", @@ -5309,7 +5309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListModelsAsyncPager", @@ -5389,7 +5389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.services.translation_service.pagers.ListModelsPager", @@ -5474,7 +5474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.RomanizeTextResponse", @@ -5558,7 +5558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.RomanizeTextResponse", @@ -5635,7 +5635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateDocumentResponse", @@ -5711,7 +5711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateDocumentResponse", @@ -5812,7 +5812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateTextResponse", @@ -5912,7 +5912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.TranslateTextResponse", @@ -5993,7 +5993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -6073,7 +6073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3.types.GlossaryEntry", @@ -6158,7 +6158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6242,7 +6242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json index c9f4757e0b92..74f2e4c9def9 100644 --- a/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json +++ b/packages/google-cloud-translate/samples/generated_samples/snippet_metadata_google.cloud.translation.v3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-translate", - "version": "3.18.0" + "version": "0.1.0" }, "snippets": [ { @@ -63,7 +63,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -159,7 +159,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -236,7 +236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -397,7 +397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.DetectLanguageResponse", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.DetectLanguageResponse", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.Glossary", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.Glossary", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.SupportedLanguages", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.SupportedLanguages", @@ -1242,7 +1242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesAsyncPager", @@ -1326,7 +1326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesPager", @@ -1403,7 +1403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateDocumentResponse", @@ -1479,7 +1479,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateDocumentResponse", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateTextResponse", @@ -1632,7 +1632,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.translate_v3beta1.types.TranslateTextResponse", diff --git a/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py b/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py index c775b26efdcd..b52b06c732f8 100644 --- a/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/packages/google-cloud-translate/tests/unit/gapic/translate_v3/test_translation_service.py @@ -15794,6 +15794,7 @@ def test_translate_text_rest_required_fields( response_value._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.translate_text(request) @@ -15853,6 +15854,7 @@ def test_translate_text_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.translate_text(**mock_args) @@ -15994,6 +15996,7 @@ def test_romanize_text_rest_required_fields( response_value._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.romanize_text(request) @@ -16048,6 +16051,7 @@ def test_romanize_text_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.romanize_text(**mock_args) @@ -16181,6 +16185,7 @@ def test_detect_language_rest_required_fields( response_value._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.detect_language(request) @@ -16228,6 +16233,7 @@ def test_detect_language_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.detect_language(**mock_args) @@ -16374,6 +16380,7 @@ def test_get_supported_languages_rest_required_fields( response_value._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_supported_languages(request) @@ -16429,6 +16436,7 @@ def test_get_supported_languages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_supported_languages(**mock_args) @@ -16573,6 +16581,7 @@ def test_translate_document_rest_required_fields( response_value._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.translate_document(request) @@ -16715,6 +16724,7 @@ def test_batch_translate_text_rest_required_fields( response_value._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.batch_translate_text(request) @@ -16860,6 +16870,7 @@ def test_batch_translate_document_rest_required_fields( response_value._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.batch_translate_document(request) @@ -16928,6 +16939,7 @@ def test_batch_translate_document_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_translate_document(**mock_args) @@ -17075,6 +17087,7 @@ def test_create_glossary_rest_required_fields( response_value._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_glossary(request) @@ -17127,6 +17140,7 @@ def test_create_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -17257,6 +17271,7 @@ def test_update_glossary_rest_required_fields( response_value._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_glossary(request) @@ -17305,6 +17320,7 @@ def test_update_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -17445,6 +17461,7 @@ def test_list_glossaries_rest_required_fields( response_value._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_glossaries(request) @@ -17499,6 +17516,7 @@ def test_list_glossaries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossaries(**mock_args) @@ -17692,6 +17710,7 @@ def test_get_glossary_rest_required_fields( response_value._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_glossary(request) @@ -17739,6 +17758,7 @@ def test_get_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -17870,6 +17890,7 @@ def test_delete_glossary_rest_required_fields( response_value._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_glossary(request) @@ -17915,6 +17936,7 @@ def test_delete_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -18049,6 +18071,7 @@ def test_get_glossary_entry_rest_required_fields( response_value._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_glossary_entry(request) @@ -18096,6 +18119,7 @@ def test_get_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary_entry(**mock_args) @@ -18241,6 +18265,7 @@ def test_list_glossary_entries_rest_required_fields( response_value._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_glossary_entries(request) @@ -18296,6 +18321,7 @@ def test_list_glossary_entries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary_entries(**mock_args) @@ -18498,6 +18524,7 @@ def test_create_glossary_entry_rest_required_fields( response_value._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_glossary_entry(request) @@ -18554,6 +18581,7 @@ def test_create_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary_entry(**mock_args) @@ -18687,6 +18715,7 @@ def test_update_glossary_entry_rest_required_fields( response_value._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_glossary_entry(request) @@ -18736,6 +18765,7 @@ def test_update_glossary_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary_entry(**mock_args) @@ -18869,6 +18899,7 @@ def test_delete_glossary_entry_rest_required_fields( response_value._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_glossary_entry(request) @@ -18914,6 +18945,7 @@ def test_delete_glossary_entry_rest_flattened(): 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"} client.delete_glossary_entry(**mock_args) @@ -19047,6 +19079,7 @@ def test_create_dataset_rest_required_fields( response_value._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_dataset(request) @@ -19099,6 +19132,7 @@ def test_create_dataset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dataset(**mock_args) @@ -19230,6 +19264,7 @@ def test_get_dataset_rest_required_fields( response_value._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_dataset(request) @@ -19275,6 +19310,7 @@ def test_get_dataset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dataset(**mock_args) @@ -19412,6 +19448,7 @@ def test_list_datasets_rest_required_fields( response_value._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_datasets(request) @@ -19465,6 +19502,7 @@ def test_list_datasets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_datasets(**mock_args) @@ -19659,6 +19697,7 @@ def test_delete_dataset_rest_required_fields( response_value._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_dataset(request) @@ -19702,6 +19741,7 @@ def test_delete_dataset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dataset(**mock_args) @@ -19838,6 +19878,7 @@ def test_create_adaptive_mt_dataset_rest_required_fields( response_value._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_adaptive_mt_dataset(request) @@ -19892,6 +19933,7 @@ def test_create_adaptive_mt_dataset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_dataset(**mock_args) @@ -20026,6 +20068,7 @@ def test_delete_adaptive_mt_dataset_rest_required_fields( response_value._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_adaptive_mt_dataset(request) @@ -20071,6 +20114,7 @@ def test_delete_adaptive_mt_dataset_rest_flattened(): 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"} client.delete_adaptive_mt_dataset(**mock_args) @@ -20207,6 +20251,7 @@ def test_get_adaptive_mt_dataset_rest_required_fields( response_value._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_adaptive_mt_dataset(request) @@ -20254,6 +20299,7 @@ def test_get_adaptive_mt_dataset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_dataset(**mock_args) @@ -20398,6 +20444,7 @@ def test_list_adaptive_mt_datasets_rest_required_fields( response_value._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_adaptive_mt_datasets(request) @@ -20452,6 +20499,7 @@ def test_list_adaptive_mt_datasets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_datasets(**mock_args) @@ -20660,6 +20708,7 @@ def test_adaptive_mt_translate_rest_required_fields( response_value._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.adaptive_mt_translate(request) @@ -20715,6 +20764,7 @@ def test_adaptive_mt_translate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.adaptive_mt_translate(**mock_args) @@ -20851,6 +20901,7 @@ def test_get_adaptive_mt_file_rest_required_fields( response_value._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_adaptive_mt_file(request) @@ -20898,6 +20949,7 @@ def test_get_adaptive_mt_file_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_file(**mock_args) @@ -21031,6 +21083,7 @@ def test_delete_adaptive_mt_file_rest_required_fields( response_value._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_adaptive_mt_file(request) @@ -21076,6 +21129,7 @@ def test_delete_adaptive_mt_file_rest_flattened(): 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"} client.delete_adaptive_mt_file(**mock_args) @@ -21213,6 +21267,7 @@ def test_import_adaptive_mt_file_rest_required_fields( response_value._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.import_adaptive_mt_file(request) @@ -21260,6 +21315,7 @@ def test_import_adaptive_mt_file_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_adaptive_mt_file(**mock_args) @@ -21403,6 +21459,7 @@ def test_list_adaptive_mt_files_rest_required_fields( response_value._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_adaptive_mt_files(request) @@ -21458,6 +21515,7 @@ def test_list_adaptive_mt_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_files(**mock_args) @@ -21666,6 +21724,7 @@ def test_list_adaptive_mt_sentences_rest_required_fields( response_value._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_adaptive_mt_sentences(request) @@ -21721,6 +21780,7 @@ def test_list_adaptive_mt_sentences_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_adaptive_mt_sentences(**mock_args) @@ -21919,6 +21979,7 @@ def test_import_data_rest_required_fields( response_value._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.import_data(request) @@ -21977,6 +22038,7 @@ def test_import_data_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_data(**mock_args) @@ -22115,6 +22177,7 @@ def test_export_data_rest_required_fields( response_value._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.export_data(request) @@ -22173,6 +22236,7 @@ def test_export_data_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.export_data(**mock_args) @@ -22317,6 +22381,7 @@ def test_list_examples_rest_required_fields( response_value._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_examples(request) @@ -22373,6 +22438,7 @@ def test_list_examples_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_examples(**mock_args) @@ -22571,6 +22637,7 @@ def test_create_model_rest_required_fields( response_value._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_model(request) @@ -22623,6 +22690,7 @@ def test_create_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -22762,6 +22830,7 @@ def test_list_models_rest_required_fields( response_value._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_models(request) @@ -22816,6 +22885,7 @@ def test_list_models_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_models(**mock_args) @@ -23009,6 +23079,7 @@ def test_get_model_rest_required_fields( response_value._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_model(request) @@ -23054,6 +23125,7 @@ def test_get_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -23185,6 +23257,7 @@ def test_delete_model_rest_required_fields( response_value._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_model(request) @@ -23228,6 +23301,7 @@ def test_delete_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -25289,6 +25363,7 @@ def test_translate_text_rest_bad_request( 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.translate_text(request) @@ -25322,6 +25397,7 @@ def test_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.translate_text(request) # Establish that the response is the type that we expect. @@ -25361,6 +25437,7 @@ def test_translate_text_rest_interceptors(null_interceptor): 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 = translation_service.TranslateTextResponse.to_json( translation_service.TranslateTextResponse() ) @@ -25407,6 +25484,7 @@ def test_romanize_text_rest_bad_request( 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.romanize_text(request) @@ -25440,6 +25518,7 @@ def test_romanize_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.romanize_text(request) # Establish that the response is the type that we expect. @@ -25479,6 +25558,7 @@ def test_romanize_text_rest_interceptors(null_interceptor): 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 = translation_service.RomanizeTextResponse.to_json( translation_service.RomanizeTextResponse() ) @@ -25525,6 +25605,7 @@ def test_detect_language_rest_bad_request( 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.detect_language(request) @@ -25558,6 +25639,7 @@ def test_detect_language_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.detect_language(request) # Establish that the response is the type that we expect. @@ -25597,6 +25679,7 @@ def test_detect_language_rest_interceptors(null_interceptor): 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 = translation_service.DetectLanguageResponse.to_json( translation_service.DetectLanguageResponse() ) @@ -25643,6 +25726,7 @@ def test_get_supported_languages_rest_bad_request( 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_supported_languages(request) @@ -25676,6 +25760,7 @@ def test_get_supported_languages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_supported_languages(request) # Establish that the response is the type that we expect. @@ -25715,6 +25800,7 @@ def test_get_supported_languages_rest_interceptors(null_interceptor): 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 = translation_service.SupportedLanguages.to_json( translation_service.SupportedLanguages() ) @@ -25761,6 +25847,7 @@ def test_translate_document_rest_bad_request( 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.translate_document(request) @@ -25796,6 +25883,7 @@ def test_translate_document_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.translate_document(request) # Establish that the response is the type that we expect. @@ -25836,6 +25924,7 @@ def test_translate_document_rest_interceptors(null_interceptor): 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 = translation_service.TranslateDocumentResponse.to_json( translation_service.TranslateDocumentResponse() ) @@ -25882,6 +25971,7 @@ def test_batch_translate_text_rest_bad_request( 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.batch_translate_text(request) @@ -25912,6 +26002,7 @@ def test_batch_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_translate_text(request) # Establish that the response is the type that we expect. @@ -25953,6 +26044,7 @@ def test_batch_translate_text_rest_interceptors(null_interceptor): 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 @@ -25997,6 +26089,7 @@ def test_batch_translate_document_rest_bad_request( 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.batch_translate_document(request) @@ -26027,6 +26120,7 @@ def test_batch_translate_document_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_translate_document(request) # Establish that the response is the type that we expect. @@ -26068,6 +26162,7 @@ def test_batch_translate_document_rest_interceptors(null_interceptor): 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 @@ -26112,6 +26207,7 @@ def test_create_glossary_rest_bad_request( 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_glossary(request) @@ -26224,6 +26320,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -26265,6 +26362,7 @@ def test_create_glossary_rest_interceptors(null_interceptor): 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 @@ -26311,6 +26409,7 @@ def test_update_glossary_rest_bad_request( 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_glossary(request) @@ -26425,6 +26524,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -26466,6 +26566,7 @@ def test_update_glossary_rest_interceptors(null_interceptor): 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 @@ -26510,6 +26611,7 @@ def test_list_glossaries_rest_bad_request( 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_glossaries(request) @@ -26545,6 +26647,7 @@ def test_list_glossaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossaries(request) # Establish that the response is the type that we expect. @@ -26585,6 +26688,7 @@ def test_list_glossaries_rest_interceptors(null_interceptor): 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 = translation_service.ListGlossariesResponse.to_json( translation_service.ListGlossariesResponse() ) @@ -26631,6 +26735,7 @@ def test_get_glossary_rest_bad_request( 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_glossary(request) @@ -26668,6 +26773,7 @@ def test_get_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -26710,6 +26816,7 @@ def test_get_glossary_rest_interceptors(null_interceptor): 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 = translation_service.Glossary.to_json( translation_service.Glossary() ) @@ -26756,6 +26863,7 @@ def test_delete_glossary_rest_bad_request( 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_glossary(request) @@ -26786,6 +26894,7 @@ def test_delete_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -26827,6 +26936,7 @@ def test_delete_glossary_rest_interceptors(null_interceptor): 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 @@ -26873,6 +26983,7 @@ def test_get_glossary_entry_rest_bad_request( 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_glossary_entry(request) @@ -26911,6 +27022,7 @@ def test_get_glossary_entry_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -26952,6 +27064,7 @@ def test_get_glossary_entry_rest_interceptors(null_interceptor): 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 = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -26996,6 +27109,7 @@ def test_list_glossary_entries_rest_bad_request( 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_glossary_entries(request) @@ -27031,6 +27145,7 @@ def test_list_glossary_entries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary_entries(request) # Establish that the response is the type that we expect. @@ -27071,6 +27186,7 @@ def test_list_glossary_entries_rest_interceptors(null_interceptor): 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 = translation_service.ListGlossaryEntriesResponse.to_json( translation_service.ListGlossaryEntriesResponse() ) @@ -27117,6 +27233,7 @@ def test_create_glossary_entry_rest_bad_request( 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_glossary_entry(request) @@ -27234,6 +27351,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27275,6 +27393,7 @@ def test_create_glossary_entry_rest_interceptors(null_interceptor): 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 = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -27323,6 +27442,7 @@ def test_update_glossary_entry_rest_bad_request( 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_glossary_entry(request) @@ -27444,6 +27564,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27485,6 +27606,7 @@ def test_update_glossary_entry_rest_interceptors(null_interceptor): 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 = common.GlossaryEntry.to_json(common.GlossaryEntry()) req.return_value.content = return_value @@ -27531,6 +27653,7 @@ def test_delete_glossary_entry_rest_bad_request( 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_glossary_entry(request) @@ -27563,6 +27686,7 @@ def test_delete_glossary_entry_rest_call_success(request_type): 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_glossary_entry(request) # Establish that the response is the type that we expect. @@ -27599,6 +27723,7 @@ def test_delete_glossary_entry_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = translation_service.DeleteGlossaryEntryRequest() metadata = [ @@ -27639,6 +27764,7 @@ def test_create_dataset_rest_bad_request( 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_dataset(request) @@ -27748,6 +27874,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_dataset(request) # Establish that the response is the type that we expect. @@ -27789,6 +27916,7 @@ def test_create_dataset_rest_interceptors(null_interceptor): 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 @@ -27833,6 +27961,7 @@ def test_get_dataset_rest_bad_request( 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_dataset(request) @@ -27875,6 +28004,7 @@ def test_get_dataset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_dataset(request) # Establish that the response is the type that we expect. @@ -27922,6 +28052,7 @@ def test_get_dataset_rest_interceptors(null_interceptor): 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 = automl_translation.Dataset.to_json(automl_translation.Dataset()) req.return_value.content = return_value @@ -27966,6 +28097,7 @@ def test_list_datasets_rest_bad_request( 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_datasets(request) @@ -28001,6 +28133,7 @@ def test_list_datasets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_datasets(request) # Establish that the response is the type that we expect. @@ -28041,6 +28174,7 @@ def test_list_datasets_rest_interceptors(null_interceptor): 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 = automl_translation.ListDatasetsResponse.to_json( automl_translation.ListDatasetsResponse() ) @@ -28087,6 +28221,7 @@ def test_delete_dataset_rest_bad_request( 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_dataset(request) @@ -28117,6 +28252,7 @@ def test_delete_dataset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_dataset(request) # Establish that the response is the type that we expect. @@ -28158,6 +28294,7 @@ def test_delete_dataset_rest_interceptors(null_interceptor): 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 @@ -28202,6 +28339,7 @@ def test_create_adaptive_mt_dataset_rest_bad_request( 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_adaptive_mt_dataset(request) @@ -28319,6 +28457,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28363,6 +28502,7 @@ def test_create_adaptive_mt_dataset_rest_interceptors(null_interceptor): 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 = adaptive_mt.AdaptiveMtDataset.to_json( adaptive_mt.AdaptiveMtDataset() ) @@ -28411,6 +28551,7 @@ def test_delete_adaptive_mt_dataset_rest_bad_request( 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_adaptive_mt_dataset(request) @@ -28443,6 +28584,7 @@ def test_delete_adaptive_mt_dataset_rest_call_success(request_type): 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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28479,6 +28621,7 @@ def test_delete_adaptive_mt_dataset_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = adaptive_mt.DeleteAdaptiveMtDatasetRequest() metadata = [ @@ -28521,6 +28664,7 @@ def test_get_adaptive_mt_dataset_rest_bad_request( 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_adaptive_mt_dataset(request) @@ -28562,6 +28706,7 @@ def test_get_adaptive_mt_dataset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_dataset(request) # Establish that the response is the type that we expect. @@ -28606,6 +28751,7 @@ def test_get_adaptive_mt_dataset_rest_interceptors(null_interceptor): 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 = adaptive_mt.AdaptiveMtDataset.to_json( adaptive_mt.AdaptiveMtDataset() ) @@ -28652,6 +28798,7 @@ def test_list_adaptive_mt_datasets_rest_bad_request( 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_adaptive_mt_datasets(request) @@ -28687,6 +28834,7 @@ def test_list_adaptive_mt_datasets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_datasets(request) # Establish that the response is the type that we expect. @@ -28727,6 +28875,7 @@ def test_list_adaptive_mt_datasets_rest_interceptors(null_interceptor): 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 = adaptive_mt.ListAdaptiveMtDatasetsResponse.to_json( adaptive_mt.ListAdaptiveMtDatasetsResponse() ) @@ -28773,6 +28922,7 @@ def test_adaptive_mt_translate_rest_bad_request( 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.adaptive_mt_translate(request) @@ -28808,6 +28958,7 @@ def test_adaptive_mt_translate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.adaptive_mt_translate(request) # Establish that the response is the type that we expect. @@ -28848,6 +28999,7 @@ def test_adaptive_mt_translate_rest_interceptors(null_interceptor): 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 = adaptive_mt.AdaptiveMtTranslateResponse.to_json( adaptive_mt.AdaptiveMtTranslateResponse() ) @@ -28896,6 +29048,7 @@ def test_get_adaptive_mt_file_rest_bad_request( 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_adaptive_mt_file(request) @@ -28935,6 +29088,7 @@ def test_get_adaptive_mt_file_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -28977,6 +29131,7 @@ def test_get_adaptive_mt_file_rest_interceptors(null_interceptor): 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 = adaptive_mt.AdaptiveMtFile.to_json(adaptive_mt.AdaptiveMtFile()) req.return_value.content = return_value @@ -29023,6 +29178,7 @@ def test_delete_adaptive_mt_file_rest_bad_request( 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_adaptive_mt_file(request) @@ -29055,6 +29211,7 @@ def test_delete_adaptive_mt_file_rest_call_success(request_type): 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_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -29091,6 +29248,7 @@ def test_delete_adaptive_mt_file_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = adaptive_mt.DeleteAdaptiveMtFileRequest() metadata = [ @@ -29133,6 +29291,7 @@ def test_import_adaptive_mt_file_rest_bad_request( 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.import_adaptive_mt_file(request) @@ -29168,6 +29327,7 @@ def test_import_adaptive_mt_file_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_adaptive_mt_file(request) # Establish that the response is the type that we expect. @@ -29207,6 +29367,7 @@ def test_import_adaptive_mt_file_rest_interceptors(null_interceptor): 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 = adaptive_mt.ImportAdaptiveMtFileResponse.to_json( adaptive_mt.ImportAdaptiveMtFileResponse() ) @@ -29255,6 +29416,7 @@ def test_list_adaptive_mt_files_rest_bad_request( 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_adaptive_mt_files(request) @@ -29292,6 +29454,7 @@ def test_list_adaptive_mt_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_files(request) # Establish that the response is the type that we expect. @@ -29332,6 +29495,7 @@ def test_list_adaptive_mt_files_rest_interceptors(null_interceptor): 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 = adaptive_mt.ListAdaptiveMtFilesResponse.to_json( adaptive_mt.ListAdaptiveMtFilesResponse() ) @@ -29380,6 +29544,7 @@ def test_list_adaptive_mt_sentences_rest_bad_request( 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_adaptive_mt_sentences(request) @@ -29417,6 +29582,7 @@ def test_list_adaptive_mt_sentences_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_adaptive_mt_sentences(request) # Establish that the response is the type that we expect. @@ -29457,6 +29623,7 @@ def test_list_adaptive_mt_sentences_rest_interceptors(null_interceptor): 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 = adaptive_mt.ListAdaptiveMtSentencesResponse.to_json( adaptive_mt.ListAdaptiveMtSentencesResponse() ) @@ -29503,6 +29670,7 @@ def test_import_data_rest_bad_request( 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.import_data(request) @@ -29533,6 +29701,7 @@ def test_import_data_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_data(request) # Establish that the response is the type that we expect. @@ -29574,6 +29743,7 @@ def test_import_data_rest_interceptors(null_interceptor): 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 @@ -29618,6 +29788,7 @@ def test_export_data_rest_bad_request( 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.export_data(request) @@ -29648,6 +29819,7 @@ def test_export_data_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_data(request) # Establish that the response is the type that we expect. @@ -29689,6 +29861,7 @@ def test_export_data_rest_interceptors(null_interceptor): 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 @@ -29733,6 +29906,7 @@ def test_list_examples_rest_bad_request( 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_examples(request) @@ -29768,6 +29942,7 @@ def test_list_examples_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_examples(request) # Establish that the response is the type that we expect. @@ -29808,6 +29983,7 @@ def test_list_examples_rest_interceptors(null_interceptor): 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 = automl_translation.ListExamplesResponse.to_json( automl_translation.ListExamplesResponse() ) @@ -29854,6 +30030,7 @@ def test_create_model_rest_bad_request( 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_model(request) @@ -29963,6 +30140,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -30004,6 +30182,7 @@ def test_create_model_rest_interceptors(null_interceptor): 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 @@ -30048,6 +30227,7 @@ def test_list_models_rest_bad_request( 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_models(request) @@ -30083,6 +30263,7 @@ def test_list_models_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_models(request) # Establish that the response is the type that we expect. @@ -30123,6 +30304,7 @@ def test_list_models_rest_interceptors(null_interceptor): 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 = automl_translation.ListModelsResponse.to_json( automl_translation.ListModelsResponse() ) @@ -30167,6 +30349,7 @@ def test_get_model_rest_bad_request(request_type=automl_translation.GetModelRequ 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_model(request) @@ -30209,6 +30392,7 @@ def test_get_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -30256,6 +30440,7 @@ def test_get_model_rest_interceptors(null_interceptor): 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 = automl_translation.Model.to_json(automl_translation.Model()) req.return_value.content = return_value @@ -30300,6 +30485,7 @@ def test_delete_model_rest_bad_request( 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_model(request) @@ -30330,6 +30516,7 @@ def test_delete_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -30371,6 +30558,7 @@ def test_delete_model_rest_interceptors(null_interceptor): 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 @@ -30415,6 +30603,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -30445,6 +30634,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -30473,6 +30663,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -30503,6 +30694,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -30533,6 +30725,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -30563,6 +30756,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -30593,6 +30787,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -30623,6 +30818,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -30653,6 +30849,7 @@ def test_get_operation_rest_bad_request( 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) @@ -30683,6 +30880,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -30713,6 +30911,7 @@ def test_list_operations_rest_bad_request( 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) @@ -30743,6 +30942,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -30773,6 +30973,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -30803,6 +31004,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py index f15bd68b6b37..dd256d6153d4 100644 --- a/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/packages/google-cloud-translate/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -4674,6 +4674,7 @@ def test_translate_text_rest_required_fields( response_value._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.translate_text(request) @@ -4803,6 +4804,7 @@ def test_detect_language_rest_required_fields( response_value._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.detect_language(request) @@ -4850,6 +4852,7 @@ def test_detect_language_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.detect_language(**mock_args) @@ -4995,6 +4998,7 @@ def test_get_supported_languages_rest_required_fields( response_value._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_supported_languages(request) @@ -5050,6 +5054,7 @@ def test_get_supported_languages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_supported_languages(**mock_args) @@ -5194,6 +5199,7 @@ def test_translate_document_rest_required_fields( response_value._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.translate_document(request) @@ -5336,6 +5342,7 @@ def test_batch_translate_text_rest_required_fields( response_value._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.batch_translate_text(request) @@ -5481,6 +5488,7 @@ def test_batch_translate_document_rest_required_fields( response_value._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.batch_translate_document(request) @@ -5549,6 +5557,7 @@ def test_batch_translate_document_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_translate_document(**mock_args) @@ -5696,6 +5705,7 @@ def test_create_glossary_rest_required_fields( response_value._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_glossary(request) @@ -5748,6 +5758,7 @@ def test_create_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -5888,6 +5899,7 @@ def test_list_glossaries_rest_required_fields( response_value._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_glossaries(request) @@ -5943,6 +5955,7 @@ def test_list_glossaries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossaries(**mock_args) @@ -6138,6 +6151,7 @@ def test_get_glossary_rest_required_fields( response_value._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_glossary(request) @@ -6185,6 +6199,7 @@ def test_get_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -6317,6 +6332,7 @@ def test_delete_glossary_rest_required_fields( response_value._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_glossary(request) @@ -6362,6 +6378,7 @@ def test_delete_glossary_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_glossary(**mock_args) @@ -7022,6 +7039,7 @@ def test_translate_text_rest_bad_request( 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.translate_text(request) @@ -7055,6 +7073,7 @@ def test_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.translate_text(request) # Establish that the response is the type that we expect. @@ -7094,6 +7113,7 @@ def test_translate_text_rest_interceptors(null_interceptor): 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 = translation_service.TranslateTextResponse.to_json( translation_service.TranslateTextResponse() ) @@ -7140,6 +7160,7 @@ def test_detect_language_rest_bad_request( 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.detect_language(request) @@ -7173,6 +7194,7 @@ def test_detect_language_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.detect_language(request) # Establish that the response is the type that we expect. @@ -7212,6 +7234,7 @@ def test_detect_language_rest_interceptors(null_interceptor): 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 = translation_service.DetectLanguageResponse.to_json( translation_service.DetectLanguageResponse() ) @@ -7258,6 +7281,7 @@ def test_get_supported_languages_rest_bad_request( 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_supported_languages(request) @@ -7291,6 +7315,7 @@ def test_get_supported_languages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_supported_languages(request) # Establish that the response is the type that we expect. @@ -7330,6 +7355,7 @@ def test_get_supported_languages_rest_interceptors(null_interceptor): 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 = translation_service.SupportedLanguages.to_json( translation_service.SupportedLanguages() ) @@ -7376,6 +7402,7 @@ def test_translate_document_rest_bad_request( 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.translate_document(request) @@ -7411,6 +7438,7 @@ def test_translate_document_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.translate_document(request) # Establish that the response is the type that we expect. @@ -7451,6 +7479,7 @@ def test_translate_document_rest_interceptors(null_interceptor): 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 = translation_service.TranslateDocumentResponse.to_json( translation_service.TranslateDocumentResponse() ) @@ -7497,6 +7526,7 @@ def test_batch_translate_text_rest_bad_request( 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.batch_translate_text(request) @@ -7527,6 +7557,7 @@ def test_batch_translate_text_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_translate_text(request) # Establish that the response is the type that we expect. @@ -7568,6 +7599,7 @@ def test_batch_translate_text_rest_interceptors(null_interceptor): 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 @@ -7612,6 +7644,7 @@ def test_batch_translate_document_rest_bad_request( 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.batch_translate_document(request) @@ -7642,6 +7675,7 @@ def test_batch_translate_document_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_translate_document(request) # Establish that the response is the type that we expect. @@ -7683,6 +7717,7 @@ def test_batch_translate_document_rest_interceptors(null_interceptor): 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 @@ -7727,6 +7762,7 @@ def test_create_glossary_rest_bad_request( 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_glossary(request) @@ -7838,6 +7874,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -7879,6 +7916,7 @@ def test_create_glossary_rest_interceptors(null_interceptor): 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 @@ -7923,6 +7961,7 @@ def test_list_glossaries_rest_bad_request( 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_glossaries(request) @@ -7958,6 +7997,7 @@ def test_list_glossaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossaries(request) # Establish that the response is the type that we expect. @@ -7998,6 +8038,7 @@ def test_list_glossaries_rest_interceptors(null_interceptor): 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 = translation_service.ListGlossariesResponse.to_json( translation_service.ListGlossariesResponse() ) @@ -8044,6 +8085,7 @@ def test_get_glossary_rest_bad_request( 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_glossary(request) @@ -8080,6 +8122,7 @@ def test_get_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -8121,6 +8164,7 @@ def test_get_glossary_rest_interceptors(null_interceptor): 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 = translation_service.Glossary.to_json( translation_service.Glossary() ) @@ -8167,6 +8211,7 @@ def test_delete_glossary_rest_bad_request( 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_glossary(request) @@ -8197,6 +8242,7 @@ def test_delete_glossary_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_glossary(request) # Establish that the response is the type that we expect. @@ -8238,6 +8284,7 @@ def test_delete_glossary_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py index 73478d4d6652..e8f2db98506c 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport from .transports.grpc_asyncio import LivestreamServiceGrpcAsyncIOTransport +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 LivestreamServiceAsyncClient: """Using Live Stream API, you can generate live streams in the @@ -289,6 +299,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.video.livestream_v1.LivestreamServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "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.livestream.v1.LivestreamService", + "credentialsType": None, + }, + ) + async def create_channel( self, request: Optional[Union[service.CreateChannelRequest, dict]] = None, @@ -298,7 +330,7 @@ async def create_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a channel with the provided unique ID in the specified region. @@ -363,8 +395,10 @@ async def sample_create_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -443,7 +477,7 @@ async def list_channels( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListChannelsAsyncPager: r"""Returns a list of all channels in the specified region. @@ -489,8 +523,10 @@ async def sample_list_channels(): 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, 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsAsyncPager: @@ -565,7 +601,7 @@ async def get_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Channel: r"""Returns the specified channel. @@ -610,8 +646,10 @@ async def sample_get_channel(): 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, 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: google.cloud.video.live_stream_v1.types.Channel: @@ -678,7 +716,7 @@ async def delete_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified channel. @@ -727,8 +765,10 @@ async def sample_delete_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -808,7 +848,7 @@ async def update_channel( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified channel. @@ -883,8 +923,10 @@ async def sample_update_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -963,7 +1005,7 @@ async def start_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts the specified channel. Part of the video pipeline will be created only when the StartChannel @@ -1014,8 +1056,10 @@ async def sample_start_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1088,7 +1132,7 @@ async def stop_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops the specified channel. Part of the video pipeline will be released when the StopChannel request @@ -1139,8 +1183,10 @@ async def sample_stop_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1215,7 +1261,7 @@ async def create_input( input_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates an input with the provided unique ID in the specified region. @@ -1280,8 +1326,10 @@ async def sample_create_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1356,7 +1404,7 @@ async def list_inputs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInputsAsyncPager: r"""Returns a list of all inputs in the specified region. @@ -1401,8 +1449,10 @@ async def sample_list_inputs(): 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, 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsAsyncPager: @@ -1477,7 +1527,7 @@ async def get_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Input: r"""Returns the specified input. @@ -1522,8 +1572,10 @@ async def sample_get_input(): 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, 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: google.cloud.video.live_stream_v1.types.Input: @@ -1585,7 +1637,7 @@ async def delete_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified input. @@ -1634,8 +1686,10 @@ async def sample_delete_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1715,7 +1769,7 @@ async def update_input( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified input. @@ -1782,8 +1836,10 @@ async def sample_update_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1860,7 +1916,7 @@ async def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Creates an event with the provided unique ID in the specified channel. @@ -1922,8 +1978,10 @@ async def sample_create_event(): 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, 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: google.cloud.video.live_stream_v1.types.Event: @@ -1990,7 +2048,7 @@ async def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsAsyncPager: r"""Returns a list of all events in the specified channel. @@ -2037,8 +2095,10 @@ async def sample_list_events(): 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, 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsAsyncPager: @@ -2113,7 +2173,7 @@ async def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Returns the specified event. @@ -2158,8 +2218,10 @@ async def sample_get_event(): 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, 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: google.cloud.video.live_stream_v1.types.Event: @@ -2222,7 +2284,7 @@ async def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified event. @@ -2264,8 +2326,10 @@ async def sample_delete_event(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2317,7 +2381,7 @@ async def list_clips( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClipsAsyncPager: r"""Returns a list of all clips in the specified channel. @@ -2362,8 +2426,10 @@ async def sample_list_clips(): 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, 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsAsyncPager: @@ -2438,7 +2504,7 @@ async def get_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Clip: r"""Returns the specified clip. @@ -2482,8 +2548,10 @@ async def sample_get_clip(): 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, 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: google.cloud.video.live_stream_v1.types.Clip: @@ -2547,7 +2615,7 @@ async def create_clip( clip_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a clip with the provided clip ID in the specified channel. @@ -2619,8 +2687,10 @@ async def sample_create_clip(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2696,7 +2766,7 @@ async def delete_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified clip job resource. This method only deletes the clip job and does not delete the VOD @@ -2746,8 +2816,10 @@ async def sample_delete_clip(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2828,7 +2900,7 @@ async def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Asset with the provided unique ID in the specified region. @@ -2893,8 +2965,10 @@ async def sample_create_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2970,7 +3044,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified asset if it is not used. @@ -3019,8 +3093,10 @@ async def sample_delete_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3099,7 +3175,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Asset: r"""Returns the specified asset. @@ -3143,8 +3219,10 @@ async def sample_get_asset(): 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, 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: google.cloud.video.live_stream_v1.types.Asset: @@ -3205,7 +3283,7 @@ async def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Returns a list of all assets in the specified region. @@ -3250,8 +3328,10 @@ async def sample_list_assets(): 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, 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsAsyncPager: @@ -3326,7 +3406,7 @@ async def get_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Pool: r"""Returns the specified pool. @@ -3370,8 +3450,10 @@ async def sample_get_pool(): 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, 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: google.cloud.video.live_stream_v1.types.Pool: @@ -3437,7 +3519,7 @@ async def update_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified pool. @@ -3498,8 +3580,10 @@ async def sample_update_pool(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3577,7 +3661,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3588,8 +3672,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3630,7 +3716,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3641,8 +3727,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3683,7 +3771,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3699,8 +3787,10 @@ async def delete_operation( 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, 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: None """ @@ -3737,7 +3827,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3752,8 +3842,10 @@ async def cancel_operation( 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, 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: None """ @@ -3790,7 +3882,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3801,8 +3893,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -3843,7 +3937,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3854,8 +3948,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py index 89c9e9a3cfb9..0f7387cd1f24 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -752,6 +762,10 @@ def __init__( # 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( @@ -818,6 +832,29 @@ def __init__( 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.livestream_v1.LivestreamServiceClient`.", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "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.livestream.v1.LivestreamService", + "credentialsType": None, + }, + ) + def create_channel( self, request: Optional[Union[service.CreateChannelRequest, dict]] = None, @@ -827,7 +864,7 @@ def create_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a channel with the provided unique ID in the specified region. @@ -892,8 +929,10 @@ def sample_create_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -969,7 +1008,7 @@ def list_channels( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListChannelsPager: r"""Returns a list of all channels in the specified region. @@ -1015,8 +1054,10 @@ def sample_list_channels(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsPager: @@ -1088,7 +1129,7 @@ def get_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Channel: r"""Returns the specified channel. @@ -1133,8 +1174,10 @@ def sample_get_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Channel: @@ -1198,7 +1241,7 @@ def delete_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified channel. @@ -1247,8 +1290,10 @@ def sample_delete_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1325,7 +1370,7 @@ def update_channel( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified channel. @@ -1400,8 +1445,10 @@ def sample_update_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1477,7 +1524,7 @@ def start_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts the specified channel. Part of the video pipeline will be created only when the StartChannel @@ -1528,8 +1575,10 @@ def sample_start_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1599,7 +1648,7 @@ def stop_channel( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops the specified channel. Part of the video pipeline will be released when the StopChannel request @@ -1650,8 +1699,10 @@ def sample_stop_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1723,7 +1774,7 @@ def create_input( input_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates an input with the provided unique ID in the specified region. @@ -1788,8 +1839,10 @@ def sample_create_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1861,7 +1914,7 @@ def list_inputs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInputsPager: r"""Returns a list of all inputs in the specified region. @@ -1906,8 +1959,10 @@ def sample_list_inputs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsPager: @@ -1979,7 +2034,7 @@ def get_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Input: r"""Returns the specified input. @@ -2024,8 +2079,10 @@ def sample_get_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Input: @@ -2084,7 +2141,7 @@ def delete_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified input. @@ -2133,8 +2190,10 @@ def sample_delete_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2211,7 +2270,7 @@ def update_input( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified input. @@ -2278,8 +2337,10 @@ def sample_update_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2353,7 +2414,7 @@ def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Creates an event with the provided unique ID in the specified channel. @@ -2415,8 +2476,10 @@ def sample_create_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Event: @@ -2480,7 +2543,7 @@ def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsPager: r"""Returns a list of all events in the specified channel. @@ -2527,8 +2590,10 @@ def sample_list_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsPager: @@ -2600,7 +2665,7 @@ def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Returns the specified event. @@ -2645,8 +2710,10 @@ def sample_get_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Event: @@ -2706,7 +2773,7 @@ def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified event. @@ -2748,8 +2815,10 @@ def sample_delete_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2798,7 +2867,7 @@ def list_clips( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClipsPager: r"""Returns a list of all clips in the specified channel. @@ -2843,8 +2912,10 @@ def sample_list_clips(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsPager: @@ -2916,7 +2987,7 @@ def get_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Clip: r"""Returns the specified clip. @@ -2960,8 +3031,10 @@ def sample_get_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Clip: @@ -3024,7 +3097,7 @@ def create_clip( clip_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a clip with the provided clip ID in the specified channel. @@ -3096,8 +3169,10 @@ def sample_create_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3170,7 +3245,7 @@ def delete_clip( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified clip job resource. This method only deletes the clip job and does not delete the VOD @@ -3220,8 +3295,10 @@ def sample_delete_clip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3299,7 +3376,7 @@ def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Asset with the provided unique ID in the specified region. @@ -3364,8 +3441,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3438,7 +3517,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified asset if it is not used. @@ -3487,8 +3566,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3564,7 +3645,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Asset: r"""Returns the specified asset. @@ -3608,8 +3689,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Asset: @@ -3667,7 +3750,7 @@ def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Returns a list of all assets in the specified region. @@ -3712,8 +3795,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsPager: @@ -3785,7 +3870,7 @@ def get_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Pool: r"""Returns the specified pool. @@ -3829,8 +3914,10 @@ def sample_get_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.live_stream_v1.types.Pool: @@ -3895,7 +3982,7 @@ def update_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified pool. @@ -3956,8 +4043,10 @@ def sample_update_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4045,7 +4134,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4056,8 +4145,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4098,7 +4189,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4109,8 +4200,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4151,7 +4244,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4167,8 +4260,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4205,7 +4300,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4220,8 +4315,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4258,7 +4355,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4269,8 +4366,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -4311,7 +4410,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4322,8 +4421,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py index b07985c95e59..477d2d52cdb6 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListChannelsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListChannelsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListInputsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListInputsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListEventsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListEventsRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListClipsRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListClipsRequest(request) @@ -675,7 +691,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -689,8 +705,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListAssetsRequest(request) @@ -749,7 +767,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -763,8 +781,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListAssetsRequest(request) diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py index 126318a1f00d..7269a445e673 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # 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.live_stream_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport +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.livestream.v1.LivestreamService", + "rpcName": 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.livestream.v1.LivestreamService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LivestreamServiceGrpcTransport(LivestreamServiceTransport): """gRPC backend transport for LivestreamService. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -252,7 +338,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def create_channel_( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_" not in self._stubs: - self._stubs["create_channel_"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateChannel", request_serializer=service.CreateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -304,7 +392,7 @@ def list_channels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channels" not in self._stubs: - self._stubs["list_channels"] = self.grpc_channel.unary_unary( + self._stubs["list_channels"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListChannels", request_serializer=service.ListChannelsRequest.serialize, response_deserializer=service.ListChannelsResponse.deserialize, @@ -328,7 +416,7 @@ def get_channel(self) -> Callable[[service.GetChannelRequest], resources.Channel # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel" not in self._stubs: - self._stubs["get_channel"] = self.grpc_channel.unary_unary( + self._stubs["get_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetChannel", request_serializer=service.GetChannelRequest.serialize, response_deserializer=resources.Channel.deserialize, @@ -354,7 +442,7 @@ def delete_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel" not in self._stubs: - self._stubs["delete_channel"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteChannel", request_serializer=service.DeleteChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -380,7 +468,7 @@ def update_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel" not in self._stubs: - self._stubs["update_channel"] = self.grpc_channel.unary_unary( + self._stubs["update_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateChannel", request_serializer=service.UpdateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def start_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_channel" not in self._stubs: - self._stubs["start_channel"] = self.grpc_channel.unary_unary( + self._stubs["start_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StartChannel", request_serializer=service.StartChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -436,7 +524,7 @@ def stop_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_channel" not in self._stubs: - self._stubs["stop_channel"] = self.grpc_channel.unary_unary( + self._stubs["stop_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StopChannel", request_serializer=service.StopChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +551,7 @@ def create_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_input" not in self._stubs: - self._stubs["create_input"] = self.grpc_channel.unary_unary( + self._stubs["create_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateInput", request_serializer=service.CreateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +577,7 @@ def list_inputs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inputs" not in self._stubs: - self._stubs["list_inputs"] = self.grpc_channel.unary_unary( + self._stubs["list_inputs"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListInputs", request_serializer=service.ListInputsRequest.serialize, response_deserializer=service.ListInputsResponse.deserialize, @@ -513,7 +601,7 @@ def get_input(self) -> Callable[[service.GetInputRequest], resources.Input]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_input" not in self._stubs: - self._stubs["get_input"] = self.grpc_channel.unary_unary( + self._stubs["get_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetInput", request_serializer=service.GetInputRequest.serialize, response_deserializer=resources.Input.deserialize, @@ -539,7 +627,7 @@ def delete_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_input" not in self._stubs: - self._stubs["delete_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteInput", request_serializer=service.DeleteInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -565,7 +653,7 @@ def update_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_input" not in self._stubs: - self._stubs["update_input"] = self.grpc_channel.unary_unary( + self._stubs["update_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateInput", request_serializer=service.UpdateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +678,7 @@ def create_event(self) -> Callable[[service.CreateEventRequest], resources.Event # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateEvent", request_serializer=service.CreateEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -617,7 +705,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListEvents", request_serializer=service.ListEventsRequest.serialize, response_deserializer=service.ListEventsResponse.deserialize, @@ -641,7 +729,7 @@ def get_event(self) -> Callable[[service.GetEventRequest], resources.Event]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetEvent", request_serializer=service.GetEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -665,7 +753,7 @@ def delete_event(self) -> Callable[[service.DeleteEventRequest], empty_pb2.Empty # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteEvent", request_serializer=service.DeleteEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -691,7 +779,7 @@ def list_clips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clips" not in self._stubs: - self._stubs["list_clips"] = self.grpc_channel.unary_unary( + self._stubs["list_clips"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListClips", request_serializer=service.ListClipsRequest.serialize, response_deserializer=service.ListClipsResponse.deserialize, @@ -715,7 +803,7 @@ def get_clip(self) -> Callable[[service.GetClipRequest], resources.Clip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clip" not in self._stubs: - self._stubs["get_clip"] = self.grpc_channel.unary_unary( + self._stubs["get_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetClip", request_serializer=service.GetClipRequest.serialize, response_deserializer=resources.Clip.deserialize, @@ -742,7 +830,7 @@ def create_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clip" not in self._stubs: - self._stubs["create_clip"] = self.grpc_channel.unary_unary( + self._stubs["create_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateClip", request_serializer=service.CreateClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -770,7 +858,7 @@ def delete_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_clip" not in self._stubs: - self._stubs["delete_clip"] = self.grpc_channel.unary_unary( + self._stubs["delete_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteClip", request_serializer=service.DeleteClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -797,7 +885,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateAsset", request_serializer=service.CreateAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +911,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteAsset", request_serializer=service.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -847,7 +935,7 @@ def get_asset(self) -> Callable[[service.GetAssetRequest], resources.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetAsset", request_serializer=service.GetAssetRequest.serialize, response_deserializer=resources.Asset.deserialize, @@ -873,7 +961,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListAssets", request_serializer=service.ListAssetsRequest.serialize, response_deserializer=service.ListAssetsResponse.deserialize, @@ -897,7 +985,7 @@ def get_pool(self) -> Callable[[service.GetPoolRequest], resources.Pool]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_pool" not in self._stubs: - self._stubs["get_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetPool", request_serializer=service.GetPoolRequest.serialize, response_deserializer=resources.Pool.deserialize, @@ -923,7 +1011,7 @@ def update_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_pool" not in self._stubs: - self._stubs["update_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdatePool", request_serializer=service.UpdatePoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -931,7 +1019,7 @@ def update_pool( return self._stubs["update_pool"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -943,7 +1031,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -960,7 +1048,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -977,7 +1065,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -996,7 +1084,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1015,7 +1103,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1032,7 +1120,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py index 6e813b87fd7b..33417b7c14df 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.video.live_stream_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, LivestreamServiceTransport from .grpc import LivestreamServiceGrpcTransport +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.livestream.v1.LivestreamService", + "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.livestream.v1.LivestreamService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LivestreamServiceGrpcAsyncIOTransport(LivestreamServiceTransport): """gRPC AsyncIO backend transport for LivestreamService. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_channel_( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_" not in self._stubs: - self._stubs["create_channel_"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateChannel", request_serializer=service.CreateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +401,7 @@ def list_channels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channels" not in self._stubs: - self._stubs["list_channels"] = self.grpc_channel.unary_unary( + self._stubs["list_channels"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListChannels", request_serializer=service.ListChannelsRequest.serialize, response_deserializer=service.ListChannelsResponse.deserialize, @@ -342,7 +427,7 @@ def get_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel" not in self._stubs: - self._stubs["get_channel"] = self.grpc_channel.unary_unary( + self._stubs["get_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetChannel", request_serializer=service.GetChannelRequest.serialize, response_deserializer=resources.Channel.deserialize, @@ -368,7 +453,7 @@ def delete_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel" not in self._stubs: - self._stubs["delete_channel"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteChannel", request_serializer=service.DeleteChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +479,7 @@ def update_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel" not in self._stubs: - self._stubs["update_channel"] = self.grpc_channel.unary_unary( + self._stubs["update_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateChannel", request_serializer=service.UpdateChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,7 @@ def start_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_channel" not in self._stubs: - self._stubs["start_channel"] = self.grpc_channel.unary_unary( + self._stubs["start_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StartChannel", request_serializer=service.StartChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -450,7 +535,7 @@ def stop_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_channel" not in self._stubs: - self._stubs["stop_channel"] = self.grpc_channel.unary_unary( + self._stubs["stop_channel"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/StopChannel", request_serializer=service.StopChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -477,7 +562,7 @@ def create_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_input" not in self._stubs: - self._stubs["create_input"] = self.grpc_channel.unary_unary( + self._stubs["create_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateInput", request_serializer=service.CreateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -503,7 +588,7 @@ def list_inputs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inputs" not in self._stubs: - self._stubs["list_inputs"] = self.grpc_channel.unary_unary( + self._stubs["list_inputs"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListInputs", request_serializer=service.ListInputsRequest.serialize, response_deserializer=service.ListInputsResponse.deserialize, @@ -529,7 +614,7 @@ def get_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_input" not in self._stubs: - self._stubs["get_input"] = self.grpc_channel.unary_unary( + self._stubs["get_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetInput", request_serializer=service.GetInputRequest.serialize, response_deserializer=resources.Input.deserialize, @@ -555,7 +640,7 @@ def delete_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_input" not in self._stubs: - self._stubs["delete_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteInput", request_serializer=service.DeleteInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -581,7 +666,7 @@ def update_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_input" not in self._stubs: - self._stubs["update_input"] = self.grpc_channel.unary_unary( + self._stubs["update_input"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdateInput", request_serializer=service.UpdateInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -608,7 +693,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateEvent", request_serializer=service.CreateEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -635,7 +720,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListEvents", request_serializer=service.ListEventsRequest.serialize, response_deserializer=service.ListEventsResponse.deserialize, @@ -661,7 +746,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetEvent", request_serializer=service.GetEventRequest.serialize, response_deserializer=resources.Event.deserialize, @@ -687,7 +772,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteEvent", request_serializer=service.DeleteEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -713,7 +798,7 @@ def list_clips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clips" not in self._stubs: - self._stubs["list_clips"] = self.grpc_channel.unary_unary( + self._stubs["list_clips"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListClips", request_serializer=service.ListClipsRequest.serialize, response_deserializer=service.ListClipsResponse.deserialize, @@ -737,7 +822,7 @@ def get_clip(self) -> Callable[[service.GetClipRequest], Awaitable[resources.Cli # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clip" not in self._stubs: - self._stubs["get_clip"] = self.grpc_channel.unary_unary( + self._stubs["get_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetClip", request_serializer=service.GetClipRequest.serialize, response_deserializer=resources.Clip.deserialize, @@ -764,7 +849,7 @@ def create_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clip" not in self._stubs: - self._stubs["create_clip"] = self.grpc_channel.unary_unary( + self._stubs["create_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateClip", request_serializer=service.CreateClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -792,7 +877,7 @@ def delete_clip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_clip" not in self._stubs: - self._stubs["delete_clip"] = self.grpc_channel.unary_unary( + self._stubs["delete_clip"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteClip", request_serializer=service.DeleteClipRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -819,7 +904,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/CreateAsset", request_serializer=service.CreateAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -845,7 +930,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/DeleteAsset", request_serializer=service.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -871,7 +956,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetAsset", request_serializer=service.GetAssetRequest.serialize, response_deserializer=resources.Asset.deserialize, @@ -897,7 +982,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/ListAssets", request_serializer=service.ListAssetsRequest.serialize, response_deserializer=service.ListAssetsResponse.deserialize, @@ -921,7 +1006,7 @@ def get_pool(self) -> Callable[[service.GetPoolRequest], Awaitable[resources.Poo # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_pool" not in self._stubs: - self._stubs["get_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/GetPool", request_serializer=service.GetPoolRequest.serialize, response_deserializer=resources.Pool.deserialize, @@ -947,7 +1032,7 @@ def update_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_pool" not in self._stubs: - self._stubs["update_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_pool"] = self._logged_channel.unary_unary( "/google.cloud.video.livestream.v1.LivestreamService/UpdatePool", request_serializer=service.UpdatePoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1179,7 +1264,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1195,7 +1280,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1212,7 +1297,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1229,7 +1314,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1248,7 +1333,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1267,7 +1352,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1284,7 +1369,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py index a9339fc9ae77..c01a31620435 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/services/livestream_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -274,8 +282,10 @@ def post_update_pool(self, response): """ def pre_create_asset( - self, request: service.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -295,8 +305,10 @@ def post_create_asset( return response def pre_create_channel( - self, request: service.CreateChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_channel Override in a subclass to manipulate the request or metadata @@ -316,8 +328,10 @@ def post_create_channel( return response def pre_create_clip( - self, request: service.CreateClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_clip Override in a subclass to manipulate the request or metadata @@ -337,8 +351,10 @@ def post_create_clip( return response def pre_create_event( - self, request: service.CreateEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -356,8 +372,10 @@ def post_create_event(self, response: resources.Event) -> resources.Event: return response def pre_create_input( - self, request: service.CreateInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_input Override in a subclass to manipulate the request or metadata @@ -377,8 +395,10 @@ def post_create_input( return response def pre_delete_asset( - self, request: service.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -398,8 +418,10 @@ def post_delete_asset( return response def pre_delete_channel( - self, request: service.DeleteChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_channel Override in a subclass to manipulate the request or metadata @@ -419,8 +441,10 @@ def post_delete_channel( return response def pre_delete_clip( - self, request: service.DeleteClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_clip Override in a subclass to manipulate the request or metadata @@ -440,8 +464,10 @@ def post_delete_clip( return response def pre_delete_event( - self, request: service.DeleteEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -450,8 +476,10 @@ def pre_delete_event( return request, metadata def pre_delete_input( - self, request: service.DeleteInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_input Override in a subclass to manipulate the request or metadata @@ -471,8 +499,10 @@ def post_delete_input( return response def pre_get_asset( - self, request: service.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -490,8 +520,10 @@ def post_get_asset(self, response: resources.Asset) -> resources.Asset: return response def pre_get_channel( - self, request: service.GetChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_channel Override in a subclass to manipulate the request or metadata @@ -509,8 +541,10 @@ def post_get_channel(self, response: resources.Channel) -> resources.Channel: return response def pre_get_clip( - self, request: service.GetClipRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetClipRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetClipRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetClipRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_clip Override in a subclass to manipulate the request or metadata @@ -528,8 +562,10 @@ def post_get_clip(self, response: resources.Clip) -> resources.Clip: return response def pre_get_event( - self, request: service.GetEventRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetEventRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetEventRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -547,8 +583,10 @@ def post_get_event(self, response: resources.Event) -> resources.Event: return response def pre_get_input( - self, request: service.GetInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_input Override in a subclass to manipulate the request or metadata @@ -566,8 +604,10 @@ def post_get_input(self, response: resources.Input) -> resources.Input: return response def pre_get_pool( - self, request: service.GetPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_pool Override in a subclass to manipulate the request or metadata @@ -585,8 +625,10 @@ def post_get_pool(self, response: resources.Pool) -> resources.Pool: return response def pre_list_assets( - self, request: service.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -606,8 +648,10 @@ def post_list_assets( return response def pre_list_channels( - self, request: service.ListChannelsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListChannelsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListChannelsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListChannelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_channels Override in a subclass to manipulate the request or metadata @@ -627,8 +671,10 @@ def post_list_channels( return response def pre_list_clips( - self, request: service.ListClipsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListClipsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListClipsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListClipsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_clips Override in a subclass to manipulate the request or metadata @@ -648,8 +694,10 @@ def post_list_clips( return response def pre_list_events( - self, request: service.ListEventsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListEventsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListEventsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -669,8 +717,10 @@ def post_list_events( return response def pre_list_inputs( - self, request: service.ListInputsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListInputsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListInputsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListInputsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_inputs Override in a subclass to manipulate the request or metadata @@ -690,8 +740,10 @@ def post_list_inputs( return response def pre_start_channel( - self, request: service.StartChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.StartChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.StartChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.StartChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start_channel Override in a subclass to manipulate the request or metadata @@ -711,8 +763,10 @@ def post_start_channel( return response def pre_stop_channel( - self, request: service.StopChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.StopChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.StopChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.StopChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop_channel Override in a subclass to manipulate the request or metadata @@ -732,8 +786,10 @@ def post_stop_channel( return response def pre_update_channel( - self, request: service.UpdateChannelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateChannelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateChannelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_channel Override in a subclass to manipulate the request or metadata @@ -753,8 +809,10 @@ def post_update_channel( return response def pre_update_input( - self, request: service.UpdateInputRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateInputRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateInputRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateInputRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_input Override in a subclass to manipulate the request or metadata @@ -774,8 +832,10 @@ def post_update_input( return response def pre_update_pool( - self, request: service.UpdatePoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdatePoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdatePoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdatePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_pool Override in a subclass to manipulate the request or metadata @@ -797,8 +857,10 @@ def post_update_pool( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -820,8 +882,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -843,8 +907,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -864,8 +930,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -885,8 +953,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -908,8 +978,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1109,7 +1181,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create asset method over HTTP. @@ -1120,8 +1192,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1134,6 +1208,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateAsset._get_transcoded_request( http_options, request @@ -1148,6 +1223,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CreateAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateAsset._get_response( self._host, @@ -1167,7 +1269,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_asset(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.livestream_v1.LivestreamServiceClient.create_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateChannel( @@ -1206,7 +1330,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create channel method over HTTP. @@ -1217,8 +1341,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1231,6 +1357,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateChannel._get_http_options() ) + request, metadata = self._interceptor.pre_create_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateChannel._get_transcoded_request( http_options, request @@ -1245,6 +1372,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CreateChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateChannel._get_response( self._host, @@ -1264,7 +1418,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_channel(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.livestream_v1.LivestreamServiceClient.create_channel_", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateClip( @@ -1302,7 +1478,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create clip method over HTTP. @@ -1313,8 +1489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1327,6 +1505,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateClip._get_http_options() ) + request, metadata = self._interceptor.pre_create_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateClip._get_transcoded_request( http_options, request @@ -1341,6 +1520,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CreateClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateClip._get_response( self._host, @@ -1360,7 +1566,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_clip(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.livestream_v1.LivestreamServiceClient.create_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1398,7 +1626,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Call the create event method over HTTP. @@ -1409,8 +1637,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Event: @@ -1424,6 +1654,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1438,6 +1669,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateEvent._get_response( self._host, @@ -1459,7 +1717,29 @@ def __call__( pb_resp = resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Event.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.livestream_v1.LivestreamServiceClient.create_event", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInput( @@ -1497,7 +1777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create input method over HTTP. @@ -1508,8 +1788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1522,6 +1804,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseCreateInput._get_http_options() ) + request, metadata = self._interceptor.pre_create_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseCreateInput._get_transcoded_request( http_options, request @@ -1536,6 +1819,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CreateInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CreateInput._get_response( self._host, @@ -1555,7 +1865,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_input(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.livestream_v1.LivestreamServiceClient.create_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CreateInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAsset( @@ -1592,7 +1924,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete asset method over HTTP. @@ -1603,8 +1935,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1617,6 +1951,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteAsset._get_transcoded_request( http_options, request @@ -1627,6 +1962,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteAsset._get_response( self._host, @@ -1645,7 +2007,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_asset(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.livestream_v1.LivestreamServiceClient.delete_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteChannel( @@ -1683,7 +2067,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete channel method over HTTP. @@ -1694,8 +2078,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1708,6 +2094,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteChannel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteChannel._get_transcoded_request( http_options, request @@ -1718,6 +2105,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteChannel._get_response( self._host, @@ -1736,7 +2150,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_channel(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.livestream_v1.LivestreamServiceClient.delete_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteClip( @@ -1773,7 +2209,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete clip method over HTTP. @@ -1784,8 +2220,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1798,6 +2236,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteClip._get_http_options() ) + request, metadata = self._interceptor.pre_delete_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteClip._get_transcoded_request( http_options, request @@ -1808,6 +2247,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteClip._get_response( self._host, @@ -1826,7 +2292,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_clip(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.livestream_v1.LivestreamServiceClient.delete_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1863,7 +2351,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete event method over HTTP. @@ -1874,13 +2362,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1891,6 +2382,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1940,7 +2458,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete input method over HTTP. @@ -1951,8 +2469,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1965,6 +2485,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteInput._get_http_options() ) + request, metadata = self._interceptor.pre_delete_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseDeleteInput._get_transcoded_request( http_options, request @@ -1975,6 +2496,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteInput._get_response( self._host, @@ -1993,7 +2541,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_input(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.livestream_v1.LivestreamServiceClient.delete_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset( @@ -2030,7 +2600,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Asset: r"""Call the get asset method over HTTP. @@ -2041,8 +2611,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Asset: @@ -2054,6 +2626,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetAsset._get_http_options() ) + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetAsset._get_transcoded_request( http_options, request @@ -2064,6 +2637,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetAsset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetAsset._get_response( self._host, @@ -2084,7 +2684,29 @@ def __call__( pb_resp = resources.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Asset.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.livestream_v1.LivestreamServiceClient.get_asset", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetChannel( @@ -2121,7 +2743,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Channel: r"""Call the get channel method over HTTP. @@ -2132,8 +2754,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Channel: @@ -2151,6 +2775,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetChannel._get_http_options() ) + request, metadata = self._interceptor.pre_get_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetChannel._get_transcoded_request( http_options, request @@ -2161,6 +2786,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetChannel._get_response( self._host, @@ -2181,7 +2833,29 @@ def __call__( pb_resp = resources.Channel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_channel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Channel.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.livestream_v1.LivestreamServiceClient.get_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClip( @@ -2218,7 +2892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Clip: r"""Call the get clip method over HTTP. @@ -2229,8 +2903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Clip: @@ -2245,6 +2921,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetClip._get_http_options() ) + request, metadata = self._interceptor.pre_get_clip(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetClip._get_transcoded_request( http_options, request @@ -2257,6 +2934,33 @@ def __call__( ) ) + 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.livestream_v1.LivestreamServiceClient.GetClip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetClip", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetClip._get_response( self._host, @@ -2277,7 +2981,29 @@ def __call__( pb_resp = resources.Clip.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_clip(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Clip.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.livestream_v1.LivestreamServiceClient.get_clip", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetClip", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2314,7 +3040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Event: r"""Call the get event method over HTTP. @@ -2325,8 +3051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Event: @@ -2340,6 +3068,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetEvent._get_transcoded_request( http_options, request @@ -2350,6 +3079,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetEvent._get_response( self._host, @@ -2370,7 +3126,29 @@ def __call__( pb_resp = resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Event.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.livestream_v1.LivestreamServiceClient.get_event", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInput( @@ -2407,7 +3185,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Input: r"""Call the get input method over HTTP. @@ -2418,8 +3196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Input: @@ -2432,6 +3212,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetInput._get_http_options() ) + request, metadata = self._interceptor.pre_get_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetInput._get_transcoded_request( http_options, request @@ -2442,6 +3223,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetInput._get_response( self._host, @@ -2462,7 +3270,29 @@ def __call__( pb_resp = resources.Input.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Input.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.livestream_v1.LivestreamServiceClient.get_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPool( @@ -2499,7 +3329,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Pool: r"""Call the get pool method over HTTP. @@ -2510,8 +3340,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Pool: @@ -2529,6 +3361,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetPool._get_http_options() ) + request, metadata = self._interceptor.pre_get_pool(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetPool._get_transcoded_request( http_options, request @@ -2541,6 +3374,33 @@ def __call__( ) ) + 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.livestream_v1.LivestreamServiceClient.GetPool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetPool._get_response( self._host, @@ -2561,7 +3421,29 @@ def __call__( pb_resp = resources.Pool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Pool.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.livestream_v1.LivestreamServiceClient.get_pool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -2598,7 +3480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2609,8 +3491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListAssetsResponse: @@ -2622,6 +3506,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListAssets._get_transcoded_request( http_options, request @@ -2632,6 +3517,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListAssets", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListAssets._get_response( self._host, @@ -2652,7 +3564,29 @@ def __call__( pb_resp = service.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListAssetsResponse.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.livestream_v1.LivestreamServiceClient.list_assets", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListChannels( @@ -2689,7 +3623,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListChannelsResponse: r"""Call the list channels method over HTTP. @@ -2700,8 +3634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListChannelsResponse: @@ -2713,6 +3649,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListChannels._get_http_options() ) + request, metadata = self._interceptor.pre_list_channels(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListChannels._get_transcoded_request( http_options, request @@ -2723,6 +3660,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListChannels", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListChannels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListChannels._get_response( self._host, @@ -2743,7 +3707,29 @@ def __call__( pb_resp = service.ListChannelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_channels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListChannelsResponse.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.livestream_v1.LivestreamServiceClient.list_channels", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListChannels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClips( @@ -2780,7 +3766,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListClipsResponse: r"""Call the list clips method over HTTP. @@ -2791,8 +3777,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListClipsResponse: @@ -2804,6 +3792,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListClips._get_http_options() ) + request, metadata = self._interceptor.pre_list_clips(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListClips._get_transcoded_request( http_options, request @@ -2814,6 +3803,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListClips", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListClips", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListClips._get_response( self._host, @@ -2834,7 +3850,29 @@ def __call__( pb_resp = service.ListClipsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clips(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListClipsResponse.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.livestream_v1.LivestreamServiceClient.list_clips", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListClips", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2871,7 +3909,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2882,8 +3920,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListEventsResponse: @@ -2895,6 +3935,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2905,6 +3946,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListEvents._get_response( self._host, @@ -2925,7 +3993,29 @@ def __call__( pb_resp = service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListEventsResponse.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.livestream_v1.LivestreamServiceClient.list_events", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInputs( @@ -2962,7 +4052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListInputsResponse: r"""Call the list inputs method over HTTP. @@ -2973,8 +4063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListInputsResponse: @@ -2986,6 +4078,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListInputs._get_http_options() ) + request, metadata = self._interceptor.pre_list_inputs(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListInputs._get_transcoded_request( http_options, request @@ -2996,6 +4089,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListInputs", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListInputs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListInputs._get_response( self._host, @@ -3016,7 +4136,29 @@ def __call__( pb_resp = service.ListInputsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_inputs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListInputsResponse.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.livestream_v1.LivestreamServiceClient.list_inputs", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListInputs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartChannel( @@ -3054,7 +4196,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start channel method over HTTP. @@ -3065,8 +4207,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3079,6 +4223,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseStartChannel._get_http_options() ) + request, metadata = self._interceptor.pre_start_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseStartChannel._get_transcoded_request( http_options, request @@ -3093,6 +4238,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.StartChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StartChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._StartChannel._get_response( self._host, @@ -3112,7 +4284,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_channel(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.livestream_v1.LivestreamServiceClient.start_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StartChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopChannel( @@ -3150,7 +4344,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the stop channel method over HTTP. @@ -3161,8 +4355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3175,6 +4371,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseStopChannel._get_http_options() ) + request, metadata = self._interceptor.pre_stop_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseStopChannel._get_transcoded_request( http_options, request @@ -3189,6 +4386,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.StopChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StopChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._StopChannel._get_response( self._host, @@ -3208,7 +4432,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_channel(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.livestream_v1.LivestreamServiceClient.stop_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "StopChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateChannel( @@ -3247,7 +4493,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update channel method over HTTP. @@ -3258,8 +4504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3272,6 +4520,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdateChannel._get_http_options() ) + request, metadata = self._interceptor.pre_update_channel(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdateChannel._get_transcoded_request( http_options, request @@ -3286,6 +4535,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.UpdateChannel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdateChannel._get_response( self._host, @@ -3305,7 +4581,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_channel(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.livestream_v1.LivestreamServiceClient.update_channel", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInput( @@ -3343,7 +4641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update input method over HTTP. @@ -3354,8 +4652,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3368,6 +4668,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdateInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_input(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdateInput._get_transcoded_request( http_options, request @@ -3382,6 +4683,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.UpdateInput", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdateInput._get_response( self._host, @@ -3401,7 +4729,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_input(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.livestream_v1.LivestreamServiceClient.update_input", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdateInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePool( @@ -3439,7 +4789,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update pool method over HTTP. @@ -3450,8 +4800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3464,6 +4816,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseUpdatePool._get_http_options() ) + request, metadata = self._interceptor.pre_update_pool(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseUpdatePool._get_transcoded_request( http_options, request @@ -3478,6 +4831,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.UpdatePool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdatePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._UpdatePool._get_response( self._host, @@ -3497,7 +4877,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_pool(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.livestream_v1.LivestreamServiceClient.update_pool", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "UpdatePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3730,7 +5132,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3740,8 +5142,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -3750,6 +5154,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3760,6 +5165,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetLocation._get_response( self._host, @@ -3779,6 +5211,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.livestream_v1.LivestreamServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3820,7 +5273,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3830,8 +5283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -3840,6 +5295,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3850,6 +5306,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListLocations._get_response( self._host, @@ -3869,6 +5352,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.livestream_v1.LivestreamServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3911,7 +5415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3921,13 +5425,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLivestreamServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3944,6 +5451,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._CancelOperation._get_response( self._host, @@ -4001,7 +5535,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -4011,13 +5545,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLivestreamServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4030,6 +5567,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._DeleteOperation._get_response( self._host, @@ -4085,7 +5649,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4095,8 +5659,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -4105,6 +5671,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -4115,6 +5682,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._GetOperation._get_response( self._host, @@ -4134,6 +5728,27 @@ def __call__( 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.livestream_v1.LivestreamServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4175,7 +5790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4185,8 +5800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4195,6 +5812,7 @@ def __call__( http_options = ( _BaseLivestreamServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLivestreamServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4205,6 +5823,33 @@ def __call__( 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.livestream_v1.LivestreamServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LivestreamServiceRestTransport._ListOperations._get_response( self._host, @@ -4224,6 +5869,27 @@ def __call__( 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.livestream_v1.LivestreamServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.livestream.v1.LivestreamService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json index 570561e03734..6c0ad77a25a4 100644 --- a/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-live-stream", - "version": "1.9.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -674,7 +674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -851,7 +851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1012,7 +1012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event" @@ -1492,7 +1492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event" @@ -1570,7 +1570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1650,7 +1650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1731,7 +1731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Asset", @@ -1811,7 +1811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Asset", @@ -1892,7 +1892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Channel", @@ -1972,7 +1972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Channel", @@ -2053,7 +2053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Clip", @@ -2133,7 +2133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Clip", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -2294,7 +2294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Event", @@ -2375,7 +2375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Input", @@ -2455,7 +2455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Input", @@ -2536,7 +2536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Pool", @@ -2616,7 +2616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.types.Pool", @@ -2697,7 +2697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsAsyncPager", @@ -2777,7 +2777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsPager", @@ -2858,7 +2858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsAsyncPager", @@ -2938,7 +2938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsPager", @@ -3019,7 +3019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsAsyncPager", @@ -3099,7 +3099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListClipsPager", @@ -3180,7 +3180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsAsyncPager", @@ -3260,7 +3260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsPager", @@ -3341,7 +3341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsAsyncPager", @@ -3421,7 +3421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsPager", @@ -3502,7 +3502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3582,7 +3582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3663,7 +3663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3743,7 +3743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3828,7 +3828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3912,7 +3912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3997,7 +3997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4081,7 +4081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4166,7 +4166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4250,7 +4250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py index 36bd6770f028..080c26abea44 100644 --- a/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py +++ b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py @@ -10864,6 +10864,7 @@ def test_create_channel_rest_required_fields(request_type=service.CreateChannelR response_value._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_channel(request) @@ -10929,6 +10930,7 @@ def test_create_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_channel(**mock_args) @@ -11068,6 +11070,7 @@ def test_list_channels_rest_required_fields(request_type=service.ListChannelsReq response_value._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_channels(request) @@ -11123,6 +11126,7 @@ def test_list_channels_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_channels(**mock_args) @@ -11312,6 +11316,7 @@ def test_get_channel_rest_required_fields(request_type=service.GetChannelRequest response_value._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_channel(request) @@ -11357,6 +11362,7 @@ def test_get_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_channel(**mock_args) @@ -11493,6 +11499,7 @@ def test_delete_channel_rest_required_fields(request_type=service.DeleteChannelR response_value._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_channel(request) @@ -11544,6 +11551,7 @@ def test_delete_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_channel(**mock_args) @@ -11676,6 +11684,7 @@ def test_update_channel_rest_required_fields(request_type=service.UpdateChannelR response_value._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_channel(request) @@ -11730,6 +11739,7 @@ def test_update_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_channel(**mock_args) @@ -11862,6 +11872,7 @@ def test_start_channel_rest_required_fields(request_type=service.StartChannelReq response_value._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.start_channel(request) @@ -11905,6 +11916,7 @@ def test_start_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_channel(**mock_args) @@ -12036,6 +12048,7 @@ def test_stop_channel_rest_required_fields(request_type=service.StopChannelReque response_value._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.stop_channel(request) @@ -12079,6 +12092,7 @@ def test_stop_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.stop_channel(**mock_args) @@ -12224,6 +12238,7 @@ def test_create_input_rest_required_fields(request_type=service.CreateInputReque response_value._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_input(request) @@ -12289,6 +12304,7 @@ def test_create_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_input(**mock_args) @@ -12428,6 +12444,7 @@ def test_list_inputs_rest_required_fields(request_type=service.ListInputsRequest response_value._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_inputs(request) @@ -12483,6 +12500,7 @@ def test_list_inputs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_inputs(**mock_args) @@ -12672,6 +12690,7 @@ def test_get_input_rest_required_fields(request_type=service.GetInputRequest): response_value._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_input(request) @@ -12717,6 +12736,7 @@ def test_get_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_input(**mock_args) @@ -12848,6 +12868,7 @@ def test_delete_input_rest_required_fields(request_type=service.DeleteInputReque response_value._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_input(request) @@ -12891,6 +12912,7 @@ def test_delete_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_input(**mock_args) @@ -13023,6 +13045,7 @@ def test_update_input_rest_required_fields(request_type=service.UpdateInputReque response_value._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_input(request) @@ -13077,6 +13100,7 @@ def test_update_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_input(**mock_args) @@ -13222,6 +13246,7 @@ def test_create_event_rest_required_fields(request_type=service.CreateEventReque response_value._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_event(request) @@ -13291,6 +13316,7 @@ def test_create_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -13431,6 +13457,7 @@ def test_list_events_rest_required_fields(request_type=service.ListEventsRequest response_value._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_events(request) @@ -13488,6 +13515,7 @@ def test_list_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_events(**mock_args) @@ -13680,6 +13708,7 @@ def test_get_event_rest_required_fields(request_type=service.GetEventRequest): response_value._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_event(request) @@ -13727,6 +13756,7 @@ def test_get_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -13855,6 +13885,7 @@ def test_delete_event_rest_required_fields(request_type=service.DeleteEventReque response_value._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_event(request) @@ -13900,6 +13931,7 @@ def test_delete_event_rest_flattened(): 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"} client.delete_event(**mock_args) @@ -14038,6 +14070,7 @@ def test_list_clips_rest_required_fields(request_type=service.ListClipsRequest): response_value._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_clips(request) @@ -14095,6 +14128,7 @@ def test_list_clips_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clips(**mock_args) @@ -14287,6 +14321,7 @@ def test_get_clip_rest_required_fields(request_type=service.GetClipRequest): response_value._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_clip(request) @@ -14334,6 +14369,7 @@ def test_get_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clip(**mock_args) @@ -14479,6 +14515,7 @@ def test_create_clip_rest_required_fields(request_type=service.CreateClipRequest response_value._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_clip(request) @@ -14546,6 +14583,7 @@ def test_create_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clip(**mock_args) @@ -14680,6 +14718,7 @@ def test_delete_clip_rest_required_fields(request_type=service.DeleteClipRequest response_value._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_clip(request) @@ -14725,6 +14764,7 @@ def test_delete_clip_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clip(**mock_args) @@ -14870,6 +14910,7 @@ def test_create_asset_rest_required_fields(request_type=service.CreateAssetReque response_value._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_asset(request) @@ -14935,6 +14976,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -15068,6 +15110,7 @@ def test_delete_asset_rest_required_fields(request_type=service.DeleteAssetReque response_value._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_asset(request) @@ -15111,6 +15154,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -15239,6 +15283,7 @@ def test_get_asset_rest_required_fields(request_type=service.GetAssetRequest): response_value._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_asset(request) @@ -15284,6 +15329,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -15421,6 +15467,7 @@ def test_list_assets_rest_required_fields(request_type=service.ListAssetsRequest response_value._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_assets(request) @@ -15476,6 +15523,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_assets(**mock_args) @@ -15665,6 +15713,7 @@ def test_get_pool_rest_required_fields(request_type=service.GetPoolRequest): response_value._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_pool(request) @@ -15710,6 +15759,7 @@ def test_get_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_pool(**mock_args) @@ -15842,6 +15892,7 @@ def test_update_pool_rest_required_fields(request_type=service.UpdatePoolRequest response_value._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_pool(request) @@ -15896,6 +15947,7 @@ def test_update_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_pool(**mock_args) @@ -17307,6 +17359,7 @@ def test_create_channel_rest_bad_request(request_type=service.CreateChannelReque 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_channel(request) @@ -17543,6 +17596,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_channel(request) # Establish that the response is the type that we expect. @@ -17582,6 +17636,7 @@ def test_create_channel_rest_interceptors(null_interceptor): 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 @@ -17624,6 +17679,7 @@ def test_list_channels_rest_bad_request(request_type=service.ListChannelsRequest 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_channels(request) @@ -17660,6 +17716,7 @@ def test_list_channels_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_channels(request) # Establish that the response is the type that we expect. @@ -17699,6 +17756,7 @@ def test_list_channels_rest_interceptors(null_interceptor): 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 = service.ListChannelsResponse.to_json( service.ListChannelsResponse() ) @@ -17743,6 +17801,7 @@ def test_get_channel_rest_bad_request(request_type=service.GetChannelRequest): 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_channel(request) @@ -17780,6 +17839,7 @@ def test_get_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_channel(request) # Establish that the response is the type that we expect. @@ -17820,6 +17880,7 @@ def test_get_channel_rest_interceptors(null_interceptor): 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 = resources.Channel.to_json(resources.Channel()) req.return_value.content = return_value @@ -17862,6 +17923,7 @@ def test_delete_channel_rest_bad_request(request_type=service.DeleteChannelReque 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_channel(request) @@ -17892,6 +17954,7 @@ def test_delete_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_channel(request) # Establish that the response is the type that we expect. @@ -17931,6 +17994,7 @@ def test_delete_channel_rest_interceptors(null_interceptor): 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 @@ -17975,6 +18039,7 @@ def test_update_channel_rest_bad_request(request_type=service.UpdateChannelReque 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_channel(request) @@ -18213,6 +18278,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_channel(request) # Establish that the response is the type that we expect. @@ -18252,6 +18318,7 @@ def test_update_channel_rest_interceptors(null_interceptor): 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 @@ -18294,6 +18361,7 @@ def test_start_channel_rest_bad_request(request_type=service.StartChannelRequest 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.start_channel(request) @@ -18324,6 +18392,7 @@ def test_start_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_channel(request) # Establish that the response is the type that we expect. @@ -18363,6 +18432,7 @@ def test_start_channel_rest_interceptors(null_interceptor): 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 @@ -18405,6 +18475,7 @@ def test_stop_channel_rest_bad_request(request_type=service.StopChannelRequest): 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.stop_channel(request) @@ -18435,6 +18506,7 @@ def test_stop_channel_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_channel(request) # Establish that the response is the type that we expect. @@ -18474,6 +18546,7 @@ def test_stop_channel_rest_interceptors(null_interceptor): 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 @@ -18516,6 +18589,7 @@ def test_create_input_rest_bad_request(request_type=service.CreateInputRequest): 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_input(request) @@ -18665,6 +18739,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_input(request) # Establish that the response is the type that we expect. @@ -18704,6 +18779,7 @@ def test_create_input_rest_interceptors(null_interceptor): 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 @@ -18746,6 +18822,7 @@ def test_list_inputs_rest_bad_request(request_type=service.ListInputsRequest): 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_inputs(request) @@ -18782,6 +18859,7 @@ def test_list_inputs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_inputs(request) # Establish that the response is the type that we expect. @@ -18821,6 +18899,7 @@ def test_list_inputs_rest_interceptors(null_interceptor): 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 = service.ListInputsResponse.to_json(service.ListInputsResponse()) req.return_value.content = return_value @@ -18863,6 +18942,7 @@ def test_get_input_rest_bad_request(request_type=service.GetInputRequest): 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_input(request) @@ -18901,6 +18981,7 @@ def test_get_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_input(request) # Establish that the response is the type that we expect. @@ -18942,6 +19023,7 @@ def test_get_input_rest_interceptors(null_interceptor): 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 = resources.Input.to_json(resources.Input()) req.return_value.content = return_value @@ -18984,6 +19066,7 @@ def test_delete_input_rest_bad_request(request_type=service.DeleteInputRequest): 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_input(request) @@ -19014,6 +19097,7 @@ def test_delete_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_input(request) # Establish that the response is the type that we expect. @@ -19053,6 +19137,7 @@ def test_delete_input_rest_interceptors(null_interceptor): 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 @@ -19097,6 +19182,7 @@ def test_update_input_rest_bad_request(request_type=service.UpdateInputRequest): 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_input(request) @@ -19248,6 +19334,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_input(request) # Establish that the response is the type that we expect. @@ -19287,6 +19374,7 @@ def test_update_input_rest_interceptors(null_interceptor): 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 @@ -19329,6 +19417,7 @@ def test_create_event_rest_bad_request(request_type=service.CreateEventRequest): 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_event(request) @@ -19458,6 +19547,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -19498,6 +19588,7 @@ def test_create_event_rest_interceptors(null_interceptor): 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 = resources.Event.to_json(resources.Event()) req.return_value.content = return_value @@ -19540,6 +19631,7 @@ def test_list_events_rest_bad_request(request_type=service.ListEventsRequest): 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_events(request) @@ -19576,6 +19668,7 @@ def test_list_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_events(request) # Establish that the response is the type that we expect. @@ -19615,6 +19708,7 @@ def test_list_events_rest_interceptors(null_interceptor): 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 = service.ListEventsResponse.to_json(service.ListEventsResponse()) req.return_value.content = return_value @@ -19659,6 +19753,7 @@ def test_get_event_rest_bad_request(request_type=service.GetEventRequest): 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_event(request) @@ -19698,6 +19793,7 @@ def test_get_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -19738,6 +19834,7 @@ def test_get_event_rest_interceptors(null_interceptor): 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 = resources.Event.to_json(resources.Event()) req.return_value.content = return_value @@ -19782,6 +19879,7 @@ def test_delete_event_rest_bad_request(request_type=service.DeleteEventRequest): 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_event(request) @@ -19814,6 +19912,7 @@ def test_delete_event_rest_call_success(request_type): 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_event(request) # Establish that the response is the type that we expect. @@ -19848,6 +19947,7 @@ def test_delete_event_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = service.DeleteEventRequest() metadata = [ @@ -19886,6 +19986,7 @@ def test_list_clips_rest_bad_request(request_type=service.ListClipsRequest): 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_clips(request) @@ -19922,6 +20023,7 @@ def test_list_clips_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clips(request) # Establish that the response is the type that we expect. @@ -19961,6 +20063,7 @@ def test_list_clips_rest_interceptors(null_interceptor): 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 = service.ListClipsResponse.to_json(service.ListClipsResponse()) req.return_value.content = return_value @@ -20005,6 +20108,7 @@ def test_get_clip_rest_bad_request(request_type=service.GetClipRequest): 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_clip(request) @@ -20044,6 +20148,7 @@ def test_get_clip_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clip(request) # Establish that the response is the type that we expect. @@ -20084,6 +20189,7 @@ def test_get_clip_rest_interceptors(null_interceptor): 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 = resources.Clip.to_json(resources.Clip()) req.return_value.content = return_value @@ -20126,6 +20232,7 @@ def test_create_clip_rest_bad_request(request_type=service.CreateClipRequest): 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_clip(request) @@ -20246,6 +20353,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_clip(request) # Establish that the response is the type that we expect. @@ -20285,6 +20393,7 @@ def test_create_clip_rest_interceptors(null_interceptor): 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 @@ -20329,6 +20438,7 @@ def test_delete_clip_rest_bad_request(request_type=service.DeleteClipRequest): 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_clip(request) @@ -20361,6 +20471,7 @@ def test_delete_clip_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clip(request) # Establish that the response is the type that we expect. @@ -20400,6 +20511,7 @@ def test_delete_clip_rest_interceptors(null_interceptor): 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 @@ -20442,6 +20554,7 @@ def test_create_asset_rest_bad_request(request_type=service.CreateAssetRequest): 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_asset(request) @@ -20559,6 +20672,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -20598,6 +20712,7 @@ def test_create_asset_rest_interceptors(null_interceptor): 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 @@ -20640,6 +20755,7 @@ def test_delete_asset_rest_bad_request(request_type=service.DeleteAssetRequest): 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_asset(request) @@ -20670,6 +20786,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -20709,6 +20826,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): 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 @@ -20751,6 +20869,7 @@ def test_get_asset_rest_bad_request(request_type=service.GetAssetRequest): 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_asset(request) @@ -20788,6 +20907,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -20828,6 +20948,7 @@ def test_get_asset_rest_interceptors(null_interceptor): 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 = resources.Asset.to_json(resources.Asset()) req.return_value.content = return_value @@ -20870,6 +20991,7 @@ def test_list_assets_rest_bad_request(request_type=service.ListAssetsRequest): 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_assets(request) @@ -20906,6 +21028,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -20945,6 +21068,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = service.ListAssetsResponse.to_json(service.ListAssetsResponse()) req.return_value.content = return_value @@ -20987,6 +21111,7 @@ def test_get_pool_rest_bad_request(request_type=service.GetPoolRequest): 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_pool(request) @@ -21022,6 +21147,7 @@ def test_get_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_pool(request) # Establish that the response is the type that we expect. @@ -21060,6 +21186,7 @@ def test_get_pool_rest_interceptors(null_interceptor): 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 = resources.Pool.to_json(resources.Pool()) req.return_value.content = return_value @@ -21104,6 +21231,7 @@ def test_update_pool_rest_bad_request(request_type=service.UpdatePoolRequest): 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_pool(request) @@ -21210,6 +21338,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_pool(request) # Establish that the response is the type that we expect. @@ -21249,6 +21378,7 @@ def test_update_pool_rest_interceptors(null_interceptor): 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 @@ -21293,6 +21423,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -21323,6 +21454,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -21351,6 +21483,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -21381,6 +21514,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -21411,6 +21545,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -21441,6 +21576,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -21471,6 +21607,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -21501,6 +21638,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -21531,6 +21669,7 @@ def test_get_operation_rest_bad_request( 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) @@ -21561,6 +21700,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -21591,6 +21731,7 @@ def test_list_operations_rest_bad_request( 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) @@ -21621,6 +21762,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py index 747954cc02fd..558c8aab67c5 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.7.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py index 747954cc02fd..558c8aab67c5 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.7.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py index 31b08aa5ae8c..03454170289d 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -65,6 +66,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +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 @@ -315,6 +325,28 @@ def __init__( 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[ @@ -326,7 +358,7 @@ async def create_cdn_key( cdn_key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new CDN key. @@ -398,8 +430,10 @@ async def sample_create_cdn_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -477,7 +511,7 @@ async def list_cdn_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCdnKeysAsyncPager: r"""Lists all CDN keys in the specified project and location. @@ -524,8 +558,10 @@ async def sample_list_cdn_keys(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager: @@ -600,7 +636,7 @@ async def get_cdn_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cdn_keys.CdnKey: r"""Returns the specified CDN key. @@ -645,8 +681,10 @@ async def sample_get_cdn_key(): 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, 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: google.cloud.video.stitcher_v1.types.CdnKey: @@ -711,7 +749,7 @@ async def delete_cdn_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified CDN key. @@ -760,8 +798,10 @@ async def sample_delete_cdn_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -843,7 +883,7 @@ async def update_cdn_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -899,8 +939,10 @@ async def sample_update_cdn_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -979,7 +1021,7 @@ async def create_vod_session( vod_session: Optional[sessions.VodSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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 @@ -1037,8 +1079,10 @@ async def sample_create_vod_session(): 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, 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: google.cloud.video.stitcher_v1.types.VodSession: @@ -1104,7 +1148,7 @@ async def get_vod_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -1150,8 +1194,10 @@ async def sample_get_vod_session(): 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, 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: google.cloud.video.stitcher_v1.types.VodSession: @@ -1215,7 +1261,7 @@ async def list_vod_stitch_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVodStitchDetailsAsyncPager: r"""Returns a list of detailed stitching information of the specified VOD session. @@ -1262,8 +1308,10 @@ async def sample_list_vod_stitch_details(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager: @@ -1340,7 +1388,7 @@ async def get_vod_stitch_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> stitch_details.VodStitchDetail: r"""Returns the specified stitching information for the specified VOD session. @@ -1386,8 +1434,10 @@ async def sample_get_vod_stitch_detail(): 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, 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: google.cloud.video.stitcher_v1.types.VodStitchDetail: @@ -1453,7 +1503,7 @@ async def list_vod_ad_tag_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVodAdTagDetailsAsyncPager: r"""Return the list of ad tag details for the specified VOD session. @@ -1500,8 +1550,10 @@ async def sample_list_vod_ad_tag_details(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager: @@ -1578,7 +1630,7 @@ async def get_vod_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.VodAdTagDetail: r"""Returns the specified ad tag detail for the specified VOD session. @@ -1624,8 +1676,10 @@ async def sample_get_vod_ad_tag_detail(): 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, 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: google.cloud.video.stitcher_v1.types.VodAdTagDetail: @@ -1691,7 +1745,7 @@ async def list_live_ad_tag_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLiveAdTagDetailsAsyncPager: r"""Return the list of ad tag details for the specified live session. @@ -1737,8 +1791,10 @@ async def sample_list_live_ad_tag_details(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager: @@ -1815,7 +1871,7 @@ async def get_live_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.LiveAdTagDetail: r"""Returns the specified ad tag detail for the specified live session. @@ -1860,8 +1916,10 @@ async def sample_get_live_ad_tag_detail(): 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, 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: google.cloud.video.stitcher_v1.types.LiveAdTagDetail: @@ -1929,7 +1987,7 @@ async def create_slate( slate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a slate. @@ -1996,8 +2054,10 @@ async def sample_create_slate(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2073,7 +2133,7 @@ async def list_slates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSlatesAsyncPager: r"""Lists all slates in the specified project and location. @@ -2119,8 +2179,10 @@ async def sample_list_slates(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager: @@ -2195,7 +2257,7 @@ async def get_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> slates.Slate: r"""Returns the specified slate. @@ -2240,8 +2302,10 @@ async def sample_get_slate(): 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, 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: google.cloud.video.stitcher_v1.types.Slate: @@ -2303,7 +2367,7 @@ async def update_slate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified slate. @@ -2358,8 +2422,10 @@ async def sample_update_slate(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2437,7 +2503,7 @@ async def delete_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified slate. @@ -2486,8 +2552,10 @@ async def sample_delete_slate(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2569,7 +2637,7 @@ async def create_live_session( live_session: Optional[sessions.LiveSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Creates a new live session. @@ -2625,8 +2693,10 @@ async def sample_create_live_session(): 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, 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: google.cloud.video.stitcher_v1.types.LiveSession: @@ -2693,7 +2763,7 @@ async def get_live_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Returns the details for the specified live session. @@ -2737,8 +2807,10 @@ async def sample_get_live_session(): 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, 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: google.cloud.video.stitcher_v1.types.LiveSession: @@ -2805,7 +2877,7 @@ async def create_live_config( live_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Registers the live config with the provided unique ID in the specified region. @@ -2875,8 +2947,10 @@ async def sample_create_live_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2954,7 +3028,7 @@ async def list_live_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -3001,8 +3075,10 @@ async def sample_list_live_configs(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager: @@ -3079,7 +3155,7 @@ async def get_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> live_configs.LiveConfig: r"""Returns the specified live config managed by the Video Stitcher service. @@ -3125,8 +3201,10 @@ async def sample_get_live_config(): 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, 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: google.cloud.video.stitcher_v1.types.LiveConfig: @@ -3189,7 +3267,7 @@ async def delete_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified live config. @@ -3238,8 +3316,10 @@ async def sample_delete_live_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3321,7 +3401,7 @@ async def update_live_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified LiveConfig. Only update fields specified in the call method body. @@ -3383,8 +3463,10 @@ async def sample_update_live_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3464,7 +3546,7 @@ async def create_vod_config( vod_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Registers the VOD config with the provided unique ID in the specified region. @@ -3534,8 +3616,10 @@ async def sample_create_vod_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3613,7 +3697,7 @@ async def list_vod_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -3660,8 +3744,10 @@ async def sample_list_vod_configs(): 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, 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager: @@ -3738,7 +3824,7 @@ async def get_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vod_configs.VodConfig: r"""Returns the specified VOD config managed by the Video Stitcher API service. @@ -3784,8 +3870,10 @@ async def sample_get_vod_config(): 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, 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: google.cloud.video.stitcher_v1.types.VodConfig: @@ -3848,7 +3936,7 @@ async def delete_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified VOD config. @@ -3897,8 +3985,10 @@ async def sample_delete_vod_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3980,7 +4070,7 @@ async def update_vod_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -4042,8 +4132,10 @@ async def sample_update_vod_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4118,7 +4210,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4129,8 +4221,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4171,7 +4265,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4182,8 +4276,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4224,7 +4320,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4240,8 +4336,10 @@ async def delete_operation( 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, 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: None """ @@ -4278,7 +4376,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4293,8 +4391,10 @@ async def cancel_operation( 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, 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: None """ 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 bf3ceecd8ddf..1178e6163405 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 @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -787,6 +797,10 @@ def __init__( # 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( @@ -853,6 +867,29 @@ def __init__( 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[ @@ -864,7 +901,7 @@ def create_cdn_key( cdn_key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new CDN key. @@ -936,8 +973,10 @@ def sample_create_cdn_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1012,7 +1051,7 @@ def list_cdn_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCdnKeysPager: r"""Lists all CDN keys in the specified project and location. @@ -1059,8 +1098,10 @@ def sample_list_cdn_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager: @@ -1132,7 +1173,7 @@ def get_cdn_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cdn_keys.CdnKey: r"""Returns the specified CDN key. @@ -1177,8 +1218,10 @@ def sample_get_cdn_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.CdnKey: @@ -1240,7 +1283,7 @@ def delete_cdn_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified CDN key. @@ -1289,8 +1332,10 @@ def sample_delete_cdn_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1369,7 +1414,7 @@ def update_cdn_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified CDN key. Only update fields specified in the call method body. @@ -1425,8 +1470,10 @@ def sample_update_cdn_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1502,7 +1549,7 @@ def create_vod_session( vod_session: Optional[sessions.VodSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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 @@ -1560,8 +1607,10 @@ def sample_create_vod_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.VodSession: @@ -1624,7 +1673,7 @@ def get_vod_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -1670,8 +1719,10 @@ def sample_get_vod_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.VodSession: @@ -1732,7 +1783,7 @@ def list_vod_stitch_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVodStitchDetailsPager: r"""Returns a list of detailed stitching information of the specified VOD session. @@ -1779,8 +1830,10 @@ def sample_list_vod_stitch_details(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager: @@ -1854,7 +1907,7 @@ def get_vod_stitch_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> stitch_details.VodStitchDetail: r"""Returns the specified stitching information for the specified VOD session. @@ -1900,8 +1953,10 @@ def sample_get_vod_stitch_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.VodStitchDetail: @@ -1964,7 +2019,7 @@ def list_vod_ad_tag_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVodAdTagDetailsPager: r"""Return the list of ad tag details for the specified VOD session. @@ -2011,8 +2066,10 @@ def sample_list_vod_ad_tag_details(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager: @@ -2086,7 +2143,7 @@ def get_vod_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.VodAdTagDetail: r"""Returns the specified ad tag detail for the specified VOD session. @@ -2132,8 +2189,10 @@ def sample_get_vod_ad_tag_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.VodAdTagDetail: @@ -2196,7 +2255,7 @@ def list_live_ad_tag_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLiveAdTagDetailsPager: r"""Return the list of ad tag details for the specified live session. @@ -2242,8 +2301,10 @@ def sample_list_live_ad_tag_details(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager: @@ -2317,7 +2378,7 @@ def get_live_ad_tag_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_tag_details.LiveAdTagDetail: r"""Returns the specified ad tag detail for the specified live session. @@ -2362,8 +2423,10 @@ def sample_get_live_ad_tag_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.LiveAdTagDetail: @@ -2428,7 +2491,7 @@ def create_slate( slate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a slate. @@ -2495,8 +2558,10 @@ def sample_create_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2569,7 +2634,7 @@ def list_slates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSlatesPager: r"""Lists all slates in the specified project and location. @@ -2615,8 +2680,10 @@ def sample_list_slates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager: @@ -2688,7 +2755,7 @@ def get_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> slates.Slate: r"""Returns the specified slate. @@ -2733,8 +2800,10 @@ def sample_get_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.Slate: @@ -2793,7 +2862,7 @@ def update_slate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified slate. @@ -2848,8 +2917,10 @@ def sample_update_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2924,7 +2995,7 @@ def delete_slate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified slate. @@ -2973,8 +3044,10 @@ def sample_delete_slate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3053,7 +3126,7 @@ def create_live_session( live_session: Optional[sessions.LiveSession] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Creates a new live session. @@ -3109,8 +3182,10 @@ def sample_create_live_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.LiveSession: @@ -3174,7 +3249,7 @@ def get_live_session( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> sessions.LiveSession: r"""Returns the details for the specified live session. @@ -3218,8 +3293,10 @@ def sample_get_live_session(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.LiveSession: @@ -3283,7 +3360,7 @@ def create_live_config( live_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Registers the live config with the provided unique ID in the specified region. @@ -3353,8 +3430,10 @@ def sample_create_live_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3429,7 +3508,7 @@ def list_live_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -3476,8 +3555,10 @@ def sample_list_live_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager: @@ -3551,7 +3632,7 @@ def get_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> live_configs.LiveConfig: r"""Returns the specified live config managed by the Video Stitcher service. @@ -3597,8 +3678,10 @@ def sample_get_live_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.LiveConfig: @@ -3658,7 +3741,7 @@ def delete_live_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified live config. @@ -3707,8 +3790,10 @@ def sample_delete_live_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3787,7 +3872,7 @@ def update_live_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified LiveConfig. Only update fields specified in the call method body. @@ -3849,8 +3934,10 @@ def sample_update_live_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3927,7 +4014,7 @@ def create_vod_config( vod_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Registers the VOD config with the provided unique ID in the specified region. @@ -3997,8 +4084,10 @@ def sample_create_vod_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4073,7 +4162,7 @@ def list_vod_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + 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. @@ -4120,8 +4209,10 @@ def sample_list_vod_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager: @@ -4195,7 +4286,7 @@ def get_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vod_configs.VodConfig: r"""Returns the specified VOD config managed by the Video Stitcher API service. @@ -4241,8 +4332,10 @@ def sample_get_vod_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.stitcher_v1.types.VodConfig: @@ -4302,7 +4395,7 @@ def delete_vod_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified VOD config. @@ -4351,8 +4444,10 @@ def sample_delete_vod_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4431,7 +4526,7 @@ def update_vod_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the specified VOD config. Only update fields specified in the call method body. @@ -4493,8 +4588,10 @@ def sample_update_vod_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4579,7 +4676,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4590,8 +4687,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4632,7 +4731,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4643,8 +4742,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4685,7 +4786,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4701,8 +4802,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4739,7 +4842,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4754,8 +4857,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py index 63ed6d96a52d..8f4dd6533e21 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py @@ -75,7 +75,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -89,8 +89,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListCdnKeysRequest(request) @@ -149,7 +151,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -163,8 +165,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListCdnKeysRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) @@ -303,7 +309,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -317,8 +323,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) @@ -383,7 +391,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -397,8 +405,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) @@ -459,7 +469,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -473,8 +483,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) @@ -539,7 +551,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -553,8 +565,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) @@ -615,7 +629,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -629,8 +643,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) @@ -695,7 +711,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -709,8 +725,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListSlatesRequest(request) @@ -769,7 +787,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -783,8 +801,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListSlatesRequest(request) @@ -847,7 +867,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -861,8 +881,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListLiveConfigsRequest(request) @@ -923,7 +945,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -937,8 +959,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListLiveConfigsRequest(request) @@ -1003,7 +1027,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1017,8 +1041,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = video_stitcher_service.ListVodConfigsRequest(request) @@ -1077,7 +1103,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1091,8 +1117,10 @@ def __init__( 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, 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`. """ self._method = method self._request = video_stitcher_service.ListVodConfigsRequest(request) diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py index a635ec756d63..1f8d50e7908b 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # 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, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport +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": 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. @@ -194,7 +275,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -284,7 +372,7 @@ def create_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -314,7 +402,7 @@ def list_cdn_keys( # 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.grpc_channel.unary_unary( + 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, @@ -340,7 +428,7 @@ def get_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -368,7 +456,7 @@ def delete_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -397,7 +485,7 @@ def update_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -427,7 +515,7 @@ def create_vod_session( # 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.grpc_channel.unary_unary( + 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, @@ -454,7 +542,7 @@ def get_vod_session( # 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.grpc_channel.unary_unary( + 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, @@ -484,7 +572,7 @@ def list_vod_stitch_details( # 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.grpc_channel.unary_unary( + 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, @@ -514,7 +602,7 @@ def get_vod_stitch_detail( # 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.grpc_channel.unary_unary( + 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, @@ -544,7 +632,7 @@ def list_vod_ad_tag_details( # 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.grpc_channel.unary_unary( + 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, @@ -573,7 +661,7 @@ def get_vod_ad_tag_detail( # 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.grpc_channel.unary_unary( + 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, @@ -603,7 +691,7 @@ def list_live_ad_tag_details( # 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.grpc_channel.unary_unary( + 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, @@ -633,7 +721,7 @@ def get_live_ad_tag_detail( # 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.grpc_channel.unary_unary( + 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, @@ -661,7 +749,7 @@ def create_slate( # 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.grpc_channel.unary_unary( + 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, @@ -691,7 +779,7 @@ def list_slates( # 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.grpc_channel.unary_unary( + 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, @@ -717,7 +805,7 @@ def get_slate( # 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.grpc_channel.unary_unary( + 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, @@ -745,7 +833,7 @@ def update_slate( # 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.grpc_channel.unary_unary( + 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, @@ -773,7 +861,7 @@ def delete_slate( # 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.grpc_channel.unary_unary( + 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, @@ -801,7 +889,7 @@ def create_live_session( # 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.grpc_channel.unary_unary( + 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, @@ -827,7 +915,7 @@ def get_live_session( # 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.grpc_channel.unary_unary( + 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, @@ -856,7 +944,7 @@ def create_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -886,7 +974,7 @@ def list_live_configs( # 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.grpc_channel.unary_unary( + 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, @@ -915,7 +1003,7 @@ def get_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -943,7 +1031,7 @@ def delete_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -972,7 +1060,7 @@ def update_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -1001,7 +1089,7 @@ def create_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1031,7 +1119,7 @@ def list_vod_configs( # 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.grpc_channel.unary_unary( + 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, @@ -1058,7 +1146,7 @@ def get_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1086,7 +1174,7 @@ def delete_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1115,7 +1203,7 @@ def update_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1123,7 +1211,7 @@ def update_vod_config( return self._stubs["update_vod_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1135,7 +1223,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1152,7 +1240,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1169,7 +1257,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1188,7 +1276,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py index 66cfca6a09dd..4ef796d8e388 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.video.stitcher_v1.types import ( ad_tag_details, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport 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. @@ -241,10 +323,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -295,7 +380,7 @@ def create_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -325,7 +410,7 @@ def list_cdn_keys( # 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.grpc_channel.unary_unary( + 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, @@ -353,7 +438,7 @@ def get_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -382,7 +467,7 @@ def delete_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -412,7 +497,7 @@ def update_cdn_key( # 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.grpc_channel.unary_unary( + 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, @@ -442,7 +527,7 @@ def create_vod_session( # 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.grpc_channel.unary_unary( + 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, @@ -471,7 +556,7 @@ def get_vod_session( # 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.grpc_channel.unary_unary( + 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, @@ -501,7 +586,7 @@ def list_vod_stitch_details( # 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.grpc_channel.unary_unary( + 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, @@ -531,7 +616,7 @@ def get_vod_stitch_detail( # 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.grpc_channel.unary_unary( + 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, @@ -561,7 +646,7 @@ def list_vod_ad_tag_details( # 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.grpc_channel.unary_unary( + 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, @@ -591,7 +676,7 @@ def get_vod_ad_tag_detail( # 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.grpc_channel.unary_unary( + 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, @@ -621,7 +706,7 @@ def list_live_ad_tag_details( # 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.grpc_channel.unary_unary( + 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, @@ -651,7 +736,7 @@ def get_live_ad_tag_detail( # 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.grpc_channel.unary_unary( + 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, @@ -679,7 +764,7 @@ def create_slate( # 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.grpc_channel.unary_unary( + 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, @@ -709,7 +794,7 @@ def list_slates( # 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.grpc_channel.unary_unary( + 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, @@ -735,7 +820,7 @@ def get_slate( # 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.grpc_channel.unary_unary( + 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, @@ -763,7 +848,7 @@ def update_slate( # 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.grpc_channel.unary_unary( + 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, @@ -791,7 +876,7 @@ def delete_slate( # 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.grpc_channel.unary_unary( + 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, @@ -820,7 +905,7 @@ def create_live_session( # 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.grpc_channel.unary_unary( + 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, @@ -848,7 +933,7 @@ def get_live_session( # 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.grpc_channel.unary_unary( + 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, @@ -878,7 +963,7 @@ def create_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -908,7 +993,7 @@ def list_live_configs( # 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.grpc_channel.unary_unary( + 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, @@ -938,7 +1023,7 @@ def get_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -967,7 +1052,7 @@ def delete_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -997,7 +1082,7 @@ def update_live_config( # 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.grpc_channel.unary_unary( + 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, @@ -1027,7 +1112,7 @@ def create_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1057,7 +1142,7 @@ def list_vod_configs( # 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.grpc_channel.unary_unary( + 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, @@ -1086,7 +1171,7 @@ def get_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1115,7 +1200,7 @@ def delete_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1145,7 +1230,7 @@ def update_vod_config( # 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.grpc_channel.unary_unary( + 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, @@ -1333,7 +1418,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1349,7 +1434,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1366,7 +1451,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1383,7 +1468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1402,7 +1487,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json b/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json index 222f0b54279a..2e9dbfeedb7e 100644 --- a/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json +++ b/packages/google-cloud-video-stitcher/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-stitcher", - "version": "0.7.14" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -405,7 +405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -666,7 +666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -755,7 +755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -843,7 +843,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -928,7 +928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -1012,7 +1012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1495,7 +1495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1656,7 +1656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1737,7 +1737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", @@ -1817,7 +1817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", @@ -1898,7 +1898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", @@ -1978,7 +1978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", @@ -2059,7 +2059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", @@ -2139,7 +2139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", @@ -2220,7 +2220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -2300,7 +2300,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", @@ -2381,7 +2381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.Slate", @@ -2461,7 +2461,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.Slate", @@ -2542,7 +2542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", @@ -2622,7 +2622,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", @@ -2703,7 +2703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", @@ -2783,7 +2783,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", @@ -2864,7 +2864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -2944,7 +2944,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodSession", @@ -3025,7 +3025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", @@ -3105,7 +3105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", @@ -3186,7 +3186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager", @@ -3266,7 +3266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager", @@ -3347,7 +3347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager", @@ -3427,7 +3427,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager", @@ -3508,7 +3508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager", @@ -3588,7 +3588,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager", @@ -3669,7 +3669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager", @@ -3749,7 +3749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager", @@ -3830,7 +3830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager", @@ -3910,7 +3910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager", @@ -3991,7 +3991,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager", @@ -4071,7 +4071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager", @@ -4152,7 +4152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager", @@ -4232,7 +4232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager", @@ -4317,7 +4317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4401,7 +4401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4486,7 +4486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4570,7 +4570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4655,7 +4655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4739,7 +4739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4824,7 +4824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4908,7 +4908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py index 25080697d07f..7d119a8b052a 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport from .transports.grpc_asyncio import TranscoderServiceGrpcAsyncIOTransport +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 TranscoderServiceAsyncClient: """Using the Transcoder API, you can queue asynchronous jobs for @@ -272,6 +282,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "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.transcoder.v1.TranscoderService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[services.CreateJobRequest, dict]] = None, @@ -280,7 +312,7 @@ async def create_job( job: Optional[resources.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Creates a job in the specified region. @@ -334,8 +366,10 @@ async def sample_create_job(): 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, 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: google.cloud.video.transcoder_v1.types.Job: @@ -396,7 +430,7 @@ async def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs in the specified region. @@ -442,8 +476,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsAsyncPager: @@ -517,7 +553,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Returns the job data. @@ -560,8 +596,10 @@ async def sample_get_job(): 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, 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: google.cloud.video.transcoder_v1.types.Job: @@ -618,7 +656,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -658,8 +696,10 @@ async def sample_delete_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -713,7 +753,7 @@ async def create_job_template( job_template_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Creates a job template in the specified region. @@ -778,8 +818,10 @@ async def sample_create_job_template(): 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, 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: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -842,7 +884,7 @@ async def list_job_templates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobTemplatesAsyncPager: r"""Lists job templates in the specified region. @@ -888,8 +930,10 @@ async def sample_list_job_templates(): 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, 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: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager: @@ -963,7 +1007,7 @@ async def get_job_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Returns the job template data. @@ -1008,8 +1052,10 @@ async def sample_get_job_template(): 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, 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: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -1068,7 +1114,7 @@ async def delete_job_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job template. @@ -1109,8 +1155,10 @@ async def sample_delete_job_template(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py index da7eec12448a..4771712408cc 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -614,6 +624,10 @@ def __init__( # 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( @@ -680,6 +694,29 @@ def __init__( 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.transcoder_v1.TranscoderServiceClient`.", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "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.transcoder.v1.TranscoderService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[services.CreateJobRequest, dict]] = None, @@ -688,7 +725,7 @@ def create_job( job: Optional[resources.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Creates a job in the specified region. @@ -742,8 +779,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.types.Job: @@ -801,7 +840,7 @@ def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists jobs in the specified region. @@ -847,8 +886,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager: @@ -919,7 +960,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Returns the job data. @@ -962,8 +1003,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.types.Job: @@ -1019,7 +1062,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -1059,8 +1102,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1111,7 +1156,7 @@ def create_job_template( job_template_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Creates a job template in the specified region. @@ -1176,8 +1221,10 @@ def sample_create_job_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -1237,7 +1284,7 @@ def list_job_templates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobTemplatesPager: r"""Lists job templates in the specified region. @@ -1283,8 +1330,10 @@ def sample_list_job_templates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager: @@ -1355,7 +1404,7 @@ def get_job_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Returns the job template data. @@ -1400,8 +1449,10 @@ def sample_get_job_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.video.transcoder_v1.types.JobTemplate: @@ -1457,7 +1508,7 @@ def delete_job_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job template. @@ -1498,8 +1549,10 @@ def sample_delete_job_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py index 478cc3688ead..8ceda6c0434c 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = services.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = services.ListJobsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = services.ListJobTemplatesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = services.ListJobTemplatesRequest(request) diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py index dbeb8d16d5cd..d5f518b44943 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # 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.transcoder_v1.types import resources, services from .base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport +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.transcoder.v1.TranscoderService", + "rpcName": 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.transcoder.v1.TranscoderService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranscoderServiceGrpcTransport(TranscoderServiceTransport): """gRPC backend transport for TranscoderService. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_job(self) -> Callable[[services.CreateJobRequest], resources.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJob", request_serializer=services.CreateJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -284,7 +370,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobs", request_serializer=services.ListJobsRequest.serialize, response_deserializer=services.ListJobsResponse.deserialize, @@ -308,7 +394,7 @@ def get_job(self) -> Callable[[services.GetJobRequest], resources.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJob", request_serializer=services.GetJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -332,7 +418,7 @@ def delete_job(self) -> Callable[[services.DeleteJobRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJob", request_serializer=services.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -358,7 +444,7 @@ def create_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job_template" not in self._stubs: - self._stubs["create_job_template"] = self.grpc_channel.unary_unary( + self._stubs["create_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJobTemplate", request_serializer=services.CreateJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -386,7 +472,7 @@ def list_job_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_job_templates" not in self._stubs: - self._stubs["list_job_templates"] = self.grpc_channel.unary_unary( + self._stubs["list_job_templates"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobTemplates", request_serializer=services.ListJobTemplatesRequest.serialize, response_deserializer=services.ListJobTemplatesResponse.deserialize, @@ -412,7 +498,7 @@ def get_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job_template" not in self._stubs: - self._stubs["get_job_template"] = self.grpc_channel.unary_unary( + self._stubs["get_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJobTemplate", request_serializer=services.GetJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -438,7 +524,7 @@ def delete_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job_template" not in self._stubs: - self._stubs["delete_job_template"] = self.grpc_channel.unary_unary( + self._stubs["delete_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJobTemplate", request_serializer=services.DeleteJobTemplateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -446,7 +532,7 @@ def delete_job_template( return self._stubs["delete_job_template"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py index 5e70c8789adb..f65ac2d65883 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.video.transcoder_v1.types import resources, services from .base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport from .grpc import TranscoderServiceGrpcTransport +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.transcoder.v1.TranscoderService", + "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.transcoder.v1.TranscoderService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TranscoderServiceGrpcAsyncIOTransport(TranscoderServiceTransport): """gRPC AsyncIO backend transport for TranscoderService. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJob", request_serializer=services.CreateJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -294,7 +379,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobs", request_serializer=services.ListJobsRequest.serialize, response_deserializer=services.ListJobsResponse.deserialize, @@ -318,7 +403,7 @@ def get_job(self) -> Callable[[services.GetJobRequest], Awaitable[resources.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJob", request_serializer=services.GetJobRequest.serialize, response_deserializer=resources.Job.deserialize, @@ -344,7 +429,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJob", request_serializer=services.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -372,7 +457,7 @@ def create_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job_template" not in self._stubs: - self._stubs["create_job_template"] = self.grpc_channel.unary_unary( + self._stubs["create_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/CreateJobTemplate", request_serializer=services.CreateJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -400,7 +485,7 @@ def list_job_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_job_templates" not in self._stubs: - self._stubs["list_job_templates"] = self.grpc_channel.unary_unary( + self._stubs["list_job_templates"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/ListJobTemplates", request_serializer=services.ListJobTemplatesRequest.serialize, response_deserializer=services.ListJobTemplatesResponse.deserialize, @@ -426,7 +511,7 @@ def get_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job_template" not in self._stubs: - self._stubs["get_job_template"] = self.grpc_channel.unary_unary( + self._stubs["get_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/GetJobTemplate", request_serializer=services.GetJobTemplateRequest.serialize, response_deserializer=resources.JobTemplate.deserialize, @@ -452,7 +537,7 @@ def delete_job_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job_template" not in self._stubs: - self._stubs["delete_job_template"] = self.grpc_channel.unary_unary( + self._stubs["delete_job_template"] = self._logged_channel.unary_unary( "/google.cloud.video.transcoder.v1.TranscoderService/DeleteJobTemplate", request_serializer=services.DeleteJobTemplateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -510,7 +595,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py index 1faac6128d09..0076df3c6aee 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -124,8 +132,10 @@ def post_list_job_templates(self, response): """ def pre_create_job( - self, request: services.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -145,8 +155,10 @@ def post_create_job(self, response: resources.Job) -> resources.Job: def pre_create_job_template( self, request: services.CreateJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.CreateJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.CreateJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_job_template Override in a subclass to manipulate the request or metadata @@ -166,8 +178,10 @@ def post_create_job_template( return response def pre_delete_job( - self, request: services.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -178,8 +192,10 @@ def pre_delete_job( def pre_delete_job_template( self, request: services.DeleteJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.DeleteJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.DeleteJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_job_template Override in a subclass to manipulate the request or metadata @@ -188,8 +204,10 @@ def pre_delete_job_template( return request, metadata def pre_get_job( - self, request: services.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: services.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -209,8 +227,8 @@ def post_get_job(self, response: resources.Job) -> resources.Job: def pre_get_job_template( self, request: services.GetJobTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.GetJobTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.GetJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job_template Override in a subclass to manipulate the request or metadata @@ -230,8 +248,10 @@ def post_get_job_template( return response def pre_list_jobs( - self, request: services.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[services.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: services.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[services.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -253,8 +273,10 @@ def post_list_jobs( def pre_list_job_templates( self, request: services.ListJobTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[services.ListJobTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + services.ListJobTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_job_templates Override in a subclass to manipulate the request or metadata @@ -401,7 +423,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Call the create job method over HTTP. @@ -411,8 +433,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Job: @@ -422,6 +446,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseCreateJob._get_transcoded_request( http_options, request @@ -436,6 +461,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._CreateJob._get_response( self._host, @@ -457,7 +509,29 @@ def __call__( pb_resp = resources.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Job.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.transcoder_v1.TranscoderServiceClient.create_job", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateJobTemplate( @@ -496,7 +570,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Call the create job template method over HTTP. @@ -507,8 +581,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.JobTemplate: @@ -518,6 +594,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_create_job_template( request, metadata ) @@ -534,6 +611,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.CreateJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._CreateJobTemplate._get_response( self._host, @@ -555,7 +659,29 @@ def __call__( pb_resp = resources.JobTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.JobTemplate.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.transcoder_v1.TranscoderServiceClient.create_job_template", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "CreateJobTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -592,7 +718,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job method over HTTP. @@ -602,13 +728,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_transcoded_request( http_options, request @@ -619,6 +748,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._DeleteJob._get_response( self._host, @@ -669,7 +825,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job template method over HTTP. @@ -680,13 +836,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job_template( request, metadata ) @@ -699,6 +858,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.DeleteJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "DeleteJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._DeleteJobTemplate._get_response( self._host, @@ -748,7 +934,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Job: r"""Call the get job method over HTTP. @@ -758,8 +944,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Job: @@ -769,6 +957,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseTranscoderServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -783,6 +972,33 @@ def __call__( ) ) + 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.transcoder_v1.TranscoderServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._GetJob._get_response( self._host, @@ -803,7 +1019,29 @@ def __call__( pb_resp = resources.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Job.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.transcoder_v1.TranscoderServiceClient.get_job", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetJobTemplate( @@ -841,7 +1079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.JobTemplate: r"""Call the get job template method over HTTP. @@ -852,8 +1090,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.JobTemplate: @@ -863,6 +1103,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseGetJobTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_get_job_template( request, metadata ) @@ -875,6 +1116,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.GetJobTemplate", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJobTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._GetJobTemplate._get_response( self._host, @@ -895,7 +1163,29 @@ def __call__( pb_resp = resources.JobTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.JobTemplate.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.transcoder_v1.TranscoderServiceClient.get_job_template", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "GetJobTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs( @@ -932,7 +1222,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> services.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -944,8 +1234,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.services.ListJobsResponse: @@ -955,6 +1247,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = _BaseTranscoderServiceRestTransport._BaseListJobs._get_transcoded_request( http_options, request @@ -965,6 +1258,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._ListJobs._get_response( self._host, @@ -985,7 +1305,29 @@ def __call__( pb_resp = services.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = services.ListJobsResponse.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.transcoder_v1.TranscoderServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobTemplates( @@ -1023,7 +1365,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> services.ListJobTemplatesResponse: r"""Call the list job templates method over HTTP. @@ -1034,8 +1376,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.services.ListJobTemplatesResponse: @@ -1047,6 +1391,7 @@ def __call__( http_options = ( _BaseTranscoderServiceRestTransport._BaseListJobTemplates._get_http_options() ) + request, metadata = self._interceptor.pre_list_job_templates( request, metadata ) @@ -1059,6 +1404,33 @@ def __call__( 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.transcoder_v1.TranscoderServiceClient.ListJobTemplates", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobTemplates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TranscoderServiceRestTransport._ListJobTemplates._get_response( self._host, @@ -1079,7 +1451,31 @@ def __call__( pb_resp = services.ListJobTemplatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_job_templates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = services.ListJobTemplatesResponse.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.transcoder_v1.TranscoderServiceClient.list_job_templates", + extra={ + "serviceName": "google.cloud.video.transcoder.v1.TranscoderService", + "rpcName": "ListJobTemplates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json index 093471c2ce59..5c4b962d53e7 100644 --- a/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-video-transcoder", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job_template" @@ -470,7 +470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job_template" @@ -548,7 +548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -625,7 +625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -783,7 +783,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", @@ -864,7 +864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -944,7 +944,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.types.Job", @@ -1025,7 +1025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager", @@ -1105,7 +1105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager", @@ -1186,7 +1186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsAsyncPager", @@ -1266,7 +1266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager", diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py index 959619ef021d..5022a6c73302 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py @@ -4309,6 +4309,7 @@ def test_create_job_rest_required_fields(request_type=services.CreateJobRequest) response_value._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_job(request) @@ -4363,6 +4364,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4501,6 +4503,7 @@ def test_list_jobs_rest_required_fields(request_type=services.ListJobsRequest): response_value._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_jobs(request) @@ -4556,6 +4559,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -4745,6 +4749,7 @@ def test_get_job_rest_required_fields(request_type=services.GetJobRequest): response_value._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_job(request) @@ -4790,6 +4795,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4917,6 +4923,7 @@ def test_delete_job_rest_required_fields(request_type=services.DeleteJobRequest) response_value._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_job(request) @@ -4960,6 +4967,7 @@ def test_delete_job_rest_flattened(): 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"} client.delete_job(**mock_args) @@ -5104,6 +5112,7 @@ def test_create_job_template_rest_required_fields( response_value._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_job_template(request) @@ -5166,6 +5175,7 @@ def test_create_job_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job_template(**mock_args) @@ -5312,6 +5322,7 @@ def test_list_job_templates_rest_required_fields( response_value._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_job_templates(request) @@ -5367,6 +5378,7 @@ def test_list_job_templates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job_templates(**mock_args) @@ -5561,6 +5573,7 @@ def test_get_job_template_rest_required_fields( response_value._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_job_template(request) @@ -5608,6 +5621,7 @@ def test_get_job_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job_template(**mock_args) @@ -5742,6 +5756,7 @@ def test_delete_job_template_rest_required_fields( response_value._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_job_template(request) @@ -5787,6 +5802,7 @@ def test_delete_job_template_rest_flattened(): 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"} client.delete_job_template(**mock_args) @@ -6366,6 +6382,7 @@ def test_create_job_rest_bad_request(request_type=services.CreateJobRequest): 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_job(request) @@ -6728,6 +6745,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6773,6 +6791,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 = resources.Job.to_json(resources.Job()) req.return_value.content = return_value @@ -6815,6 +6834,7 @@ def test_list_jobs_rest_bad_request(request_type=services.ListJobsRequest): 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_jobs(request) @@ -6851,6 +6871,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -6890,6 +6911,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = services.ListJobsResponse.to_json(services.ListJobsResponse()) req.return_value.content = return_value @@ -6932,6 +6954,7 @@ def test_get_job_rest_bad_request(request_type=services.GetJobRequest): 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_job(request) @@ -6975,6 +6998,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7020,6 +7044,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = resources.Job.to_json(resources.Job()) req.return_value.content = return_value @@ -7062,6 +7087,7 @@ def test_delete_job_rest_bad_request(request_type=services.DeleteJobRequest): 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_job(request) @@ -7092,6 +7118,7 @@ def test_delete_job_rest_call_success(request_type): 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_job(request) # Establish that the response is the type that we expect. @@ -7126,6 +7153,7 @@ def test_delete_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = services.DeleteJobRequest() metadata = [ @@ -7166,6 +7194,7 @@ def test_create_job_template_rest_bad_request( 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_job_template(request) @@ -7499,6 +7528,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job_template(request) # Establish that the response is the type that we expect. @@ -7539,6 +7569,7 @@ def test_create_job_template_rest_interceptors(null_interceptor): 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 = resources.JobTemplate.to_json(resources.JobTemplate()) req.return_value.content = return_value @@ -7583,6 +7614,7 @@ def test_list_job_templates_rest_bad_request( 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_job_templates(request) @@ -7619,6 +7651,7 @@ def test_list_job_templates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job_templates(request) # Establish that the response is the type that we expect. @@ -7660,6 +7693,7 @@ def test_list_job_templates_rest_interceptors(null_interceptor): 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 = services.ListJobTemplatesResponse.to_json( services.ListJobTemplatesResponse() ) @@ -7704,6 +7738,7 @@ def test_get_job_template_rest_bad_request(request_type=services.GetJobTemplateR 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_job_template(request) @@ -7739,6 +7774,7 @@ def test_get_job_template_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job_template(request) # Establish that the response is the type that we expect. @@ -7777,6 +7813,7 @@ def test_get_job_template_rest_interceptors(null_interceptor): 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 = resources.JobTemplate.to_json(resources.JobTemplate()) req.return_value.content = return_value @@ -7821,6 +7858,7 @@ def test_delete_job_template_rest_bad_request( 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_job_template(request) @@ -7851,6 +7889,7 @@ def test_delete_job_template_rest_call_success(request_type): 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_job_template(request) # Establish that the response is the type that we expect. @@ -7887,6 +7926,7 @@ def test_delete_job_template_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = services.DeleteJobTemplateRequest() metadata = [ diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py index 7c2aea04f1cb..7032b3ae25b8 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +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 VideoIntelligenceServiceAsyncClient: """Service that implements the Video Intelligence API.""" @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py index 2b93cb9adc53..b3e545349294 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -566,6 +576,10 @@ def __init__( # 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( @@ -632,6 +646,29 @@ def __init__( 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.videointelligence_v1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py index 7f9e8a54c275..a11e09feb562 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +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.videointelligence.v1.VideoIntelligenceService", + "rpcName": 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.videointelligence.v1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py index 95035f260faf..1d3be6b13e40 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +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.videointelligence.v1.VideoIntelligenceService", + "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.videointelligence.v1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py index 05fd2cc8f0a1..e72c2ce9bf35 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1/services/video_intelligence_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( 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.videointelligence_v1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(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.videointelligence_v1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py index a34e91042374..b70c707a4cc3 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1beta2.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py index 14b362c629ca..57dff58c1232 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -566,6 +576,10 @@ def __init__( # 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( @@ -632,6 +646,29 @@ def __init__( 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.videointelligence_v1beta2.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py index ab5f1eaa03ec..d391b5d6d1f3 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1beta2.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +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.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": 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.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1beta2.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py index 6097f85f192b..cc9858d48c61 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1beta2.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +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.videointelligence.v1beta2.VideoIntelligenceService", + "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.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1beta2.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py index dfd0783333af..ecfec18ca101 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1beta2/services/video_intelligence_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( 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.videointelligence_v1beta2.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(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.videointelligence_v1beta2.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1beta2.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py index b5a88c366ffd..c924363a5545 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1p1beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py index a46a045ac051..c41f9af5be61 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -566,6 +576,10 @@ def __init__( # 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( @@ -632,6 +646,29 @@ def __init__( 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.videointelligence_v1p1beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py index 5de0f73002c8..bb9bb0d048d7 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p1beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +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.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": 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.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py index 9ddfda34e2bf..38bb47960533 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p1beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +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.videointelligence.v1p1beta1.VideoIntelligenceService", + "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.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py index 9d690d5afce8..473bbebeb681 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p1beta1/services/video_intelligence_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( 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.videointelligence_v1p1beta1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(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.videointelligence_v1p1beta1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py index d3bf9c203da8..fa81290fee29 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +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 VideoIntelligenceServiceAsyncClient: """Service that implements Google Cloud Video Intelligence API.""" @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1p2beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py index 95bac44c8cba..067889ada479 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -566,6 +576,10 @@ def __init__( # 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( @@ -632,6 +646,29 @@ def __init__( 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.videointelligence_v1p2beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -640,7 +677,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -710,8 +747,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py index fcf763638e1e..9d73373d3566 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p2beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +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.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": 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.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py index 5119cccaae32..f01a380f2207 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p2beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +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.videointelligence.v1p2beta1.VideoIntelligenceService", + "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.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py index 3690efd18d20..18ee902a0f73 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p2beta1/services/video_intelligence_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_annotate_video(self, response): def pre_annotate_video( self, request: video_intelligence.AnnotateVideoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_intelligence.AnnotateVideoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for annotate_video Override in a subclass to manipulate the request or metadata @@ -287,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the annotate video method over HTTP. @@ -297,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -311,6 +323,7 @@ def __call__( http_options = ( _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_http_options() ) + request, metadata = self._interceptor.pre_annotate_video(request, metadata) transcoded_request = _BaseVideoIntelligenceServiceRestTransport._BaseAnnotateVideo._get_transcoded_request( http_options, request @@ -325,6 +338,33 @@ def __call__( 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.videointelligence_v1p2beta1.VideoIntelligenceServiceClient.AnnotateVideo", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VideoIntelligenceServiceRestTransport._AnnotateVideo._get_response( @@ -346,7 +386,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_annotate_video(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.videointelligence_v1p2beta1.VideoIntelligenceServiceClient.annotate_video", + extra={ + "serviceName": "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService", + "rpcName": "AnnotateVideo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py index 954fef29f5d3..dd0ac9794b00 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -58,6 +59,15 @@ StreamingVideoIntelligenceServiceGrpcAsyncIOTransport, ) +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 StreamingVideoIntelligenceServiceAsyncClient: """Service that implements streaming Video Intelligence API.""" @@ -275,6 +285,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1p3beta1.StreamingVideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "credentialsType": None, + }, + ) + def streaming_annotate_video( self, requests: Optional[ @@ -283,7 +315,7 @@ def streaming_annotate_video( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[video_intelligence.StreamingAnnotateVideoResponse]]: r"""Performs video annotation with bidirectional streaming: emitting results while sending video/audio @@ -337,8 +369,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py index 73616a417b7b..854840dace8e 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.rpc import status_pb2 # type: ignore from google.cloud.videointelligence_v1p3beta1.types import video_intelligence @@ -576,6 +586,10 @@ def __init__( # 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( @@ -648,6 +662,29 @@ def __init__( 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.videointelligence_v1p3beta1.StreamingVideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "credentialsType": None, + }, + ) + def streaming_annotate_video( self, requests: Optional[ @@ -656,7 +693,7 @@ def streaming_annotate_video( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[video_intelligence.StreamingAnnotateVideoResponse]: r"""Performs video annotation with bidirectional streaming: emitting results while sending video/audio @@ -710,8 +747,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py index 9ef7433f7a28..78fa164e0e6c 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, StreamingVideoIntelligenceServiceTransport +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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "rpcName": 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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingVideoIntelligenceServiceGrpcTransport( StreamingVideoIntelligenceServiceTransport @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,9 @@ def streaming_annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_annotate_video" not in self._stubs: - self._stubs["streaming_annotate_video"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_annotate_video" + ] = self._logged_channel.stream_stream( "/google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService/StreamingAnnotateVideo", request_serializer=video_intelligence.StreamingAnnotateVideoRequest.serialize, response_deserializer=video_intelligence.StreamingAnnotateVideoResponse.deserialize, @@ -269,7 +357,7 @@ def streaming_annotate_video( return self._stubs["streaming_annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py index 5b4e00989830..07d0c3ecbf24 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/streaming_video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, StreamingVideoIntelligenceServiceTransport from .grpc import StreamingVideoIntelligenceServiceGrpcTransport +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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "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.videointelligence.v1p3beta1.StreamingVideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingVideoIntelligenceServiceGrpcAsyncIOTransport( StreamingVideoIntelligenceServiceTransport @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,9 @@ def streaming_annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_annotate_video" not in self._stubs: - self._stubs["streaming_annotate_video"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_annotate_video" + ] = self._logged_channel.stream_stream( "/google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceService/StreamingAnnotateVideo", request_serializer=video_intelligence.StreamingAnnotateVideoRequest.serialize, response_deserializer=video_intelligence.StreamingAnnotateVideoResponse.deserialize, @@ -302,7 +389,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py index 002f73484ccb..8d4555b51335 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .transports.grpc_asyncio import VideoIntelligenceServiceGrpcAsyncIOTransport +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 VideoIntelligenceServiceAsyncClient: """Service that implements the Video Intelligence API.""" @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.videointelligence_v1p3beta1.VideoIntelligenceServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + async def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -272,7 +304,7 @@ async def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -342,8 +374,10 @@ async def sample_annotate_video(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py index 8224567a519b..c67589a85a2c 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -564,6 +574,10 @@ def __init__( # 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( @@ -630,6 +644,29 @@ def __init__( 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.videointelligence_v1p3beta1.VideoIntelligenceServiceClient`.", + extra={ + "serviceName": "google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "credentialsType": None, + }, + ) + def annotate_video( self, request: Optional[Union[video_intelligence.AnnotateVideoRequest, dict]] = None, @@ -638,7 +675,7 @@ def annotate_video( features: Optional[MutableSequence[video_intelligence.Feature]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` @@ -708,8 +745,10 @@ def sample_annotate_video(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py index 1c772bb4b634..f5b7be999d7a 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport +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.videointelligence.v1p3beta1.VideoIntelligenceService", + "rpcName": 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.videointelligence.v1p3beta1.VideoIntelligenceService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcTransport(VideoIntelligenceServiceTransport): """gRPC backend transport for VideoIntelligenceService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -281,7 +369,7 @@ def annotate_video( return self._stubs["annotate_video"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py index a12e77d64aea..81eddfd672dd 100644 --- a/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-videointelligence/google/cloud/videointelligence_v1p3beta1/services/video_intelligence_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.videointelligence_v1p3beta1.types import video_intelligence from .base import DEFAULT_CLIENT_INFO, VideoIntelligenceServiceTransport from .grpc import VideoIntelligenceServiceGrpcTransport +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.videointelligence.v1p3beta1.VideoIntelligenceService", + "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.videointelligence.v1p3beta1.VideoIntelligenceService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VideoIntelligenceServiceGrpcAsyncIOTransport(VideoIntelligenceServiceTransport): """gRPC AsyncIO backend transport for VideoIntelligenceService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def annotate_video( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_video" not in self._stubs: - self._stubs["annotate_video"] = self.grpc_channel.unary_unary( + self._stubs["annotate_video"] = self._logged_channel.unary_unary( "/google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService/AnnotateVideo", request_serializer=video_intelligence.AnnotateVideoRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +403,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json index 1737a6d46ac6..e198e62e8a23 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json index b5dc9f4a37e0..3f3ec25e9b73 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json index be02fff47af4..99531c7a7090 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json index b995488fce46..5fad06591e51 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json index 5a911d4aef3f..b409a29f032a 100644 --- a/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json +++ b/packages/google-cloud-videointelligence/samples/generated_samples/snippet_metadata_google.cloud.videointelligence.v1p3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-videointelligence", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.videointelligence_v1p3beta1.types.StreamingAnnotateVideoResponse]", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py index 4c67b5e35250..abe1746b3ca4 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._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.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( 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.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py index 905fb61e115b..326527bea4a5 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1beta2/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._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.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( 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.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py index 77057a7c6aa3..ed326cef6887 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p1beta1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._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.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( 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.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py index cb8325fc463d..1c49e3264c22 100644 --- a/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py +++ b/packages/google-cloud-videointelligence/tests/unit/gapic/videointelligence_v1p2beta1/test_video_intelligence_service.py @@ -1520,6 +1520,7 @@ def test_annotate_video_rest_required_fields( response_value._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.annotate_video(request) @@ -1564,6 +1565,7 @@ def test_annotate_video_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.annotate_video(**mock_args) @@ -1786,6 +1788,7 @@ def test_annotate_video_rest_bad_request( 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.annotate_video(request) @@ -1816,6 +1819,7 @@ def test_annotate_video_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.annotate_video(request) # Establish that the response is the type that we expect. @@ -1857,6 +1861,7 @@ def test_annotate_video_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-vision/google/cloud/vision/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py index 7977f25d0c15..300f4cce72b5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -263,6 +273,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -274,7 +306,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -318,8 +350,10 @@ async def sample_batch_annotate_images(): 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, 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: google.cloud.vision_v1.types.BatchAnnotateImagesResponse: @@ -376,7 +410,7 @@ async def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -429,8 +463,10 @@ async def sample_batch_annotate_files(): 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, 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: google.cloud.vision_v1.types.BatchAnnotateFilesResponse: @@ -488,7 +524,7 @@ async def async_batch_annotate_images( output_config: Optional[image_annotator.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run asynchronous image detection and annotation for a list of images. @@ -553,8 +589,10 @@ async def sample_async_batch_annotate_images(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -626,7 +664,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -680,8 +718,10 @@ async def sample_async_batch_annotate_files(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -746,7 +786,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -757,8 +797,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py index 8a91bfc7a82a..d6412d5acdb5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -609,6 +619,10 @@ def __init__( # 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( @@ -674,6 +688,29 @@ def __init__( 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.vision_v1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -685,7 +722,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -729,8 +766,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.BatchAnnotateImagesResponse: @@ -784,7 +823,7 @@ def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -837,8 +876,10 @@ def sample_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.BatchAnnotateFilesResponse: @@ -893,7 +934,7 @@ def async_batch_annotate_images( output_config: Optional[image_annotator.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run asynchronous image detection and annotation for a list of images. @@ -958,8 +999,10 @@ def sample_async_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1030,7 +1073,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -1084,8 +1127,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1162,7 +1207,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1173,8 +1218,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py index 4d2627563cc7..787d3832ccbb 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +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.vision.v1.ImageAnnotator", + "rpcName": 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.vision.v1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -313,7 +401,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -352,7 +440,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +476,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +486,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -406,7 +498,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py index ab225ab52338..e937b2d873c4 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +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.vision.v1.ImageAnnotator", + "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.vision.v1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -323,7 +408,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -363,7 +448,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +485,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -481,7 +570,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -497,7 +586,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py index 49fa4a5aced3..cf7fb6976885 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -102,9 +110,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -127,9 +136,10 @@ def post_async_batch_annotate_files( def pre_async_batch_annotate_images( self, request: image_annotator.AsyncBatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateImagesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_images @@ -152,8 +162,11 @@ def post_async_batch_annotate_images( def pre_batch_annotate_files( self, request: image_annotator.BatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_files Override in a subclass to manipulate the request or metadata @@ -175,8 +188,11 @@ def post_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -198,8 +214,10 @@ def post_batch_annotate_images( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -391,7 +409,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -404,8 +422,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -418,6 +438,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -434,6 +455,33 @@ def __call__( 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.vision_v1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -455,7 +503,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(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.vision_v1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AsyncBatchAnnotateImages( @@ -494,7 +564,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate images method over HTTP. @@ -506,8 +576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -520,6 +592,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_images( request, metadata ) @@ -536,6 +609,33 @@ def __call__( 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.vision_v1.ImageAnnotatorClient.AsyncBatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateImages._get_response( @@ -557,7 +657,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_images(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.vision_v1.ImageAnnotatorClient.async_batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateFiles( @@ -595,7 +717,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Call the batch annotate files method over HTTP. @@ -606,8 +728,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateFilesResponse: @@ -617,6 +741,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_files( request, metadata ) @@ -633,6 +758,33 @@ def __call__( 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.vision_v1.ImageAnnotatorClient.BatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateFiles._get_response( self._host, @@ -654,7 +806,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateFilesResponse.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.vision_v1.ImageAnnotatorClient.batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -693,7 +869,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -704,8 +880,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -717,6 +895,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -733,6 +912,33 @@ def __call__( 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.vision_v1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -754,7 +960,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.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.vision_v1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -837,7 +1067,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -847,8 +1077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -857,6 +1089,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseImageAnnotatorRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -867,6 +1100,33 @@ def __call__( 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.vision_v1.ImageAnnotatorClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._GetOperation._get_response( self._host, @@ -886,6 +1146,27 @@ def __call__( 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.vision_v1.ImageAnnotatorAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ImageAnnotator", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py index ac11eaeaccd7..bc271d167944 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -286,6 +296,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -362,8 +394,10 @@ async def sample_create_product_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, 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: google.cloud.vision_v1.types.ProductSet: @@ -433,7 +467,7 @@ async def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -484,8 +518,10 @@ async def sample_list_product_sets(): 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, 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: google.cloud.vision_v1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -561,7 +597,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -610,8 +646,10 @@ async def sample_get_product_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, 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: google.cloud.vision_v1.types.ProductSet: @@ -678,7 +716,7 @@ async def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -737,8 +775,10 @@ async def sample_update_product_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, 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: google.cloud.vision_v1.types.ProductSet: @@ -808,7 +848,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -854,8 +894,10 @@ async def sample_delete_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -911,7 +953,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -980,8 +1022,10 @@ async def sample_create_product(): 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, 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: google.cloud.vision_v1.types.Product: @@ -1046,7 +1090,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Lists products in an unspecified order. @@ -1097,8 +1141,10 @@ async def sample_list_products(): 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, 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: google.cloud.vision_v1.services.product_search.pagers.ListProductsAsyncPager: @@ -1172,7 +1218,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1221,8 +1267,10 @@ async def sample_get_product(): 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, 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: google.cloud.vision_v1.types.Product: @@ -1284,7 +1332,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1352,8 +1400,10 @@ async def sample_update_product(): 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, 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: google.cloud.vision_v1.types.Product: @@ -1418,7 +1468,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1465,8 +1515,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1522,7 +1574,7 @@ async def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1611,8 +1663,10 @@ async def sample_create_reference_image(): 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, 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: google.cloud.vision_v1.types.ReferenceImage: @@ -1679,7 +1733,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -1729,8 +1783,10 @@ async def sample_delete_reference_image(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1784,7 +1840,7 @@ async def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1837,8 +1893,10 @@ async def sample_list_reference_images(): 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, 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: google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1914,7 +1972,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1964,8 +2022,10 @@ async def sample_get_reference_image(): 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, 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: google.cloud.vision_v1.types.ReferenceImage: @@ -2029,7 +2089,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2092,8 +2152,10 @@ async def sample_add_product_to_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2152,7 +2214,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2207,8 +2269,10 @@ async def sample_remove_product_from_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2266,7 +2330,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2321,8 +2385,10 @@ async def sample_list_products_in_product_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, 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: google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2404,7 +2470,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2471,8 +2537,10 @@ async def sample_import_product_sets(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2554,7 +2622,7 @@ async def purge_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -2629,8 +2697,10 @@ async def sample_purge_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2708,7 +2778,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2719,8 +2789,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py index e1a95284428f..030b357a857c 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -650,6 +660,10 @@ def __init__( # 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( @@ -715,6 +729,29 @@ def __init__( 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.vision_v1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -726,7 +763,7 @@ def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -791,8 +828,10 @@ def sample_create_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.ProductSet: @@ -859,7 +898,7 @@ def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -910,8 +949,10 @@ def sample_list_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.services.product_search.pagers.ListProductSetsPager: @@ -984,7 +1025,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1033,8 +1074,10 @@ def sample_get_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.ProductSet: @@ -1098,7 +1141,7 @@ def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1157,8 +1200,10 @@ def sample_update_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.ProductSet: @@ -1225,7 +1270,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -1271,8 +1316,10 @@ def sample_delete_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1325,7 +1372,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1394,8 +1441,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.Product: @@ -1457,7 +1506,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Lists products in an unspecified order. @@ -1508,8 +1557,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.services.product_search.pagers.ListProductsPager: @@ -1580,7 +1631,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1629,8 +1680,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.Product: @@ -1689,7 +1742,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1757,8 +1810,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.Product: @@ -1820,7 +1875,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1867,8 +1922,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1921,7 +1978,7 @@ def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2010,8 +2067,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.ReferenceImage: @@ -2075,7 +2134,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -2125,8 +2184,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2177,7 +2238,7 @@ def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesPager: r"""Lists reference images. @@ -2230,8 +2291,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesPager: @@ -2304,7 +2367,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2354,8 +2417,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.types.ReferenceImage: @@ -2416,7 +2481,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2479,8 +2544,10 @@ def sample_add_product_to_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2538,7 +2605,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2593,8 +2660,10 @@ def sample_remove_product_from_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2651,7 +2720,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2706,8 +2775,10 @@ def sample_list_products_in_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2788,7 +2859,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2855,8 +2926,10 @@ def sample_import_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2935,7 +3008,7 @@ def purge_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -3010,8 +3083,10 @@ def sample_purge_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3099,7 +3174,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3110,8 +3185,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py index bd49207fa3a0..7809b963ea70 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -465,8 +475,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -623,8 +637,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py index b96d939d95db..84b7d7b314f9 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +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.vision.v1.ProductSearch", + "rpcName": 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.vision.v1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -199,7 +280,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -295,7 +383,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -329,7 +417,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -361,7 +449,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -398,7 +486,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -428,7 +516,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -465,7 +553,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -499,7 +587,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -531,7 +619,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -574,7 +662,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -605,7 +693,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -655,7 +743,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -690,7 +778,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -725,7 +813,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -758,7 +846,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -794,7 +882,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -825,7 +915,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -861,7 +951,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -900,7 +992,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -954,7 +1046,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -962,7 +1054,7 @@ def purge_products( return self._stubs["purge_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -974,7 +1066,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py index 8cf21332e609..3cb26f4ff0a2 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +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.vision.v1.ProductSearch", + "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.vision.v1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -246,10 +328,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +357,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -305,7 +390,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -339,7 +424,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -372,7 +457,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -409,7 +494,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -441,7 +526,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -479,7 +564,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -513,7 +598,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -546,7 +631,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -590,7 +675,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -623,7 +708,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -673,7 +758,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -708,7 +793,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -743,7 +828,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -776,7 +861,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -813,7 +898,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -845,7 +932,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -881,7 +968,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -921,7 +1010,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -976,7 +1065,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1269,7 +1358,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1285,7 +1374,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py index a2d580b8b90b..743384dbd371 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1/services/product_search/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -203,9 +211,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -217,8 +226,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -240,9 +252,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -265,9 +278,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -290,8 +304,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -302,9 +319,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -316,9 +334,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -330,8 +349,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -353,8 +375,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -376,9 +401,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -401,9 +427,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -426,8 +453,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -449,9 +479,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -474,10 +505,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -500,9 +531,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -525,8 +557,11 @@ def post_list_reference_images( def pre_purge_products( self, request: product_search_service.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.PurgeProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -548,10 +583,10 @@ def post_purge_products( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -563,8 +598,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -586,9 +624,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -611,8 +650,10 @@ def post_update_product_set( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -818,7 +859,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the add product to product set method over HTTP. @@ -830,13 +871,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -853,6 +897,33 @@ def __call__( 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.vision_v1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -904,7 +975,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -914,8 +985,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -925,6 +998,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -939,6 +1013,33 @@ def __call__( 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.vision_v1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -960,7 +1061,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -998,7 +1121,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -1008,8 +1131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -1024,6 +1149,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -1040,6 +1166,33 @@ def __call__( 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.vision_v1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -1061,7 +1214,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1099,7 +1276,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1109,8 +1286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1122,6 +1301,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1138,6 +1318,33 @@ def __call__( 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.vision_v1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1159,7 +1366,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1196,7 +1427,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -1206,13 +1437,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1223,6 +1457,33 @@ def __call__( 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.vision_v1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1272,7 +1533,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product set method over HTTP. @@ -1282,13 +1543,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1301,6 +1565,33 @@ def __call__( 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.vision_v1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1350,7 +1641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete reference image method over HTTP. @@ -1360,13 +1651,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1379,6 +1673,33 @@ def __call__( 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.vision_v1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1428,7 +1749,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1438,8 +1759,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -1449,6 +1772,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1463,6 +1787,33 @@ def __call__( ) ) + 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.vision_v1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1483,7 +1834,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1520,7 +1893,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1530,8 +1903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -1546,6 +1921,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1556,6 +1932,33 @@ def __call__( 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.vision_v1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1576,7 +1979,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1613,7 +2040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1623,8 +2050,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1636,6 +2065,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1648,6 +2078,33 @@ def __call__( 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.vision_v1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1668,7 +2125,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1706,7 +2187,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import product sets method over HTTP. @@ -1716,8 +2197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1730,6 +2213,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1746,6 +2230,33 @@ def __call__( 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.vision_v1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1765,7 +2276,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_product_sets(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.vision_v1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1802,7 +2335,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1812,8 +2345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsResponse: @@ -1823,6 +2358,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1833,6 +2369,33 @@ def __call__( 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.vision_v1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1853,7 +2416,31 @@ def __call__( pb_resp = product_search_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsResponse.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.vision_v1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1890,7 +2477,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1900,8 +2487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductSetsResponse: @@ -1911,6 +2500,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1923,6 +2513,33 @@ def __call__( 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.vision_v1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1943,7 +2560,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.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.vision_v1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1981,7 +2622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1993,8 +2634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsInProductSetResponse: @@ -2006,6 +2649,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -2018,6 +2662,33 @@ def __call__( 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.vision_v1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -2040,7 +2711,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.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.vision_v1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2077,7 +2774,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2087,8 +2784,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListReferenceImagesResponse: @@ -2098,6 +2797,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2110,6 +2810,33 @@ def __call__( 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.vision_v1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2130,7 +2857,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.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.vision_v1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -2168,7 +2921,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -2178,8 +2931,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2192,6 +2947,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -2206,6 +2962,33 @@ def __call__( 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.vision_v1.ProductSearchClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._PurgeProducts._get_response( self._host, @@ -2225,7 +3008,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(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.vision_v1.ProductSearchClient.purge_products", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2264,7 +3069,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the remove product from product set method over HTTP. @@ -2276,13 +3081,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2299,6 +3107,33 @@ def __call__( 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.vision_v1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2352,7 +3187,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2362,8 +3197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -2373,6 +3210,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2387,6 +3225,33 @@ def __call__( 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.vision_v1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2408,7 +3273,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2446,7 +3333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2456,8 +3343,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -2472,6 +3361,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2488,6 +3378,33 @@ def __call__( 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.vision_v1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2509,7 +3426,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2744,7 +3685,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2754,8 +3695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2764,6 +3707,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2774,6 +3718,33 @@ def __call__( 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.vision_v1.ProductSearchClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetOperation._get_response( self._host, @@ -2793,6 +3764,27 @@ def __call__( 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.vision_v1.ProductSearchAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vision.v1.ProductSearch", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py index 42b13364b0f1..3e7fecb23cee 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p1beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -266,7 +298,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -310,8 +342,10 @@ async def sample_batch_annotate_images(): 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, 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: google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py index 81cb6c0891a7..a5722d3edd77 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.vision_v1p1beta1.types import image_annotator from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport @@ -559,6 +569,10 @@ def __init__( # 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( @@ -624,6 +638,29 @@ def __init__( 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.vision_v1p1beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -635,7 +672,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -679,8 +716,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py index 590b6b7f8042..ad00804e3880 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.vision_v1p1beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +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.vision.v1p1beta1.ImageAnnotator", + "rpcName": 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.vision.v1p1beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p1beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -268,7 +354,7 @@ def batch_annotate_images( return self._stubs["batch_annotate_images"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py index 25580ea2d0a1..0391fb740c62 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p1beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +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.vision.v1p1beta1.ImageAnnotator", + "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.vision.v1p1beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p1beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -301,7 +386,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py index edfcce45ff5e..3b0bd72d46c7 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p1beta1/services/image_annotator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,11 @@ def post_batch_annotate_images(self, response): def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -223,7 +234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -234,8 +245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -247,6 +260,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -263,6 +277,33 @@ def __call__( 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.vision_v1p1beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -284,7 +325,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.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.vision_v1p1beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p1beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py index e04a295b0b33..1d2cdf892ec1 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -258,6 +268,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p2beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -269,7 +301,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -313,8 +345,10 @@ async def sample_batch_annotate_images(): 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, 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: google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse: @@ -373,7 +407,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple @@ -427,8 +461,10 @@ async def sample_async_batch_annotate_files(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py index 93667ce3afb3..6aad5eff1b1f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -562,6 +572,10 @@ def __init__( # 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( @@ -627,6 +641,29 @@ def __init__( 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.vision_v1p2beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -638,7 +675,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -682,8 +719,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse: @@ -739,7 +778,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple @@ -793,8 +832,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py index ebbfce76c6aa..10fc99a14455 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1p2beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +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.vision.v1p2beta1.ImageAnnotator", + "rpcName": 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.vision.v1p2beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -310,7 +398,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +408,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py index 9ae33f599295..1ec4b8b92929 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p2beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +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.vision.v1p2beta1.ImageAnnotator", + "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.vision.v1p2beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -321,7 +406,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p2beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -369,7 +456,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py index c7fede3ba805..6787e920ee4f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p2beta1/services/image_annotator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,9 +94,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -111,8 +120,11 @@ def post_async_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -285,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -298,8 +310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -312,6 +326,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -328,6 +343,33 @@ def __call__( 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.vision_v1p2beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -349,7 +391,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(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.vision_v1p2beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -388,7 +452,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -399,8 +463,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -412,6 +478,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -428,6 +495,33 @@ def __call__( 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.vision_v1p2beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -449,7 +543,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.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.vision_v1p2beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p2beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py index a3f1d2d20e4d..a1b4562e1d75 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -262,6 +272,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p3beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -273,7 +305,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -317,8 +349,10 @@ async def sample_batch_annotate_images(): 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, 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: google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse: @@ -377,7 +411,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -431,8 +465,10 @@ async def sample_async_batch_annotate_files(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py index ea5864856ff6..ba7808116b46 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -608,6 +618,10 @@ def __init__( # 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( @@ -673,6 +687,29 @@ def __init__( 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.vision_v1p3beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -684,7 +721,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -728,8 +765,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse: @@ -785,7 +824,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -839,8 +878,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py index 54ecf833617a..12feeafc9404 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1p3beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +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.vision.v1p3beta1.ImageAnnotator", + "rpcName": 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.vision.v1p3beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -310,7 +398,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +408,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py index 355b5880f8c9..8d65c9b1655f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p3beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +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.vision.v1p3beta1.ImageAnnotator", + "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.vision.v1p3beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -321,7 +406,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -366,7 +453,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py index 2c870cbd94c0..893070a36e86 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/image_annotator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,9 +94,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -111,8 +120,11 @@ def post_async_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -285,7 +297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -298,8 +310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -312,6 +326,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -328,6 +343,33 @@ def __call__( 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.vision_v1p3beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -349,7 +391,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(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.vision_v1p3beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -388,7 +452,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -399,8 +463,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -412,6 +478,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -428,6 +495,33 @@ def __call__( 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.vision_v1p3beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -449,7 +543,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.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.vision_v1p3beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py index c89f89176a85..86bd928b665f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -286,6 +296,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p3beta1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -362,8 +394,10 @@ async def sample_create_product_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, 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -433,7 +467,7 @@ async def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -484,8 +518,10 @@ async def sample_list_product_sets(): 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, 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -561,7 +597,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -610,8 +646,10 @@ async def sample_get_product_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, 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -678,7 +716,7 @@ async def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -737,8 +775,10 @@ async def sample_update_product_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, 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -808,7 +848,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. @@ -858,8 +898,10 @@ async def sample_delete_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -915,7 +957,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -984,8 +1026,10 @@ async def sample_create_product(): 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, 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1050,7 +1094,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Lists products in an unspecified order. @@ -1101,8 +1145,10 @@ async def sample_list_products(): 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, 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsAsyncPager: @@ -1176,7 +1222,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1225,8 +1271,10 @@ async def sample_get_product(): 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, 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1288,7 +1336,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only display_name, description and labels can be updated right now. @@ -1356,8 +1404,10 @@ async def sample_update_product(): 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, 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1422,7 +1472,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1472,8 +1522,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1529,7 +1581,7 @@ async def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1618,8 +1670,10 @@ async def sample_create_reference_image(): 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, 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: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -1686,7 +1740,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -1741,8 +1795,10 @@ async def sample_delete_reference_image(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1796,7 +1852,7 @@ async def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1849,8 +1905,10 @@ async def sample_list_reference_images(): 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, 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1926,7 +1984,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1977,8 +2035,10 @@ async def sample_get_reference_image(): 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, 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: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2042,7 +2102,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2105,8 +2165,10 @@ async def sample_add_product_to_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2165,7 +2227,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2225,8 +2287,10 @@ async def sample_remove_product_from_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2284,7 +2348,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2339,8 +2403,10 @@ async def sample_list_products_in_product_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, 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2422,7 +2488,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2489,8 +2555,10 @@ async def sample_import_product_sets(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py index e637b3c4472c..b5881aa7b3de 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore @@ -650,6 +660,10 @@ def __init__( # 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( @@ -715,6 +729,29 @@ def __init__( 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.vision_v1p3beta1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -726,7 +763,7 @@ def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -791,8 +828,10 @@ def sample_create_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -859,7 +898,7 @@ def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -910,8 +949,10 @@ def sample_list_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsPager: @@ -984,7 +1025,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1033,8 +1074,10 @@ def sample_get_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -1098,7 +1141,7 @@ def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1157,8 +1200,10 @@ def sample_update_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.ProductSet: @@ -1225,7 +1270,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. @@ -1275,8 +1320,10 @@ def sample_delete_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1329,7 +1376,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1398,8 +1445,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1461,7 +1510,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Lists products in an unspecified order. @@ -1512,8 +1561,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsPager: @@ -1584,7 +1635,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1633,8 +1684,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1693,7 +1746,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only display_name, description and labels can be updated right now. @@ -1761,8 +1814,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.Product: @@ -1824,7 +1879,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1874,8 +1929,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1928,7 +1985,7 @@ def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2017,8 +2074,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2082,7 +2141,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -2137,8 +2196,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2189,7 +2250,7 @@ def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesPager: r"""Lists reference images. @@ -2242,8 +2303,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesPager: @@ -2316,7 +2379,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2367,8 +2430,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.types.ReferenceImage: @@ -2429,7 +2494,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2492,8 +2557,10 @@ def sample_add_product_to_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2551,7 +2618,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2611,8 +2678,10 @@ def sample_remove_product_from_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2669,7 +2738,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2724,8 +2793,10 @@ def sample_list_products_in_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2806,7 +2877,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2873,8 +2944,10 @@ def sample_import_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py index eec21adfcbbc..1b53dd1025b5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -465,8 +475,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -623,8 +637,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py index 8786d7073ea1..84a672dce485 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1p3beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +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.vision.v1p3beta1.ProductSearch", + "rpcName": 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.vision.v1p3beta1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -201,7 +282,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +351,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -297,7 +385,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -331,7 +419,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -363,7 +451,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -400,7 +488,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -434,7 +522,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -471,7 +559,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -505,7 +593,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -537,7 +625,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -580,7 +668,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -614,7 +702,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -664,7 +752,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -703,7 +791,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -738,7 +826,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -771,7 +859,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -807,7 +895,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -843,7 +933,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -879,7 +969,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -918,7 +1010,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -926,7 +1018,7 @@ def import_product_sets( return self._stubs["import_product_sets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py index b40242d5afd4..a55c851950ca 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p3beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +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.vision.v1p3beta1.ProductSearch", + "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.vision.v1p3beta1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -248,10 +330,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -307,7 +392,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -341,7 +426,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -374,7 +459,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -411,7 +496,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -447,7 +532,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -485,7 +570,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -519,7 +604,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -552,7 +637,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -596,7 +681,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -632,7 +717,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -682,7 +767,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -721,7 +806,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -756,7 +841,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -789,7 +874,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -826,7 +911,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -863,7 +950,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -899,7 +986,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -939,7 +1028,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p3beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1203,7 +1292,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py index ecff283c0049..33d4b036fdb0 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p3beta1/services/product_search/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -195,9 +203,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -209,8 +218,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -232,9 +244,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -257,9 +270,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -282,8 +296,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -294,9 +311,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -308,9 +326,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -322,8 +341,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -345,8 +367,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -368,9 +393,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -393,9 +419,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -418,8 +445,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -441,9 +471,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -466,10 +497,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -492,9 +523,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -517,10 +549,10 @@ def post_list_reference_images( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -532,8 +564,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -555,9 +590,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -747,7 +783,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the add product to product set method over HTTP. @@ -759,13 +795,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -782,6 +821,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -833,7 +899,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -843,8 +909,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -854,6 +922,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -868,6 +937,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -889,7 +985,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p3beta1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -927,7 +1045,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -937,8 +1055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -953,6 +1073,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -969,6 +1090,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -990,7 +1138,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p3beta1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1028,7 +1200,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1038,8 +1210,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1051,6 +1225,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1067,6 +1242,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1088,7 +1290,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1p3beta1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1125,7 +1351,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -1135,13 +1361,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1152,6 +1381,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1201,7 +1457,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product set method over HTTP. @@ -1211,13 +1467,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1230,6 +1489,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1279,7 +1565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete reference image method over HTTP. @@ -1289,13 +1575,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1308,6 +1597,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1357,7 +1673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1367,8 +1683,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -1378,6 +1696,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1392,6 +1711,33 @@ def __call__( ) ) + 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.vision_v1p3beta1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1412,7 +1758,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p3beta1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1449,7 +1817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1459,8 +1827,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -1475,6 +1845,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1485,6 +1856,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1505,7 +1903,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p3beta1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1542,7 +1964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1552,8 +1974,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1565,6 +1989,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1577,6 +2002,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1597,7 +2049,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1p3beta1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1635,7 +2111,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import product sets method over HTTP. @@ -1645,8 +2121,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1659,6 +2137,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1675,6 +2154,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1694,7 +2200,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_product_sets(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.vision_v1p3beta1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1731,7 +2259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1741,8 +2269,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsResponse: @@ -1752,6 +2282,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1762,6 +2293,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1782,7 +2340,31 @@ def __call__( pb_resp = product_search_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsResponse.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.vision_v1p3beta1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1819,7 +2401,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1829,8 +2411,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductSetsResponse: @@ -1840,6 +2424,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1852,6 +2437,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1872,7 +2484,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.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.vision_v1p3beta1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1910,7 +2546,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1922,8 +2558,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsInProductSetResponse: @@ -1935,6 +2573,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -1947,6 +2586,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -1969,7 +2635,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.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.vision_v1p3beta1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2006,7 +2698,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2016,8 +2708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListReferenceImagesResponse: @@ -2027,6 +2721,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2039,6 +2734,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2059,7 +2781,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.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.vision_v1p3beta1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2098,7 +2846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the remove product from product set method over HTTP. @@ -2110,13 +2858,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2133,6 +2884,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2186,7 +2964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2196,8 +2974,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -2207,6 +2987,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2221,6 +3002,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2242,7 +3050,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p3beta1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2280,7 +3110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2290,8 +3120,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -2306,6 +3138,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2322,6 +3155,33 @@ def __call__( 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.vision_v1p3beta1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2343,7 +3203,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p3beta1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p3beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py index e194ca38362b..558c8aab67c5 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py index 72df8a7df27f..86929de94d8e 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .transports.grpc_asyncio import ImageAnnotatorGrpcAsyncIOTransport +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 ImageAnnotatorAsyncClient: """Service that performs Google Cloud Vision API detection tasks @@ -262,6 +272,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p4beta1.ImageAnnotatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + async def batch_annotate_images( self, request: Optional[ @@ -273,7 +305,7 @@ async def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -317,8 +349,10 @@ async def sample_batch_annotate_images(): 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, 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: google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse: @@ -375,7 +409,7 @@ async def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -428,8 +462,10 @@ async def sample_batch_annotate_files(): 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, 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: google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse: @@ -487,7 +523,7 @@ async def async_batch_annotate_images( output_config: Optional[image_annotator.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run asynchronous image detection and annotation for a list of images. @@ -552,8 +588,10 @@ async def sample_async_batch_annotate_images(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -625,7 +663,7 @@ async def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -679,8 +717,10 @@ async def sample_async_batch_annotate_files(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py index c32c3e3889fa..d26392f790de 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 @@ -608,6 +618,10 @@ def __init__( # 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( @@ -673,6 +687,29 @@ def __init__( 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.vision_v1p4beta1.ImageAnnotatorClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "credentialsType": None, + }, + ) + def batch_annotate_images( self, request: Optional[ @@ -684,7 +721,7 @@ def batch_annotate_images( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Run image detection and annotation for a batch of images. @@ -728,8 +765,10 @@ def sample_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse: @@ -783,7 +822,7 @@ def batch_annotate_files( requests: Optional[MutableSequence[image_annotator.AnnotateFileRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Service that performs image detection and annotation for a batch of files. Now only "application/pdf", @@ -836,8 +875,10 @@ def sample_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse: @@ -892,7 +933,7 @@ def async_batch_annotate_images( output_config: Optional[image_annotator.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run asynchronous image detection and annotation for a list of images. @@ -957,8 +998,10 @@ def sample_async_batch_annotate_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1029,7 +1072,7 @@ def async_batch_annotate_files( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple @@ -1083,8 +1126,10 @@ def sample_async_batch_annotate_files(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py index 12437efda993..8684ac7c8674 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1p4beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport +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.vision.v1p4beta1.ImageAnnotator", + "rpcName": 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.vision.v1p4beta1.ImageAnnotator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcTransport(ImageAnnotatorTransport): """gRPC backend transport for ImageAnnotator. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -313,7 +401,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -352,7 +440,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +476,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +486,7 @@ def async_batch_annotate_files( return self._stubs["async_batch_annotate_files"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py index a51ad52ec0e6..7797ee1575f8 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p4beta1.types import image_annotator from .base import DEFAULT_CLIENT_INFO, ImageAnnotatorTransport from .grpc import ImageAnnotatorGrpcTransport +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.vision.v1p4beta1.ImageAnnotator", + "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.vision.v1p4beta1.ImageAnnotator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageAnnotatorGrpcAsyncIOTransport(ImageAnnotatorTransport): """gRPC AsyncIO backend transport for ImageAnnotator. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_images" not in self._stubs: - self._stubs["batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateImages", request_serializer=image_annotator.BatchAnnotateImagesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateImagesResponse.deserialize, @@ -323,7 +408,7 @@ def batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_annotate_files" not in self._stubs: - self._stubs["batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs["batch_annotate_files"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/BatchAnnotateFiles", request_serializer=image_annotator.BatchAnnotateFilesRequest.serialize, response_deserializer=image_annotator.BatchAnnotateFilesResponse.deserialize, @@ -363,7 +448,9 @@ def async_batch_annotate_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_images" not in self._stubs: - self._stubs["async_batch_annotate_images"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_images" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateImages", request_serializer=image_annotator.AsyncBatchAnnotateImagesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +485,9 @@ def async_batch_annotate_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "async_batch_annotate_files" not in self._stubs: - self._stubs["async_batch_annotate_files"] = self.grpc_channel.unary_unary( + self._stubs[ + "async_batch_annotate_files" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ImageAnnotator/AsyncBatchAnnotateFiles", request_serializer=image_annotator.AsyncBatchAnnotateFilesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -464,7 +553,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py index 657058388ad6..6c7b44849bc1 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/image_annotator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -102,9 +110,10 @@ def post_batch_annotate_images(self, response): def pre_async_batch_annotate_files( self, request: image_annotator.AsyncBatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateFilesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_files @@ -127,9 +136,10 @@ def post_async_batch_annotate_files( def pre_async_batch_annotate_images( self, request: image_annotator.AsyncBatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - image_annotator.AsyncBatchAnnotateImagesRequest, Sequence[Tuple[str, str]] + image_annotator.AsyncBatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for async_batch_annotate_images @@ -152,8 +162,11 @@ def post_async_batch_annotate_images( def pre_batch_annotate_files( self, request: image_annotator.BatchAnnotateFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateFilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_files Override in a subclass to manipulate the request or metadata @@ -175,8 +188,11 @@ def post_batch_annotate_files( def pre_batch_annotate_images( self, request: image_annotator.BatchAnnotateImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_annotator.BatchAnnotateImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_annotator.BatchAnnotateImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_annotate_images Override in a subclass to manipulate the request or metadata @@ -349,7 +365,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate files method over HTTP. @@ -362,8 +378,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -376,6 +394,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_files( request, metadata ) @@ -392,6 +411,33 @@ def __call__( 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.vision_v1p4beta1.ImageAnnotatorClient.AsyncBatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateFiles._get_response( @@ -413,7 +459,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_files(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.vision_v1p4beta1.ImageAnnotatorClient.async_batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AsyncBatchAnnotateImages( @@ -452,7 +520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the async batch annotate images method over HTTP. @@ -464,8 +532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -478,6 +548,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseAsyncBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_async_batch_annotate_images( request, metadata ) @@ -494,6 +565,33 @@ def __call__( 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.vision_v1p4beta1.ImageAnnotatorClient.AsyncBatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ImageAnnotatorRestTransport._AsyncBatchAnnotateImages._get_response( @@ -515,7 +613,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_async_batch_annotate_images(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.vision_v1p4beta1.ImageAnnotatorClient.async_batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "AsyncBatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateFiles( @@ -553,7 +673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateFilesResponse: r"""Call the batch annotate files method over HTTP. @@ -564,8 +684,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateFilesResponse: @@ -575,6 +697,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateFiles._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_files( request, metadata ) @@ -591,6 +714,33 @@ def __call__( 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.vision_v1p4beta1.ImageAnnotatorClient.BatchAnnotateFiles", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateFiles._get_response( self._host, @@ -612,7 +762,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateFilesResponse.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.vision_v1p4beta1.ImageAnnotatorClient.batch_annotate_files", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchAnnotateImages( @@ -651,7 +825,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> image_annotator.BatchAnnotateImagesResponse: r"""Call the batch annotate images method over HTTP. @@ -662,8 +836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.image_annotator.BatchAnnotateImagesResponse: @@ -675,6 +851,7 @@ def __call__( http_options = ( _BaseImageAnnotatorRestTransport._BaseBatchAnnotateImages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_annotate_images( request, metadata ) @@ -691,6 +868,33 @@ def __call__( 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.vision_v1p4beta1.ImageAnnotatorClient.BatchAnnotateImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageAnnotatorRestTransport._BatchAnnotateImages._get_response( self._host, @@ -712,7 +916,31 @@ def __call__( pb_resp = image_annotator.BatchAnnotateImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_annotate_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + image_annotator.BatchAnnotateImagesResponse.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.vision_v1p4beta1.ImageAnnotatorClient.batch_annotate_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ImageAnnotator", + "rpcName": "BatchAnnotateImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py index 94d731dff25b..640fb1fdca6f 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .transports.grpc_asyncio import ProductSearchGrpcAsyncIOTransport +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 ProductSearchAsyncClient: """Manages Products and ProductSets of reference images for use in @@ -287,6 +297,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vision_v1p4beta1.ProductSearchAsyncClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "credentialsType": None, + }, + ) + async def create_product_set( self, request: Optional[ @@ -298,7 +330,7 @@ async def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -363,8 +395,10 @@ async def sample_create_product_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, 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -434,7 +468,7 @@ async def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsAsyncPager: r"""Lists ProductSets in an unspecified order. @@ -485,8 +519,10 @@ async def sample_list_product_sets(): 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, 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsAsyncPager: @@ -562,7 +598,7 @@ async def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -611,8 +647,10 @@ async def sample_get_product_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, 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -679,7 +717,7 @@ async def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -738,8 +776,10 @@ async def sample_update_product_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, 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -809,7 +849,7 @@ async def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -855,8 +895,10 @@ async def sample_delete_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -912,7 +954,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -981,8 +1023,10 @@ async def sample_create_product(): 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, 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1047,7 +1091,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Lists products in an unspecified order. @@ -1098,8 +1142,10 @@ async def sample_list_products(): 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, 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsAsyncPager: @@ -1173,7 +1219,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1222,8 +1268,10 @@ async def sample_get_product(): 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, 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1285,7 +1333,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1353,8 +1401,10 @@ async def sample_update_product(): 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, 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1419,7 +1469,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1466,8 +1516,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1523,7 +1575,7 @@ async def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -1612,8 +1664,10 @@ async def sample_create_reference_image(): 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, 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: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -1680,7 +1734,7 @@ async def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -1731,8 +1785,10 @@ async def sample_delete_reference_image(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1786,7 +1842,7 @@ async def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesAsyncPager: r"""Lists reference images. @@ -1839,8 +1895,10 @@ async def sample_list_reference_images(): 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, 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesAsyncPager: @@ -1916,7 +1974,7 @@ async def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -1967,8 +2025,10 @@ async def sample_get_reference_image(): 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, 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: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2032,7 +2092,7 @@ async def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2095,8 +2155,10 @@ async def sample_add_product_to_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2155,7 +2217,7 @@ async def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2210,8 +2272,10 @@ async def sample_remove_product_from_product_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2269,7 +2333,7 @@ async def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetAsyncPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2324,8 +2388,10 @@ async def sample_list_products_in_product_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, 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager: @@ -2407,7 +2473,7 @@ async def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2474,8 +2540,10 @@ async def sample_import_product_sets(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2557,7 +2625,7 @@ async def purge_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -2632,8 +2700,10 @@ async def sample_purge_products(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py index 804a4f7e52d1..a0cee9ef0d6b 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import empty_pb2 # type: ignore @@ -651,6 +661,10 @@ def __init__( # 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( @@ -716,6 +730,29 @@ def __init__( 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.vision_v1p4beta1.ProductSearchClient`.", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "credentialsType": None, + }, + ) + def create_product_set( self, request: Optional[ @@ -727,7 +764,7 @@ def create_product_set( product_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Creates and returns a new ProductSet resource. @@ -792,8 +829,10 @@ def sample_create_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -860,7 +899,7 @@ def list_product_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductSetsPager: r"""Lists ProductSets in an unspecified order. @@ -911,8 +950,10 @@ def sample_list_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsPager: @@ -985,7 +1026,7 @@ def get_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Gets information associated with a ProductSet. @@ -1034,8 +1075,10 @@ def sample_get_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -1099,7 +1142,7 @@ def update_product_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -1158,8 +1201,10 @@ def sample_update_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.ProductSet: @@ -1226,7 +1271,7 @@ def delete_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. @@ -1272,8 +1317,10 @@ def sample_delete_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1326,7 +1373,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Creates and returns a new product resource. @@ -1395,8 +1442,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1458,7 +1507,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Lists products in an unspecified order. @@ -1509,8 +1558,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsPager: @@ -1581,7 +1632,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Gets information associated with a Product. @@ -1630,8 +1681,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1690,7 +1743,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Makes changes to a Product resource. Only the ``display_name``, ``description``, and ``labels`` fields can be updated right now. @@ -1758,8 +1811,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.Product: @@ -1821,7 +1876,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a product and its reference images. @@ -1868,8 +1923,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1922,7 +1979,7 @@ def create_reference_image( reference_image_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Creates and returns a new ReferenceImage resource. @@ -2011,8 +2068,10 @@ def sample_create_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2076,7 +2135,7 @@ def delete_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes a reference image. @@ -2127,8 +2186,10 @@ def sample_delete_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2179,7 +2240,7 @@ def list_reference_images( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReferenceImagesPager: r"""Lists reference images. @@ -2232,8 +2293,10 @@ def sample_list_reference_images(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesPager: @@ -2306,7 +2369,7 @@ def get_reference_image( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Gets information associated with a ReferenceImage. @@ -2357,8 +2420,10 @@ def sample_get_reference_image(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.types.ReferenceImage: @@ -2419,7 +2484,7 @@ def add_product_to_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Adds a Product to the specified ProductSet. If the Product is already present, no change is made. @@ -2482,8 +2547,10 @@ def sample_add_product_to_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2541,7 +2608,7 @@ def remove_product_from_product_set( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a Product from the specified ProductSet. @@ -2596,8 +2663,10 @@ def sample_remove_product_from_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2654,7 +2723,7 @@ def list_products_in_product_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsInProductSetPager: r"""Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the @@ -2709,8 +2778,10 @@ def sample_list_products_in_product_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetPager: @@ -2791,7 +2862,7 @@ def import_product_sets( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. @@ -2858,8 +2929,10 @@ def sample_import_product_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2938,7 +3011,7 @@ def purge_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. @@ -3013,8 +3086,10 @@ def sample_purge_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py index ce5b978033b3..b46cbcb43a13 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductSetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -451,7 +461,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -465,8 +475,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListReferenceImagesRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) @@ -609,7 +623,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -623,8 +637,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_search_service.ListProductsInProductSetRequest(request) diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py index 3d35ad5603d8..9d911ff400cb 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vision_v1p4beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport +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.vision.v1p4beta1.ProductSearch", + "rpcName": 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.vision.v1p4beta1.ProductSearch", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcTransport(ProductSearchTransport): """gRPC backend transport for ProductSearch. @@ -201,7 +282,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +351,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -297,7 +385,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -331,7 +419,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -363,7 +451,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -400,7 +488,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -430,7 +518,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -467,7 +555,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -501,7 +589,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -533,7 +621,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -576,7 +664,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -607,7 +695,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -657,7 +745,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -692,7 +780,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -727,7 +815,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -760,7 +848,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -796,7 +884,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -827,7 +917,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -863,7 +953,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -902,7 +994,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -956,7 +1048,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1056,7 @@ def purge_products( return self._stubs["purge_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py index f0aad5b7ea14..36eeddf047cd 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vision_v1p4beta1.types import product_search_service from .base import DEFAULT_CLIENT_INFO, ProductSearchTransport from .grpc import ProductSearchGrpcTransport +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.vision.v1p4beta1.ProductSearch", + "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.vision.v1p4beta1.ProductSearch", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductSearchGrpcAsyncIOTransport(ProductSearchTransport): """gRPC AsyncIO backend transport for ProductSearch. @@ -248,10 +330,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -307,7 +392,7 @@ def create_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product_set" not in self._stubs: - self._stubs["create_product_set"] = self.grpc_channel.unary_unary( + self._stubs["create_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProductSet", request_serializer=product_search_service.CreateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -341,7 +426,7 @@ def list_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_product_sets" not in self._stubs: - self._stubs["list_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductSets", request_serializer=product_search_service.ListProductSetsRequest.serialize, response_deserializer=product_search_service.ListProductSetsResponse.deserialize, @@ -374,7 +459,7 @@ def get_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product_set" not in self._stubs: - self._stubs["get_product_set"] = self.grpc_channel.unary_unary( + self._stubs["get_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProductSet", request_serializer=product_search_service.GetProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -411,7 +496,7 @@ def update_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product_set" not in self._stubs: - self._stubs["update_product_set"] = self.grpc_channel.unary_unary( + self._stubs["update_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProductSet", request_serializer=product_search_service.UpdateProductSetRequest.serialize, response_deserializer=product_search_service.ProductSet.deserialize, @@ -443,7 +528,7 @@ def delete_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_set" not in self._stubs: - self._stubs["delete_product_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_set"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProductSet", request_serializer=product_search_service.DeleteProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -481,7 +566,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateProduct", request_serializer=product_search_service.CreateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -515,7 +600,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProducts", request_serializer=product_search_service.ListProductsRequest.serialize, response_deserializer=product_search_service.ListProductsResponse.deserialize, @@ -548,7 +633,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetProduct", request_serializer=product_search_service.GetProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -592,7 +677,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/UpdateProduct", request_serializer=product_search_service.UpdateProductRequest.serialize, response_deserializer=product_search_service.Product.deserialize, @@ -625,7 +710,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteProduct", request_serializer=product_search_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -675,7 +760,7 @@ def create_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reference_image" not in self._stubs: - self._stubs["create_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["create_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/CreateReferenceImage", request_serializer=product_search_service.CreateReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -710,7 +795,7 @@ def delete_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reference_image" not in self._stubs: - self._stubs["delete_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["delete_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/DeleteReferenceImage", request_serializer=product_search_service.DeleteReferenceImageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -745,7 +830,7 @@ def list_reference_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reference_images" not in self._stubs: - self._stubs["list_reference_images"] = self.grpc_channel.unary_unary( + self._stubs["list_reference_images"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListReferenceImages", request_serializer=product_search_service.ListReferenceImagesRequest.serialize, response_deserializer=product_search_service.ListReferenceImagesResponse.deserialize, @@ -778,7 +863,7 @@ def get_reference_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reference_image" not in self._stubs: - self._stubs["get_reference_image"] = self.grpc_channel.unary_unary( + self._stubs["get_reference_image"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/GetReferenceImage", request_serializer=product_search_service.GetReferenceImageRequest.serialize, response_deserializer=product_search_service.ReferenceImage.deserialize, @@ -815,7 +900,9 @@ def add_product_to_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_product_to_product_set" not in self._stubs: - self._stubs["add_product_to_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_product_to_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/AddProductToProductSet", request_serializer=product_search_service.AddProductToProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -847,7 +934,7 @@ def remove_product_from_product_set( if "remove_product_from_product_set" not in self._stubs: self._stubs[ "remove_product_from_product_set" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/RemoveProductFromProductSet", request_serializer=product_search_service.RemoveProductFromProductSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -883,7 +970,9 @@ def list_products_in_product_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products_in_product_set" not in self._stubs: - self._stubs["list_products_in_product_set"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_products_in_product_set" + ] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ListProductsInProductSet", request_serializer=product_search_service.ListProductsInProductSetRequest.serialize, response_deserializer=product_search_service.ListProductsInProductSetResponse.deserialize, @@ -923,7 +1012,7 @@ def import_product_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_product_sets" not in self._stubs: - self._stubs["import_product_sets"] = self.grpc_channel.unary_unary( + self._stubs["import_product_sets"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/ImportProductSets", request_serializer=product_search_service.ImportProductSetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -978,7 +1067,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.vision.v1p4beta1.ProductSearch/PurgeProducts", request_serializer=product_search_service.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1247,7 +1336,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py index efa44e5bd1c7..3c4c6b3bb5b8 100644 --- a/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py +++ b/packages/google-cloud-vision/google/cloud/vision_v1p4beta1/services/product_search/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -203,9 +211,10 @@ def post_update_product_set(self, response): def pre_add_product_to_product_set( self, request: product_search_service.AddProductToProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.AddProductToProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.AddProductToProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_product_to_product_set @@ -217,8 +226,11 @@ def pre_add_product_to_product_set( def pre_create_product( self, request: product_search_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.CreateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -240,9 +252,10 @@ def post_create_product( def pre_create_product_set( self, request: product_search_service.CreateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.CreateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_product_set @@ -265,9 +278,10 @@ def post_create_product_set( def pre_create_reference_image( self, request: product_search_service.CreateReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.CreateReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.CreateReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_reference_image @@ -290,8 +304,11 @@ def post_create_reference_image( def pre_delete_product( self, request: product_search_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.DeleteProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -302,9 +319,10 @@ def pre_delete_product( def pre_delete_product_set( self, request: product_search_service.DeleteProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_product_set @@ -316,9 +334,10 @@ def pre_delete_product_set( def pre_delete_reference_image( self, request: product_search_service.DeleteReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.DeleteReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.DeleteReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_reference_image @@ -330,8 +349,11 @@ def pre_delete_reference_image( def pre_get_product( self, request: product_search_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -353,8 +375,11 @@ def post_get_product( def pre_get_product_set( self, request: product_search_service.GetProductSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.GetProductSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.GetProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_product_set Override in a subclass to manipulate the request or metadata @@ -376,9 +401,10 @@ def post_get_product_set( def pre_get_reference_image( self, request: product_search_service.GetReferenceImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.GetReferenceImageRequest, Sequence[Tuple[str, str]] + product_search_service.GetReferenceImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_reference_image @@ -401,9 +427,10 @@ def post_get_reference_image( def pre_import_product_sets( self, request: product_search_service.ImportProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ImportProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ImportProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_product_sets @@ -426,8 +453,11 @@ def post_import_product_sets( def pre_list_products( self, request: product_search_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.ListProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -449,9 +479,10 @@ def post_list_products( def pre_list_product_sets( self, request: product_search_service.ListProductSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListProductSetsRequest, Sequence[Tuple[str, str]] + product_search_service.ListProductSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_product_sets @@ -474,10 +505,10 @@ def post_list_product_sets( def pre_list_products_in_product_set( self, request: product_search_service.ListProductsInProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.ListProductsInProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_products_in_product_set @@ -500,9 +531,10 @@ def post_list_products_in_product_set( def pre_list_reference_images( self, request: product_search_service.ListReferenceImagesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.ListReferenceImagesRequest, Sequence[Tuple[str, str]] + product_search_service.ListReferenceImagesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_reference_images @@ -525,8 +557,11 @@ def post_list_reference_images( def pre_purge_products( self, request: product_search_service.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.PurgeProductsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -548,10 +583,10 @@ def post_purge_products( def pre_remove_product_from_product_set( self, request: product_search_service.RemoveProductFromProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ product_search_service.RemoveProductFromProductSetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_product_from_product_set @@ -563,8 +598,11 @@ def pre_remove_product_from_product_set( def pre_update_product( self, request: product_search_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_search_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_search_service.UpdateProductRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -586,9 +624,10 @@ def post_update_product( def pre_update_product_set( self, request: product_search_service.UpdateProductSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_search_service.UpdateProductSetRequest, Sequence[Tuple[str, str]] + product_search_service.UpdateProductSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_product_set @@ -778,7 +817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the add product to product set method over HTTP. @@ -790,13 +829,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseAddProductToProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_add_product_to_product_set( request, metadata ) @@ -813,6 +855,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.AddProductToProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "AddProductToProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._AddProductToProductSet._get_response( self._host, @@ -864,7 +933,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the create product method over HTTP. @@ -874,8 +943,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -885,6 +956,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -899,6 +971,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.CreateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProduct._get_response( self._host, @@ -920,7 +1019,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p4beta1.ProductSearchClient.create_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProductSet( @@ -958,7 +1079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the create product set method over HTTP. @@ -968,8 +1089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -984,6 +1107,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_product_set( request, metadata ) @@ -1000,6 +1124,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.CreateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateProductSet._get_response( self._host, @@ -1021,7 +1172,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p4beta1.ProductSearchClient.create_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReferenceImage( @@ -1059,7 +1234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the create reference image method over HTTP. @@ -1069,8 +1244,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1082,6 +1259,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseCreateReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_create_reference_image( request, metadata ) @@ -1098,6 +1276,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.CreateReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._CreateReferenceImage._get_response( self._host, @@ -1119,7 +1324,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1p4beta1.ProductSearchClient.create_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "CreateReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -1156,7 +1385,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -1166,13 +1395,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1183,6 +1415,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProduct._get_response( self._host, @@ -1232,7 +1491,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product set method over HTTP. @@ -1242,13 +1501,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_set( request, metadata ) @@ -1261,6 +1523,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.DeleteProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteProductSet._get_response( self._host, @@ -1310,7 +1599,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete reference image method over HTTP. @@ -1320,13 +1609,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseDeleteReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reference_image( request, metadata ) @@ -1339,6 +1631,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.DeleteReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "DeleteReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._DeleteReferenceImage._get_response( self._host, @@ -1388,7 +1707,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the get product method over HTTP. @@ -1398,8 +1717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -1409,6 +1730,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = ( _BaseProductSearchRestTransport._BaseGetProduct._get_transcoded_request( @@ -1423,6 +1745,33 @@ def __call__( ) ) + 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.vision_v1p4beta1.ProductSearchClient.GetProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProduct._get_response( self._host, @@ -1443,7 +1792,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p4beta1.ProductSearchClient.get_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProductSet( @@ -1480,7 +1851,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the get product set method over HTTP. @@ -1490,8 +1861,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -1506,6 +1879,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_product_set(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseGetProductSet._get_transcoded_request( http_options, request @@ -1516,6 +1890,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.GetProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetProductSet._get_response( self._host, @@ -1536,7 +1937,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p4beta1.ProductSearchClient.get_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReferenceImage( @@ -1573,7 +1998,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ReferenceImage: r"""Call the get reference image method over HTTP. @@ -1583,8 +2008,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ReferenceImage: @@ -1596,6 +2023,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseGetReferenceImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_reference_image( request, metadata ) @@ -1608,6 +2036,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.GetReferenceImage", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._GetReferenceImage._get_response( self._host, @@ -1628,7 +2083,31 @@ def __call__( pb_resp = product_search_service.ReferenceImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reference_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ReferenceImage.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.vision_v1p4beta1.ProductSearchClient.get_reference_image", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "GetReferenceImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProductSets( @@ -1666,7 +2145,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import product sets method over HTTP. @@ -1676,8 +2155,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1690,6 +2171,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseImportProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_import_product_sets( request, metadata ) @@ -1706,6 +2188,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.ImportProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ImportProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ImportProductSets._get_response( self._host, @@ -1725,7 +2234,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_product_sets(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.vision_v1p4beta1.ProductSearchClient.import_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ImportProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1762,7 +2293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1772,8 +2303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsResponse: @@ -1783,6 +2316,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1793,6 +2327,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.ListProducts", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProducts._get_response( self._host, @@ -1813,7 +2374,31 @@ def __call__( pb_resp = product_search_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsResponse.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.vision_v1p4beta1.ProductSearchClient.list_products", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductSets( @@ -1850,7 +2435,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductSetsResponse: r"""Call the list product sets method over HTTP. @@ -1860,8 +2445,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductSetsResponse: @@ -1871,6 +2458,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_product_sets( request, metadata ) @@ -1883,6 +2471,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.ListProductSets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListProductSets._get_response( self._host, @@ -1903,7 +2518,31 @@ def __call__( pb_resp = product_search_service.ListProductSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_product_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductSetsResponse.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.vision_v1p4beta1.ProductSearchClient.list_product_sets", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProductsInProductSet( @@ -1941,7 +2580,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListProductsInProductSetResponse: r"""Call the list products in product set method over HTTP. @@ -1953,8 +2592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListProductsInProductSetResponse: @@ -1966,6 +2607,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListProductsInProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_products_in_product_set( request, metadata ) @@ -1978,6 +2620,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.ListProductsInProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._ListProductsInProductSet._get_response( @@ -2000,7 +2669,33 @@ def __call__( pb_resp = product_search_service.ListProductsInProductSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products_in_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListProductsInProductSetResponse.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.vision_v1p4beta1.ProductSearchClient.list_products_in_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListProductsInProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferenceImages( @@ -2037,7 +2732,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ListReferenceImagesResponse: r"""Call the list reference images method over HTTP. @@ -2047,8 +2742,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ListReferenceImagesResponse: @@ -2058,6 +2755,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseListReferenceImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_reference_images( request, metadata ) @@ -2070,6 +2768,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.ListReferenceImages", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._ListReferenceImages._get_response( self._host, @@ -2090,7 +2815,33 @@ def __call__( pb_resp = product_search_service.ListReferenceImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reference_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + product_search_service.ListReferenceImagesResponse.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.vision_v1p4beta1.ProductSearchClient.list_reference_images", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "ListReferenceImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -2128,7 +2879,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -2138,8 +2889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2152,6 +2905,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -2166,6 +2920,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._PurgeProducts._get_response( self._host, @@ -2185,7 +2966,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(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.vision_v1p4beta1.ProductSearchClient.purge_products", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveProductFromProductSet( @@ -2224,7 +3027,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the remove product from product set method over HTTP. @@ -2236,13 +3039,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductSearchRestTransport._BaseRemoveProductFromProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_remove_product_from_product_set( request, metadata ) @@ -2259,6 +3065,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.RemoveProductFromProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "RemoveProductFromProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductSearchRestTransport._RemoveProductFromProductSet._get_response( @@ -2312,7 +3145,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.Product: r"""Call the update product method over HTTP. @@ -2322,8 +3155,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.Product: @@ -2333,6 +3168,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductSearchRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -2347,6 +3183,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProduct._get_response( self._host, @@ -2368,7 +3231,29 @@ def __call__( pb_resp = product_search_service.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.Product.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.vision_v1p4beta1.ProductSearchClient.update_product", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProductSet( @@ -2406,7 +3291,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_search_service.ProductSet: r"""Call the update product set method over HTTP. @@ -2416,8 +3301,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_search_service.ProductSet: @@ -2432,6 +3319,7 @@ def __call__( http_options = ( _BaseProductSearchRestTransport._BaseUpdateProductSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_product_set( request, metadata ) @@ -2448,6 +3336,33 @@ def __call__( 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.vision_v1p4beta1.ProductSearchClient.UpdateProductSet", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductSearchRestTransport._UpdateProductSet._get_response( self._host, @@ -2469,7 +3384,31 @@ def __call__( pb_resp = product_search_service.ProductSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_search_service.ProductSet.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.vision_v1p4beta1.ProductSearchClient.update_product_set", + extra={ + "serviceName": "google.cloud.vision.v1p4beta1.ProductSearch", + "rpcName": "UpdateProductSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json index eb9273fbcb25..8508099e5ba2 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateFilesResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateFilesResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateImagesResponse", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.BatchAnnotateImagesResponse", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -784,7 +784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -958,7 +958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -1135,7 +1135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -1312,7 +1312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -1393,7 +1393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1470,7 +1470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1548,7 +1548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1625,7 +1625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1703,7 +1703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1780,7 +1780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ReferenceImage", @@ -2345,7 +2345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductSetsPager", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2832,7 +2832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsAsyncPager", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListProductsPager", @@ -2993,7 +2993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.services.product_search.pagers.ListReferenceImagesPager", @@ -3154,7 +3154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3400,7 +3400,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3482,7 +3482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.ProductSet", @@ -3651,7 +3651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", @@ -3735,7 +3735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1.types.Product", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json index bc393f84f224..3274884f3da9 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p1beta1.types.BatchAnnotateImagesResponse", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json index d5658bd403b8..1737a0ce6698 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p2beta1.types.BatchAnnotateImagesResponse", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json index 076255146208..da3759f8bc75 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p3beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.BatchAnnotateImagesResponse", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -454,7 +454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -628,7 +628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -717,7 +717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -805,7 +805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -894,7 +894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -982,7 +982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1140,7 +1140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1218,7 +1218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1295,7 +1295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1373,7 +1373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1450,7 +1450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -1850,7 +1850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -1930,7 +1930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ReferenceImage", @@ -2015,7 +2015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductSetsPager", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListProductsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.services.product_search.pagers.ListReferenceImagesPager", @@ -2828,7 +2828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -2909,7 +2909,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -2991,7 +2991,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -3075,7 +3075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.ProductSet", @@ -3160,7 +3160,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", @@ -3244,7 +3244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p3beta1.types.Product", diff --git a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json index dadadbdda95c..e239e7f4ae0e 100644 --- a/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json +++ b/packages/google-cloud-vision/samples/generated_samples/snippet_metadata_google.cloud.vision.v1p4beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vision", - "version": "3.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateFilesResponse", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.BatchAnnotateImagesResponse", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -784,7 +784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "add_product_to_product_set" @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -958,7 +958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -1135,7 +1135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -1312,7 +1312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -1393,7 +1393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1470,7 +1470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_set" @@ -1548,7 +1548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1625,7 +1625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -1703,7 +1703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1780,7 +1780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reference_image" @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ReferenceImage", @@ -2345,7 +2345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsAsyncPager", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductSetsPager", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetAsyncPager", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsInProductSetPager", @@ -2832,7 +2832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsAsyncPager", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListProductsPager", @@ -2993,7 +2993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesAsyncPager", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.services.product_search.pagers.ListReferenceImagesPager", @@ -3154,7 +3154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3400,7 +3400,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_product_from_product_set" @@ -3482,7 +3482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.ProductSet", @@ -3651,7 +3651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", @@ -3735,7 +3735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vision_v1p4beta1.types.Product", diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py index 0f3b214297e6..9e386afc3818 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_image_annotator.py @@ -2425,6 +2425,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._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.batch_annotate_images(request) @@ -2474,6 +2475,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_images(**mock_args) @@ -2607,6 +2609,7 @@ def test_batch_annotate_files_rest_required_fields( response_value._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.batch_annotate_files(request) @@ -2658,6 +2661,7 @@ def test_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_files(**mock_args) @@ -2795,6 +2799,7 @@ def test_async_batch_annotate_images_rest_required_fields( response_value._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.async_batch_annotate_images(request) @@ -2853,6 +2858,7 @@ def test_async_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_images(**mock_args) @@ -2991,6 +2997,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._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.async_batch_annotate_files(request) @@ -3040,6 +3047,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_files(**mock_args) @@ -3421,6 +3429,7 @@ def test_batch_annotate_images_rest_bad_request( 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.batch_annotate_images(request) @@ -3454,6 +3463,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3493,6 +3503,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -3539,6 +3550,7 @@ def test_batch_annotate_files_rest_bad_request( 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.batch_annotate_files(request) @@ -3572,6 +3584,7 @@ def test_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3611,6 +3624,7 @@ def test_batch_annotate_files_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateFilesResponse.to_json( image_annotator.BatchAnnotateFilesResponse() ) @@ -3657,6 +3671,7 @@ def test_async_batch_annotate_images_rest_bad_request( 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.async_batch_annotate_images(request) @@ -3687,6 +3702,7 @@ def test_async_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3728,6 +3744,7 @@ def test_async_batch_annotate_images_rest_interceptors(null_interceptor): 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 @@ -3772,6 +3789,7 @@ def test_async_batch_annotate_files_rest_bad_request( 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.async_batch_annotate_files(request) @@ -3802,6 +3820,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3843,6 +3862,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): 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 @@ -3889,6 +3909,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3919,6 +3940,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py index 321cdcd137b2..1287f1cb8b0d 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1/test_product_search.py @@ -8517,6 +8517,7 @@ def test_create_product_set_rest_required_fields( response_value._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_product_set(request) @@ -8572,6 +8573,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -8716,6 +8718,7 @@ def test_list_product_sets_rest_required_fields( response_value._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_product_sets(request) @@ -8769,6 +8772,7 @@ def test_list_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_sets(**mock_args) @@ -8963,6 +8967,7 @@ def test_get_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9010,6 +9015,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -9143,6 +9149,7 @@ def test_update_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9193,6 +9200,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -9326,6 +9334,7 @@ def test_delete_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9371,6 +9380,7 @@ def test_delete_product_set_rest_flattened(): 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"} client.delete_product_set(**mock_args) @@ -9505,6 +9515,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -9560,6 +9571,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -9699,6 +9711,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -9752,6 +9765,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -9945,6 +9959,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -9990,6 +10005,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -10118,6 +10134,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -10166,6 +10183,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -10295,6 +10313,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -10338,6 +10357,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -10476,6 +10496,7 @@ def test_create_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10533,6 +10554,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -10668,6 +10690,7 @@ def test_delete_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10713,6 +10736,7 @@ def test_delete_reference_image_rest_flattened(): 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"} client.delete_reference_image(**mock_args) @@ -10858,6 +10882,7 @@ def test_list_reference_images_rest_required_fields( response_value._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_reference_images(request) @@ -10915,6 +10940,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_images(**mock_args) @@ -11118,6 +11144,7 @@ def test_get_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -11165,6 +11192,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -11303,6 +11331,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._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.add_product_to_product_set(request) @@ -11357,6 +11386,7 @@ def test_add_product_to_product_set_rest_flattened(): 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"} client.add_product_to_product_set(**mock_args) @@ -11496,6 +11526,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._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.remove_product_from_product_set(request) @@ -11552,6 +11583,7 @@ def test_remove_product_from_product_set_rest_flattened(): 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"} client.remove_product_from_product_set(**mock_args) @@ -11698,6 +11730,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._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_products_in_product_set(request) @@ -11755,6 +11788,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products_in_product_set(**mock_args) @@ -11958,6 +11992,7 @@ def test_import_product_sets_rest_required_fields( response_value._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.import_product_sets(request) @@ -12014,6 +12049,7 @@ def test_import_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_product_sets(**mock_args) @@ -12152,6 +12188,7 @@ def test_purge_products_rest_required_fields( response_value._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.purge_products(request) @@ -12195,6 +12232,7 @@ def test_purge_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.purge_products(**mock_args) @@ -13323,6 +13361,7 @@ def test_create_product_set_rest_bad_request( 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_product_set(request) @@ -13443,6 +13482,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13484,6 +13524,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13530,6 +13571,7 @@ def test_list_product_sets_rest_bad_request( 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_product_sets(request) @@ -13565,6 +13607,7 @@ def test_list_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_sets(request) # Establish that the response is the type that we expect. @@ -13605,6 +13648,7 @@ def test_list_product_sets_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13651,6 +13695,7 @@ def test_get_product_set_rest_bad_request( 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_product_set(request) @@ -13687,6 +13732,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13728,6 +13774,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13778,6 +13825,7 @@ def test_update_product_set_rest_bad_request( 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_product_set(request) @@ -13902,6 +13950,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13943,6 +13992,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13989,6 +14039,7 @@ def test_delete_product_set_rest_bad_request( 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_product_set(request) @@ -14019,6 +14070,7 @@ def test_delete_product_set_rest_call_success(request_type): 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_product_set(request) # Establish that the response is the type that we expect. @@ -14055,6 +14107,7 @@ def test_delete_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductSetRequest() metadata = [ @@ -14095,6 +14148,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -14207,6 +14261,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14250,6 +14305,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14296,6 +14352,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -14331,6 +14388,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -14371,6 +14429,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -14417,6 +14476,7 @@ def test_get_product_rest_bad_request( 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_product(request) @@ -14455,6 +14515,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14498,6 +14559,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14546,6 +14608,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -14660,6 +14723,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14703,6 +14767,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14749,6 +14814,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -14779,6 +14845,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -14815,6 +14882,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14855,6 +14923,7 @@ def test_create_reference_image_rest_bad_request( 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_reference_image(request) @@ -14970,6 +15039,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -15011,6 +15081,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15059,6 +15130,7 @@ def test_delete_reference_image_rest_bad_request( 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_reference_image(request) @@ -15091,6 +15163,7 @@ def test_delete_reference_image_rest_call_success(request_type): 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_reference_image(request) # Establish that the response is the type that we expect. @@ -15127,6 +15200,7 @@ def test_delete_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -15167,6 +15241,7 @@ def test_list_reference_images_rest_bad_request( 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_reference_images(request) @@ -15205,6 +15280,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_images(request) # Establish that the response is the type that we expect. @@ -15246,6 +15322,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): 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 = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -15294,6 +15371,7 @@ def test_get_reference_image_rest_bad_request( 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_reference_image(request) @@ -15332,6 +15410,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -15373,6 +15452,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15419,6 +15499,7 @@ def test_add_product_to_product_set_rest_bad_request( 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.add_product_to_product_set(request) @@ -15449,6 +15530,7 @@ def test_add_product_to_product_set_rest_call_success(request_type): 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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -15485,6 +15567,7 @@ def test_add_product_to_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -15525,6 +15608,7 @@ def test_remove_product_from_product_set_rest_bad_request( 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.remove_product_from_product_set(request) @@ -15555,6 +15639,7 @@ def test_remove_product_from_product_set_rest_call_success(request_type): 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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15591,6 +15676,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15631,6 +15717,7 @@ def test_list_products_in_product_set_rest_bad_request( 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_products_in_product_set(request) @@ -15668,6 +15755,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products_in_product_set(request) # Establish that the response is the type that we expect. @@ -15708,6 +15796,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15754,6 +15843,7 @@ def test_import_product_sets_rest_bad_request( 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.import_product_sets(request) @@ -15784,6 +15874,7 @@ def test_import_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15825,6 +15916,7 @@ def test_import_product_sets_rest_interceptors(null_interceptor): 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 @@ -15869,6 +15961,7 @@ def test_purge_products_rest_bad_request( 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.purge_products(request) @@ -15899,6 +15992,7 @@ def test_purge_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_products(request) # Establish that the response is the type that we expect. @@ -15940,6 +16034,7 @@ def test_purge_products_rest_interceptors(null_interceptor): 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 @@ -15986,6 +16081,7 @@ def test_get_operation_rest_bad_request( 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) @@ -16016,6 +16112,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py index 4fca11157aea..bc7d67520e21 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py @@ -1458,6 +1458,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._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.batch_annotate_images(request) @@ -1507,6 +1508,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_images(**mock_args) @@ -1736,6 +1738,7 @@ def test_batch_annotate_images_rest_bad_request( 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.batch_annotate_images(request) @@ -1769,6 +1772,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -1808,6 +1812,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py index e315a83efcdc..95b558563eb8 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py @@ -1782,6 +1782,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._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.batch_annotate_images(request) @@ -1831,6 +1832,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_images(**mock_args) @@ -1966,6 +1968,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._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.async_batch_annotate_files(request) @@ -2015,6 +2018,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_files(**mock_args) @@ -2296,6 +2300,7 @@ def test_batch_annotate_images_rest_bad_request( 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.batch_annotate_images(request) @@ -2329,6 +2334,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -2368,6 +2374,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -2414,6 +2421,7 @@ def test_async_batch_annotate_files_rest_bad_request( 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.async_batch_annotate_files(request) @@ -2444,6 +2452,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -2485,6 +2494,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py index 7f289ba5bfd6..d38612cd962f 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py @@ -1786,6 +1786,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._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.batch_annotate_images(request) @@ -1835,6 +1836,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_images(**mock_args) @@ -1970,6 +1972,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._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.async_batch_annotate_files(request) @@ -2019,6 +2022,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_files(**mock_args) @@ -2300,6 +2304,7 @@ def test_batch_annotate_images_rest_bad_request( 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.batch_annotate_images(request) @@ -2333,6 +2338,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -2372,6 +2378,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -2418,6 +2425,7 @@ def test_async_batch_annotate_files_rest_bad_request( 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.async_batch_annotate_files(request) @@ -2448,6 +2456,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -2489,6 +2498,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py index 2e0bcfa82b38..b71651854ec6 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p3beta1/test_product_search.py @@ -8188,6 +8188,7 @@ def test_create_product_set_rest_required_fields( response_value._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_product_set(request) @@ -8243,6 +8244,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -8387,6 +8389,7 @@ def test_list_product_sets_rest_required_fields( response_value._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_product_sets(request) @@ -8440,6 +8443,7 @@ def test_list_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_sets(**mock_args) @@ -8634,6 +8638,7 @@ def test_get_product_set_rest_required_fields( response_value._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_product_set(request) @@ -8681,6 +8686,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -8814,6 +8820,7 @@ def test_update_product_set_rest_required_fields( response_value._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_product_set(request) @@ -8864,6 +8871,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -8997,6 +9005,7 @@ def test_delete_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9042,6 +9051,7 @@ def test_delete_product_set_rest_flattened(): 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"} client.delete_product_set(**mock_args) @@ -9176,6 +9186,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -9231,6 +9242,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -9371,6 +9383,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -9424,6 +9437,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -9618,6 +9632,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -9663,6 +9678,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -9792,6 +9808,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -9840,6 +9857,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -9969,6 +9987,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -10012,6 +10031,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -10151,6 +10171,7 @@ def test_create_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10208,6 +10229,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -10343,6 +10365,7 @@ def test_delete_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10388,6 +10411,7 @@ def test_delete_reference_image_rest_flattened(): 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"} client.delete_reference_image(**mock_args) @@ -10533,6 +10557,7 @@ def test_list_reference_images_rest_required_fields( response_value._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_reference_images(request) @@ -10590,6 +10615,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_images(**mock_args) @@ -10793,6 +10819,7 @@ def test_get_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10840,6 +10867,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -10978,6 +11006,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._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.add_product_to_product_set(request) @@ -11032,6 +11061,7 @@ def test_add_product_to_product_set_rest_flattened(): 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"} client.add_product_to_product_set(**mock_args) @@ -11171,6 +11201,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._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.remove_product_from_product_set(request) @@ -11227,6 +11258,7 @@ def test_remove_product_from_product_set_rest_flattened(): 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"} client.remove_product_from_product_set(**mock_args) @@ -11373,6 +11405,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._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_products_in_product_set(request) @@ -11430,6 +11463,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products_in_product_set(**mock_args) @@ -11633,6 +11667,7 @@ def test_import_product_sets_rest_required_fields( response_value._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.import_product_sets(request) @@ -11689,6 +11724,7 @@ def test_import_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_product_sets(**mock_args) @@ -12776,6 +12812,7 @@ def test_create_product_set_rest_bad_request( 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_product_set(request) @@ -12896,6 +12933,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -12937,6 +12975,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -12983,6 +13022,7 @@ def test_list_product_sets_rest_bad_request( 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_product_sets(request) @@ -13018,6 +13058,7 @@ def test_list_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_sets(request) # Establish that the response is the type that we expect. @@ -13058,6 +13099,7 @@ def test_list_product_sets_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13104,6 +13146,7 @@ def test_get_product_set_rest_bad_request( 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_product_set(request) @@ -13140,6 +13183,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13181,6 +13225,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13231,6 +13276,7 @@ def test_update_product_set_rest_bad_request( 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_product_set(request) @@ -13355,6 +13401,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13396,6 +13443,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13442,6 +13490,7 @@ def test_delete_product_set_rest_bad_request( 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_product_set(request) @@ -13472,6 +13521,7 @@ def test_delete_product_set_rest_call_success(request_type): 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_product_set(request) # Establish that the response is the type that we expect. @@ -13508,6 +13558,7 @@ def test_delete_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductSetRequest() metadata = [ @@ -13548,6 +13599,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -13660,6 +13712,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -13703,6 +13756,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -13749,6 +13803,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -13784,6 +13839,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -13824,6 +13880,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -13870,6 +13927,7 @@ def test_get_product_rest_bad_request( 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_product(request) @@ -13908,6 +13966,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -13951,6 +14010,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -13999,6 +14059,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -14113,6 +14174,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14156,6 +14218,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14202,6 +14265,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -14232,6 +14296,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -14268,6 +14333,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14308,6 +14374,7 @@ def test_create_reference_image_rest_bad_request( 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_reference_image(request) @@ -14423,6 +14490,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -14464,6 +14532,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -14512,6 +14581,7 @@ def test_delete_reference_image_rest_bad_request( 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_reference_image(request) @@ -14544,6 +14614,7 @@ def test_delete_reference_image_rest_call_success(request_type): 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_reference_image(request) # Establish that the response is the type that we expect. @@ -14580,6 +14651,7 @@ def test_delete_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -14620,6 +14692,7 @@ def test_list_reference_images_rest_bad_request( 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_reference_images(request) @@ -14658,6 +14731,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_images(request) # Establish that the response is the type that we expect. @@ -14699,6 +14773,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): 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 = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -14747,6 +14822,7 @@ def test_get_reference_image_rest_bad_request( 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_reference_image(request) @@ -14785,6 +14861,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -14826,6 +14903,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -14872,6 +14950,7 @@ def test_add_product_to_product_set_rest_bad_request( 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.add_product_to_product_set(request) @@ -14902,6 +14981,7 @@ def test_add_product_to_product_set_rest_call_success(request_type): 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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -14938,6 +15018,7 @@ def test_add_product_to_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -14978,6 +15059,7 @@ def test_remove_product_from_product_set_rest_bad_request( 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.remove_product_from_product_set(request) @@ -15008,6 +15090,7 @@ def test_remove_product_from_product_set_rest_call_success(request_type): 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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15044,6 +15127,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15084,6 +15168,7 @@ def test_list_products_in_product_set_rest_bad_request( 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_products_in_product_set(request) @@ -15121,6 +15206,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products_in_product_set(request) # Establish that the response is the type that we expect. @@ -15161,6 +15247,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15207,6 +15294,7 @@ def test_import_product_sets_rest_bad_request( 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.import_product_sets(request) @@ -15237,6 +15325,7 @@ def test_import_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15278,6 +15367,7 @@ def test_import_product_sets_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py index 8f6a1d9c4c0a..9718f97a0637 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py @@ -2414,6 +2414,7 @@ def test_batch_annotate_images_rest_required_fields( response_value._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.batch_annotate_images(request) @@ -2463,6 +2464,7 @@ def test_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_images(**mock_args) @@ -2596,6 +2598,7 @@ def test_batch_annotate_files_rest_required_fields( response_value._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.batch_annotate_files(request) @@ -2647,6 +2650,7 @@ def test_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_annotate_files(**mock_args) @@ -2784,6 +2788,7 @@ def test_async_batch_annotate_images_rest_required_fields( response_value._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.async_batch_annotate_images(request) @@ -2842,6 +2847,7 @@ def test_async_batch_annotate_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_images(**mock_args) @@ -2980,6 +2986,7 @@ def test_async_batch_annotate_files_rest_required_fields( response_value._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.async_batch_annotate_files(request) @@ -3029,6 +3036,7 @@ def test_async_batch_annotate_files_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.async_batch_annotate_files(**mock_args) @@ -3410,6 +3418,7 @@ def test_batch_annotate_images_rest_bad_request( 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.batch_annotate_images(request) @@ -3443,6 +3452,7 @@ def test_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3482,6 +3492,7 @@ def test_batch_annotate_images_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateImagesResponse.to_json( image_annotator.BatchAnnotateImagesResponse() ) @@ -3528,6 +3539,7 @@ def test_batch_annotate_files_rest_bad_request( 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.batch_annotate_files(request) @@ -3561,6 +3573,7 @@ def test_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3600,6 +3613,7 @@ def test_batch_annotate_files_rest_interceptors(null_interceptor): 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 = image_annotator.BatchAnnotateFilesResponse.to_json( image_annotator.BatchAnnotateFilesResponse() ) @@ -3646,6 +3660,7 @@ def test_async_batch_annotate_images_rest_bad_request( 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.async_batch_annotate_images(request) @@ -3676,6 +3691,7 @@ def test_async_batch_annotate_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_images(request) # Establish that the response is the type that we expect. @@ -3717,6 +3733,7 @@ def test_async_batch_annotate_images_rest_interceptors(null_interceptor): 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 @@ -3761,6 +3778,7 @@ def test_async_batch_annotate_files_rest_bad_request( 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.async_batch_annotate_files(request) @@ -3791,6 +3809,7 @@ def test_async_batch_annotate_files_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.async_batch_annotate_files(request) # Establish that the response is the type that we expect. @@ -3832,6 +3851,7 @@ def test_async_batch_annotate_files_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py index 68698377853a..e9d31f2a351f 100644 --- a/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py +++ b/packages/google-cloud-vision/tests/unit/gapic/vision_v1p4beta1/test_product_search.py @@ -8517,6 +8517,7 @@ def test_create_product_set_rest_required_fields( response_value._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_product_set(request) @@ -8572,6 +8573,7 @@ def test_create_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -8716,6 +8718,7 @@ def test_list_product_sets_rest_required_fields( response_value._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_product_sets(request) @@ -8769,6 +8772,7 @@ def test_list_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_sets(**mock_args) @@ -8963,6 +8967,7 @@ def test_get_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9010,6 +9015,7 @@ def test_get_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -9143,6 +9149,7 @@ def test_update_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9193,6 +9200,7 @@ def test_update_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product_set(**mock_args) @@ -9326,6 +9334,7 @@ def test_delete_product_set_rest_required_fields( response_value._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_product_set(request) @@ -9371,6 +9380,7 @@ def test_delete_product_set_rest_flattened(): 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"} client.delete_product_set(**mock_args) @@ -9505,6 +9515,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -9560,6 +9571,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -9700,6 +9712,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -9753,6 +9766,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -9947,6 +9961,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -9992,6 +10007,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -10121,6 +10137,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -10169,6 +10186,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -10298,6 +10316,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -10341,6 +10360,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -10480,6 +10500,7 @@ def test_create_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10537,6 +10558,7 @@ def test_create_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -10672,6 +10694,7 @@ def test_delete_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -10717,6 +10740,7 @@ def test_delete_reference_image_rest_flattened(): 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"} client.delete_reference_image(**mock_args) @@ -10862,6 +10886,7 @@ def test_list_reference_images_rest_required_fields( response_value._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_reference_images(request) @@ -10919,6 +10944,7 @@ def test_list_reference_images_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_images(**mock_args) @@ -11122,6 +11148,7 @@ def test_get_reference_image_rest_required_fields( response_value._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_reference_image(request) @@ -11169,6 +11196,7 @@ def test_get_reference_image_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reference_image(**mock_args) @@ -11307,6 +11335,7 @@ def test_add_product_to_product_set_rest_required_fields( response_value._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.add_product_to_product_set(request) @@ -11361,6 +11390,7 @@ def test_add_product_to_product_set_rest_flattened(): 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"} client.add_product_to_product_set(**mock_args) @@ -11500,6 +11530,7 @@ def test_remove_product_from_product_set_rest_required_fields( response_value._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.remove_product_from_product_set(request) @@ -11556,6 +11587,7 @@ def test_remove_product_from_product_set_rest_flattened(): 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"} client.remove_product_from_product_set(**mock_args) @@ -11702,6 +11734,7 @@ def test_list_products_in_product_set_rest_required_fields( response_value._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_products_in_product_set(request) @@ -11759,6 +11792,7 @@ def test_list_products_in_product_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products_in_product_set(**mock_args) @@ -11962,6 +11996,7 @@ def test_import_product_sets_rest_required_fields( response_value._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.import_product_sets(request) @@ -12018,6 +12053,7 @@ def test_import_product_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_product_sets(**mock_args) @@ -12156,6 +12192,7 @@ def test_purge_products_rest_required_fields( response_value._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.purge_products(request) @@ -12199,6 +12236,7 @@ def test_purge_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.purge_products(**mock_args) @@ -13327,6 +13365,7 @@ def test_create_product_set_rest_bad_request( 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_product_set(request) @@ -13447,6 +13486,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13488,6 +13528,7 @@ def test_create_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13534,6 +13575,7 @@ def test_list_product_sets_rest_bad_request( 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_product_sets(request) @@ -13569,6 +13611,7 @@ def test_list_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_sets(request) # Establish that the response is the type that we expect. @@ -13609,6 +13652,7 @@ def test_list_product_sets_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductSetsResponse.to_json( product_search_service.ListProductSetsResponse() ) @@ -13655,6 +13699,7 @@ def test_get_product_set_rest_bad_request( 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_product_set(request) @@ -13691,6 +13736,7 @@ def test_get_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13732,6 +13778,7 @@ def test_get_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13782,6 +13829,7 @@ def test_update_product_set_rest_bad_request( 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_product_set(request) @@ -13906,6 +13954,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product_set(request) # Establish that the response is the type that we expect. @@ -13947,6 +13996,7 @@ def test_update_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ProductSet.to_json( product_search_service.ProductSet() ) @@ -13993,6 +14043,7 @@ def test_delete_product_set_rest_bad_request( 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_product_set(request) @@ -14023,6 +14074,7 @@ def test_delete_product_set_rest_call_success(request_type): 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_product_set(request) # Establish that the response is the type that we expect. @@ -14059,6 +14111,7 @@ def test_delete_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductSetRequest() metadata = [ @@ -14099,6 +14152,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -14211,6 +14265,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14254,6 +14309,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14300,6 +14356,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -14335,6 +14392,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -14375,6 +14433,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsResponse.to_json( product_search_service.ListProductsResponse() ) @@ -14421,6 +14480,7 @@ def test_get_product_rest_bad_request( 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_product(request) @@ -14459,6 +14519,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14502,6 +14563,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14550,6 +14612,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -14664,6 +14727,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -14707,6 +14771,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = product_search_service.Product.to_json( product_search_service.Product() ) @@ -14753,6 +14818,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -14783,6 +14849,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -14819,6 +14886,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteProductRequest() metadata = [ @@ -14859,6 +14927,7 @@ def test_create_reference_image_rest_bad_request( 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_reference_image(request) @@ -14974,6 +15043,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -15015,6 +15085,7 @@ def test_create_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15063,6 +15134,7 @@ def test_delete_reference_image_rest_bad_request( 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_reference_image(request) @@ -15095,6 +15167,7 @@ def test_delete_reference_image_rest_call_success(request_type): 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_reference_image(request) # Establish that the response is the type that we expect. @@ -15131,6 +15204,7 @@ def test_delete_reference_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.DeleteReferenceImageRequest() metadata = [ @@ -15171,6 +15245,7 @@ def test_list_reference_images_rest_bad_request( 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_reference_images(request) @@ -15209,6 +15284,7 @@ def test_list_reference_images_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_images(request) # Establish that the response is the type that we expect. @@ -15250,6 +15326,7 @@ def test_list_reference_images_rest_interceptors(null_interceptor): 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 = product_search_service.ListReferenceImagesResponse.to_json( product_search_service.ListReferenceImagesResponse() ) @@ -15298,6 +15375,7 @@ def test_get_reference_image_rest_bad_request( 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_reference_image(request) @@ -15336,6 +15414,7 @@ def test_get_reference_image_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reference_image(request) # Establish that the response is the type that we expect. @@ -15377,6 +15456,7 @@ def test_get_reference_image_rest_interceptors(null_interceptor): 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 = product_search_service.ReferenceImage.to_json( product_search_service.ReferenceImage() ) @@ -15423,6 +15503,7 @@ def test_add_product_to_product_set_rest_bad_request( 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.add_product_to_product_set(request) @@ -15453,6 +15534,7 @@ def test_add_product_to_product_set_rest_call_success(request_type): 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.add_product_to_product_set(request) # Establish that the response is the type that we expect. @@ -15489,6 +15571,7 @@ def test_add_product_to_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.AddProductToProductSetRequest() metadata = [ @@ -15529,6 +15612,7 @@ def test_remove_product_from_product_set_rest_bad_request( 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.remove_product_from_product_set(request) @@ -15559,6 +15643,7 @@ def test_remove_product_from_product_set_rest_call_success(request_type): 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.remove_product_from_product_set(request) # Establish that the response is the type that we expect. @@ -15595,6 +15680,7 @@ def test_remove_product_from_product_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_search_service.RemoveProductFromProductSetRequest() metadata = [ @@ -15635,6 +15721,7 @@ def test_list_products_in_product_set_rest_bad_request( 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_products_in_product_set(request) @@ -15672,6 +15759,7 @@ def test_list_products_in_product_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products_in_product_set(request) # Establish that the response is the type that we expect. @@ -15712,6 +15800,7 @@ def test_list_products_in_product_set_rest_interceptors(null_interceptor): 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 = product_search_service.ListProductsInProductSetResponse.to_json( product_search_service.ListProductsInProductSetResponse() ) @@ -15758,6 +15847,7 @@ def test_import_product_sets_rest_bad_request( 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.import_product_sets(request) @@ -15788,6 +15878,7 @@ def test_import_product_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_product_sets(request) # Establish that the response is the type that we expect. @@ -15829,6 +15920,7 @@ def test_import_product_sets_rest_interceptors(null_interceptor): 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 @@ -15873,6 +15965,7 @@ def test_purge_products_rest_bad_request( 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.purge_products(request) @@ -15903,6 +15996,7 @@ def test_purge_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_products(request) # Establish that the response is the type that we expect. @@ -15944,6 +16038,7 @@ def test_purge_products_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.5" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.5" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py index e76cda9c069f..9ea8990b70f9 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .transports.grpc_asyncio import AppPlatformGrpcAsyncIOTransport +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 AppPlatformAsyncClient: """Service describing handlers for resources""" @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.AppPlatformAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "credentialsType": None, + }, + ) + async def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_applications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApplicationsAsyncPager: r"""Lists Applications in a given project and location. @@ -320,8 +352,10 @@ async def sample_list_applications(): 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, 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: google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsAsyncPager: @@ -396,7 +430,7 @@ async def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -437,8 +471,10 @@ async def sample_get_application(): 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, 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: google.cloud.visionai_v1.types.Application: @@ -498,7 +534,7 @@ async def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Application in a given project and location. @@ -554,8 +590,10 @@ async def sample_create_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -630,7 +668,7 @@ async def update_application( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Application. @@ -689,8 +727,10 @@ async def sample_update_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -766,7 +806,7 @@ async def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Application. @@ -811,8 +851,10 @@ async def sample_delete_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -891,7 +933,7 @@ async def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a single Application. @@ -940,8 +982,10 @@ async def sample_deploy_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1012,7 +1056,7 @@ async def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys a single Application. @@ -1062,8 +1106,10 @@ async def sample_undeploy_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1137,7 +1183,7 @@ async def add_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1190,8 +1236,10 @@ async def sample_add_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1265,7 +1313,7 @@ async def remove_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1318,8 +1366,10 @@ async def sample_remove_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1393,7 +1443,7 @@ async def update_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1446,8 +1496,10 @@ async def sample_update_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1519,7 +1571,7 @@ async def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists Instances in a given project and location. @@ -1564,8 +1616,10 @@ async def sample_list_instances(): 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, 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: google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesAsyncPager: @@ -1640,7 +1694,7 @@ async def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -1681,8 +1735,10 @@ async def sample_get_instance(): 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, 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: google.cloud.visionai_v1.types.Instance: @@ -1745,7 +1801,7 @@ async def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1803,8 +1859,10 @@ async def sample_create_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1878,7 +1936,7 @@ async def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1932,8 +1990,10 @@ async def sample_delete_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2011,7 +2071,7 @@ async def update_application_instances( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2069,8 +2129,10 @@ async def sample_update_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2144,7 +2206,7 @@ async def list_drafts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDraftsAsyncPager: r"""Lists Drafts in a given project and location. @@ -2189,8 +2251,10 @@ async def sample_list_drafts(): 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, 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: google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsAsyncPager: @@ -2265,7 +2329,7 @@ async def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2306,8 +2370,10 @@ async def sample_get_draft(): 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, 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: google.cloud.visionai_v1.types.Draft: @@ -2368,7 +2434,7 @@ async def create_draft( draft_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Draft in a given project and location. @@ -2430,8 +2496,10 @@ async def sample_create_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2508,7 +2576,7 @@ async def update_draft( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Draft. @@ -2567,8 +2635,10 @@ async def sample_update_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2644,7 +2714,7 @@ async def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Draft. @@ -2689,8 +2759,10 @@ async def sample_delete_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2769,7 +2841,7 @@ async def list_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessorsAsyncPager: r"""Lists Processors in a given project and location. @@ -2814,8 +2886,10 @@ async def sample_list_processors(): 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, 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: google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsAsyncPager: @@ -2890,7 +2964,7 @@ async def list_prebuilt_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -2933,8 +3007,10 @@ async def sample_list_prebuilt_processors(): 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, 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: google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse: @@ -2995,7 +3071,7 @@ async def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3036,8 +3112,10 @@ async def sample_get_processor(): 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, 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: google.cloud.visionai_v1.types.Processor: @@ -3100,7 +3178,7 @@ async def create_processor( processor_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Processor in a given project and location. @@ -3163,8 +3241,10 @@ async def sample_create_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3240,7 +3320,7 @@ async def update_processor( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Processor. @@ -3299,8 +3379,10 @@ async def sample_update_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3375,7 +3457,7 @@ async def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Processor. @@ -3420,8 +3502,10 @@ async def sample_delete_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3499,7 +3583,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3510,8 +3594,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3552,7 +3638,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3563,8 +3649,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3605,7 +3693,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3621,8 +3709,10 @@ async def delete_operation( 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, 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: None """ @@ -3659,7 +3749,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3674,8 +3764,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py index 5f54a1eeff92..b69e79da45d5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -682,6 +692,10 @@ def __init__( # 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( @@ -744,6 +758,29 @@ def __init__( 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.visionai_v1.AppPlatformClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "credentialsType": None, + }, + ) + def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -751,7 +788,7 @@ def list_applications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApplicationsPager: r"""Lists Applications in a given project and location. @@ -796,8 +833,10 @@ def sample_list_applications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsPager: @@ -869,7 +908,7 @@ def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -910,8 +949,10 @@ def sample_get_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Application: @@ -968,7 +1009,7 @@ def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Application in a given project and location. @@ -1024,8 +1065,10 @@ def sample_create_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1097,7 +1140,7 @@ def update_application( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Application. @@ -1156,8 +1199,10 @@ def sample_update_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1230,7 +1275,7 @@ def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Application. @@ -1275,8 +1320,10 @@ def sample_delete_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1352,7 +1399,7 @@ def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deploys a single Application. @@ -1401,8 +1448,10 @@ def sample_deploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1470,7 +1519,7 @@ def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeploys a single Application. @@ -1520,8 +1569,10 @@ def sample_undeploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1592,7 +1643,7 @@ def add_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1645,8 +1696,10 @@ def sample_add_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1719,7 +1772,7 @@ def remove_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1772,8 +1825,10 @@ def sample_remove_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1846,7 +1901,7 @@ def update_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1899,8 +1954,10 @@ def sample_update_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1971,7 +2028,7 @@ def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesPager: r"""Lists Instances in a given project and location. @@ -2016,8 +2073,10 @@ def sample_list_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesPager: @@ -2089,7 +2148,7 @@ def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -2130,8 +2189,10 @@ def sample_get_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Instance: @@ -2191,7 +2252,7 @@ def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2249,8 +2310,10 @@ def sample_create_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2323,7 +2386,7 @@ def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -2377,8 +2440,10 @@ def sample_delete_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2455,7 +2520,7 @@ def update_application_instances( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2513,8 +2578,10 @@ def sample_update_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2587,7 +2654,7 @@ def list_drafts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDraftsPager: r"""Lists Drafts in a given project and location. @@ -2632,8 +2699,10 @@ def sample_list_drafts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsPager: @@ -2705,7 +2774,7 @@ def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2746,8 +2815,10 @@ def sample_get_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Draft: @@ -2805,7 +2876,7 @@ def create_draft( draft_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Draft in a given project and location. @@ -2867,8 +2938,10 @@ def sample_create_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2942,7 +3015,7 @@ def update_draft( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Draft. @@ -3001,8 +3074,10 @@ def sample_update_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3075,7 +3150,7 @@ def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Draft. @@ -3120,8 +3195,10 @@ def sample_delete_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3197,7 +3274,7 @@ def list_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessorsPager: r"""Lists Processors in a given project and location. @@ -3242,8 +3319,10 @@ def sample_list_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsPager: @@ -3315,7 +3394,7 @@ def list_prebuilt_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -3358,8 +3437,10 @@ def sample_list_prebuilt_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse: @@ -3417,7 +3498,7 @@ def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3458,8 +3539,10 @@ def sample_get_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Processor: @@ -3519,7 +3602,7 @@ def create_processor( processor_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Processor in a given project and location. @@ -3582,8 +3665,10 @@ def sample_create_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3656,7 +3741,7 @@ def update_processor( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Processor. @@ -3715,8 +3800,10 @@ def sample_update_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3788,7 +3875,7 @@ def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Processor. @@ -3833,8 +3920,10 @@ def sample_delete_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3922,7 +4011,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3933,8 +4022,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3975,7 +4066,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3986,8 +4077,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4028,7 +4121,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4044,8 +4137,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4082,7 +4177,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4097,8 +4192,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py index 3ebc5d8aabed..ca5d097251f5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListApplicationsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListApplicationsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListInstancesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListInstancesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListDraftsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListDraftsRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListProcessorsRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListProcessorsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py index 1d37ac4d0390..54d6f86d4a69 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport +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.visionai.v1.AppPlatform", + "rpcName": 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.visionai.v1.AppPlatform", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcTransport(AppPlatformTransport): """gRPC backend transport for AppPlatform. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -300,7 +388,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -327,7 +415,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -462,7 +550,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -496,7 +586,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -530,7 +620,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +646,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -582,7 +672,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -613,7 +703,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -644,7 +736,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -675,7 +769,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +797,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -725,7 +821,7 @@ def get_draft(self) -> Callable[[platform.GetDraftRequest], platform.Draft]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -751,7 +847,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -777,7 +873,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -803,7 +899,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +925,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -859,7 +955,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -885,7 +981,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -912,7 +1008,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1034,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1060,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1068,7 @@ def delete_processor( return self._stubs["delete_processor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -984,7 +1080,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1001,7 +1097,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1018,7 +1114,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1037,7 +1133,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py index 73c184c06dbc..e2e0d33fc07c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .grpc import AppPlatformGrpcTransport +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.visionai.v1.AppPlatform", + "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.visionai.v1.AppPlatform", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcAsyncIOTransport(AppPlatformTransport): """gRPC AsyncIO backend transport for AppPlatform. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -310,7 +395,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -339,7 +424,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -367,7 +452,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +604,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +639,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +667,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -606,7 +693,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -638,7 +725,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -670,7 +759,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +793,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +821,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -754,7 +847,7 @@ def get_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -780,7 +873,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -806,7 +899,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +925,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -860,7 +953,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -890,7 +983,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -916,7 +1009,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -945,7 +1038,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -973,7 +1066,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1094,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1169,7 +1262,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1185,7 +1278,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1202,7 +1295,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1219,7 +1312,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1238,7 +1331,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py index 8a838c3e6068..f7ac39bbab1c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/app_platform/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -281,8 +289,11 @@ def post_update_processor(self, response): def pre_add_application_stream_input( self, request: platform.AddApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.AddApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.AddApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_application_stream_input Override in a subclass to manipulate the request or metadata @@ -304,8 +315,10 @@ def post_add_application_stream_input( def pre_create_application( self, request: platform.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -327,8 +340,11 @@ def post_create_application( def pre_create_application_instances( self, request: platform.CreateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_application_instances Override in a subclass to manipulate the request or metadata @@ -348,8 +364,10 @@ def post_create_application_instances( return response def pre_create_draft( - self, request: platform.CreateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.CreateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_draft Override in a subclass to manipulate the request or metadata @@ -371,8 +389,10 @@ def post_create_draft( def pre_create_processor( self, request: platform.CreateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_processor Override in a subclass to manipulate the request or metadata @@ -394,8 +414,10 @@ def post_create_processor( def pre_delete_application( self, request: platform.DeleteApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_application Override in a subclass to manipulate the request or metadata @@ -417,8 +439,11 @@ def post_delete_application( def pre_delete_application_instances( self, request: platform.DeleteApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_application_instances Override in a subclass to manipulate the request or metadata @@ -438,8 +463,10 @@ def post_delete_application_instances( return response def pre_delete_draft( - self, request: platform.DeleteDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.DeleteDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_draft Override in a subclass to manipulate the request or metadata @@ -461,8 +488,10 @@ def post_delete_draft( def pre_delete_processor( self, request: platform.DeleteProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_processor Override in a subclass to manipulate the request or metadata @@ -484,8 +513,10 @@ def post_delete_processor( def pre_deploy_application( self, request: platform.DeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for deploy_application Override in a subclass to manipulate the request or metadata @@ -507,8 +538,8 @@ def post_deploy_application( def pre_get_application( self, request: platform.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -528,8 +559,10 @@ def post_get_application( return response def pre_get_draft( - self, request: platform.GetDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_draft Override in a subclass to manipulate the request or metadata @@ -547,8 +580,10 @@ def post_get_draft(self, response: platform.Draft) -> platform.Draft: return response def pre_get_instance( - self, request: platform.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +601,10 @@ def post_get_instance(self, response: platform.Instance) -> platform.Instance: return response def pre_get_processor( - self, request: platform.GetProcessorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetProcessorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_processor Override in a subclass to manipulate the request or metadata @@ -587,8 +624,10 @@ def post_get_processor(self, response: platform.Processor) -> platform.Processor def pre_list_applications( self, request: platform.ListApplicationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListApplicationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListApplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_applications Override in a subclass to manipulate the request or metadata @@ -608,8 +647,10 @@ def post_list_applications( return response def pre_list_drafts( - self, request: platform.ListDraftsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.ListDraftsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_drafts Override in a subclass to manipulate the request or metadata @@ -631,8 +672,8 @@ def post_list_drafts( def pre_list_instances( self, request: platform.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -654,8 +695,10 @@ def post_list_instances( def pre_list_prebuilt_processors( self, request: platform.ListPrebuiltProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_prebuilt_processors Override in a subclass to manipulate the request or metadata @@ -677,8 +720,8 @@ def post_list_prebuilt_processors( def pre_list_processors( self, request: platform.ListProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_processors Override in a subclass to manipulate the request or metadata @@ -700,8 +743,11 @@ def post_list_processors( def pre_remove_application_stream_input( self, request: platform.RemoveApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.RemoveApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.RemoveApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_application_stream_input Override in a subclass to manipulate the request or metadata @@ -723,8 +769,10 @@ def post_remove_application_stream_input( def pre_undeploy_application( self, request: platform.UndeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UndeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UndeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undeploy_application Override in a subclass to manipulate the request or metadata @@ -746,8 +794,10 @@ def post_undeploy_application( def pre_update_application( self, request: platform.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -769,8 +819,11 @@ def post_update_application( def pre_update_application_instances( self, request: platform.UpdateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_instances Override in a subclass to manipulate the request or metadata @@ -792,8 +845,11 @@ def post_update_application_instances( def pre_update_application_stream_input( self, request: platform.UpdateApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_stream_input Override in a subclass to manipulate the request or metadata @@ -813,8 +869,10 @@ def post_update_application_stream_input( return response def pre_update_draft( - self, request: platform.UpdateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.UpdateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_draft Override in a subclass to manipulate the request or metadata @@ -836,8 +894,10 @@ def post_update_draft( def pre_update_processor( self, request: platform.UpdateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_processor Override in a subclass to manipulate the request or metadata @@ -859,8 +919,10 @@ def post_update_processor( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -880,8 +942,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -901,8 +965,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -924,8 +990,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1149,7 +1217,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add application stream input method over HTTP. @@ -1161,8 +1229,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1175,6 +1245,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseAddApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_add_application_stream_input( request, metadata ) @@ -1191,6 +1262,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.AddApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._AddApplicationStreamInput._get_response( @@ -1212,7 +1310,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_application_stream_input(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.visionai_v1.AppPlatformClient.add_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplication( @@ -1250,7 +1370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create application method over HTTP. @@ -1260,8 +1380,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1274,6 +1396,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -1290,6 +1413,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.CreateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateApplication._get_response( self._host, @@ -1309,7 +1459,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_application(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.visionai_v1.AppPlatformClient.create_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplicationInstances( @@ -1348,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create application instances method over HTTP. @@ -1360,8 +1532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1374,6 +1548,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_application_instances( request, metadata ) @@ -1390,6 +1565,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.CreateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._CreateApplicationInstances._get_response( @@ -1411,7 +1613,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_application_instances(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.visionai_v1.AppPlatformClient.create_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDraft( @@ -1449,7 +1673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create draft method over HTTP. @@ -1459,8 +1683,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1473,6 +1699,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_create_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_transcoded_request( @@ -1493,6 +1720,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.CreateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateDraft._get_response( self._host, @@ -1512,7 +1766,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_draft(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.visionai_v1.AppPlatformClient.create_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcessor( @@ -1550,7 +1826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create processor method over HTTP. @@ -1560,8 +1836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1574,6 +1852,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_create_processor( request, metadata ) @@ -1590,6 +1869,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.CreateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateProcessor._get_response( self._host, @@ -1609,7 +1915,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_processor(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.visionai_v1.AppPlatformClient.create_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CreateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplication( @@ -1646,7 +1974,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application method over HTTP. @@ -1656,8 +1984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1670,6 +2000,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplication._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application( request, metadata ) @@ -1682,6 +2013,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.DeleteApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteApplication._get_response( self._host, @@ -1700,7 +2058,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_application(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.visionai_v1.AppPlatformClient.delete_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplicationInstances( @@ -1739,7 +2119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application instances method over HTTP. @@ -1751,8 +2131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1765,6 +2147,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application_instances( request, metadata ) @@ -1781,6 +2164,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.DeleteApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._DeleteApplicationInstances._get_response( @@ -1802,7 +2212,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_application_instances(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.visionai_v1.AppPlatformClient.delete_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDraft( @@ -1839,7 +2271,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete draft method over HTTP. @@ -1849,8 +2281,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1863,6 +2297,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_http_options() ) + request, metadata = self._interceptor.pre_delete_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_transcoded_request( @@ -1877,6 +2312,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.DeleteDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteDraft._get_response( self._host, @@ -1895,7 +2357,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_draft(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.visionai_v1.AppPlatformClient.delete_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcessor( @@ -1932,7 +2416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete processor method over HTTP. @@ -1942,8 +2426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1956,6 +2442,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_processor( request, metadata ) @@ -1968,6 +2455,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.DeleteProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteProcessor._get_response( self._host, @@ -1986,7 +2500,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_processor(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.visionai_v1.AppPlatformClient.delete_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployApplication( @@ -2024,7 +2560,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy application method over HTTP. @@ -2034,8 +2570,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2048,6 +2586,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_application( request, metadata ) @@ -2064,6 +2603,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.DeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeployApplication._get_response( self._host, @@ -2083,7 +2649,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_application(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.visionai_v1.AppPlatformClient.deploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication( @@ -2120,7 +2708,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Call the get application method over HTTP. @@ -2130,8 +2718,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Application: @@ -2141,6 +2731,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseGetApplication._get_transcoded_request( http_options, request @@ -2151,6 +2742,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.GetApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetApplication._get_response( self._host, @@ -2171,7 +2789,29 @@ def __call__( pb_resp = platform.Application.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Application.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.visionai_v1.AppPlatformClient.get_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDraft(_BaseAppPlatformRestTransport._BaseGetDraft, AppPlatformRestStub): @@ -2206,7 +2846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Call the get draft method over HTTP. @@ -2216,8 +2856,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Draft: @@ -2227,6 +2869,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_http_options() ) + request, metadata = self._interceptor.pre_get_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_transcoded_request( @@ -2241,6 +2884,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.GetDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetDraft._get_response( self._host, @@ -2261,7 +2931,29 @@ def __call__( pb_resp = platform.Draft.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Draft.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.visionai_v1.AppPlatformClient.get_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2298,7 +2990,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Call the get instance method over HTTP. @@ -2308,8 +3000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Instance: @@ -2321,6 +3015,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_transcoded_request( @@ -2335,6 +3030,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.GetInstance", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetInstance._get_response( self._host, @@ -2355,7 +3077,29 @@ def __call__( pb_resp = platform.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Instance.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.visionai_v1.AppPlatformClient.get_instance", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcessor( @@ -2392,7 +3136,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Call the get processor method over HTTP. @@ -2402,8 +3146,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Processor: @@ -2415,6 +3161,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_get_processor(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_transcoded_request( @@ -2429,6 +3176,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.GetProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetProcessor._get_response( self._host, @@ -2449,7 +3223,29 @@ def __call__( pb_resp = platform.Processor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Processor.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.visionai_v1.AppPlatformClient.get_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApplications( @@ -2486,7 +3282,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListApplicationsResponse: r"""Call the list applications method over HTTP. @@ -2497,8 +3293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListApplicationsResponse: @@ -2510,6 +3308,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListApplications._get_http_options() ) + request, metadata = self._interceptor.pre_list_applications( request, metadata ) @@ -2522,6 +3321,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.ListApplications", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListApplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListApplications._get_response( self._host, @@ -2542,7 +3368,31 @@ def __call__( pb_resp = platform.ListApplicationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_applications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListApplicationsResponse.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.visionai_v1.AppPlatformClient.list_applications", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListApplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDrafts( @@ -2579,7 +3429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListDraftsResponse: r"""Call the list drafts method over HTTP. @@ -2590,8 +3440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListDraftsResponse: @@ -2603,6 +3455,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_http_options() ) + request, metadata = self._interceptor.pre_list_drafts(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_transcoded_request( @@ -2617,6 +3470,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.ListDrafts", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListDrafts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListDrafts._get_response( self._host, @@ -2637,7 +3517,29 @@ def __call__( pb_resp = platform.ListDraftsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_drafts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListDraftsResponse.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.visionai_v1.AppPlatformClient.list_drafts", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListDrafts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -2674,7 +3576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -2685,8 +3587,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListInstancesResponse: @@ -2698,6 +3602,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -2710,6 +3615,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.ListInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListInstances._get_response( self._host, @@ -2730,7 +3662,29 @@ def __call__( pb_resp = platform.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListInstancesResponse.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.visionai_v1.AppPlatformClient.list_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrebuiltProcessors( @@ -2768,7 +3722,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""Call the list prebuilt processors method over HTTP. @@ -2779,8 +3733,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListPrebuiltProcessorsResponse: @@ -2792,6 +3748,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListPrebuiltProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_prebuilt_processors( request, metadata ) @@ -2808,6 +3765,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.ListPrebuiltProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListPrebuiltProcessors._get_response( self._host, @@ -2829,7 +3813,31 @@ def __call__( pb_resp = platform.ListPrebuiltProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_prebuilt_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListPrebuiltProcessorsResponse.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.visionai_v1.AppPlatformClient.list_prebuilt_processors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcessors( @@ -2866,7 +3874,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListProcessorsResponse: r"""Call the list processors method over HTTP. @@ -2877,8 +3885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListProcessorsResponse: @@ -2890,6 +3900,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_processors(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListProcessors._get_transcoded_request( http_options, request @@ -2900,6 +3911,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.ListProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListProcessors._get_response( self._host, @@ -2920,7 +3958,29 @@ def __call__( pb_resp = platform.ListProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListProcessorsResponse.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.visionai_v1.AppPlatformClient.list_processors", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveApplicationStreamInput( @@ -2959,7 +4019,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove application stream input method over HTTP. @@ -2971,8 +4031,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2985,6 +4047,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseRemoveApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_remove_application_stream_input( request, metadata ) @@ -3001,6 +4064,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.RemoveApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._RemoveApplicationStreamInput._get_response( @@ -3022,7 +4112,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_application_stream_input(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.visionai_v1.AppPlatformClient.remove_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployApplication( @@ -3060,7 +4172,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy application method over HTTP. @@ -3071,8 +4183,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3085,6 +4199,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUndeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_application( request, metadata ) @@ -3101,6 +4216,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.UndeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UndeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UndeployApplication._get_response( self._host, @@ -3120,7 +4262,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_application(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.visionai_v1.AppPlatformClient.undeploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UndeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -3158,7 +4322,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application method over HTTP. @@ -3168,8 +4332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3182,6 +4348,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -3198,6 +4365,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.UpdateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateApplication._get_response( self._host, @@ -3217,7 +4411,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application(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.visionai_v1.AppPlatformClient.update_application", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationInstances( @@ -3256,7 +4472,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application instances method over HTTP. @@ -3268,8 +4484,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3282,6 +4500,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_instances( request, metadata ) @@ -3298,6 +4517,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.UpdateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationInstances._get_response( @@ -3319,7 +4565,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application_instances(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.visionai_v1.AppPlatformClient.update_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationStreamInput( @@ -3358,7 +4626,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application stream input method over HTTP. @@ -3370,8 +4638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3384,6 +4654,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_stream_input( request, metadata ) @@ -3400,6 +4671,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.UpdateApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationStreamInput._get_response( @@ -3421,7 +4719,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application_stream_input(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.visionai_v1.AppPlatformClient.update_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDraft( @@ -3459,7 +4779,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update draft method over HTTP. @@ -3469,8 +4789,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3483,6 +4805,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_update_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_transcoded_request( @@ -3503,6 +4826,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.UpdateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateDraft._get_response( self._host, @@ -3522,7 +4872,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_draft(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.visionai_v1.AppPlatformClient.update_draft", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcessor( @@ -3560,7 +4932,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update processor method over HTTP. @@ -3570,8 +4942,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3584,6 +4958,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_update_processor( request, metadata ) @@ -3600,6 +4975,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.UpdateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateProcessor._get_response( self._host, @@ -3619,7 +5021,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_processor(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.visionai_v1.AppPlatformClient.update_processor", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "UpdateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3884,7 +5308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3894,13 +5318,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAppPlatformRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3917,6 +5344,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CancelOperation._get_response( self._host, @@ -3973,7 +5427,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3983,13 +5437,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAppPlatformRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4002,6 +5459,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteOperation._get_response( self._host, @@ -4057,7 +5541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4067,8 +5551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -4077,6 +5563,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_transcoded_request( @@ -4091,6 +5578,33 @@ def __call__( ) ) + 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.visionai_v1.AppPlatformClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetOperation._get_response( self._host, @@ -4110,6 +5624,27 @@ def __call__( 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.visionai_v1.AppPlatformAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4150,7 +5685,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4160,8 +5695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4170,6 +5707,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4180,6 +5718,33 @@ def __call__( 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.visionai_v1.AppPlatformClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListOperations._get_response( self._host, @@ -4199,6 +5764,27 @@ def __call__( 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.visionai_v1.AppPlatformAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.AppPlatform", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py index 13159bd850aa..7b2cdd7cd582 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, HealthCheckServiceTransport from .transports.grpc_asyncio import HealthCheckServiceGrpcAsyncIOTransport +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 HealthCheckServiceAsyncClient: """HealthCheckService provides an interface for Vertex AI Vision @@ -264,13 +274,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.HealthCheckServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "credentialsType": None, + }, + ) + async def health_check( self, request: Optional[Union[health_service.HealthCheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> health_service.HealthCheckResponse: r"""HealthCheck method checks the health status of the cluster. @@ -307,8 +339,10 @@ async def sample_health_check(): 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, 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: google.cloud.visionai_v1.types.HealthCheckResponse: @@ -354,7 +388,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -365,8 +399,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -407,7 +443,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -418,8 +454,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -460,7 +498,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -476,8 +514,10 @@ async def delete_operation( 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, 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: None """ @@ -514,7 +554,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -529,8 +569,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py index 0f8e5214449b..ca4030762e7c 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -588,6 +598,10 @@ def __init__( # 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( @@ -654,13 +668,36 @@ def __init__( 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.visionai_v1.HealthCheckServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "credentialsType": None, + }, + ) + def health_check( self, request: Optional[Union[health_service.HealthCheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> health_service.HealthCheckResponse: r"""HealthCheck method checks the health status of the cluster. @@ -697,8 +734,10 @@ def sample_health_check(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.HealthCheckResponse: @@ -755,7 +794,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -766,8 +805,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -808,7 +849,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -819,8 +860,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -861,7 +904,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -877,8 +920,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -915,7 +960,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -930,8 +975,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py index bd92d1e3455f..fa2c91f7de9b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import health_service from .base import DEFAULT_CLIENT_INFO, HealthCheckServiceTransport +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.visionai.v1.HealthCheckService", + "rpcName": 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.visionai.v1.HealthCheckService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HealthCheckServiceGrpcTransport(HealthCheckServiceTransport): """gRPC backend transport for HealthCheckService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def health_check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "health_check" not in self._stubs: - self._stubs["health_check"] = self.grpc_channel.unary_unary( + self._stubs["health_check"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.HealthCheckService/HealthCheck", request_serializer=health_service.HealthCheckRequest.serialize, response_deserializer=health_service.HealthCheckResponse.deserialize, @@ -269,7 +355,7 @@ def health_check( return self._stubs["health_check"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -281,7 +367,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -298,7 +384,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -315,7 +401,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -334,7 +420,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py index 3ac0415dba00..d5559a1d4c09 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import health_service from .base import DEFAULT_CLIENT_INFO, HealthCheckServiceTransport from .grpc import HealthCheckServiceGrpcTransport +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.visionai.v1.HealthCheckService", + "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.visionai.v1.HealthCheckService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HealthCheckServiceGrpcAsyncIOTransport(HealthCheckServiceTransport): """gRPC AsyncIO backend transport for HealthCheckService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def health_check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "health_check" not in self._stubs: - self._stubs["health_check"] = self.grpc_channel.unary_unary( + self._stubs["health_check"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.HealthCheckService/HealthCheck", request_serializer=health_service.HealthCheckRequest.serialize, response_deserializer=health_service.HealthCheckResponse.deserialize, @@ -313,7 +398,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -329,7 +414,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -346,7 +431,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -363,7 +448,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -382,7 +467,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py index c224591dae3e..b40ac0368cb7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/health_check_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -81,8 +89,10 @@ def post_health_check(self, response): def pre_health_check( self, request: health_service.HealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[health_service.HealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + health_service.HealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for health_check Override in a subclass to manipulate the request or metadata @@ -104,8 +114,10 @@ def post_health_check( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +137,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -146,8 +160,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -169,8 +185,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -312,7 +330,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> health_service.HealthCheckResponse: r"""Call the health check method over HTTP. @@ -323,8 +341,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.health_service.HealthCheckResponse: @@ -336,6 +356,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseHealthCheck._get_http_options() ) + request, metadata = self._interceptor.pre_health_check(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseHealthCheck._get_transcoded_request( http_options, request @@ -346,6 +367,33 @@ def __call__( 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.visionai_v1.HealthCheckServiceClient.HealthCheck", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "HealthCheck", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._HealthCheck._get_response( self._host, @@ -366,7 +414,31 @@ def __call__( pb_resp = health_service.HealthCheckResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_health_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = health_service.HealthCheckResponse.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.visionai_v1.HealthCheckServiceClient.health_check", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "HealthCheck", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -419,7 +491,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -429,13 +501,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseHealthCheckServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -452,6 +527,33 @@ def __call__( 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.visionai_v1.HealthCheckServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._CancelOperation._get_response( self._host, @@ -509,7 +611,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -519,13 +621,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseHealthCheckServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -538,6 +643,33 @@ def __call__( 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.visionai_v1.HealthCheckServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._DeleteOperation._get_response( self._host, @@ -594,7 +726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -604,8 +736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -614,6 +748,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -624,6 +759,33 @@ def __call__( 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.visionai_v1.HealthCheckServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._GetOperation._get_response( self._host, @@ -643,6 +805,27 @@ def __call__( 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.visionai_v1.HealthCheckServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -684,7 +867,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -694,8 +877,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -704,6 +889,7 @@ def __call__( http_options = ( _BaseHealthCheckServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseHealthCheckServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -714,6 +900,33 @@ def __call__( 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.visionai_v1.HealthCheckServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthCheckServiceRestTransport._ListOperations._get_response( self._host, @@ -733,6 +946,27 @@ def __call__( 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.visionai_v1.HealthCheckServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.HealthCheckService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py index 21056dfe8680..1b74cadbfd27 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .transports.grpc_asyncio import LiveVideoAnalyticsGrpcAsyncIOTransport +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 LiveVideoAnalyticsAsyncClient: """Service describing handlers for resources. The service @@ -277,6 +287,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.LiveVideoAnalyticsAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + async def list_public_operators( self, request: Optional[Union[lva_service.ListPublicOperatorsRequest, dict]] = None, @@ -284,7 +316,7 @@ async def list_public_operators( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicOperatorsAsyncPager: r"""ListPublicOperators returns all the operators in public registry. @@ -330,8 +362,10 @@ async def sample_list_public_operators(): 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, 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsAsyncPager: @@ -407,7 +441,7 @@ async def resolve_operator_info( queries: Optional[MutableSequence[lva_service.OperatorQuery]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""ResolveOperatorInfo returns the operator information based on the request. @@ -461,8 +495,10 @@ async def sample_resolve_operator_info(): 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, 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: google.cloud.visionai_v1.types.ResolveOperatorInfoResponse: @@ -525,7 +561,7 @@ async def list_operators( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOperatorsAsyncPager: r"""Lists Operators in a given project and location. @@ -570,8 +606,10 @@ async def sample_list_operators(): 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, 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsAsyncPager: @@ -646,7 +684,7 @@ async def get_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Gets details of a single Operator. @@ -687,8 +725,10 @@ async def sample_get_operator(): 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, 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: google.cloud.visionai_v1.types.Operator: @@ -751,7 +791,7 @@ async def create_operator( operator_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Operator in a given project and location. @@ -810,8 +850,10 @@ async def sample_create_operator(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -888,7 +930,7 @@ async def update_operator( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Operator. @@ -943,8 +985,10 @@ async def sample_update_operator(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1020,7 +1064,7 @@ async def delete_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Operator. @@ -1065,8 +1109,10 @@ async def sample_delete_operator(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1145,7 +1191,7 @@ async def list_analyses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalysesAsyncPager: r"""Lists Analyses in a given project and location. @@ -1190,8 +1236,10 @@ async def sample_list_analyses(): 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, 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesAsyncPager: @@ -1266,7 +1314,7 @@ async def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -1307,8 +1355,10 @@ async def sample_get_analysis(): 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, 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: google.cloud.visionai_v1.types.Analysis: @@ -1371,7 +1421,7 @@ async def create_analysis( analysis_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Analysis in a given project and location. @@ -1430,8 +1480,10 @@ async def sample_create_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1508,7 +1560,7 @@ async def update_analysis( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Analysis. @@ -1563,8 +1615,10 @@ async def sample_update_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1640,7 +1694,7 @@ async def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Analysis. @@ -1685,8 +1739,10 @@ async def sample_delete_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1765,7 +1821,7 @@ async def list_processes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessesAsyncPager: r"""Lists Processes in a given project and location. @@ -1810,8 +1866,10 @@ async def sample_list_processes(): 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, 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesAsyncPager: @@ -1886,7 +1944,7 @@ async def get_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Process: r"""Gets details of a single Process. @@ -1927,8 +1985,10 @@ async def sample_get_process(): 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, 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: google.cloud.visionai_v1.types.Process: @@ -1991,7 +2051,7 @@ async def create_process( process_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Process in a given project and location. @@ -2054,8 +2114,10 @@ async def sample_create_process(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2132,7 +2194,7 @@ async def update_process( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Process. @@ -2191,8 +2253,10 @@ async def sample_update_process(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2268,7 +2332,7 @@ async def delete_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Process. @@ -2313,8 +2377,10 @@ async def sample_delete_process(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2394,7 +2460,7 @@ async def batch_run_process( requests: Optional[MutableSequence[lva_service.CreateProcessRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Run all of the processes to "completion". Max time for each process is the LRO time limit. @@ -2456,8 +2522,10 @@ async def sample_batch_run_process(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2530,7 +2598,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2541,8 +2609,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2583,7 +2653,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2594,8 +2664,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2636,7 +2708,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2652,8 +2724,10 @@ async def delete_operation( 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, 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: None """ @@ -2690,7 +2764,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2705,8 +2779,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py index 9249645a2a0d..45f7465972b7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -665,6 +675,10 @@ def __init__( # 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( @@ -731,6 +745,29 @@ def __init__( 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.visionai_v1.LiveVideoAnalyticsClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + def list_public_operators( self, request: Optional[Union[lva_service.ListPublicOperatorsRequest, dict]] = None, @@ -738,7 +775,7 @@ def list_public_operators( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicOperatorsPager: r"""ListPublicOperators returns all the operators in public registry. @@ -784,8 +821,10 @@ def sample_list_public_operators(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsPager: @@ -858,7 +897,7 @@ def resolve_operator_info( queries: Optional[MutableSequence[lva_service.OperatorQuery]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""ResolveOperatorInfo returns the operator information based on the request. @@ -912,8 +951,10 @@ def sample_resolve_operator_info(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.ResolveOperatorInfoResponse: @@ -973,7 +1014,7 @@ def list_operators( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOperatorsPager: r"""Lists Operators in a given project and location. @@ -1018,8 +1059,10 @@ def sample_list_operators(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsPager: @@ -1091,7 +1134,7 @@ def get_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Gets details of a single Operator. @@ -1132,8 +1175,10 @@ def sample_get_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Operator: @@ -1193,7 +1238,7 @@ def create_operator( operator_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Operator in a given project and location. @@ -1252,8 +1297,10 @@ def sample_create_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1327,7 +1374,7 @@ def update_operator( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Operator. @@ -1382,8 +1429,10 @@ def sample_update_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1456,7 +1505,7 @@ def delete_operator( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Operator. @@ -1501,8 +1550,10 @@ def sample_delete_operator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1578,7 +1629,7 @@ def list_analyses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalysesPager: r"""Lists Analyses in a given project and location. @@ -1623,8 +1674,10 @@ def sample_list_analyses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1.services.live_video_analytics.pagers.ListAnalysesPager: @@ -1696,7 +1749,7 @@ def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -1737,8 +1790,10 @@ def sample_get_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1.types.Analysis: @@ -1798,7 +1853,7 @@ def create_analysis( analysis_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Analysis in a given project and location. @@ -1857,8 +1912,10 @@ def sample_create_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1932,7 +1989,7 @@ def update_analysis( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Analysis. @@ -1987,8 +2044,10 @@ def sample_update_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -2061,7 +2120,7 @@ def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Analysis. @@ -2106,8 +2165,10 @@ def sample_delete_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -2183,7 +2244,7 @@ def list_processes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessesPager: r"""Lists Processes in a given project and location. @@ -2228,8 +2289,10 @@ def sample_list_processes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesPager: @@ -2301,7 +2364,7 @@ def get_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Process: r"""Gets details of a single Process. @@ -2342,8 +2405,10 @@ def sample_get_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Process: @@ -2403,7 +2468,7 @@ def create_process( process_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Process in a given project and location. @@ -2466,8 +2531,10 @@ def sample_create_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2541,7 +2608,7 @@ def update_process( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Process. @@ -2600,8 +2667,10 @@ def sample_update_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2674,7 +2743,7 @@ def delete_process( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Process. @@ -2719,8 +2788,10 @@ def sample_delete_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2797,7 +2868,7 @@ def batch_run_process( requests: Optional[MutableSequence[lva_service.CreateProcessRequest]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Run all of the processes to "completion". Max time for each process is the LRO time limit. @@ -2859,8 +2930,10 @@ def sample_batch_run_process(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2943,7 +3016,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2954,8 +3027,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2996,7 +3071,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3007,8 +3082,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3049,7 +3126,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3065,8 +3142,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3103,7 +3182,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3118,8 +3197,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py index f19e538a9810..ea344017d17e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = lva_service.ListPublicOperatorsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = lva_service.ListPublicOperatorsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = lva_service.ListOperatorsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = lva_service.ListOperatorsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = lva_service.ListAnalysesRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = lva_service.ListAnalysesRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = lva_service.ListProcessesRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = lva_service.ListProcessesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py index 2f35b2804e26..2725fee93a5b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport +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.visionai.v1.LiveVideoAnalytics", + "rpcName": 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.visionai.v1.LiveVideoAnalytics", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcTransport(LiveVideoAnalyticsTransport): """gRPC backend transport for LiveVideoAnalytics. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def list_public_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_operators" not in self._stubs: - self._stubs["list_public_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_public_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListPublicOperators", request_serializer=lva_service.ListPublicOperatorsRequest.serialize, response_deserializer=lva_service.ListPublicOperatorsResponse.deserialize, @@ -308,7 +396,7 @@ def resolve_operator_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_operator_info" not in self._stubs: - self._stubs["resolve_operator_info"] = self.grpc_channel.unary_unary( + self._stubs["resolve_operator_info"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ResolveOperatorInfo", request_serializer=lva_service.ResolveOperatorInfoRequest.serialize, response_deserializer=lva_service.ResolveOperatorInfoResponse.deserialize, @@ -336,7 +424,7 @@ def list_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operators" not in self._stubs: - self._stubs["list_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListOperators", request_serializer=lva_service.ListOperatorsRequest.serialize, response_deserializer=lva_service.ListOperatorsResponse.deserialize, @@ -362,7 +450,7 @@ def get_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operator" not in self._stubs: - self._stubs["get_operator"] = self.grpc_channel.unary_unary( + self._stubs["get_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetOperator", request_serializer=lva_service.GetOperatorRequest.serialize, response_deserializer=lva_resources.Operator.deserialize, @@ -389,7 +477,7 @@ def create_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_operator" not in self._stubs: - self._stubs["create_operator"] = self.grpc_channel.unary_unary( + self._stubs["create_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateOperator", request_serializer=lva_service.CreateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +503,7 @@ def update_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_operator" not in self._stubs: - self._stubs["update_operator"] = self.grpc_channel.unary_unary( + self._stubs["update_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateOperator", request_serializer=lva_service.UpdateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +529,7 @@ def delete_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operator" not in self._stubs: - self._stubs["delete_operator"] = self.grpc_channel.unary_unary( + self._stubs["delete_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteOperator", request_serializer=lva_service.DeleteOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -467,7 +555,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -493,7 +581,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -520,7 +608,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -546,7 +634,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -572,7 +660,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +688,7 @@ def list_processes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processes" not in self._stubs: - self._stubs["list_processes"] = self.grpc_channel.unary_unary( + self._stubs["list_processes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListProcesses", request_serializer=lva_service.ListProcessesRequest.serialize, response_deserializer=lva_service.ListProcessesResponse.deserialize, @@ -626,7 +714,7 @@ def get_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_process" not in self._stubs: - self._stubs["get_process"] = self.grpc_channel.unary_unary( + self._stubs["get_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetProcess", request_serializer=lva_service.GetProcessRequest.serialize, response_deserializer=lva_resources.Process.deserialize, @@ -653,7 +741,7 @@ def create_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_process" not in self._stubs: - self._stubs["create_process"] = self.grpc_channel.unary_unary( + self._stubs["create_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateProcess", request_serializer=lva_service.CreateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +767,7 @@ def update_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_process" not in self._stubs: - self._stubs["update_process"] = self.grpc_channel.unary_unary( + self._stubs["update_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateProcess", request_serializer=lva_service.UpdateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -705,7 +793,7 @@ def delete_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_process" not in self._stubs: - self._stubs["delete_process"] = self.grpc_channel.unary_unary( + self._stubs["delete_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteProcess", request_serializer=lva_service.DeleteProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -732,7 +820,7 @@ def batch_run_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_process" not in self._stubs: - self._stubs["batch_run_process"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/BatchRunProcess", request_serializer=lva_service.BatchRunProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -740,7 +828,7 @@ def batch_run_process( return self._stubs["batch_run_process"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -752,7 +840,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -769,7 +857,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -786,7 +874,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -805,7 +893,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py index ddf5373e05ea..c8dddc3b58b3 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .grpc import LiveVideoAnalyticsGrpcTransport +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.visionai.v1.LiveVideoAnalytics", + "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.visionai.v1.LiveVideoAnalytics", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcAsyncIOTransport(LiveVideoAnalyticsTransport): """gRPC AsyncIO backend transport for LiveVideoAnalytics. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def list_public_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_operators" not in self._stubs: - self._stubs["list_public_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_public_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListPublicOperators", request_serializer=lva_service.ListPublicOperatorsRequest.serialize, response_deserializer=lva_service.ListPublicOperatorsResponse.deserialize, @@ -318,7 +403,7 @@ def resolve_operator_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_operator_info" not in self._stubs: - self._stubs["resolve_operator_info"] = self.grpc_channel.unary_unary( + self._stubs["resolve_operator_info"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ResolveOperatorInfo", request_serializer=lva_service.ResolveOperatorInfoRequest.serialize, response_deserializer=lva_service.ResolveOperatorInfoResponse.deserialize, @@ -346,7 +431,7 @@ def list_operators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operators" not in self._stubs: - self._stubs["list_operators"] = self.grpc_channel.unary_unary( + self._stubs["list_operators"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListOperators", request_serializer=lva_service.ListOperatorsRequest.serialize, response_deserializer=lva_service.ListOperatorsResponse.deserialize, @@ -372,7 +457,7 @@ def get_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operator" not in self._stubs: - self._stubs["get_operator"] = self.grpc_channel.unary_unary( + self._stubs["get_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetOperator", request_serializer=lva_service.GetOperatorRequest.serialize, response_deserializer=lva_resources.Operator.deserialize, @@ -401,7 +486,7 @@ def create_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_operator" not in self._stubs: - self._stubs["create_operator"] = self.grpc_channel.unary_unary( + self._stubs["create_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateOperator", request_serializer=lva_service.CreateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def update_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_operator" not in self._stubs: - self._stubs["update_operator"] = self.grpc_channel.unary_unary( + self._stubs["update_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateOperator", request_serializer=lva_service.UpdateOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +542,7 @@ def delete_operator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operator" not in self._stubs: - self._stubs["delete_operator"] = self.grpc_channel.unary_unary( + self._stubs["delete_operator"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteOperator", request_serializer=lva_service.DeleteOperatorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -511,7 +596,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -540,7 +625,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -568,7 +653,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -596,7 +681,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def list_processes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processes" not in self._stubs: - self._stubs["list_processes"] = self.grpc_channel.unary_unary( + self._stubs["list_processes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/ListProcesses", request_serializer=lva_service.ListProcessesRequest.serialize, response_deserializer=lva_service.ListProcessesResponse.deserialize, @@ -650,7 +735,7 @@ def get_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_process" not in self._stubs: - self._stubs["get_process"] = self.grpc_channel.unary_unary( + self._stubs["get_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/GetProcess", request_serializer=lva_service.GetProcessRequest.serialize, response_deserializer=lva_resources.Process.deserialize, @@ -679,7 +764,7 @@ def create_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_process" not in self._stubs: - self._stubs["create_process"] = self.grpc_channel.unary_unary( + self._stubs["create_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/CreateProcess", request_serializer=lva_service.CreateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +792,7 @@ def update_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_process" not in self._stubs: - self._stubs["update_process"] = self.grpc_channel.unary_unary( + self._stubs["update_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/UpdateProcess", request_serializer=lva_service.UpdateProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -735,7 +820,7 @@ def delete_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_process" not in self._stubs: - self._stubs["delete_process"] = self.grpc_channel.unary_unary( + self._stubs["delete_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/DeleteProcess", request_serializer=lva_service.DeleteProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -764,7 +849,7 @@ def batch_run_process( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_process" not in self._stubs: - self._stubs["batch_run_process"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_process"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.LiveVideoAnalytics/BatchRunProcess", request_serializer=lva_service.BatchRunProcessRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -892,7 +977,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -908,7 +993,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -925,7 +1010,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -942,7 +1027,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -961,7 +1046,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py index dd2934cf70d9..03adc94ff4e8 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/live_video_analytics/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -217,8 +225,10 @@ def post_update_process(self, response): def pre_batch_run_process( self, request: lva_service.BatchRunProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.BatchRunProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.BatchRunProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_run_process Override in a subclass to manipulate the request or metadata @@ -240,8 +250,10 @@ def post_batch_run_process( def pre_create_analysis( self, request: lva_service.CreateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_analysis Override in a subclass to manipulate the request or metadata @@ -263,8 +275,10 @@ def post_create_analysis( def pre_create_operator( self, request: lva_service.CreateOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_operator Override in a subclass to manipulate the request or metadata @@ -286,8 +300,10 @@ def post_create_operator( def pre_create_process( self, request: lva_service.CreateProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_process Override in a subclass to manipulate the request or metadata @@ -309,8 +325,10 @@ def post_create_process( def pre_delete_analysis( self, request: lva_service.DeleteAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_analysis Override in a subclass to manipulate the request or metadata @@ -332,8 +350,10 @@ def post_delete_analysis( def pre_delete_operator( self, request: lva_service.DeleteOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operator Override in a subclass to manipulate the request or metadata @@ -355,8 +375,10 @@ def post_delete_operator( def pre_delete_process( self, request: lva_service.DeleteProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_process Override in a subclass to manipulate the request or metadata @@ -378,8 +400,8 @@ def post_delete_process( def pre_get_analysis( self, request: lva_service.GetAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_analysis Override in a subclass to manipulate the request or metadata @@ -401,8 +423,8 @@ def post_get_analysis( def pre_get_operator( self, request: lva_service.GetOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_operator Override in a subclass to manipulate the request or metadata @@ -424,8 +446,8 @@ def post_get_operator( def pre_get_process( self, request: lva_service.GetProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetProcessRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_process Override in a subclass to manipulate the request or metadata @@ -447,8 +469,10 @@ def post_get_process( def pre_list_analyses( self, request: lva_service.ListAnalysesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListAnalysesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListAnalysesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_analyses Override in a subclass to manipulate the request or metadata @@ -470,8 +494,10 @@ def post_list_analyses( def pre_list_operators( self, request: lva_service.ListOperatorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListOperatorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListOperatorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operators Override in a subclass to manipulate the request or metadata @@ -493,8 +519,10 @@ def post_list_operators( def pre_list_processes( self, request: lva_service.ListProcessesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListProcessesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListProcessesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_processes Override in a subclass to manipulate the request or metadata @@ -516,8 +544,10 @@ def post_list_processes( def pre_list_public_operators( self, request: lva_service.ListPublicOperatorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListPublicOperatorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListPublicOperatorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_public_operators Override in a subclass to manipulate the request or metadata @@ -539,8 +569,10 @@ def post_list_public_operators( def pre_resolve_operator_info( self, request: lva_service.ResolveOperatorInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ResolveOperatorInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ResolveOperatorInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resolve_operator_info Override in a subclass to manipulate the request or metadata @@ -562,8 +594,10 @@ def post_resolve_operator_info( def pre_update_analysis( self, request: lva_service.UpdateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_analysis Override in a subclass to manipulate the request or metadata @@ -585,8 +619,10 @@ def post_update_analysis( def pre_update_operator( self, request: lva_service.UpdateOperatorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateOperatorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateOperatorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_operator Override in a subclass to manipulate the request or metadata @@ -608,8 +644,10 @@ def post_update_operator( def pre_update_process( self, request: lva_service.UpdateProcessRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateProcessRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateProcessRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_process Override in a subclass to manipulate the request or metadata @@ -631,8 +669,10 @@ def post_update_process( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -652,8 +692,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -673,8 +715,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -696,8 +740,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -923,7 +969,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch run process method over HTTP. @@ -934,8 +980,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -948,6 +996,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseBatchRunProcess._get_http_options() ) + request, metadata = self._interceptor.pre_batch_run_process( request, metadata ) @@ -964,6 +1013,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.BatchRunProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "BatchRunProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._BatchRunProcess._get_response( self._host, @@ -983,7 +1059,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_run_process(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.visionai_v1.LiveVideoAnalyticsClient.batch_run_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "BatchRunProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnalysis( @@ -1022,7 +1120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create analysis method over HTTP. @@ -1032,8 +1130,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1046,6 +1146,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_create_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_transcoded_request( http_options, request @@ -1060,6 +1161,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.CreateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateAnalysis._get_response( self._host, @@ -1079,7 +1207,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_analysis(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.visionai_v1.LiveVideoAnalyticsClient.create_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateOperator( @@ -1118,7 +1268,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create operator method over HTTP. @@ -1128,8 +1278,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1142,6 +1294,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateOperator._get_http_options() ) + request, metadata = self._interceptor.pre_create_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateOperator._get_transcoded_request( http_options, request @@ -1156,6 +1309,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.CreateOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateOperator._get_response( self._host, @@ -1175,7 +1355,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_operator(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.visionai_v1.LiveVideoAnalyticsClient.create_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcess( @@ -1214,7 +1416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create process method over HTTP. @@ -1224,8 +1426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1238,6 +1442,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateProcess._get_http_options() ) + request, metadata = self._interceptor.pre_create_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateProcess._get_transcoded_request( http_options, request @@ -1252,6 +1457,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.CreateProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateProcess._get_response( self._host, @@ -1271,7 +1503,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_process(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.visionai_v1.LiveVideoAnalyticsClient.create_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CreateProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnalysis( @@ -1309,7 +1563,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete analysis method over HTTP. @@ -1319,8 +1573,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1333,6 +1589,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_transcoded_request( http_options, request @@ -1343,6 +1600,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.DeleteAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteAnalysis._get_response( self._host, @@ -1361,7 +1645,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_analysis(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.visionai_v1.LiveVideoAnalyticsClient.delete_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOperator( @@ -1399,7 +1705,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete operator method over HTTP. @@ -1409,8 +1715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1423,6 +1731,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperator._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperator._get_transcoded_request( http_options, request @@ -1433,6 +1742,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.DeleteOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperator._get_response( self._host, @@ -1451,7 +1787,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_operator(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.visionai_v1.LiveVideoAnalyticsClient.delete_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcess( @@ -1489,7 +1847,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete process method over HTTP. @@ -1499,8 +1857,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1513,6 +1873,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteProcess._get_http_options() ) + request, metadata = self._interceptor.pre_delete_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteProcess._get_transcoded_request( http_options, request @@ -1523,6 +1884,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.DeleteProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteProcess._get_response( self._host, @@ -1541,7 +1929,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_process(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.visionai_v1.LiveVideoAnalyticsClient.delete_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnalysis( @@ -1579,7 +1989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Call the get analysis method over HTTP. @@ -1589,8 +1999,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_resources.Analysis: @@ -1602,6 +2014,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_get_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_transcoded_request( http_options, request @@ -1612,6 +2025,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.GetAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetAnalysis._get_response( self._host, @@ -1632,7 +2072,29 @@ def __call__( pb_resp = lva_resources.Analysis.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Analysis.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.visionai_v1.LiveVideoAnalyticsClient.get_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOperator( @@ -1670,7 +2132,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Operator: r"""Call the get operator method over HTTP. @@ -1680,8 +2142,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_resources.Operator: @@ -1693,6 +2157,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperator._get_http_options() ) + request, metadata = self._interceptor.pre_get_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperator._get_transcoded_request( http_options, request @@ -1703,6 +2168,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.GetOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperator._get_response( self._host, @@ -1723,7 +2215,29 @@ def __call__( pb_resp = lva_resources.Operator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_operator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Operator.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.visionai_v1.LiveVideoAnalyticsClient.get_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcess( @@ -1760,7 +2274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Process: r"""Call the get process method over HTTP. @@ -1770,8 +2284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_resources.Process: @@ -1783,6 +2299,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetProcess._get_http_options() ) + request, metadata = self._interceptor.pre_get_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetProcess._get_transcoded_request( http_options, request @@ -1793,6 +2310,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.GetProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetProcess._get_response( self._host, @@ -1813,7 +2357,29 @@ def __call__( pb_resp = lva_resources.Process.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_process(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Process.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.visionai_v1.LiveVideoAnalyticsClient.get_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnalyses( @@ -1851,7 +2417,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListAnalysesResponse: r"""Call the list analyses method over HTTP. @@ -1862,8 +2428,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ListAnalysesResponse: @@ -1875,6 +2443,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_http_options() ) + request, metadata = self._interceptor.pre_list_analyses(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_transcoded_request( http_options, request @@ -1885,6 +2454,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ListAnalyses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListAnalyses._get_response( self._host, @@ -1905,7 +2501,31 @@ def __call__( pb_resp = lva_service.ListAnalysesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListAnalysesResponse.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.visionai_v1.LiveVideoAnalyticsClient.list_analyses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOperators( @@ -1943,7 +2563,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListOperatorsResponse: r"""Call the list operators method over HTTP. @@ -1954,8 +2574,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ListOperatorsResponse: @@ -1967,6 +2589,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperators._get_http_options() ) + request, metadata = self._interceptor.pre_list_operators(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperators._get_transcoded_request( http_options, request @@ -1977,6 +2600,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ListOperators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperators._get_response( self._host, @@ -1997,7 +2647,31 @@ def __call__( pb_resp = lva_service.ListOperatorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_operators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListOperatorsResponse.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.visionai_v1.LiveVideoAnalyticsClient.list_operators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcesses( @@ -2035,7 +2709,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListProcessesResponse: r"""Call the list processes method over HTTP. @@ -2046,8 +2720,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ListProcessesResponse: @@ -2059,6 +2735,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListProcesses._get_http_options() ) + request, metadata = self._interceptor.pre_list_processes(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListProcesses._get_transcoded_request( http_options, request @@ -2069,6 +2746,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ListProcesses", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListProcesses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListProcesses._get_response( self._host, @@ -2089,7 +2793,31 @@ def __call__( pb_resp = lva_service.ListProcessesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListProcessesResponse.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.visionai_v1.LiveVideoAnalyticsClient.list_processes", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListProcesses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPublicOperators( @@ -2127,7 +2855,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListPublicOperatorsResponse: r"""Call the list public operators method over HTTP. @@ -2138,8 +2866,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ListPublicOperatorsResponse: @@ -2151,6 +2881,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListPublicOperators._get_http_options() ) + request, metadata = self._interceptor.pre_list_public_operators( request, metadata ) @@ -2163,6 +2894,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ListPublicOperators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListPublicOperators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._ListPublicOperators._get_response( @@ -2185,7 +2943,31 @@ def __call__( pb_resp = lva_service.ListPublicOperatorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_public_operators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListPublicOperatorsResponse.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.visionai_v1.LiveVideoAnalyticsClient.list_public_operators", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListPublicOperators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResolveOperatorInfo( @@ -2224,7 +3006,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ResolveOperatorInfoResponse: r"""Call the resolve operator info method over HTTP. @@ -2235,8 +3017,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ResolveOperatorInfoResponse: @@ -2248,6 +3032,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseResolveOperatorInfo._get_http_options() ) + request, metadata = self._interceptor.pre_resolve_operator_info( request, metadata ) @@ -2264,6 +3049,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ResolveOperatorInfo", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ResolveOperatorInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._ResolveOperatorInfo._get_response( @@ -2287,7 +3099,31 @@ def __call__( pb_resp = lva_service.ResolveOperatorInfoResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resolve_operator_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ResolveOperatorInfoResponse.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.visionai_v1.LiveVideoAnalyticsClient.resolve_operator_info", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ResolveOperatorInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnalysis( @@ -2326,7 +3162,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update analysis method over HTTP. @@ -2336,8 +3172,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2350,6 +3188,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_update_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_transcoded_request( http_options, request @@ -2364,6 +3203,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.UpdateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateAnalysis._get_response( self._host, @@ -2383,7 +3249,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_analysis(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.visionai_v1.LiveVideoAnalyticsClient.update_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOperator( @@ -2422,7 +3310,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update operator method over HTTP. @@ -2432,8 +3320,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2446,6 +3336,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateOperator._get_http_options() ) + request, metadata = self._interceptor.pre_update_operator(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateOperator._get_transcoded_request( http_options, request @@ -2460,6 +3351,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.UpdateOperator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateOperator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateOperator._get_response( self._host, @@ -2479,7 +3397,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_operator(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.visionai_v1.LiveVideoAnalyticsClient.update_operator", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateOperator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcess( @@ -2518,7 +3458,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update process method over HTTP. @@ -2528,8 +3468,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2542,6 +3484,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateProcess._get_http_options() ) + request, metadata = self._interceptor.pre_update_process(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateProcess._get_transcoded_request( http_options, request @@ -2556,6 +3499,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.UpdateProcess", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateProcess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateProcess._get_response( self._host, @@ -2575,7 +3545,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_process(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.visionai_v1.LiveVideoAnalyticsClient.update_process", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "UpdateProcess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2772,7 +3764,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2782,13 +3774,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2805,6 +3800,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CancelOperation._get_response( self._host, @@ -2862,7 +3884,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2872,13 +3894,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2891,6 +3916,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperation._get_response( self._host, @@ -2947,7 +3999,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2957,8 +4009,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2967,6 +4021,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2977,6 +4032,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperation._get_response( self._host, @@ -2996,6 +4078,27 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3037,7 +4140,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3047,8 +4150,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3057,6 +4162,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3067,6 +4173,33 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperations._get_response( self._host, @@ -3086,6 +4219,27 @@ def __call__( 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.visionai_v1.LiveVideoAnalyticsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py index 8acca5f7b137..43eb87908cda 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .transports.grpc_asyncio import StreamingServiceGrpcAsyncIOTransport +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 StreamingServiceAsyncClient: """Streaming service for receiving and sending packets.""" @@ -264,13 +274,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.StreamingServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[AsyncIterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.SendPacketsResponse]]: r"""Send packets to the series. @@ -316,8 +348,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1.types.SendPacketsResponse]: @@ -352,7 +386,7 @@ def receive_packets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.ReceivePacketsResponse]]: r"""Receive packets from the series. @@ -399,8 +433,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]: @@ -435,7 +471,7 @@ def receive_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.ReceiveEventsResponse]]: r"""Receive events given the stream name. @@ -481,8 +517,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]: @@ -517,7 +555,7 @@ async def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -553,8 +591,10 @@ async def sample_acquire_lease(): 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, 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: google.cloud.visionai_v1.types.Lease: @@ -598,7 +638,7 @@ async def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -633,8 +673,10 @@ async def sample_renew_lease(): 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, 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: google.cloud.visionai_v1.types.Lease: @@ -678,7 +720,7 @@ async def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -713,8 +755,10 @@ async def sample_release_lease(): 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, 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: google.cloud.visionai_v1.types.ReleaseLeaseResponse: @@ -758,7 +802,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -769,8 +813,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -811,7 +857,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -822,8 +868,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -864,7 +912,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -880,8 +928,10 @@ async def delete_operation( 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, 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: None """ @@ -918,7 +968,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -933,8 +983,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py index 33f8163fd896..ec2c0017dd81 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -589,6 +599,10 @@ def __init__( # 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( @@ -655,13 +669,36 @@ def __init__( 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.visionai_v1.StreamingServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[Iterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.SendPacketsResponse]: r"""Send packets to the series. @@ -707,8 +744,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1.types.SendPacketsResponse]: @@ -739,7 +778,7 @@ def receive_packets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.ReceivePacketsResponse]: r"""Receive packets from the series. @@ -786,8 +825,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]: @@ -818,7 +859,7 @@ def receive_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.ReceiveEventsResponse]: r"""Receive events given the stream name. @@ -864,8 +905,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]: @@ -898,7 +941,7 @@ def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -934,8 +977,10 @@ def sample_acquire_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Lease: @@ -977,7 +1022,7 @@ def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -1012,8 +1057,10 @@ def sample_renew_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Lease: @@ -1055,7 +1102,7 @@ def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -1090,8 +1137,10 @@ def sample_release_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.ReleaseLeaseResponse: @@ -1146,7 +1195,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1157,8 +1206,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1199,7 +1250,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1210,8 +1261,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1252,7 +1305,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1268,8 +1321,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1306,7 +1361,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1321,8 +1376,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py index 092525adbc12..e5c086e0da5e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport +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.visionai.v1.StreamingService", + "rpcName": 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.visionai.v1.StreamingService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcTransport(StreamingServiceTransport): """gRPC backend transport for StreamingService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -288,7 +374,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -317,7 +403,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -343,7 +429,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -369,7 +455,7 @@ def renew_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -397,7 +483,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -405,7 +491,7 @@ def release_lease( return self._stubs["release_lease"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -417,7 +503,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -434,7 +520,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -451,7 +537,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -470,7 +556,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py index fd6aa6dc1ccf..552df3174288 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .grpc import StreamingServiceGrpcTransport +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.visionai.v1.StreamingService", + "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.visionai.v1.StreamingService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcAsyncIOTransport(StreamingServiceTransport): """gRPC AsyncIO backend transport for StreamingService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -297,7 +382,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -326,7 +411,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -354,7 +439,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -382,7 +467,7 @@ def renew_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -411,7 +496,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -479,7 +564,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -495,7 +580,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -512,7 +597,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -529,7 +614,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -548,7 +633,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py index ea660554efea..72884e194c76 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streaming_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -97,8 +105,10 @@ def post_renew_lease(self, response): def pre_acquire_lease( self, request: streaming_service.AcquireLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for acquire_lease Override in a subclass to manipulate the request or metadata @@ -120,8 +130,10 @@ def post_acquire_lease( def pre_release_lease( self, request: streaming_service.ReleaseLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for release_lease Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def post_release_lease( def pre_renew_lease( self, request: streaming_service.RenewLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.RenewLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.RenewLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for renew_lease Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_renew_lease( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -187,8 +203,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -208,8 +226,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -231,8 +251,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -373,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the acquire lease method over HTTP. @@ -384,8 +406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.Lease: @@ -395,6 +419,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseAcquireLease._get_http_options() ) + request, metadata = self._interceptor.pre_acquire_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseAcquireLease._get_transcoded_request( http_options, request @@ -409,6 +434,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.AcquireLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "AcquireLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._AcquireLease._get_response( self._host, @@ -430,7 +482,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acquire_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.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.visionai_v1.StreamingServiceClient.acquire_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "AcquireLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReceiveEvents( @@ -445,7 +519,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceiveEvents is not available over REST transport" @@ -463,7 +537,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceivePackets is not available over REST transport" @@ -504,7 +578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""Call the release lease method over HTTP. @@ -514,8 +588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.ReleaseLeaseResponse: @@ -525,6 +601,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseReleaseLease._get_http_options() ) + request, metadata = self._interceptor.pre_release_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseReleaseLease._get_transcoded_request( http_options, request @@ -539,6 +616,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.ReleaseLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ReleaseLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ReleaseLease._get_response( self._host, @@ -560,7 +664,31 @@ def __call__( pb_resp = streaming_service.ReleaseLeaseResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_release_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.ReleaseLeaseResponse.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.visionai_v1.StreamingServiceClient.release_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ReleaseLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenewLease( @@ -598,7 +726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the renew lease method over HTTP. @@ -608,8 +736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.Lease: @@ -619,6 +749,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseRenewLease._get_http_options() ) + request, metadata = self._interceptor.pre_renew_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseRenewLease._get_transcoded_request( http_options, request @@ -633,6 +764,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.RenewLease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "RenewLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._RenewLease._get_response( self._host, @@ -654,7 +812,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_renew_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.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.visionai_v1.StreamingServiceClient.renew_lease", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "RenewLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SendPackets( @@ -669,7 +849,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method SendPackets is not available over REST transport" @@ -773,7 +953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -783,13 +963,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamingServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -806,6 +989,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._CancelOperation._get_response( self._host, @@ -863,7 +1073,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -873,13 +1083,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamingServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -892,6 +1105,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._DeleteOperation._get_response( self._host, @@ -947,7 +1187,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -957,8 +1197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -967,6 +1209,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -977,6 +1220,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetOperation._get_response( self._host, @@ -996,6 +1266,27 @@ def __call__( 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.visionai_v1.StreamingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1036,7 +1327,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1046,8 +1337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1056,6 +1349,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1066,6 +1360,33 @@ def __call__( 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.visionai_v1.StreamingServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListOperations._get_response( self._host, @@ -1085,6 +1406,27 @@ def __call__( 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.visionai_v1.StreamingServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamingService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py index 886545a28528..a5bd17cfd43b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .transports.grpc_asyncio import StreamsServiceGrpcAsyncIOTransport +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 StreamsServiceAsyncClient: """Service describing handlers for resources. @@ -278,6 +288,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.StreamsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -285,7 +317,7 @@ async def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersAsyncPager: r"""Lists Clusters in a given project and location. @@ -330,8 +362,10 @@ async def sample_list_clusters(): 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, 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: google.cloud.visionai_v1.services.streams_service.pagers.ListClustersAsyncPager: @@ -406,7 +440,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -447,8 +481,10 @@ async def sample_get_cluster(): 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, 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: google.cloud.visionai_v1.types.Cluster: @@ -511,7 +547,7 @@ async def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Cluster in a given project and location. @@ -570,8 +606,10 @@ async def sample_create_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -648,7 +686,7 @@ async def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Cluster. @@ -703,8 +741,10 @@ async def sample_update_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -780,7 +820,7 @@ async def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Cluster. @@ -825,8 +865,10 @@ async def sample_delete_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -905,7 +947,7 @@ async def list_streams( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListStreamsAsyncPager: r"""Lists Streams in a given project and location. @@ -950,8 +992,10 @@ async def sample_list_streams(): 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, 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: google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsAsyncPager: @@ -1026,7 +1070,7 @@ async def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1067,8 +1111,10 @@ async def sample_get_stream(): 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, 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: google.cloud.visionai_v1.types.Stream: @@ -1135,7 +1181,7 @@ async def create_stream( stream_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Stream in a given project and location. @@ -1193,8 +1239,10 @@ async def sample_create_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1272,7 +1320,7 @@ async def update_stream( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Stream. @@ -1327,8 +1375,10 @@ async def sample_update_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1405,7 +1455,7 @@ async def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Stream. @@ -1450,8 +1500,10 @@ async def sample_delete_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1533,7 +1585,7 @@ async def get_stream_thumbnail( gcs_object_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Gets the thumbnail (image snapshot) of a single Stream. @@ -1590,8 +1642,10 @@ async def sample_get_stream_thumbnail(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1667,7 +1721,7 @@ async def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -1710,8 +1764,10 @@ async def sample_generate_stream_hls_token(): 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, 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: google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse: @@ -1772,7 +1828,7 @@ async def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsAsyncPager: r"""Lists Events in a given project and location. @@ -1817,8 +1873,10 @@ async def sample_list_events(): 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, 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: google.cloud.visionai_v1.services.streams_service.pagers.ListEventsAsyncPager: @@ -1893,7 +1951,7 @@ async def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -1934,8 +1992,10 @@ async def sample_get_event(): 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, 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: google.cloud.visionai_v1.types.Event: @@ -1996,7 +2056,7 @@ async def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Event in a given project and location. @@ -2054,8 +2114,10 @@ async def sample_create_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2132,7 +2194,7 @@ async def update_event( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Event. @@ -2187,8 +2249,10 @@ async def sample_update_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2264,7 +2328,7 @@ async def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Event. @@ -2309,8 +2373,10 @@ async def sample_delete_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2389,7 +2455,7 @@ async def list_series( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSeriesAsyncPager: r"""Lists Series in a given project and location. @@ -2434,8 +2500,10 @@ async def sample_list_series(): 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, 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: google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesAsyncPager: @@ -2510,7 +2578,7 @@ async def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2551,8 +2619,10 @@ async def sample_get_series(): 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, 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: google.cloud.visionai_v1.types.Series: @@ -2613,7 +2683,7 @@ async def create_series( series_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Series in a given project and location. @@ -2676,8 +2746,10 @@ async def sample_create_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2754,7 +2826,7 @@ async def update_series( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Event. @@ -2814,8 +2886,10 @@ async def sample_update_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2891,7 +2965,7 @@ async def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Series. @@ -2936,8 +3010,10 @@ async def sample_delete_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3020,7 +3096,7 @@ async def materialize_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Materialize a channel. @@ -3081,8 +3157,10 @@ async def sample_materialize_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3157,7 +3235,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3168,8 +3246,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3210,7 +3290,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3221,8 +3301,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3263,7 +3345,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3279,8 +3361,10 @@ async def delete_operation( 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, 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: None """ @@ -3317,7 +3401,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3332,8 +3416,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py index 0595104ccf2a..3c3c2e121e4e 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -690,6 +700,10 @@ def __init__( # 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( @@ -755,6 +769,29 @@ def __init__( 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.visionai_v1.StreamsServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -762,7 +799,7 @@ def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersPager: r"""Lists Clusters in a given project and location. @@ -807,8 +844,10 @@ def sample_list_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.streams_service.pagers.ListClustersPager: @@ -880,7 +919,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -921,8 +960,10 @@ def sample_get_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Cluster: @@ -982,7 +1023,7 @@ def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Cluster in a given project and location. @@ -1041,8 +1082,10 @@ def sample_create_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1116,7 +1159,7 @@ def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Cluster. @@ -1171,8 +1214,10 @@ def sample_update_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1245,7 +1290,7 @@ def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Cluster. @@ -1290,8 +1335,10 @@ def sample_delete_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1367,7 +1414,7 @@ def list_streams( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListStreamsPager: r"""Lists Streams in a given project and location. @@ -1412,8 +1459,10 @@ def sample_list_streams(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsPager: @@ -1485,7 +1534,7 @@ def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1526,8 +1575,10 @@ def sample_get_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1.types.Stream: @@ -1591,7 +1642,7 @@ def create_stream( stream_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Stream in a given project and location. @@ -1649,8 +1700,10 @@ def sample_create_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1725,7 +1778,7 @@ def update_stream( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Stream. @@ -1780,8 +1833,10 @@ def sample_update_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1855,7 +1910,7 @@ def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Stream. @@ -1900,8 +1955,10 @@ def sample_delete_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1980,7 +2037,7 @@ def get_stream_thumbnail( gcs_object_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Gets the thumbnail (image snapshot) of a single Stream. @@ -2037,8 +2094,10 @@ def sample_get_stream_thumbnail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2111,7 +2170,7 @@ def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -2154,8 +2213,10 @@ def sample_generate_stream_hls_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse: @@ -2215,7 +2276,7 @@ def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsPager: r"""Lists Events in a given project and location. @@ -2260,8 +2321,10 @@ def sample_list_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.streams_service.pagers.ListEventsPager: @@ -2333,7 +2396,7 @@ def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -2374,8 +2437,10 @@ def sample_get_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Event: @@ -2433,7 +2498,7 @@ def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Event in a given project and location. @@ -2491,8 +2556,10 @@ def sample_create_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2566,7 +2633,7 @@ def update_event( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Event. @@ -2621,8 +2688,10 @@ def sample_update_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2695,7 +2764,7 @@ def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Event. @@ -2740,8 +2809,10 @@ def sample_delete_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2817,7 +2888,7 @@ def list_series( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSeriesPager: r"""Lists Series in a given project and location. @@ -2862,8 +2933,10 @@ def sample_list_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesPager: @@ -2935,7 +3008,7 @@ def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2976,8 +3049,10 @@ def sample_get_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Series: @@ -3035,7 +3110,7 @@ def create_series( series_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Series in a given project and location. @@ -3098,8 +3173,10 @@ def sample_create_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3173,7 +3250,7 @@ def update_series( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Event. @@ -3233,8 +3310,10 @@ def sample_update_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3307,7 +3386,7 @@ def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Series. @@ -3352,8 +3431,10 @@ def sample_delete_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3433,7 +3514,7 @@ def materialize_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Materialize a channel. @@ -3494,8 +3575,10 @@ def sample_materialize_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3580,7 +3663,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3591,8 +3674,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3633,7 +3718,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3644,8 +3729,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3686,7 +3773,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3702,8 +3789,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3740,7 +3829,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3755,8 +3844,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py index 97a21bfb4d5c..173c167f9c65 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListClustersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListClustersRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListStreamsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListStreamsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListEventsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListEventsRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListSeriesRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListSeriesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py index e51ffe95d003..adf5cd921dcf 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import common, streams_resources, streams_service from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport +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.visionai.v1.StreamsService", + "rpcName": 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.visionai.v1.StreamsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcTransport(StreamsServiceTransport): """gRPC backend transport for StreamsService. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -252,7 +338,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -304,7 +392,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -331,7 +419,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -357,7 +445,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -383,7 +471,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -411,7 +499,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -437,7 +525,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -463,7 +551,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +577,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -515,7 +603,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -544,7 +632,7 @@ def get_stream_thumbnail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream_thumbnail" not in self._stubs: - self._stubs["get_stream_thumbnail"] = self.grpc_channel.unary_unary( + self._stubs["get_stream_thumbnail"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStreamThumbnail", request_serializer=streams_service.GetStreamThumbnailRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +662,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -602,7 +690,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -628,7 +716,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -654,7 +742,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -680,7 +768,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -706,7 +794,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -734,7 +822,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -760,7 +848,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -786,7 +874,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +900,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -838,7 +926,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -866,7 +954,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -874,7 +962,7 @@ def materialize_channel( return self._stubs["materialize_channel"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -886,7 +974,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -903,7 +991,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -920,7 +1008,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -939,7 +1027,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py index 9643064c9501..9fa0ec853a08 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import common, streams_resources, streams_service from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .grpc import StreamsServiceGrpcTransport +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.visionai.v1.StreamsService", + "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.visionai.v1.StreamsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcAsyncIOTransport(StreamsServiceTransport): """gRPC AsyncIO backend transport for StreamsService. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -315,7 +400,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -344,7 +429,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +457,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -400,7 +485,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -457,7 +542,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -485,7 +570,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -513,7 +598,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +626,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -570,7 +655,7 @@ def get_stream_thumbnail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream_thumbnail" not in self._stubs: - self._stubs["get_stream_thumbnail"] = self.grpc_channel.unary_unary( + self._stubs["get_stream_thumbnail"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetStreamThumbnail", request_serializer=streams_service.GetStreamThumbnailRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +685,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -629,7 +714,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -657,7 +742,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -685,7 +770,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -713,7 +798,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +826,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -770,7 +855,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -798,7 +883,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -826,7 +911,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -854,7 +939,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -882,7 +967,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -910,7 +995,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1063,7 +1148,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1079,7 +1164,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1096,7 +1181,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1113,7 +1198,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1132,7 +1217,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py index 1e62f921ef9a..f41c3b236278 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/streams_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -257,8 +265,10 @@ def post_update_stream(self, response): def pre_create_cluster( self, request: streams_service.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -280,8 +290,10 @@ def post_create_cluster( def pre_create_event( self, request: streams_service.CreateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -303,8 +315,10 @@ def post_create_event( def pre_create_series( self, request: streams_service.CreateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_series Override in a subclass to manipulate the request or metadata @@ -326,8 +340,10 @@ def post_create_series( def pre_create_stream( self, request: streams_service.CreateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_stream Override in a subclass to manipulate the request or metadata @@ -349,8 +365,10 @@ def post_create_stream( def pre_delete_cluster( self, request: streams_service.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -372,8 +390,10 @@ def post_delete_cluster( def pre_delete_event( self, request: streams_service.DeleteEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -395,8 +415,10 @@ def post_delete_event( def pre_delete_series( self, request: streams_service.DeleteSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_series Override in a subclass to manipulate the request or metadata @@ -418,8 +440,10 @@ def post_delete_series( def pre_delete_stream( self, request: streams_service.DeleteStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_stream Override in a subclass to manipulate the request or metadata @@ -441,9 +465,10 @@ def post_delete_stream( def pre_generate_stream_hls_token( self, request: streams_service.GenerateStreamHlsTokenRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - streams_service.GenerateStreamHlsTokenRequest, Sequence[Tuple[str, str]] + streams_service.GenerateStreamHlsTokenRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stream_hls_token @@ -466,8 +491,10 @@ def post_generate_stream_hls_token( def pre_get_cluster( self, request: streams_service.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -487,8 +514,10 @@ def post_get_cluster(self, response: common.Cluster) -> common.Cluster: def pre_get_event( self, request: streams_service.GetEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -510,8 +539,10 @@ def post_get_event( def pre_get_series( self, request: streams_service.GetSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_series Override in a subclass to manipulate the request or metadata @@ -533,8 +564,10 @@ def post_get_series( def pre_get_stream( self, request: streams_service.GetStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_stream Override in a subclass to manipulate the request or metadata @@ -556,8 +589,11 @@ def post_get_stream( def pre_get_stream_thumbnail( self, request: streams_service.GetStreamThumbnailRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamThumbnailRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamThumbnailRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_stream_thumbnail Override in a subclass to manipulate the request or metadata @@ -579,8 +615,10 @@ def post_get_stream_thumbnail( def pre_list_clusters( self, request: streams_service.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -602,8 +640,10 @@ def post_list_clusters( def pre_list_events( self, request: streams_service.ListEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -625,8 +665,10 @@ def post_list_events( def pre_list_series( self, request: streams_service.ListSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_series Override in a subclass to manipulate the request or metadata @@ -648,8 +690,10 @@ def post_list_series( def pre_list_streams( self, request: streams_service.ListStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_streams Override in a subclass to manipulate the request or metadata @@ -671,8 +715,11 @@ def post_list_streams( def pre_materialize_channel( self, request: streams_service.MaterializeChannelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.MaterializeChannelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.MaterializeChannelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for materialize_channel Override in a subclass to manipulate the request or metadata @@ -694,8 +741,10 @@ def post_materialize_channel( def pre_update_cluster( self, request: streams_service.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -717,8 +766,10 @@ def post_update_cluster( def pre_update_event( self, request: streams_service.UpdateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_event Override in a subclass to manipulate the request or metadata @@ -740,8 +791,10 @@ def post_update_event( def pre_update_series( self, request: streams_service.UpdateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_series Override in a subclass to manipulate the request or metadata @@ -763,8 +816,10 @@ def post_update_series( def pre_update_stream( self, request: streams_service.UpdateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_stream Override in a subclass to manipulate the request or metadata @@ -786,8 +841,10 @@ def post_update_stream( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -807,8 +864,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -828,8 +887,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -851,8 +912,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1079,7 +1142,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -1089,8 +1152,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1103,6 +1168,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1117,6 +1183,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.CreateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateCluster._get_response( self._host, @@ -1136,7 +1229,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.visionai_v1.StreamsServiceClient.create_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1174,7 +1289,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create event method over HTTP. @@ -1184,8 +1299,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1198,6 +1315,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1212,6 +1330,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateEvent._get_response( self._host, @@ -1231,7 +1376,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event(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.visionai_v1.StreamsServiceClient.create_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSeries( @@ -1269,7 +1436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create series method over HTTP. @@ -1279,8 +1446,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1293,6 +1462,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_create_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateSeries._get_transcoded_request( http_options, request @@ -1307,6 +1477,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.CreateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateSeries._get_response( self._host, @@ -1326,7 +1523,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_series(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.visionai_v1.StreamsServiceClient.create_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateStream( @@ -1364,7 +1583,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create stream method over HTTP. @@ -1374,8 +1593,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1388,6 +1609,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateStream._get_transcoded_request( http_options, request @@ -1402,6 +1624,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.CreateStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateStream._get_response( self._host, @@ -1421,7 +1670,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_stream(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.visionai_v1.StreamsServiceClient.create_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CreateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -1458,7 +1729,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -1468,8 +1739,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1482,6 +1755,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -1492,6 +1766,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteCluster._get_response( self._host, @@ -1510,7 +1811,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.visionai_v1.StreamsServiceClient.delete_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1547,7 +1870,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete event method over HTTP. @@ -1557,8 +1880,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1571,6 +1896,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1581,6 +1907,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1599,7 +1952,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_event(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.visionai_v1.StreamsServiceClient.delete_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSeries( @@ -1636,7 +2011,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete series method over HTTP. @@ -1646,8 +2021,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1660,6 +2037,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_http_options() ) + request, metadata = self._interceptor.pre_delete_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_transcoded_request( http_options, request @@ -1670,6 +2048,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.DeleteSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteSeries._get_response( self._host, @@ -1688,7 +2093,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_series(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.visionai_v1.StreamsServiceClient.delete_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteStream( @@ -1725,7 +2152,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete stream method over HTTP. @@ -1735,8 +2162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1749,6 +2178,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteStream._get_transcoded_request( http_options, request @@ -1759,6 +2189,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.DeleteStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteStream._get_response( self._host, @@ -1777,7 +2234,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_stream(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.visionai_v1.StreamsServiceClient.delete_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStreamHlsToken( @@ -1816,7 +2295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Call the generate stream hls token method over HTTP. @@ -1827,8 +2306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.GenerateStreamHlsTokenResponse: @@ -1840,6 +2321,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGenerateStreamHlsToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stream_hls_token( request, metadata ) @@ -1856,6 +2338,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.GenerateStreamHlsToken", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StreamsServiceRestTransport._GenerateStreamHlsToken._get_response( @@ -1879,7 +2388,31 @@ def __call__( pb_resp = streams_service.GenerateStreamHlsTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stream_hls_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + streams_service.GenerateStreamHlsTokenResponse.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.visionai_v1.StreamsServiceClient.generate_stream_hls_token", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -1916,7 +2449,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Call the get cluster method over HTTP. @@ -1926,8 +2459,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.Cluster: @@ -1939,6 +2474,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -1951,6 +2487,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.GetCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetCluster._get_response( self._host, @@ -1971,7 +2534,29 @@ def __call__( pb_resp = common.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.Cluster.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.visionai_v1.StreamsServiceClient.get_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2008,7 +2593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Call the get event method over HTTP. @@ -2018,8 +2603,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Event: @@ -2029,6 +2616,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_transcoded_request( @@ -2043,6 +2631,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetEvent._get_response( self._host, @@ -2063,7 +2678,29 @@ def __call__( pb_resp = streams_resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Event.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.visionai_v1.StreamsServiceClient.get_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSeries( @@ -2100,7 +2737,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Call the get series method over HTTP. @@ -2110,8 +2747,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Series: @@ -2121,6 +2760,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_http_options() ) + request, metadata = self._interceptor.pre_get_series(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_transcoded_request( @@ -2135,6 +2775,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.GetSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetSeries._get_response( self._host, @@ -2155,7 +2822,29 @@ def __call__( pb_resp = streams_resources.Series.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Series.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.visionai_v1.StreamsServiceClient.get_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStream( @@ -2192,7 +2881,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Call the get stream method over HTTP. @@ -2202,8 +2891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Stream: @@ -2219,6 +2910,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_transcoded_request( @@ -2233,6 +2925,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.GetStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStream._get_response( self._host, @@ -2253,7 +2972,29 @@ def __call__( pb_resp = streams_resources.Stream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Stream.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.visionai_v1.StreamsServiceClient.get_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStreamThumbnail( @@ -2291,7 +3032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get stream thumbnail method over HTTP. @@ -2302,8 +3043,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2316,6 +3059,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStreamThumbnail._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream_thumbnail( request, metadata ) @@ -2332,6 +3076,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.GetStreamThumbnail", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStreamThumbnail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStreamThumbnail._get_response( self._host, @@ -2351,7 +3122,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream_thumbnail(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.visionai_v1.StreamsServiceClient.get_stream_thumbnail", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetStreamThumbnail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -2388,7 +3181,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -2399,8 +3192,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListClustersResponse: @@ -2412,6 +3207,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -2422,6 +3218,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.ListClusters", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListClusters._get_response( self._host, @@ -2442,7 +3265,31 @@ def __call__( pb_resp = streams_service.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListClustersResponse.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.visionai_v1.StreamsServiceClient.list_clusters", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2479,7 +3326,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2490,8 +3337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListEventsResponse: @@ -2503,6 +3352,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2515,6 +3365,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListEvents._get_response( self._host, @@ -2535,7 +3412,31 @@ def __call__( pb_resp = streams_service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListEventsResponse.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.visionai_v1.StreamsServiceClient.list_events", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSeries( @@ -2572,7 +3473,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListSeriesResponse: r"""Call the list series method over HTTP. @@ -2583,8 +3484,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListSeriesResponse: @@ -2596,6 +3499,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListSeries._get_http_options() ) + request, metadata = self._interceptor.pre_list_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListSeries._get_transcoded_request( http_options, request @@ -2608,6 +3512,33 @@ def __call__( ) ) + 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.visionai_v1.StreamsServiceClient.ListSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListSeries._get_response( self._host, @@ -2628,7 +3559,31 @@ def __call__( pb_resp = streams_service.ListSeriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListSeriesResponse.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.visionai_v1.StreamsServiceClient.list_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListStreams( @@ -2665,7 +3620,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListStreamsResponse: r"""Call the list streams method over HTTP. @@ -2676,8 +3631,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListStreamsResponse: @@ -2689,6 +3646,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_streams(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListStreams._get_transcoded_request( http_options, request @@ -2699,6 +3657,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.ListStreams", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListStreams._get_response( self._host, @@ -2719,7 +3704,31 @@ def __call__( pb_resp = streams_service.ListStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListStreamsResponse.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.visionai_v1.StreamsServiceClient.list_streams", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MaterializeChannel( @@ -2757,7 +3766,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the materialize channel method over HTTP. @@ -2767,8 +3776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2781,6 +3792,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseMaterializeChannel._get_http_options() ) + request, metadata = self._interceptor.pre_materialize_channel( request, metadata ) @@ -2797,6 +3809,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.MaterializeChannel", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "MaterializeChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._MaterializeChannel._get_response( self._host, @@ -2816,7 +3855,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_materialize_channel(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.visionai_v1.StreamsServiceClient.materialize_channel", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "MaterializeChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -2854,7 +3915,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -2864,8 +3925,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2878,6 +3941,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -2892,6 +3956,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateCluster._get_response( self._host, @@ -2911,7 +4002,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.visionai_v1.StreamsServiceClient.update_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEvent( @@ -2949,7 +4062,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update event method over HTTP. @@ -2959,8 +4072,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2973,6 +4088,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_transcoded_request( http_options, request @@ -2987,6 +4103,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.UpdateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateEvent._get_response( self._host, @@ -3006,7 +4149,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event(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.visionai_v1.StreamsServiceClient.update_event", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSeries( @@ -3044,7 +4209,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update series method over HTTP. @@ -3054,8 +4219,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3068,6 +4235,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_update_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_transcoded_request( http_options, request @@ -3082,6 +4250,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.UpdateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateSeries._get_response( self._host, @@ -3101,7 +4296,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_series(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.visionai_v1.StreamsServiceClient.update_series", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateStream( @@ -3139,7 +4356,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update stream method over HTTP. @@ -3149,8 +4366,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3163,6 +4382,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateStream._get_transcoded_request( http_options, request @@ -3177,6 +4397,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.UpdateStream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateStream._get_response( self._host, @@ -3196,7 +4443,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_stream(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.visionai_v1.StreamsServiceClient.update_stream", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "UpdateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3437,7 +4706,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3447,13 +4716,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4742,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4825,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3536,13 +4835,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4857,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4939,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3620,8 +4949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -3630,6 +4961,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3640,6 +4972,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetOperation._get_response( self._host, @@ -3659,6 +5018,27 @@ def __call__( 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.visionai_v1.StreamsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3699,7 +5079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3709,8 +5089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3719,6 +5101,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3729,6 +5112,33 @@ def __call__( 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.visionai_v1.StreamsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListOperations._get_response( self._host, @@ -3748,6 +5158,27 @@ def __call__( 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.visionai_v1.StreamsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.StreamsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py index 1b30cf61711d..608cf03c4ea5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WarehouseTransport from .transports.grpc_asyncio import WarehouseGrpcAsyncIOTransport +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 WarehouseAsyncClient: """Service that manages media content + metadata for streaming.""" @@ -280,6 +290,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1.WarehouseAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "credentialsType": None, + }, + ) + async def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -289,7 +321,7 @@ async def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -352,8 +384,10 @@ async def sample_create_asset(): 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, 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: google.cloud.visionai_v1.types.Asset: @@ -424,7 +458,7 @@ async def update_asset( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -474,8 +508,10 @@ async def sample_update_asset(): 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, 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: google.cloud.visionai_v1.types.Asset: @@ -545,7 +581,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -588,8 +624,10 @@ async def sample_get_asset(): 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, 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: google.cloud.visionai_v1.types.Asset: @@ -655,7 +693,7 @@ async def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Lists an list of assets inside corpus. @@ -700,8 +738,10 @@ async def sample_list_assets(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsAsyncPager: @@ -776,7 +816,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes asset inside corpus. @@ -823,8 +863,10 @@ async def sample_delete_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -902,7 +944,7 @@ async def upload_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Upload asset by specifing the asset Cloud Storage uri. For video warehouse, it requires users who call @@ -954,8 +996,10 @@ async def sample_upload_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1012,7 +1056,7 @@ async def generate_retrieval_url( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Generates a signed url for downloading the asset. For video warehouse, please see comment of UploadAsset @@ -1052,8 +1096,10 @@ async def sample_generate_retrieval_url(): 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, 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: google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse: @@ -1099,7 +1145,7 @@ async def analyze_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Analyze asset to power search capability. @@ -1139,8 +1185,10 @@ async def sample_analyze_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1197,7 +1245,7 @@ async def index_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Index one asset for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1238,8 +1286,10 @@ async def sample_index_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1296,7 +1346,7 @@ async def remove_index_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove one asset's index data for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1337,8 +1387,10 @@ async def sample_remove_index_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1396,7 +1448,7 @@ async def view_indexed_assets( index: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewIndexedAssetsAsyncPager: r"""Lists assets inside an index. @@ -1442,8 +1494,10 @@ async def sample_view_indexed_assets(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsAsyncPager: @@ -1520,7 +1574,7 @@ async def create_index( index_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates an Index under the corpus. @@ -1589,8 +1643,10 @@ async def sample_create_index(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1667,7 +1723,7 @@ async def update_index( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an Index under the corpus. Users can perform a metadata-only update or trigger a full index rebuild with @@ -1730,8 +1786,10 @@ async def sample_update_index(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1807,7 +1865,7 @@ async def get_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Gets the details of a single Index under a Corpus. @@ -1850,8 +1908,10 @@ async def sample_get_index(): 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, 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: google.cloud.visionai_v1.types.Index: @@ -1915,7 +1975,7 @@ async def list_indexes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIndexesAsyncPager: r"""List all Indexes in a given Corpus. @@ -1960,8 +2020,10 @@ async def sample_list_indexes(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesAsyncPager: @@ -2036,7 +2098,7 @@ async def delete_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a single Index. In order to delete an index, the caller must make sure that it is not deployed to any @@ -2085,8 +2147,10 @@ async def sample_delete_index(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2166,7 +2230,7 @@ async def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a corpus inside a project. @@ -2222,8 +2286,10 @@ async def sample_create_corpus(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2297,7 +2363,7 @@ async def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -2340,8 +2406,10 @@ async def sample_get_corpus(): 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, 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: google.cloud.visionai_v1.types.Corpus: @@ -2405,7 +2473,7 @@ async def update_corpus( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -2456,8 +2524,10 @@ async def sample_update_corpus(): 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, 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: google.cloud.visionai_v1.types.Corpus: @@ -2524,7 +2594,7 @@ async def list_corpora( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCorporaAsyncPager: r"""Lists all corpora in a project. @@ -2568,8 +2638,10 @@ async def sample_list_corpora(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaAsyncPager: @@ -2644,7 +2716,7 @@ async def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a corpus only if its empty. Returns empty response. @@ -2685,8 +2757,10 @@ async def sample_delete_corpus(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2737,7 +2811,7 @@ async def analyze_corpus( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Analyzes a corpus. @@ -2777,8 +2851,10 @@ async def sample_analyze_corpus(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2837,7 +2913,7 @@ async def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -2890,8 +2966,10 @@ async def sample_create_data_schema(): 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, 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: google.cloud.visionai_v1.types.DataSchema: @@ -2956,7 +3034,7 @@ async def update_data_schema( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -3008,8 +3086,10 @@ async def sample_update_data_schema(): 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, 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: google.cloud.visionai_v1.types.DataSchema: @@ -3075,7 +3155,7 @@ async def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -3119,8 +3199,10 @@ async def sample_get_data_schema(): 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, 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: google.cloud.visionai_v1.types.DataSchema: @@ -3182,7 +3264,7 @@ async def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes data schema inside corpus. @@ -3222,8 +3304,10 @@ async def sample_delete_data_schema(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3275,7 +3359,7 @@ async def list_data_schemas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSchemasAsyncPager: r"""Lists a list of data schemas inside corpus. @@ -3320,8 +3404,10 @@ async def sample_list_data_schemas(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasAsyncPager: @@ -3398,7 +3484,7 @@ async def create_annotation( annotation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -3460,8 +3546,10 @@ async def sample_create_annotation(): 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, 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: google.cloud.visionai_v1.types.Annotation: @@ -3527,7 +3615,7 @@ async def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -3572,8 +3660,10 @@ async def sample_get_annotation(): 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, 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: google.cloud.visionai_v1.types.Annotation: @@ -3635,7 +3725,7 @@ async def list_annotations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnnotationsAsyncPager: r"""Lists a list of annotations inside asset. @@ -3680,8 +3770,10 @@ async def sample_list_annotations(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsAsyncPager: @@ -3757,7 +3849,7 @@ async def update_annotation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -3807,8 +3899,10 @@ async def sample_update_annotation(): 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, 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: google.cloud.visionai_v1.types.Annotation: @@ -3874,7 +3968,7 @@ async def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes annotation inside asset. @@ -3915,8 +4009,10 @@ async def sample_delete_annotation(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3967,7 +4063,7 @@ def ingest_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[warehouse.IngestAssetResponse]]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -4021,8 +4117,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1.types.IngestAssetResponse]: @@ -4055,7 +4153,7 @@ async def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Supported by STREAM_VIDEO corpus type. Generates clips for downloading. The api takes in a time range, and generates a clip @@ -4096,8 +4194,10 @@ async def sample_clip_asset(): 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, 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: google.cloud.visionai_v1.types.ClipAssetResponse: @@ -4141,7 +4241,7 @@ async def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -4180,8 +4280,10 @@ async def sample_generate_hls_uri(): 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, 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: google.cloud.visionai_v1.types.GenerateHlsUriResponse: @@ -4227,7 +4329,7 @@ async def import_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Imports assets (images plus annotations) from a meta file on cloud storage. Each row in the meta file is @@ -4271,8 +4373,10 @@ async def sample_import_assets(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4332,7 +4436,7 @@ async def create_search_config( search_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -4411,8 +4515,10 @@ async def sample_create_search_config(): 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, 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: google.cloud.visionai_v1.types.SearchConfig: @@ -4479,7 +4585,7 @@ async def update_search_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -4547,8 +4653,10 @@ async def sample_update_search_config(): 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, 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: google.cloud.visionai_v1.types.SearchConfig: @@ -4614,7 +4722,7 @@ async def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -4658,8 +4766,10 @@ async def sample_get_search_config(): 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, 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: google.cloud.visionai_v1.types.SearchConfig: @@ -4721,7 +4831,7 @@ async def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a search configuration inside a corpus. @@ -4766,8 +4876,10 @@ async def sample_delete_search_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4819,7 +4931,7 @@ async def list_search_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchConfigsAsyncPager: r"""Lists all search configurations inside a corpus. @@ -4865,8 +4977,10 @@ async def sample_list_search_configs(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsAsyncPager: @@ -4943,7 +5057,7 @@ async def create_search_hypernym( search_hypernym_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Creates a SearchHypernym inside a corpus. @@ -5003,8 +5117,10 @@ async def sample_create_search_hypernym(): 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, 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5073,7 +5189,7 @@ async def update_search_hypernym( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Updates a SearchHypernym inside a corpus. @@ -5126,8 +5242,10 @@ async def sample_update_search_hypernym(): 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, 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5195,7 +5313,7 @@ async def get_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Gets a SearchHypernym inside a corpus. @@ -5240,8 +5358,10 @@ async def sample_get_search_hypernym(): 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, 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5305,7 +5425,7 @@ async def delete_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a SearchHypernym inside a corpus. @@ -5347,8 +5467,10 @@ async def sample_delete_search_hypernym(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5400,7 +5522,7 @@ async def list_search_hypernyms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchHypernymsAsyncPager: r"""Lists SearchHypernyms inside a corpus. @@ -5446,8 +5568,10 @@ async def sample_list_search_hypernyms(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsAsyncPager: @@ -5521,7 +5645,7 @@ async def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsAsyncPager: r"""Search media asset. @@ -5558,8 +5682,10 @@ async def sample_search_assets(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsAsyncPager: @@ -5619,7 +5745,7 @@ async def search_index_endpoint( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchIndexEndpointAsyncPager: r"""Search a deployed index endpoint (IMAGE corpus type only). @@ -5662,8 +5788,10 @@ async def sample_search_index_endpoint(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointAsyncPager: @@ -5728,7 +5856,7 @@ async def create_index_endpoint( index_endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates an IndexEndpoint. @@ -5798,8 +5926,10 @@ async def sample_create_index_endpoint(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5876,7 +6006,7 @@ async def get_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Gets an IndexEndpoint. @@ -5919,8 +6049,10 @@ async def sample_get_index_endpoint(): 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, 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: google.cloud.visionai_v1.types.IndexEndpoint: @@ -5981,7 +6113,7 @@ async def list_index_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIndexEndpointsAsyncPager: r"""Lists all IndexEndpoints in a project. @@ -6026,8 +6158,10 @@ async def sample_list_index_endpoints(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsAsyncPager: @@ -6103,7 +6237,7 @@ async def update_index_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an IndexEndpoint. @@ -6160,8 +6294,10 @@ async def sample_update_index_endpoint(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6238,7 +6374,7 @@ async def delete_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes an IndexEndpoint. @@ -6284,8 +6420,10 @@ async def sample_delete_index_endpoint(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6363,7 +6501,7 @@ async def deploy_index( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys an Index to IndexEndpoint. @@ -6407,8 +6545,10 @@ async def sample_deploy_index(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6467,7 +6607,7 @@ async def undeploy_index( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys an Index from IndexEndpoint. @@ -6508,8 +6648,10 @@ async def sample_undeploy_index(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6571,7 +6713,7 @@ async def create_collection( collection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a collection. @@ -6639,8 +6781,10 @@ async def sample_create_collection(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6715,7 +6859,7 @@ async def delete_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a collection. @@ -6763,8 +6907,10 @@ async def sample_delete_collection(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6843,7 +6989,7 @@ async def get_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Gets a collection. @@ -6888,8 +7034,10 @@ async def sample_get_collection(): 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, 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: google.cloud.visionai_v1.types.Collection: @@ -6952,7 +7100,7 @@ async def update_collection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Updates a collection. @@ -7012,8 +7160,10 @@ async def sample_update_collection(): 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, 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: google.cloud.visionai_v1.types.Collection: @@ -7079,7 +7229,7 @@ async def list_collections( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCollectionsAsyncPager: r"""Lists collections inside a corpus. @@ -7123,8 +7273,10 @@ async def sample_list_collections(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsAsyncPager: @@ -7199,7 +7351,7 @@ async def add_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Adds an item into a Collection. @@ -7246,8 +7398,10 @@ async def sample_add_collection_item(): 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, 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: google.cloud.visionai_v1.types.AddCollectionItemResponse: @@ -7310,7 +7464,7 @@ async def remove_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Removes an item from a collection. @@ -7357,8 +7511,10 @@ async def sample_remove_collection_item(): 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, 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: google.cloud.visionai_v1.types.RemoveCollectionItemResponse: @@ -7421,7 +7577,7 @@ async def view_collection_items( collection: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewCollectionItemsAsyncPager: r"""View items inside a collection. @@ -7466,8 +7622,10 @@ async def sample_view_collection_items(): 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, 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: google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsAsyncPager: @@ -7543,7 +7701,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -7554,8 +7712,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -7596,7 +7756,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -7607,8 +7767,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -7649,7 +7811,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -7665,8 +7827,10 @@ async def delete_operation( 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, 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: None """ @@ -7703,7 +7867,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -7718,8 +7882,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py index 45001703e78d..b16c5d797ff1 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.location import locations_pb2 # type: ignore @@ -781,6 +791,10 @@ def __init__( # 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( @@ -843,6 +857,29 @@ def __init__( 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.visionai_v1.WarehouseClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "credentialsType": None, + }, + ) + def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -852,7 +889,7 @@ def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -915,8 +952,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Asset: @@ -984,7 +1023,7 @@ def update_asset( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -1034,8 +1073,10 @@ def sample_update_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Asset: @@ -1102,7 +1143,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -1145,8 +1186,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Asset: @@ -1209,7 +1252,7 @@ def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Lists an list of assets inside corpus. @@ -1254,8 +1297,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsPager: @@ -1327,7 +1372,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes asset inside corpus. @@ -1374,8 +1419,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1450,7 +1497,7 @@ def upload_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Upload asset by specifing the asset Cloud Storage uri. For video warehouse, it requires users who call @@ -1502,8 +1549,10 @@ def sample_upload_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1558,7 +1607,7 @@ def generate_retrieval_url( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Generates a signed url for downloading the asset. For video warehouse, please see comment of UploadAsset @@ -1598,8 +1647,10 @@ def sample_generate_retrieval_url(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse: @@ -1643,7 +1694,7 @@ def analyze_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Analyze asset to power search capability. @@ -1683,8 +1734,10 @@ def sample_analyze_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1739,7 +1792,7 @@ def index_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Index one asset for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1780,8 +1833,10 @@ def sample_index_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1836,7 +1891,7 @@ def remove_index_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove one asset's index data for search. Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND @@ -1877,8 +1932,10 @@ def sample_remove_index_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1934,7 +1991,7 @@ def view_indexed_assets( index: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewIndexedAssetsPager: r"""Lists assets inside an index. @@ -1980,8 +2037,10 @@ def sample_view_indexed_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsPager: @@ -2055,7 +2114,7 @@ def create_index( index_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates an Index under the corpus. @@ -2124,8 +2183,10 @@ def sample_create_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2199,7 +2260,7 @@ def update_index( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an Index under the corpus. Users can perform a metadata-only update or trigger a full index rebuild with @@ -2262,8 +2323,10 @@ def sample_update_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2336,7 +2399,7 @@ def get_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Gets the details of a single Index under a Corpus. @@ -2379,8 +2442,10 @@ def sample_get_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Index: @@ -2441,7 +2506,7 @@ def list_indexes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIndexesPager: r"""List all Indexes in a given Corpus. @@ -2486,8 +2551,10 @@ def sample_list_indexes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesPager: @@ -2559,7 +2626,7 @@ def delete_index( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete a single Index. In order to delete an index, the caller must make sure that it is not deployed to any @@ -2608,8 +2675,10 @@ def sample_delete_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2686,7 +2755,7 @@ def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a corpus inside a project. @@ -2742,8 +2811,10 @@ def sample_create_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2814,7 +2885,7 @@ def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -2857,8 +2928,10 @@ def sample_get_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Corpus: @@ -2919,7 +2992,7 @@ def update_corpus( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -2970,8 +3043,10 @@ def sample_update_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Corpus: @@ -3035,7 +3110,7 @@ def list_corpora( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCorporaPager: r"""Lists all corpora in a project. @@ -3079,8 +3154,10 @@ def sample_list_corpora(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaPager: @@ -3152,7 +3229,7 @@ def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a corpus only if its empty. Returns empty response. @@ -3193,8 +3270,10 @@ def sample_delete_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3242,7 +3321,7 @@ def analyze_corpus( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Analyzes a corpus. @@ -3282,8 +3361,10 @@ def sample_analyze_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3340,7 +3421,7 @@ def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -3393,8 +3474,10 @@ def sample_create_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.DataSchema: @@ -3456,7 +3539,7 @@ def update_data_schema( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -3508,8 +3591,10 @@ def sample_update_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.DataSchema: @@ -3572,7 +3657,7 @@ def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -3616,8 +3701,10 @@ def sample_get_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.DataSchema: @@ -3676,7 +3763,7 @@ def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes data schema inside corpus. @@ -3716,8 +3803,10 @@ def sample_delete_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3766,7 +3855,7 @@ def list_data_schemas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSchemasPager: r"""Lists a list of data schemas inside corpus. @@ -3811,8 +3900,10 @@ def sample_list_data_schemas(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasPager: @@ -3886,7 +3977,7 @@ def create_annotation( annotation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -3948,8 +4039,10 @@ def sample_create_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Annotation: @@ -4012,7 +4105,7 @@ def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -4057,8 +4150,10 @@ def sample_get_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Annotation: @@ -4117,7 +4212,7 @@ def list_annotations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnnotationsPager: r"""Lists a list of annotations inside asset. @@ -4162,8 +4257,10 @@ def sample_list_annotations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsPager: @@ -4236,7 +4333,7 @@ def update_annotation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -4286,8 +4383,10 @@ def sample_update_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Annotation: @@ -4350,7 +4449,7 @@ def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes annotation inside asset. @@ -4391,8 +4490,10 @@ def sample_delete_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4440,7 +4541,7 @@ def ingest_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[warehouse.IngestAssetResponse]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -4494,8 +4595,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1.types.IngestAssetResponse]: @@ -4526,7 +4629,7 @@ def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Supported by STREAM_VIDEO corpus type. Generates clips for downloading. The api takes in a time range, and generates a clip @@ -4567,8 +4670,10 @@ def sample_clip_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.ClipAssetResponse: @@ -4610,7 +4715,7 @@ def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -4649,8 +4754,10 @@ def sample_generate_hls_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.GenerateHlsUriResponse: @@ -4694,7 +4801,7 @@ def import_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Imports assets (images plus annotations) from a meta file on cloud storage. Each row in the meta file is @@ -4738,8 +4845,10 @@ def sample_import_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4797,7 +4906,7 @@ def create_search_config( search_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -4876,8 +4985,10 @@ def sample_create_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchConfig: @@ -4941,7 +5052,7 @@ def update_search_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -5009,8 +5120,10 @@ def sample_update_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchConfig: @@ -5073,7 +5186,7 @@ def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -5117,8 +5230,10 @@ def sample_get_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchConfig: @@ -5177,7 +5292,7 @@ def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a search configuration inside a corpus. @@ -5222,8 +5337,10 @@ def sample_delete_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5272,7 +5389,7 @@ def list_search_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchConfigsPager: r"""Lists all search configurations inside a corpus. @@ -5318,8 +5435,10 @@ def sample_list_search_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsPager: @@ -5393,7 +5512,7 @@ def create_search_hypernym( search_hypernym_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Creates a SearchHypernym inside a corpus. @@ -5453,8 +5572,10 @@ def sample_create_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5520,7 +5641,7 @@ def update_search_hypernym( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Updates a SearchHypernym inside a corpus. @@ -5573,8 +5694,10 @@ def sample_update_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5639,7 +5762,7 @@ def get_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Gets a SearchHypernym inside a corpus. @@ -5684,8 +5807,10 @@ def sample_get_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.SearchHypernym: @@ -5746,7 +5871,7 @@ def delete_search_hypernym( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a SearchHypernym inside a corpus. @@ -5788,8 +5913,10 @@ def sample_delete_search_hypernym(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5838,7 +5965,7 @@ def list_search_hypernyms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchHypernymsPager: r"""Lists SearchHypernyms inside a corpus. @@ -5884,8 +6011,10 @@ def sample_list_search_hypernyms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsPager: @@ -5956,7 +6085,7 @@ def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsPager: r"""Search media asset. @@ -5993,8 +6122,10 @@ def sample_search_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsPager: @@ -6052,7 +6183,7 @@ def search_index_endpoint( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchIndexEndpointPager: r"""Search a deployed index endpoint (IMAGE corpus type only). @@ -6095,8 +6226,10 @@ def sample_search_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointPager: @@ -6159,7 +6292,7 @@ def create_index_endpoint( index_endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates an IndexEndpoint. @@ -6229,8 +6362,10 @@ def sample_create_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6304,7 +6439,7 @@ def get_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Gets an IndexEndpoint. @@ -6347,8 +6482,10 @@ def sample_get_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.IndexEndpoint: @@ -6406,7 +6543,7 @@ def list_index_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIndexEndpointsPager: r"""Lists all IndexEndpoints in a project. @@ -6451,8 +6588,10 @@ def sample_list_index_endpoints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsPager: @@ -6525,7 +6664,7 @@ def update_index_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an IndexEndpoint. @@ -6582,8 +6721,10 @@ def sample_update_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6657,7 +6798,7 @@ def delete_index_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes an IndexEndpoint. @@ -6703,8 +6844,10 @@ def sample_delete_index_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6779,7 +6922,7 @@ def deploy_index( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deploys an Index to IndexEndpoint. @@ -6823,8 +6966,10 @@ def sample_deploy_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6881,7 +7026,7 @@ def undeploy_index( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeploys an Index from IndexEndpoint. @@ -6922,8 +7067,10 @@ def sample_undeploy_index(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6983,7 +7130,7 @@ def create_collection( collection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a collection. @@ -7051,8 +7198,10 @@ def sample_create_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -7124,7 +7273,7 @@ def delete_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a collection. @@ -7172,8 +7321,10 @@ def sample_delete_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -7249,7 +7400,7 @@ def get_collection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Gets a collection. @@ -7294,8 +7445,10 @@ def sample_get_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Collection: @@ -7355,7 +7508,7 @@ def update_collection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Updates a collection. @@ -7415,8 +7568,10 @@ def sample_update_collection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.Collection: @@ -7479,7 +7634,7 @@ def list_collections( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCollectionsPager: r"""Lists collections inside a corpus. @@ -7523,8 +7678,10 @@ def sample_list_collections(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsPager: @@ -7596,7 +7753,7 @@ def add_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Adds an item into a Collection. @@ -7643,8 +7800,10 @@ def sample_add_collection_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.AddCollectionItemResponse: @@ -7704,7 +7863,7 @@ def remove_collection_item( item: Optional[warehouse.CollectionItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Removes an item from a collection. @@ -7751,8 +7910,10 @@ def sample_remove_collection_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.types.RemoveCollectionItemResponse: @@ -7812,7 +7973,7 @@ def view_collection_items( collection: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ViewCollectionItemsPager: r"""View items inside a collection. @@ -7857,8 +8018,10 @@ def sample_view_collection_items(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsPager: @@ -7944,7 +8107,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -7955,8 +8118,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -7997,7 +8162,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -8008,8 +8173,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -8050,7 +8217,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -8066,8 +8233,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -8104,7 +8273,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -8119,8 +8288,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py index 160445512781..85b0bd97b0ef 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListAssetsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListAssetsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ViewIndexedAssetsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ViewIndexedAssetsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListIndexesRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListIndexesRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListCorporaRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListCorporaRequest(request) @@ -675,7 +691,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -689,8 +705,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListDataSchemasRequest(request) @@ -749,7 +767,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -763,8 +781,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListDataSchemasRequest(request) @@ -827,7 +847,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -841,8 +861,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListAnnotationsRequest(request) @@ -901,7 +923,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -915,8 +937,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListAnnotationsRequest(request) @@ -979,7 +1003,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -993,8 +1017,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListSearchConfigsRequest(request) @@ -1053,7 +1079,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1067,8 +1093,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListSearchConfigsRequest(request) @@ -1131,7 +1159,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1145,8 +1173,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListSearchHypernymsRequest(request) @@ -1205,7 +1235,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1219,8 +1249,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListSearchHypernymsRequest(request) @@ -1283,7 +1315,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1297,8 +1329,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.SearchAssetsRequest(request) @@ -1357,7 +1391,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1371,8 +1405,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.SearchAssetsRequest(request) @@ -1435,7 +1471,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1449,8 +1485,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.SearchIndexEndpointRequest(request) @@ -1509,7 +1547,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1523,8 +1561,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.SearchIndexEndpointRequest(request) @@ -1587,7 +1627,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1601,8 +1641,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListIndexEndpointsRequest(request) @@ -1661,7 +1703,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1675,8 +1717,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListIndexEndpointsRequest(request) @@ -1739,7 +1783,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1753,8 +1797,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListCollectionsRequest(request) @@ -1813,7 +1859,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1827,8 +1873,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListCollectionsRequest(request) @@ -1891,7 +1939,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1905,8 +1953,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ViewCollectionItemsRequest(request) @@ -1965,7 +2015,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1979,8 +2029,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ViewCollectionItemsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py index 372e53e0beca..d553900dfba7 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,12 +28,90 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport +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.visionai.v1.Warehouse", + "rpcName": 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.visionai.v1.Warehouse", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcTransport(WarehouseTransport): """gRPC backend transport for Warehouse. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def create_asset(self) -> Callable[[warehouse.CreateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -295,7 +383,7 @@ def update_asset(self) -> Callable[[warehouse.UpdateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -319,7 +407,7 @@ def get_asset(self) -> Callable[[warehouse.GetAssetRequest], warehouse.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -345,7 +433,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -371,7 +459,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -409,7 +497,7 @@ def upload_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_asset" not in self._stubs: - self._stubs["upload_asset"] = self.grpc_channel.unary_unary( + self._stubs["upload_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UploadAsset", request_serializer=warehouse.UploadAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -440,7 +528,7 @@ def generate_retrieval_url( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_retrieval_url" not in self._stubs: - self._stubs["generate_retrieval_url"] = self.grpc_channel.unary_unary( + self._stubs["generate_retrieval_url"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateRetrievalUrl", request_serializer=warehouse.GenerateRetrievalUrlRequest.serialize, response_deserializer=warehouse.GenerateRetrievalUrlResponse.deserialize, @@ -466,7 +554,7 @@ def analyze_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_asset" not in self._stubs: - self._stubs["analyze_asset"] = self.grpc_channel.unary_unary( + self._stubs["analyze_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeAsset", request_serializer=warehouse.AnalyzeAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "index_asset" not in self._stubs: - self._stubs["index_asset"] = self.grpc_channel.unary_unary( + self._stubs["index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/IndexAsset", request_serializer=warehouse.IndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def remove_index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_index_asset" not in self._stubs: - self._stubs["remove_index_asset"] = self.grpc_channel.unary_unary( + self._stubs["remove_index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveIndexAsset", request_serializer=warehouse.RemoveIndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -548,7 +636,7 @@ def view_indexed_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_indexed_assets" not in self._stubs: - self._stubs["view_indexed_assets"] = self.grpc_channel.unary_unary( + self._stubs["view_indexed_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewIndexedAssets", request_serializer=warehouse.ViewIndexedAssetsRequest.serialize, response_deserializer=warehouse.ViewIndexedAssetsResponse.deserialize, @@ -574,7 +662,7 @@ def create_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index" not in self._stubs: - self._stubs["create_index"] = self.grpc_channel.unary_unary( + self._stubs["create_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndex", request_serializer=warehouse.CreateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +690,7 @@ def update_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index" not in self._stubs: - self._stubs["update_index"] = self.grpc_channel.unary_unary( + self._stubs["update_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndex", request_serializer=warehouse.UpdateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -626,7 +714,7 @@ def get_index(self) -> Callable[[warehouse.GetIndexRequest], warehouse.Index]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index" not in self._stubs: - self._stubs["get_index"] = self.grpc_channel.unary_unary( + self._stubs["get_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndex", request_serializer=warehouse.GetIndexRequest.serialize, response_deserializer=warehouse.Index.deserialize, @@ -652,7 +740,7 @@ def list_indexes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_indexes" not in self._stubs: - self._stubs["list_indexes"] = self.grpc_channel.unary_unary( + self._stubs["list_indexes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexes", request_serializer=warehouse.ListIndexesRequest.serialize, response_deserializer=warehouse.ListIndexesResponse.deserialize, @@ -680,7 +768,7 @@ def delete_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index" not in self._stubs: - self._stubs["delete_index"] = self.grpc_channel.unary_unary( + self._stubs["delete_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndex", request_serializer=warehouse.DeleteIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -706,7 +794,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -730,7 +818,7 @@ def get_corpus(self) -> Callable[[warehouse.GetCorpusRequest], warehouse.Corpus] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -756,7 +844,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -782,7 +870,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -809,7 +897,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -835,7 +923,7 @@ def analyze_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_corpus" not in self._stubs: - self._stubs["analyze_corpus"] = self.grpc_channel.unary_unary( + self._stubs["analyze_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeCorpus", request_serializer=warehouse.AnalyzeCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -861,7 +949,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -887,7 +975,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -913,7 +1001,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -939,7 +1027,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -967,7 +1055,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -993,7 +1081,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1019,7 +1107,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1047,7 +1135,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -1073,7 +1161,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1099,7 +1187,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1129,7 +1217,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -1160,7 +1248,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -1188,7 +1276,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -1217,7 +1305,7 @@ def import_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_assets" not in self._stubs: - self._stubs["import_assets"] = self.grpc_channel.unary_unary( + self._stubs["import_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ImportAssets", request_serializer=warehouse.ImportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1258,7 +1346,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1298,7 +1386,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1324,7 +1412,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1353,7 +1441,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1381,7 +1469,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1407,7 +1495,7 @@ def create_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_hypernym" not in self._stubs: - self._stubs["create_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["create_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchHypernym", request_serializer=warehouse.CreateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1433,7 +1521,7 @@ def update_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_hypernym" not in self._stubs: - self._stubs["update_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["update_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchHypernym", request_serializer=warehouse.UpdateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1459,7 +1547,7 @@ def get_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_hypernym" not in self._stubs: - self._stubs["get_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["get_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchHypernym", request_serializer=warehouse.GetSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1485,7 +1573,7 @@ def delete_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_hypernym" not in self._stubs: - self._stubs["delete_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchHypernym", request_serializer=warehouse.DeleteSearchHypernymRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1513,7 +1601,7 @@ def list_search_hypernyms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_hypernyms" not in self._stubs: - self._stubs["list_search_hypernyms"] = self.grpc_channel.unary_unary( + self._stubs["list_search_hypernyms"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchHypernyms", request_serializer=warehouse.ListSearchHypernymsRequest.serialize, response_deserializer=warehouse.ListSearchHypernymsResponse.deserialize, @@ -1539,7 +1627,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1568,7 +1656,7 @@ def search_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_index_endpoint" not in self._stubs: - self._stubs["search_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["search_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchIndexEndpoint", request_serializer=warehouse.SearchIndexEndpointRequest.serialize, response_deserializer=warehouse.SearchIndexEndpointResponse.deserialize, @@ -1594,7 +1682,7 @@ def create_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index_endpoint" not in self._stubs: - self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndexEndpoint", request_serializer=warehouse.CreateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1620,7 +1708,7 @@ def get_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index_endpoint" not in self._stubs: - self._stubs["get_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndexEndpoint", request_serializer=warehouse.GetIndexEndpointRequest.serialize, response_deserializer=warehouse.IndexEndpoint.deserialize, @@ -1648,7 +1736,7 @@ def list_index_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_index_endpoints" not in self._stubs: - self._stubs["list_index_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_index_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexEndpoints", request_serializer=warehouse.ListIndexEndpointsRequest.serialize, response_deserializer=warehouse.ListIndexEndpointsResponse.deserialize, @@ -1674,7 +1762,7 @@ def update_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index_endpoint" not in self._stubs: - self._stubs["update_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndexEndpoint", request_serializer=warehouse.UpdateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1700,7 +1788,7 @@ def delete_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index_endpoint" not in self._stubs: - self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndexEndpoint", request_serializer=warehouse.DeleteIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1726,7 +1814,7 @@ def deploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_index" not in self._stubs: - self._stubs["deploy_index"] = self.grpc_channel.unary_unary( + self._stubs["deploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeployIndex", request_serializer=warehouse.DeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1752,7 +1840,7 @@ def undeploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_index" not in self._stubs: - self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UndeployIndex", request_serializer=warehouse.UndeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1778,7 +1866,7 @@ def create_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collection" not in self._stubs: - self._stubs["create_collection"] = self.grpc_channel.unary_unary( + self._stubs["create_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCollection", request_serializer=warehouse.CreateCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1804,7 +1892,7 @@ def delete_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collection" not in self._stubs: - self._stubs["delete_collection"] = self.grpc_channel.unary_unary( + self._stubs["delete_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCollection", request_serializer=warehouse.DeleteCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1830,7 +1918,7 @@ def get_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collection" not in self._stubs: - self._stubs["get_collection"] = self.grpc_channel.unary_unary( + self._stubs["get_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCollection", request_serializer=warehouse.GetCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1856,7 +1944,7 @@ def update_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collection" not in self._stubs: - self._stubs["update_collection"] = self.grpc_channel.unary_unary( + self._stubs["update_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCollection", request_serializer=warehouse.UpdateCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1884,7 +1972,7 @@ def list_collections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collections" not in self._stubs: - self._stubs["list_collections"] = self.grpc_channel.unary_unary( + self._stubs["list_collections"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCollections", request_serializer=warehouse.ListCollectionsRequest.serialize, response_deserializer=warehouse.ListCollectionsResponse.deserialize, @@ -1912,7 +2000,7 @@ def add_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_collection_item" not in self._stubs: - self._stubs["add_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["add_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AddCollectionItem", request_serializer=warehouse.AddCollectionItemRequest.serialize, response_deserializer=warehouse.AddCollectionItemResponse.deserialize, @@ -1940,7 +2028,7 @@ def remove_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_collection_item" not in self._stubs: - self._stubs["remove_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["remove_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveCollectionItem", request_serializer=warehouse.RemoveCollectionItemRequest.serialize, response_deserializer=warehouse.RemoveCollectionItemResponse.deserialize, @@ -1968,7 +2056,7 @@ def view_collection_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_collection_items" not in self._stubs: - self._stubs["view_collection_items"] = self.grpc_channel.unary_unary( + self._stubs["view_collection_items"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewCollectionItems", request_serializer=warehouse.ViewCollectionItemsRequest.serialize, response_deserializer=warehouse.ViewCollectionItemsResponse.deserialize, @@ -1976,7 +2064,7 @@ def view_collection_items( return self._stubs["view_collection_items"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1988,7 +2076,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -2005,7 +2093,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -2022,7 +2110,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -2041,7 +2129,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py index a0098d4d36d8..c9850ed05d98 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -27,14 +30,93 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport from .grpc import WarehouseGrpcTransport +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.visionai.v1.Warehouse", + "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.visionai.v1.Warehouse", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcAsyncIOTransport(WarehouseTransport): """gRPC AsyncIO backend transport for Warehouse. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -309,7 +394,7 @@ def update_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -335,7 +420,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -363,7 +448,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -389,7 +474,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +512,7 @@ def upload_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_asset" not in self._stubs: - self._stubs["upload_asset"] = self.grpc_channel.unary_unary( + self._stubs["upload_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UploadAsset", request_serializer=warehouse.UploadAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -459,7 +544,7 @@ def generate_retrieval_url( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_retrieval_url" not in self._stubs: - self._stubs["generate_retrieval_url"] = self.grpc_channel.unary_unary( + self._stubs["generate_retrieval_url"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateRetrievalUrl", request_serializer=warehouse.GenerateRetrievalUrlRequest.serialize, response_deserializer=warehouse.GenerateRetrievalUrlResponse.deserialize, @@ -485,7 +570,7 @@ def analyze_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_asset" not in self._stubs: - self._stubs["analyze_asset"] = self.grpc_channel.unary_unary( + self._stubs["analyze_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeAsset", request_serializer=warehouse.AnalyzeAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -512,7 +597,7 @@ def index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "index_asset" not in self._stubs: - self._stubs["index_asset"] = self.grpc_channel.unary_unary( + self._stubs["index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/IndexAsset", request_serializer=warehouse.IndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +626,7 @@ def remove_index_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_index_asset" not in self._stubs: - self._stubs["remove_index_asset"] = self.grpc_channel.unary_unary( + self._stubs["remove_index_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveIndexAsset", request_serializer=warehouse.RemoveIndexAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -570,7 +655,7 @@ def view_indexed_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_indexed_assets" not in self._stubs: - self._stubs["view_indexed_assets"] = self.grpc_channel.unary_unary( + self._stubs["view_indexed_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewIndexedAssets", request_serializer=warehouse.ViewIndexedAssetsRequest.serialize, response_deserializer=warehouse.ViewIndexedAssetsResponse.deserialize, @@ -596,7 +681,7 @@ def create_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index" not in self._stubs: - self._stubs["create_index"] = self.grpc_channel.unary_unary( + self._stubs["create_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndex", request_serializer=warehouse.CreateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def update_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index" not in self._stubs: - self._stubs["update_index"] = self.grpc_channel.unary_unary( + self._stubs["update_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndex", request_serializer=warehouse.UpdateIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -650,7 +735,7 @@ def get_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index" not in self._stubs: - self._stubs["get_index"] = self.grpc_channel.unary_unary( + self._stubs["get_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndex", request_serializer=warehouse.GetIndexRequest.serialize, response_deserializer=warehouse.Index.deserialize, @@ -678,7 +763,7 @@ def list_indexes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_indexes" not in self._stubs: - self._stubs["list_indexes"] = self.grpc_channel.unary_unary( + self._stubs["list_indexes"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexes", request_serializer=warehouse.ListIndexesRequest.serialize, response_deserializer=warehouse.ListIndexesResponse.deserialize, @@ -706,7 +791,7 @@ def delete_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index" not in self._stubs: - self._stubs["delete_index"] = self.grpc_channel.unary_unary( + self._stubs["delete_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndex", request_serializer=warehouse.DeleteIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -732,7 +817,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -758,7 +843,7 @@ def get_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -784,7 +869,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -812,7 +897,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -839,7 +924,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -867,7 +952,7 @@ def analyze_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_corpus" not in self._stubs: - self._stubs["analyze_corpus"] = self.grpc_channel.unary_unary( + self._stubs["analyze_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AnalyzeCorpus", request_serializer=warehouse.AnalyzeCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -893,7 +978,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -919,7 +1004,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -945,7 +1030,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -971,7 +1056,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -999,7 +1084,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -1025,7 +1110,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1051,7 +1136,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1079,7 +1164,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -1105,7 +1190,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -1131,7 +1216,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1163,7 +1248,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -1194,7 +1279,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -1224,7 +1309,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -1253,7 +1338,7 @@ def import_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_assets" not in self._stubs: - self._stubs["import_assets"] = self.grpc_channel.unary_unary( + self._stubs["import_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ImportAssets", request_serializer=warehouse.ImportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1296,7 +1381,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1338,7 +1423,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1366,7 +1451,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1395,7 +1480,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1424,7 +1509,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1452,7 +1537,7 @@ def create_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_hypernym" not in self._stubs: - self._stubs["create_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["create_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateSearchHypernym", request_serializer=warehouse.CreateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1480,7 +1565,7 @@ def update_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_hypernym" not in self._stubs: - self._stubs["update_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["update_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateSearchHypernym", request_serializer=warehouse.UpdateSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1508,7 +1593,7 @@ def get_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_hypernym" not in self._stubs: - self._stubs["get_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["get_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetSearchHypernym", request_serializer=warehouse.GetSearchHypernymRequest.serialize, response_deserializer=warehouse.SearchHypernym.deserialize, @@ -1534,7 +1619,7 @@ def delete_search_hypernym( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_hypernym" not in self._stubs: - self._stubs["delete_search_hypernym"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_hypernym"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteSearchHypernym", request_serializer=warehouse.DeleteSearchHypernymRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1563,7 +1648,7 @@ def list_search_hypernyms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_hypernyms" not in self._stubs: - self._stubs["list_search_hypernyms"] = self.grpc_channel.unary_unary( + self._stubs["list_search_hypernyms"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListSearchHypernyms", request_serializer=warehouse.ListSearchHypernymsRequest.serialize, response_deserializer=warehouse.ListSearchHypernymsResponse.deserialize, @@ -1591,7 +1676,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1621,7 +1706,7 @@ def search_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_index_endpoint" not in self._stubs: - self._stubs["search_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["search_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/SearchIndexEndpoint", request_serializer=warehouse.SearchIndexEndpointRequest.serialize, response_deserializer=warehouse.SearchIndexEndpointResponse.deserialize, @@ -1649,7 +1734,7 @@ def create_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_index_endpoint" not in self._stubs: - self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateIndexEndpoint", request_serializer=warehouse.CreateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1677,7 +1762,7 @@ def get_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_index_endpoint" not in self._stubs: - self._stubs["get_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetIndexEndpoint", request_serializer=warehouse.GetIndexEndpointRequest.serialize, response_deserializer=warehouse.IndexEndpoint.deserialize, @@ -1706,7 +1791,7 @@ def list_index_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_index_endpoints" not in self._stubs: - self._stubs["list_index_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_index_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListIndexEndpoints", request_serializer=warehouse.ListIndexEndpointsRequest.serialize, response_deserializer=warehouse.ListIndexEndpointsResponse.deserialize, @@ -1734,7 +1819,7 @@ def update_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_index_endpoint" not in self._stubs: - self._stubs["update_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateIndexEndpoint", request_serializer=warehouse.UpdateIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1762,7 +1847,7 @@ def delete_index_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_index_endpoint" not in self._stubs: - self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_index_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteIndexEndpoint", request_serializer=warehouse.DeleteIndexEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1788,7 +1873,7 @@ def deploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_index" not in self._stubs: - self._stubs["deploy_index"] = self.grpc_channel.unary_unary( + self._stubs["deploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeployIndex", request_serializer=warehouse.DeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1816,7 +1901,7 @@ def undeploy_index( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_index" not in self._stubs: - self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_index"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UndeployIndex", request_serializer=warehouse.UndeployIndexRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1844,7 +1929,7 @@ def create_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collection" not in self._stubs: - self._stubs["create_collection"] = self.grpc_channel.unary_unary( + self._stubs["create_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/CreateCollection", request_serializer=warehouse.CreateCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1872,7 +1957,7 @@ def delete_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collection" not in self._stubs: - self._stubs["delete_collection"] = self.grpc_channel.unary_unary( + self._stubs["delete_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/DeleteCollection", request_serializer=warehouse.DeleteCollectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1898,7 +1983,7 @@ def get_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collection" not in self._stubs: - self._stubs["get_collection"] = self.grpc_channel.unary_unary( + self._stubs["get_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/GetCollection", request_serializer=warehouse.GetCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1924,7 +2009,7 @@ def update_collection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collection" not in self._stubs: - self._stubs["update_collection"] = self.grpc_channel.unary_unary( + self._stubs["update_collection"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/UpdateCollection", request_serializer=warehouse.UpdateCollectionRequest.serialize, response_deserializer=warehouse.Collection.deserialize, @@ -1952,7 +2037,7 @@ def list_collections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collections" not in self._stubs: - self._stubs["list_collections"] = self.grpc_channel.unary_unary( + self._stubs["list_collections"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ListCollections", request_serializer=warehouse.ListCollectionsRequest.serialize, response_deserializer=warehouse.ListCollectionsResponse.deserialize, @@ -1981,7 +2066,7 @@ def add_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_collection_item" not in self._stubs: - self._stubs["add_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["add_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/AddCollectionItem", request_serializer=warehouse.AddCollectionItemRequest.serialize, response_deserializer=warehouse.AddCollectionItemResponse.deserialize, @@ -2010,7 +2095,7 @@ def remove_collection_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_collection_item" not in self._stubs: - self._stubs["remove_collection_item"] = self.grpc_channel.unary_unary( + self._stubs["remove_collection_item"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/RemoveCollectionItem", request_serializer=warehouse.RemoveCollectionItemRequest.serialize, response_deserializer=warehouse.RemoveCollectionItemResponse.deserialize, @@ -2039,7 +2124,7 @@ def view_collection_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "view_collection_items" not in self._stubs: - self._stubs["view_collection_items"] = self.grpc_channel.unary_unary( + self._stubs["view_collection_items"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1.Warehouse/ViewCollectionItems", request_serializer=warehouse.ViewCollectionItemsRequest.serialize, response_deserializer=warehouse.ViewCollectionItemsResponse.deserialize, @@ -2437,7 +2522,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -2453,7 +2538,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -2470,7 +2555,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -2487,7 +2572,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -2506,7 +2591,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py index f2bb45f69c8e..845f3c188a16 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1/services/warehouse/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -550,8 +558,10 @@ def post_view_indexed_assets(self, response): def pre_add_collection_item( self, request: warehouse.AddCollectionItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AddCollectionItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.AddCollectionItemRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_collection_item Override in a subclass to manipulate the request or metadata @@ -573,8 +583,8 @@ def post_add_collection_item( def pre_analyze_asset( self, request: warehouse.AnalyzeAssetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AnalyzeAssetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.AnalyzeAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_asset Override in a subclass to manipulate the request or metadata @@ -596,8 +606,8 @@ def post_analyze_asset( def pre_analyze_corpus( self, request: warehouse.AnalyzeCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.AnalyzeCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.AnalyzeCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_corpus Override in a subclass to manipulate the request or metadata @@ -617,8 +627,10 @@ def post_analyze_corpus( return response def pre_clip_asset( - self, request: warehouse.ClipAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ClipAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for clip_asset Override in a subclass to manipulate the request or metadata @@ -640,8 +652,10 @@ def post_clip_asset( def pre_create_annotation( self, request: warehouse.CreateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_annotation Override in a subclass to manipulate the request or metadata @@ -661,8 +675,10 @@ def post_create_annotation( return response def pre_create_asset( - self, request: warehouse.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -682,8 +698,10 @@ def post_create_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_create_collection( self, request: warehouse.CreateCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_collection Override in a subclass to manipulate the request or metadata @@ -705,8 +723,8 @@ def post_create_collection( def pre_create_corpus( self, request: warehouse.CreateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_corpus Override in a subclass to manipulate the request or metadata @@ -728,8 +746,10 @@ def post_create_corpus( def pre_create_data_schema( self, request: warehouse.CreateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_schema Override in a subclass to manipulate the request or metadata @@ -749,8 +769,10 @@ def post_create_data_schema( return response def pre_create_index( - self, request: warehouse.CreateIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_index Override in a subclass to manipulate the request or metadata @@ -772,8 +794,10 @@ def post_create_index( def pre_create_index_endpoint( self, request: warehouse.CreateIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_index_endpoint Override in a subclass to manipulate the request or metadata @@ -795,8 +819,10 @@ def post_create_index_endpoint( def pre_create_search_config( self, request: warehouse.CreateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_config Override in a subclass to manipulate the request or metadata @@ -818,8 +844,10 @@ def post_create_search_config( def pre_create_search_hypernym( self, request: warehouse.CreateSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_hypernym Override in a subclass to manipulate the request or metadata @@ -841,8 +869,10 @@ def post_create_search_hypernym( def pre_delete_annotation( self, request: warehouse.DeleteAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_annotation Override in a subclass to manipulate the request or metadata @@ -851,8 +881,10 @@ def pre_delete_annotation( return request, metadata def pre_delete_asset( - self, request: warehouse.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -874,8 +906,10 @@ def post_delete_asset( def pre_delete_collection( self, request: warehouse.DeleteCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_collection Override in a subclass to manipulate the request or metadata @@ -897,8 +931,8 @@ def post_delete_collection( def pre_delete_corpus( self, request: warehouse.DeleteCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_corpus Override in a subclass to manipulate the request or metadata @@ -909,8 +943,10 @@ def pre_delete_corpus( def pre_delete_data_schema( self, request: warehouse.DeleteDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_schema Override in a subclass to manipulate the request or metadata @@ -919,8 +955,10 @@ def pre_delete_data_schema( return request, metadata def pre_delete_index( - self, request: warehouse.DeleteIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_index Override in a subclass to manipulate the request or metadata @@ -942,8 +980,10 @@ def post_delete_index( def pre_delete_index_endpoint( self, request: warehouse.DeleteIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_index_endpoint Override in a subclass to manipulate the request or metadata @@ -965,8 +1005,10 @@ def post_delete_index_endpoint( def pre_delete_search_config( self, request: warehouse.DeleteSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_config Override in a subclass to manipulate the request or metadata @@ -977,8 +1019,10 @@ def pre_delete_search_config( def pre_delete_search_hypernym( self, request: warehouse.DeleteSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_hypernym Override in a subclass to manipulate the request or metadata @@ -987,8 +1031,10 @@ def pre_delete_search_hypernym( return request, metadata def pre_deploy_index( - self, request: warehouse.DeployIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeployIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeployIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeployIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for deploy_index Override in a subclass to manipulate the request or metadata @@ -1010,8 +1056,10 @@ def post_deploy_index( def pre_generate_hls_uri( self, request: warehouse.GenerateHlsUriRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_hls_uri Override in a subclass to manipulate the request or metadata @@ -1033,8 +1081,10 @@ def post_generate_hls_uri( def pre_generate_retrieval_url( self, request: warehouse.GenerateRetrievalUrlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateRetrievalUrlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateRetrievalUrlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_retrieval_url Override in a subclass to manipulate the request or metadata @@ -1056,8 +1106,8 @@ def post_generate_retrieval_url( def pre_get_annotation( self, request: warehouse.GetAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_annotation Override in a subclass to manipulate the request or metadata @@ -1077,8 +1127,10 @@ def post_get_annotation( return response def pre_get_asset( - self, request: warehouse.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -1098,8 +1150,8 @@ def post_get_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_get_collection( self, request: warehouse.GetCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_collection Override in a subclass to manipulate the request or metadata @@ -1119,8 +1171,10 @@ def post_get_collection( return response def pre_get_corpus( - self, request: warehouse.GetCorpusRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetCorpusRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_corpus Override in a subclass to manipulate the request or metadata @@ -1140,8 +1194,8 @@ def post_get_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_get_data_schema( self, request: warehouse.GetDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_data_schema Override in a subclass to manipulate the request or metadata @@ -1161,8 +1215,10 @@ def post_get_data_schema( return response def pre_get_index( - self, request: warehouse.GetIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_index Override in a subclass to manipulate the request or metadata @@ -1182,8 +1238,10 @@ def post_get_index(self, response: warehouse.Index) -> warehouse.Index: def pre_get_index_endpoint( self, request: warehouse.GetIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1205,8 +1263,10 @@ def post_get_index_endpoint( def pre_get_search_config( self, request: warehouse.GetSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_config Override in a subclass to manipulate the request or metadata @@ -1228,8 +1288,10 @@ def post_get_search_config( def pre_get_search_hypernym( self, request: warehouse.GetSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_hypernym Override in a subclass to manipulate the request or metadata @@ -1251,8 +1313,8 @@ def post_get_search_hypernym( def pre_import_assets( self, request: warehouse.ImportAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ImportAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ImportAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_assets Override in a subclass to manipulate the request or metadata @@ -1272,8 +1334,10 @@ def post_import_assets( return response def pre_index_asset( - self, request: warehouse.IndexAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.IndexAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.IndexAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.IndexAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for index_asset Override in a subclass to manipulate the request or metadata @@ -1295,8 +1359,10 @@ def post_index_asset( def pre_list_annotations( self, request: warehouse.ListAnnotationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListAnnotationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListAnnotationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_annotations Override in a subclass to manipulate the request or metadata @@ -1316,8 +1382,10 @@ def post_list_annotations( return response def pre_list_assets( - self, request: warehouse.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -1339,8 +1407,10 @@ def post_list_assets( def pre_list_collections( self, request: warehouse.ListCollectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListCollectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListCollectionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_collections Override in a subclass to manipulate the request or metadata @@ -1360,8 +1430,10 @@ def post_list_collections( return response def pre_list_corpora( - self, request: warehouse.ListCorporaRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListCorporaRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_corpora Override in a subclass to manipulate the request or metadata @@ -1383,8 +1455,10 @@ def post_list_corpora( def pre_list_data_schemas( self, request: warehouse.ListDataSchemasRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListDataSchemasRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListDataSchemasRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_schemas Override in a subclass to manipulate the request or metadata @@ -1406,8 +1480,10 @@ def post_list_data_schemas( def pre_list_index_endpoints( self, request: warehouse.ListIndexEndpointsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListIndexEndpointsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListIndexEndpointsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_index_endpoints Override in a subclass to manipulate the request or metadata @@ -1427,8 +1503,10 @@ def post_list_index_endpoints( return response def pre_list_indexes( - self, request: warehouse.ListIndexesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListIndexesRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListIndexesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListIndexesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_indexes Override in a subclass to manipulate the request or metadata @@ -1450,8 +1528,10 @@ def post_list_indexes( def pre_list_search_configs( self, request: warehouse.ListSearchConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_configs Override in a subclass to manipulate the request or metadata @@ -1473,8 +1553,10 @@ def post_list_search_configs( def pre_list_search_hypernyms( self, request: warehouse.ListSearchHypernymsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchHypernymsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchHypernymsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_hypernyms Override in a subclass to manipulate the request or metadata @@ -1496,8 +1578,10 @@ def post_list_search_hypernyms( def pre_remove_collection_item( self, request: warehouse.RemoveCollectionItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.RemoveCollectionItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.RemoveCollectionItemRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_collection_item Override in a subclass to manipulate the request or metadata @@ -1519,8 +1603,10 @@ def post_remove_collection_item( def pre_remove_index_asset( self, request: warehouse.RemoveIndexAssetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.RemoveIndexAssetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.RemoveIndexAssetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_index_asset Override in a subclass to manipulate the request or metadata @@ -1542,8 +1628,8 @@ def post_remove_index_asset( def pre_search_assets( self, request: warehouse.SearchAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_assets Override in a subclass to manipulate the request or metadata @@ -1565,8 +1651,10 @@ def post_search_assets( def pre_search_index_endpoint( self, request: warehouse.SearchIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.SearchIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1588,8 +1676,8 @@ def post_search_index_endpoint( def pre_undeploy_index( self, request: warehouse.UndeployIndexRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UndeployIndexRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UndeployIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undeploy_index Override in a subclass to manipulate the request or metadata @@ -1611,8 +1699,10 @@ def post_undeploy_index( def pre_update_annotation( self, request: warehouse.UpdateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_annotation Override in a subclass to manipulate the request or metadata @@ -1632,8 +1722,10 @@ def post_update_annotation( return response def pre_update_asset( - self, request: warehouse.UpdateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_asset Override in a subclass to manipulate the request or metadata @@ -1653,8 +1745,10 @@ def post_update_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_update_collection( self, request: warehouse.UpdateCollectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCollectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateCollectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_collection Override in a subclass to manipulate the request or metadata @@ -1676,8 +1770,8 @@ def post_update_collection( def pre_update_corpus( self, request: warehouse.UpdateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_corpus Override in a subclass to manipulate the request or metadata @@ -1697,8 +1791,10 @@ def post_update_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_update_data_schema( self, request: warehouse.UpdateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_schema Override in a subclass to manipulate the request or metadata @@ -1718,8 +1814,10 @@ def post_update_data_schema( return response def pre_update_index( - self, request: warehouse.UpdateIndexRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateIndexRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateIndexRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateIndexRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_index Override in a subclass to manipulate the request or metadata @@ -1741,8 +1839,10 @@ def post_update_index( def pre_update_index_endpoint( self, request: warehouse.UpdateIndexEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateIndexEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateIndexEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_index_endpoint Override in a subclass to manipulate the request or metadata @@ -1764,8 +1864,10 @@ def post_update_index_endpoint( def pre_update_search_config( self, request: warehouse.UpdateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_config Override in a subclass to manipulate the request or metadata @@ -1787,8 +1889,10 @@ def post_update_search_config( def pre_update_search_hypernym( self, request: warehouse.UpdateSearchHypernymRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchHypernymRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchHypernymRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_hypernym Override in a subclass to manipulate the request or metadata @@ -1808,8 +1912,10 @@ def post_update_search_hypernym( return response def pre_upload_asset( - self, request: warehouse.UploadAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UploadAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UploadAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UploadAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upload_asset Override in a subclass to manipulate the request or metadata @@ -1831,8 +1937,10 @@ def post_upload_asset( def pre_view_collection_items( self, request: warehouse.ViewCollectionItemsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ViewCollectionItemsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ViewCollectionItemsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for view_collection_items Override in a subclass to manipulate the request or metadata @@ -1854,8 +1962,10 @@ def post_view_collection_items( def pre_view_indexed_assets( self, request: warehouse.ViewIndexedAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ViewIndexedAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ViewIndexedAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for view_indexed_assets Override in a subclass to manipulate the request or metadata @@ -1877,8 +1987,10 @@ def post_view_indexed_assets( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1898,8 +2010,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1919,8 +2033,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1942,8 +2058,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2166,7 +2284,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.AddCollectionItemResponse: r"""Call the add collection item method over HTTP. @@ -2177,8 +2295,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.AddCollectionItemResponse: @@ -2190,6 +2310,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAddCollectionItem._get_http_options() ) + request, metadata = self._interceptor.pre_add_collection_item( request, metadata ) @@ -2206,6 +2327,33 @@ def __call__( 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.visionai_v1.WarehouseClient.AddCollectionItem", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AddCollectionItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AddCollectionItem._get_response( self._host, @@ -2227,7 +2375,31 @@ def __call__( pb_resp = warehouse.AddCollectionItemResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_collection_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.AddCollectionItemResponse.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.visionai_v1.WarehouseClient.add_collection_item", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AddCollectionItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeAsset( @@ -2265,7 +2437,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the analyze asset method over HTTP. @@ -2275,8 +2447,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2289,6 +2463,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAnalyzeAsset._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseAnalyzeAsset._get_transcoded_request( @@ -2307,6 +2482,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.AnalyzeAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AnalyzeAsset._get_response( self._host, @@ -2326,7 +2528,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_asset(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.visionai_v1.WarehouseClient.analyze_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeCorpus( @@ -2364,7 +2588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the analyze corpus method over HTTP. @@ -2374,8 +2598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2388,6 +2614,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseAnalyzeCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseAnalyzeCorpus._get_transcoded_request( @@ -2408,6 +2635,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.AnalyzeCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._AnalyzeCorpus._get_response( self._host, @@ -2427,7 +2681,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_corpus(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.visionai_v1.WarehouseClient.analyze_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "AnalyzeCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ClipAsset(_BaseWarehouseRestTransport._BaseClipAsset, WarehouseRestStub): @@ -2463,7 +2739,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Call the clip asset method over HTTP. @@ -2473,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ClipAssetResponse: @@ -2484,6 +2762,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseClipAsset._get_http_options() ) + request, metadata = self._interceptor.pre_clip_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseClipAsset._get_transcoded_request( @@ -2502,6 +2781,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ClipAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ClipAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ClipAsset._get_response( self._host, @@ -2523,7 +2829,29 @@ def __call__( pb_resp = warehouse.ClipAssetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clip_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ClipAssetResponse.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.visionai_v1.WarehouseClient.clip_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ClipAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnnotation( @@ -2561,7 +2889,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the create annotation method over HTTP. @@ -2571,8 +2899,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -2585,6 +2915,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_create_annotation( request, metadata ) @@ -2601,6 +2932,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAnnotation._get_response( self._host, @@ -2622,7 +2980,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1.WarehouseClient.create_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAsset(_BaseWarehouseRestTransport._BaseCreateAsset, WarehouseRestStub): @@ -2658,7 +3038,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the create asset method over HTTP. @@ -2669,8 +3049,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -2687,6 +3069,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_transcoded_request( @@ -2705,6 +3088,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.CreateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAsset._get_response( self._host, @@ -2726,7 +3136,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1.WarehouseClient.create_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCollection( @@ -2764,7 +3196,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create collection method over HTTP. @@ -2774,8 +3206,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2788,6 +3222,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCollection._get_http_options() ) + request, metadata = self._interceptor.pre_create_collection( request, metadata ) @@ -2804,6 +3239,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCollection._get_response( self._host, @@ -2823,7 +3285,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_collection(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.visionai_v1.WarehouseClient.create_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCorpus( @@ -2861,7 +3345,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create corpus method over HTTP. @@ -2871,8 +3355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2885,6 +3371,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_create_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_transcoded_request( @@ -2903,6 +3390,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.CreateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCorpus._get_response( self._host, @@ -2922,7 +3436,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_corpus(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.visionai_v1.WarehouseClient.create_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataSchema( @@ -2960,7 +3496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the create data schema method over HTTP. @@ -2970,8 +3506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -2984,6 +3522,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_schema( request, metadata ) @@ -3000,6 +3539,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateDataSchema._get_response( self._host, @@ -3021,7 +3587,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1.WarehouseClient.create_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIndex(_BaseWarehouseRestTransport._BaseCreateIndex, WarehouseRestStub): @@ -3057,7 +3645,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create index method over HTTP. @@ -3067,8 +3655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3081,6 +3671,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateIndex._get_http_options() ) + request, metadata = self._interceptor.pre_create_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateIndex._get_transcoded_request( @@ -3099,6 +3690,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.CreateIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateIndex._get_response( self._host, @@ -3118,7 +3736,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_index(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.visionai_v1.WarehouseClient.create_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIndexEndpoint( @@ -3156,7 +3796,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create index endpoint method over HTTP. @@ -3167,8 +3807,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3181,6 +3823,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_create_index_endpoint( request, metadata ) @@ -3197,6 +3840,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateIndexEndpoint._get_response( self._host, @@ -3216,7 +3886,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_index_endpoint(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.visionai_v1.WarehouseClient.create_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchConfig( @@ -3254,7 +3946,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the create search config method over HTTP. @@ -3265,8 +3957,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -3279,6 +3973,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_config( request, metadata ) @@ -3295,6 +3990,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchConfig._get_response( self._host, @@ -3316,7 +4038,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1.WarehouseClient.create_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchHypernym( @@ -3354,7 +4098,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the create search hypernym method over HTTP. @@ -3365,8 +4109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchHypernym: @@ -3381,6 +4127,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_hypernym( request, metadata ) @@ -3397,6 +4144,33 @@ def __call__( 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.visionai_v1.WarehouseClient.CreateSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchHypernym._get_response( self._host, @@ -3418,7 +4192,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.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.visionai_v1.WarehouseClient.create_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CreateSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnnotation( @@ -3455,7 +4251,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete annotation method over HTTP. @@ -3466,13 +4262,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_annotation( request, metadata ) @@ -3485,6 +4284,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAnnotation._get_response( self._host, @@ -3532,7 +4358,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete asset method over HTTP. @@ -3542,8 +4368,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3556,6 +4384,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_transcoded_request( @@ -3570,6 +4399,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAsset._get_response( self._host, @@ -3588,7 +4444,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_asset(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.visionai_v1.WarehouseClient.delete_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCollection( @@ -3625,7 +4503,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete collection method over HTTP. @@ -3636,8 +4514,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3650,6 +4530,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteCollection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_collection( request, metadata ) @@ -3662,6 +4543,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCollection._get_response( self._host, @@ -3680,7 +4588,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_collection(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.visionai_v1.WarehouseClient.delete_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCorpus( @@ -3717,7 +4647,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete corpus method over HTTP. @@ -3727,13 +4657,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_delete_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_transcoded_request( @@ -3748,6 +4681,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.DeleteCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCorpus._get_response( self._host, @@ -3797,7 +4757,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete data schema method over HTTP. @@ -3807,13 +4767,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_schema( request, metadata ) @@ -3826,6 +4789,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteDataSchema._get_response( self._host, @@ -3873,7 +4863,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete index method over HTTP. @@ -3883,8 +4873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3897,6 +4889,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteIndex._get_http_options() ) + request, metadata = self._interceptor.pre_delete_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteIndex._get_transcoded_request( @@ -3911,6 +4904,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.DeleteIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteIndex._get_response( self._host, @@ -3929,7 +4949,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_index(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.visionai_v1.WarehouseClient.delete_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteIndexEndpoint( @@ -3966,7 +5008,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete index endpoint method over HTTP. @@ -3977,8 +5019,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3991,6 +5035,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_index_endpoint( request, metadata ) @@ -4003,6 +5048,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteIndexEndpoint._get_response( self._host, @@ -4021,7 +5093,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_index_endpoint(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.visionai_v1.WarehouseClient.delete_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSearchConfig( @@ -4058,7 +5152,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete search config method over HTTP. @@ -4069,13 +5163,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_config( request, metadata ) @@ -4088,6 +5185,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchConfig._get_response( self._host, @@ -4137,7 +5261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete search hypernym method over HTTP. @@ -4148,13 +5272,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_hypernym( request, metadata ) @@ -4167,6 +5294,33 @@ def __call__( 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.visionai_v1.WarehouseClient.DeleteSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchHypernym._get_response( self._host, @@ -4215,7 +5369,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy index method over HTTP. @@ -4225,8 +5379,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4239,6 +5395,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeployIndex._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeployIndex._get_transcoded_request( @@ -4257,6 +5414,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.DeployIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeployIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeployIndex._get_response( self._host, @@ -4276,7 +5460,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_index(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.visionai_v1.WarehouseClient.deploy_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeployIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateHlsUri( @@ -4314,7 +5520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Call the generate hls uri method over HTTP. @@ -4325,8 +5531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.GenerateHlsUriResponse: @@ -4338,6 +5546,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateHlsUri._get_http_options() ) + request, metadata = self._interceptor.pre_generate_hls_uri( request, metadata ) @@ -4360,6 +5569,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GenerateHlsUri", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateHlsUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateHlsUri._get_response( self._host, @@ -4381,7 +5617,31 @@ def __call__( pb_resp = warehouse.GenerateHlsUriResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_hls_uri(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateHlsUriResponse.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.visionai_v1.WarehouseClient.generate_hls_uri", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateHlsUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateRetrievalUrl( @@ -4419,7 +5679,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateRetrievalUrlResponse: r"""Call the generate retrieval url method over HTTP. @@ -4430,8 +5690,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.GenerateRetrievalUrlResponse: @@ -4443,6 +5705,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateRetrievalUrl._get_http_options() ) + request, metadata = self._interceptor.pre_generate_retrieval_url( request, metadata ) @@ -4459,6 +5722,33 @@ def __call__( 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.visionai_v1.WarehouseClient.GenerateRetrievalUrl", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateRetrievalUrl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateRetrievalUrl._get_response( self._host, @@ -4480,7 +5770,31 @@ def __call__( pb_resp = warehouse.GenerateRetrievalUrlResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_retrieval_url(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateRetrievalUrlResponse.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.visionai_v1.WarehouseClient.generate_retrieval_url", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GenerateRetrievalUrl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotation( @@ -4517,7 +5831,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the get annotation method over HTTP. @@ -4528,8 +5842,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -4542,6 +5858,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_transcoded_request( @@ -4556,6 +5873,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAnnotation._get_response( self._host, @@ -4576,7 +5920,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1.WarehouseClient.get_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset(_BaseWarehouseRestTransport._BaseGetAsset, WarehouseRestStub): @@ -4611,7 +5977,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the get asset method over HTTP. @@ -4621,8 +5987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -4637,6 +6005,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetAsset._get_http_options() + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAsset._get_transcoded_request( @@ -4651,9 +6020,36 @@ def __call__( ) ) - # Send the request - response = WarehouseRestTransport._GetAsset._get_response( - self._host, + 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.visionai_v1.WarehouseClient.GetAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = WarehouseRestTransport._GetAsset._get_response( + self._host, metadata, query_params, self._session, @@ -4671,7 +6067,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1.WarehouseClient.get_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCollection( @@ -4708,7 +6126,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Call the get collection method over HTTP. @@ -4719,8 +6137,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Collection: @@ -4733,6 +6153,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCollection._get_http_options() ) + request, metadata = self._interceptor.pre_get_collection(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCollection._get_transcoded_request( @@ -4747,6 +6168,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCollection._get_response( self._host, @@ -4767,7 +6215,29 @@ def __call__( pb_resp = warehouse.Collection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Collection.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.visionai_v1.WarehouseClient.get_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCorpus(_BaseWarehouseRestTransport._BaseGetCorpus, WarehouseRestStub): @@ -4802,7 +6272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the get corpus method over HTTP. @@ -4812,8 +6282,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Corpus: @@ -4827,6 +6299,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_get_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_transcoded_request( @@ -4841,6 +6314,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCorpus._get_response( self._host, @@ -4861,7 +6361,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.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.visionai_v1.WarehouseClient.get_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSchema( @@ -4898,7 +6420,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the get data schema method over HTTP. @@ -4908,8 +6430,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -4922,6 +6446,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_schema(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_transcoded_request( @@ -4936,6 +6461,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetDataSchema._get_response( self._host, @@ -4956,7 +6508,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1.WarehouseClient.get_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIndex(_BaseWarehouseRestTransport._BaseGetIndex, WarehouseRestStub): @@ -4991,7 +6565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Index: r"""Call the get index method over HTTP. @@ -5001,8 +6575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Index: @@ -5015,6 +6591,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetIndex._get_http_options() + request, metadata = self._interceptor.pre_get_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetIndex._get_transcoded_request( @@ -5029,6 +6606,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIndex._get_response( self._host, @@ -5049,7 +6653,29 @@ def __call__( pb_resp = warehouse.Index.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_index(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Index.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.visionai_v1.WarehouseClient.get_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIndexEndpoint( @@ -5086,7 +6712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.IndexEndpoint: r"""Call the get index endpoint method over HTTP. @@ -5096,8 +6722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.IndexEndpoint: @@ -5109,6 +6737,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_get_index_endpoint( request, metadata ) @@ -5121,6 +6750,33 @@ def __call__( 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.visionai_v1.WarehouseClient.GetIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIndexEndpoint._get_response( self._host, @@ -5141,7 +6797,29 @@ def __call__( pb_resp = warehouse.IndexEndpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.IndexEndpoint.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.visionai_v1.WarehouseClient.get_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchConfig( @@ -5178,7 +6856,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the get search config method over HTTP. @@ -5188,8 +6866,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -5202,6 +6882,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_config( request, metadata ) @@ -5216,6 +6897,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchConfig._get_response( self._host, @@ -5236,7 +6944,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1.WarehouseClient.get_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchHypernym( @@ -5273,7 +7003,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the get search hypernym method over HTTP. @@ -5284,8 +7014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchHypernym: @@ -5300,6 +7032,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_hypernym( request, metadata ) @@ -5312,6 +7045,33 @@ def __call__( 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.visionai_v1.WarehouseClient.GetSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchHypernym._get_response( self._host, @@ -5332,7 +7092,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.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.visionai_v1.WarehouseClient.get_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAssets( @@ -5370,7 +7152,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import assets method over HTTP. @@ -5380,8 +7162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5394,6 +7178,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseImportAssets._get_http_options() ) + request, metadata = self._interceptor.pre_import_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseImportAssets._get_transcoded_request( @@ -5412,6 +7197,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ImportAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ImportAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ImportAssets._get_response( self._host, @@ -5431,7 +7243,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_assets(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.visionai_v1.WarehouseClient.import_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ImportAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IndexAsset(_BaseWarehouseRestTransport._BaseIndexAsset, WarehouseRestStub): @@ -5467,7 +7301,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the index asset method over HTTP. @@ -5477,8 +7311,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5491,6 +7327,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseIndexAsset._get_http_options() ) + request, metadata = self._interceptor.pre_index_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseIndexAsset._get_transcoded_request( @@ -5509,6 +7346,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.IndexAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "IndexAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._IndexAsset._get_response( self._host, @@ -5528,7 +7392,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_index_asset(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.visionai_v1.WarehouseClient.index_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "IndexAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IngestAsset(_BaseWarehouseRestTransport._BaseIngestAsset, WarehouseRestStub): @@ -5541,7 +7427,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method IngestAsset is not available over REST transport" @@ -5581,7 +7467,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAnnotationsResponse: r"""Call the list annotations method over HTTP. @@ -5592,8 +7478,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListAnnotationsResponse: @@ -5605,6 +7493,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAnnotations._get_http_options() ) + request, metadata = self._interceptor.pre_list_annotations( request, metadata ) @@ -5619,6 +7508,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListAnnotations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAnnotations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAnnotations._get_response( self._host, @@ -5639,7 +7555,31 @@ def __call__( pb_resp = warehouse.ListAnnotationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_annotations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAnnotationsResponse.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.visionai_v1.WarehouseClient.list_annotations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAnnotations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets(_BaseWarehouseRestTransport._BaseListAssets, WarehouseRestStub): @@ -5674,7 +7614,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -5684,8 +7624,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListAssetsResponse: @@ -5695,6 +7637,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListAssets._get_transcoded_request( @@ -5709,6 +7652,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAssets._get_response( self._host, @@ -5729,7 +7699,29 @@ def __call__( pb_resp = warehouse.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAssetsResponse.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.visionai_v1.WarehouseClient.list_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCollections( @@ -5766,7 +7758,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCollectionsResponse: r"""Call the list collections method over HTTP. @@ -5776,8 +7768,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListCollectionsResponse: @@ -5787,6 +7781,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCollections._get_http_options() ) + request, metadata = self._interceptor.pre_list_collections( request, metadata ) @@ -5801,6 +7796,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListCollections", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCollections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCollections._get_response( self._host, @@ -5821,7 +7843,31 @@ def __call__( pb_resp = warehouse.ListCollectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_collections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCollectionsResponse.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.visionai_v1.WarehouseClient.list_collections", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCollections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCorpora(_BaseWarehouseRestTransport._BaseListCorpora, WarehouseRestStub): @@ -5856,7 +7902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCorporaResponse: r"""Call the list corpora method over HTTP. @@ -5866,8 +7912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListCorporaResponse: @@ -5877,6 +7925,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCorpora._get_http_options() ) + request, metadata = self._interceptor.pre_list_corpora(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListCorpora._get_transcoded_request( @@ -5891,6 +7940,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListCorpora", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCorpora", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCorpora._get_response( self._host, @@ -5911,7 +7987,29 @@ def __call__( pb_resp = warehouse.ListCorporaResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_corpora(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCorporaResponse.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.visionai_v1.WarehouseClient.list_corpora", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListCorpora", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSchemas( @@ -5948,7 +8046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListDataSchemasResponse: r"""Call the list data schemas method over HTTP. @@ -5958,8 +8056,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListDataSchemasResponse: @@ -5969,6 +8069,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListDataSchemas._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_schemas( request, metadata ) @@ -5983,6 +8084,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListDataSchemas", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListDataSchemas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListDataSchemas._get_response( self._host, @@ -6003,7 +8131,31 @@ def __call__( pb_resp = warehouse.ListDataSchemasResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_schemas(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListDataSchemasResponse.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.visionai_v1.WarehouseClient.list_data_schemas", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListDataSchemas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIndexEndpoints( @@ -6040,7 +8192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListIndexEndpointsResponse: r"""Call the list index endpoints method over HTTP. @@ -6051,8 +8203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListIndexEndpointsResponse: @@ -6064,6 +8218,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListIndexEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_index_endpoints( request, metadata ) @@ -6076,6 +8231,33 @@ def __call__( 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.visionai_v1.WarehouseClient.ListIndexEndpoints", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListIndexEndpoints._get_response( self._host, @@ -6096,7 +8278,31 @@ def __call__( pb_resp = warehouse.ListIndexEndpointsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_index_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListIndexEndpointsResponse.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.visionai_v1.WarehouseClient.list_index_endpoints", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIndexes(_BaseWarehouseRestTransport._BaseListIndexes, WarehouseRestStub): @@ -6131,7 +8337,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListIndexesResponse: r"""Call the list indexes method over HTTP. @@ -6141,8 +8347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListIndexesResponse: @@ -6152,6 +8360,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListIndexes._get_http_options() ) + request, metadata = self._interceptor.pre_list_indexes(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListIndexes._get_transcoded_request( @@ -6166,6 +8375,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListIndexes", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListIndexes._get_response( self._host, @@ -6186,7 +8422,29 @@ def __call__( pb_resp = warehouse.ListIndexesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_indexes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListIndexesResponse.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.visionai_v1.WarehouseClient.list_indexes", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListIndexes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchConfigs( @@ -6223,7 +8481,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchConfigsResponse: r"""Call the list search configs method over HTTP. @@ -6234,8 +8492,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListSearchConfigsResponse: @@ -6247,6 +8507,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_configs( request, metadata ) @@ -6259,6 +8520,33 @@ def __call__( 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.visionai_v1.WarehouseClient.ListSearchConfigs", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchConfigs._get_response( self._host, @@ -6279,7 +8567,31 @@ def __call__( pb_resp = warehouse.ListSearchConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchConfigsResponse.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.visionai_v1.WarehouseClient.list_search_configs", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchHypernyms( @@ -6316,7 +8628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchHypernymsResponse: r"""Call the list search hypernyms method over HTTP. @@ -6327,8 +8639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListSearchHypernymsResponse: @@ -6340,6 +8654,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchHypernyms._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_hypernyms( request, metadata ) @@ -6352,6 +8667,33 @@ def __call__( 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.visionai_v1.WarehouseClient.ListSearchHypernyms", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchHypernyms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchHypernyms._get_response( self._host, @@ -6372,7 +8714,31 @@ def __call__( pb_resp = warehouse.ListSearchHypernymsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_hypernyms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchHypernymsResponse.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.visionai_v1.WarehouseClient.list_search_hypernyms", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListSearchHypernyms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveCollectionItem( @@ -6410,7 +8776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.RemoveCollectionItemResponse: r"""Call the remove collection item method over HTTP. @@ -6421,8 +8787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.RemoveCollectionItemResponse: @@ -6434,6 +8802,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseRemoveCollectionItem._get_http_options() ) + request, metadata = self._interceptor.pre_remove_collection_item( request, metadata ) @@ -6450,6 +8819,33 @@ def __call__( 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.visionai_v1.WarehouseClient.RemoveCollectionItem", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveCollectionItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._RemoveCollectionItem._get_response( self._host, @@ -6471,7 +8867,31 @@ def __call__( pb_resp = warehouse.RemoveCollectionItemResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_collection_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.RemoveCollectionItemResponse.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.visionai_v1.WarehouseClient.remove_collection_item", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveCollectionItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveIndexAsset( @@ -6509,7 +8929,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove index asset method over HTTP. @@ -6519,8 +8939,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6533,6 +8955,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseRemoveIndexAsset._get_http_options() ) + request, metadata = self._interceptor.pre_remove_index_asset( request, metadata ) @@ -6549,6 +8972,33 @@ def __call__( 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.visionai_v1.WarehouseClient.RemoveIndexAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveIndexAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._RemoveIndexAsset._get_response( self._host, @@ -6568,7 +9018,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_index_asset(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.visionai_v1.WarehouseClient.remove_index_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "RemoveIndexAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAssets( @@ -6606,7 +9078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchAssetsResponse: r"""Call the search assets method over HTTP. @@ -6616,8 +9088,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchAssetsResponse: @@ -6627,6 +9101,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_http_options() ) + request, metadata = self._interceptor.pre_search_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_transcoded_request( @@ -6645,6 +9120,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.SearchAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchAssets._get_response( self._host, @@ -6666,7 +9168,29 @@ def __call__( pb_resp = warehouse.SearchAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchAssetsResponse.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.visionai_v1.WarehouseClient.search_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchIndexEndpoint( @@ -6704,7 +9228,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchIndexEndpointResponse: r"""Call the search index endpoint method over HTTP. @@ -6715,8 +9239,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchIndexEndpointResponse: @@ -6728,6 +9254,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_search_index_endpoint( request, metadata ) @@ -6744,6 +9271,33 @@ def __call__( 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.visionai_v1.WarehouseClient.SearchIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchIndexEndpoint._get_response( self._host, @@ -6765,7 +9319,31 @@ def __call__( pb_resp = warehouse.SearchIndexEndpointResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_index_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchIndexEndpointResponse.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.visionai_v1.WarehouseClient.search_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "SearchIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployIndex( @@ -6803,7 +9381,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy index method over HTTP. @@ -6814,8 +9392,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6828,6 +9408,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUndeployIndex._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUndeployIndex._get_transcoded_request( @@ -6848,6 +9429,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.UndeployIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UndeployIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UndeployIndex._get_response( self._host, @@ -6867,7 +9475,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_index(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.visionai_v1.WarehouseClient.undeploy_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UndeployIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnnotation( @@ -6905,7 +9535,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the update annotation method over HTTP. @@ -6916,8 +9546,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -6930,6 +9562,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_update_annotation( request, metadata ) @@ -6946,6 +9579,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAnnotation._get_response( self._host, @@ -6967,7 +9627,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1.WarehouseClient.update_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAsset(_BaseWarehouseRestTransport._BaseUpdateAsset, WarehouseRestStub): @@ -7003,7 +9685,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the update asset method over HTTP. @@ -7013,8 +9695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -7031,6 +9715,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_update_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_transcoded_request( @@ -7049,6 +9734,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.UpdateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAsset._get_response( self._host, @@ -7070,7 +9782,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1.WarehouseClient.update_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCollection( @@ -7108,7 +9842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Collection: r"""Call the update collection method over HTTP. @@ -7119,8 +9853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Collection: @@ -7133,6 +9869,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCollection._get_http_options() ) + request, metadata = self._interceptor.pre_update_collection( request, metadata ) @@ -7149,6 +9886,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateCollection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCollection._get_response( self._host, @@ -7170,7 +9934,29 @@ def __call__( pb_resp = warehouse.Collection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Collection.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.visionai_v1.WarehouseClient.update_collection", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCorpus( @@ -7208,7 +9994,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the update corpus method over HTTP. @@ -7218,8 +10004,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Corpus: @@ -7233,6 +10021,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_update_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_transcoded_request( @@ -7251,6 +10040,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.UpdateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCorpus._get_response( self._host, @@ -7272,7 +10088,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.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.visionai_v1.WarehouseClient.update_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataSchema( @@ -7310,7 +10148,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the update data schema method over HTTP. @@ -7320,8 +10158,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -7334,6 +10174,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_schema( request, metadata ) @@ -7350,6 +10191,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateDataSchema._get_response( self._host, @@ -7371,7 +10239,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1.WarehouseClient.update_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIndex(_BaseWarehouseRestTransport._BaseUpdateIndex, WarehouseRestStub): @@ -7407,7 +10297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update index method over HTTP. @@ -7417,8 +10307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -7431,6 +10323,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateIndex._get_http_options() ) + request, metadata = self._interceptor.pre_update_index(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateIndex._get_transcoded_request( @@ -7449,6 +10342,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.UpdateIndex", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndex", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateIndex._get_response( self._host, @@ -7468,7 +10388,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_index(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.visionai_v1.WarehouseClient.update_index", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndex", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIndexEndpoint( @@ -7506,7 +10448,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update index endpoint method over HTTP. @@ -7517,8 +10459,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -7531,6 +10475,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateIndexEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_update_index_endpoint( request, metadata ) @@ -7547,6 +10492,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateIndexEndpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndexEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateIndexEndpoint._get_response( self._host, @@ -7566,7 +10538,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_index_endpoint(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.visionai_v1.WarehouseClient.update_index_endpoint", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateIndexEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchConfig( @@ -7604,7 +10598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the update search config method over HTTP. @@ -7615,8 +10609,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -7629,6 +10625,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_config( request, metadata ) @@ -7645,6 +10642,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchConfig._get_response( self._host, @@ -7666,7 +10690,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1.WarehouseClient.update_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchHypernym( @@ -7704,7 +10750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchHypernym: r"""Call the update search hypernym method over HTTP. @@ -7715,8 +10761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchHypernym: @@ -7731,6 +10779,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchHypernym._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_hypernym( request, metadata ) @@ -7747,6 +10796,33 @@ def __call__( 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.visionai_v1.WarehouseClient.UpdateSearchHypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchHypernym", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchHypernym._get_response( self._host, @@ -7768,7 +10844,29 @@ def __call__( pb_resp = warehouse.SearchHypernym.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_hypernym(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchHypernym.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.visionai_v1.WarehouseClient.update_search_hypernym", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UpdateSearchHypernym", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UploadAsset(_BaseWarehouseRestTransport._BaseUploadAsset, WarehouseRestStub): @@ -7804,7 +10902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the upload asset method over HTTP. @@ -7814,8 +10912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -7828,6 +10928,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUploadAsset._get_http_options() ) + request, metadata = self._interceptor.pre_upload_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUploadAsset._get_transcoded_request( @@ -7846,6 +10947,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.UploadAsset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UploadAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UploadAsset._get_response( self._host, @@ -7865,7 +10993,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upload_asset(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.visionai_v1.WarehouseClient.upload_asset", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "UploadAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ViewCollectionItems( @@ -7902,7 +11052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ViewCollectionItemsResponse: r"""Call the view collection items method over HTTP. @@ -7913,8 +11063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ViewCollectionItemsResponse: @@ -7926,6 +11078,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseViewCollectionItems._get_http_options() ) + request, metadata = self._interceptor.pre_view_collection_items( request, metadata ) @@ -7938,6 +11091,33 @@ def __call__( 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.visionai_v1.WarehouseClient.ViewCollectionItems", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewCollectionItems", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ViewCollectionItems._get_response( self._host, @@ -7958,7 +11138,31 @@ def __call__( pb_resp = warehouse.ViewCollectionItemsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_view_collection_items(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ViewCollectionItemsResponse.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.visionai_v1.WarehouseClient.view_collection_items", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewCollectionItems", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ViewIndexedAssets( @@ -7995,7 +11199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ViewIndexedAssetsResponse: r"""Call the view indexed assets method over HTTP. @@ -8006,8 +11210,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ViewIndexedAssetsResponse: @@ -8019,6 +11225,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseViewIndexedAssets._get_http_options() ) + request, metadata = self._interceptor.pre_view_indexed_assets( request, metadata ) @@ -8031,6 +11238,33 @@ def __call__( 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.visionai_v1.WarehouseClient.ViewIndexedAssets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewIndexedAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ViewIndexedAssets._get_response( self._host, @@ -8051,7 +11285,31 @@ def __call__( pb_resp = warehouse.ViewIndexedAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_view_indexed_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ViewIndexedAssetsResponse.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.visionai_v1.WarehouseClient.view_indexed_assets", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ViewIndexedAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -8611,7 +11869,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -8621,13 +11879,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -8648,6 +11909,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CancelOperation._get_response( self._host, @@ -8704,7 +11992,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -8714,13 +12002,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -8735,6 +12026,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteOperation._get_response( self._host, @@ -8790,7 +12108,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -8800,8 +12118,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -8810,6 +12130,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetOperation._get_transcoded_request( @@ -8824,6 +12145,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetOperation._get_response( self._host, @@ -8843,6 +12191,27 @@ def __call__( 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.visionai_v1.WarehouseAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -8883,7 +12252,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -8893,8 +12262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -8903,6 +12274,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListOperations._get_transcoded_request( @@ -8917,6 +12289,33 @@ def __call__( ) ) + 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.visionai_v1.WarehouseClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListOperations._get_response( self._host, @@ -8936,6 +12335,27 @@ def __call__( 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.visionai_v1.WarehouseAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1.Warehouse", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.5" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py index 7a0c4c5492a9..d41efa0924cc 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .transports.grpc_asyncio import AppPlatformGrpcAsyncIOTransport +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 AppPlatformAsyncClient: """Service describing handlers for resources""" @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1alpha1.AppPlatformAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "credentialsType": None, + }, + ) + async def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_applications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApplicationsAsyncPager: r"""Lists Applications in a given project and location. @@ -320,8 +352,10 @@ async def sample_list_applications(): 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, 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsAsyncPager: @@ -396,7 +430,7 @@ async def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -437,8 +471,10 @@ async def sample_get_application(): 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, 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: google.cloud.visionai_v1alpha1.types.Application: @@ -498,7 +534,7 @@ async def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Application in a given project and location. @@ -554,8 +590,10 @@ async def sample_create_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -630,7 +668,7 @@ async def update_application( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Application. @@ -689,8 +727,10 @@ async def sample_update_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -766,7 +806,7 @@ async def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Application. @@ -811,8 +851,10 @@ async def sample_delete_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -891,7 +933,7 @@ async def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a single Application. @@ -940,8 +982,10 @@ async def sample_deploy_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1012,7 +1056,7 @@ async def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys a single Application. @@ -1062,8 +1106,10 @@ async def sample_undeploy_application(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1137,7 +1183,7 @@ async def add_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1190,8 +1236,10 @@ async def sample_add_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1265,7 +1313,7 @@ async def remove_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1318,8 +1366,10 @@ async def sample_remove_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1393,7 +1443,7 @@ async def update_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1446,8 +1496,10 @@ async def sample_update_application_stream_input(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1519,7 +1571,7 @@ async def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists Instances in a given project and location. @@ -1564,8 +1616,10 @@ async def sample_list_instances(): 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, 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesAsyncPager: @@ -1640,7 +1694,7 @@ async def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -1681,8 +1735,10 @@ async def sample_get_instance(): 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, 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: google.cloud.visionai_v1alpha1.types.Instance: @@ -1743,7 +1799,7 @@ async def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1801,8 +1857,10 @@ async def sample_create_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1876,7 +1934,7 @@ async def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1930,8 +1988,10 @@ async def sample_delete_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2010,7 +2070,7 @@ async def update_application_instances( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2068,8 +2128,10 @@ async def sample_update_application_instances(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2143,7 +2205,7 @@ async def list_drafts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDraftsAsyncPager: r"""Lists Drafts in a given project and location. @@ -2188,8 +2250,10 @@ async def sample_list_drafts(): 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, 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsAsyncPager: @@ -2264,7 +2328,7 @@ async def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2305,8 +2369,10 @@ async def sample_get_draft(): 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, 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: google.cloud.visionai_v1alpha1.types.Draft: @@ -2367,7 +2433,7 @@ async def create_draft( draft_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Draft in a given project and location. @@ -2429,8 +2495,10 @@ async def sample_create_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2507,7 +2575,7 @@ async def update_draft( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Draft. @@ -2566,8 +2634,10 @@ async def sample_update_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2643,7 +2713,7 @@ async def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Draft. @@ -2688,8 +2758,10 @@ async def sample_delete_draft(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2768,7 +2840,7 @@ async def list_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessorsAsyncPager: r"""Lists Processors in a given project and location. @@ -2813,8 +2885,10 @@ async def sample_list_processors(): 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, 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsAsyncPager: @@ -2889,7 +2963,7 @@ async def list_prebuilt_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -2932,8 +3006,10 @@ async def sample_list_prebuilt_processors(): 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, 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: google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse: @@ -2994,7 +3070,7 @@ async def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3035,8 +3111,10 @@ async def sample_get_processor(): 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, 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: google.cloud.visionai_v1alpha1.types.Processor: @@ -3099,7 +3177,7 @@ async def create_processor( processor_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Processor in a given project and location. @@ -3162,8 +3240,10 @@ async def sample_create_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3239,7 +3319,7 @@ async def update_processor( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Processor. @@ -3298,8 +3378,10 @@ async def sample_update_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3374,7 +3456,7 @@ async def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Processor. @@ -3419,8 +3501,10 @@ async def sample_delete_processor(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3498,7 +3582,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3509,8 +3593,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3551,7 +3637,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3562,8 +3648,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3604,7 +3692,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3620,8 +3708,10 @@ async def delete_operation( 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, 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: None """ @@ -3658,7 +3748,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3673,8 +3763,10 @@ async def cancel_operation( 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, 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: None """ @@ -3711,7 +3803,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3724,8 +3816,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3830,7 +3924,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3844,8 +3938,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3950,7 +4046,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3965,8 +4061,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -4010,7 +4108,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4021,8 +4119,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -4063,7 +4163,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4074,8 +4174,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py index 7977ca639991..382e32a19406 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -682,6 +692,10 @@ def __init__( # 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( @@ -744,6 +758,29 @@ def __init__( 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.visionai_v1alpha1.AppPlatformClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "credentialsType": None, + }, + ) + def list_applications( self, request: Optional[Union[platform.ListApplicationsRequest, dict]] = None, @@ -751,7 +788,7 @@ def list_applications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApplicationsPager: r"""Lists Applications in a given project and location. @@ -796,8 +833,10 @@ def sample_list_applications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsPager: @@ -869,7 +908,7 @@ def get_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Gets details of a single Application. @@ -910,8 +949,10 @@ def sample_get_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Application: @@ -968,7 +1009,7 @@ def create_application( application: Optional[platform.Application] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Application in a given project and location. @@ -1024,8 +1065,10 @@ def sample_create_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1097,7 +1140,7 @@ def update_application( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Application. @@ -1156,8 +1199,10 @@ def sample_update_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1230,7 +1275,7 @@ def delete_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Application. @@ -1275,8 +1320,10 @@ def sample_delete_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1352,7 +1399,7 @@ def deploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deploys a single Application. @@ -1401,8 +1448,10 @@ def sample_deploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1470,7 +1519,7 @@ def undeploy_application( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeploys a single Application. @@ -1520,8 +1569,10 @@ def sample_undeploy_application(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1592,7 +1643,7 @@ def add_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -1645,8 +1696,10 @@ def sample_add_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1719,7 +1772,7 @@ def remove_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -1772,8 +1825,10 @@ def sample_remove_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1846,7 +1901,7 @@ def update_application_stream_input( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update target stream input to the Application, if the Application is deployed, the corresponding instance based will @@ -1899,8 +1954,10 @@ def sample_update_application_stream_input(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1971,7 +2028,7 @@ def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesPager: r"""Lists Instances in a given project and location. @@ -2016,8 +2073,10 @@ def sample_list_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesPager: @@ -2089,7 +2148,7 @@ def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Gets details of a single Instance. @@ -2130,8 +2189,10 @@ def sample_get_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Instance: @@ -2189,7 +2250,7 @@ def create_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2247,8 +2308,10 @@ def sample_create_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2321,7 +2384,7 @@ def delete_application_instances( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove target stream input to the Application, if the Application is deployed, the corresponding instance @@ -2375,8 +2438,10 @@ def sample_delete_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2454,7 +2519,7 @@ def update_application_instances( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds target stream input to the Application. If the Application is deployed, the corresponding new @@ -2512,8 +2577,10 @@ def sample_update_application_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2586,7 +2653,7 @@ def list_drafts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDraftsPager: r"""Lists Drafts in a given project and location. @@ -2631,8 +2698,10 @@ def sample_list_drafts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsPager: @@ -2704,7 +2773,7 @@ def get_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Gets details of a single Draft. @@ -2745,8 +2814,10 @@ def sample_get_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Draft: @@ -2804,7 +2875,7 @@ def create_draft( draft_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Draft in a given project and location. @@ -2866,8 +2937,10 @@ def sample_create_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2941,7 +3014,7 @@ def update_draft( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Draft. @@ -3000,8 +3073,10 @@ def sample_update_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3074,7 +3149,7 @@ def delete_draft( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Draft. @@ -3119,8 +3194,10 @@ def sample_delete_draft(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3196,7 +3273,7 @@ def list_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProcessorsPager: r"""Lists Processors in a given project and location. @@ -3241,8 +3318,10 @@ def sample_list_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsPager: @@ -3314,7 +3393,7 @@ def list_prebuilt_processors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""ListPrebuiltProcessors is a custom pass-through verb that Lists Prebuilt Processors. @@ -3357,8 +3436,10 @@ def sample_list_prebuilt_processors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse: @@ -3416,7 +3497,7 @@ def get_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Gets details of a single Processor. @@ -3457,8 +3538,10 @@ def sample_get_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Processor: @@ -3518,7 +3601,7 @@ def create_processor( processor_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Processor in a given project and location. @@ -3581,8 +3664,10 @@ def sample_create_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3655,7 +3740,7 @@ def update_processor( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Processor. @@ -3714,8 +3799,10 @@ def sample_update_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3787,7 +3874,7 @@ def delete_processor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Processor. @@ -3832,8 +3919,10 @@ def sample_delete_processor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3921,7 +4010,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3932,8 +4021,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3974,7 +4065,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3985,8 +4076,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4027,7 +4120,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4043,8 +4136,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4081,7 +4176,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4096,8 +4191,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4134,7 +4231,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -4147,8 +4244,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4253,7 +4352,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -4267,8 +4366,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4373,7 +4474,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -4388,8 +4489,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -4431,7 +4534,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4442,8 +4545,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -4484,7 +4589,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4495,8 +4600,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py index 2054eb71e747..8a76e39245f5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListApplicationsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListApplicationsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListInstancesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListInstancesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListDraftsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListDraftsRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = platform.ListProcessorsRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = platform.ListProcessorsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py index 8cdcf1d88c7e..ecb80c836547 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport +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.visionai.v1alpha1.AppPlatform", + "rpcName": 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.visionai.v1alpha1.AppPlatform", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcTransport(AppPlatformTransport): """gRPC backend transport for AppPlatform. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -300,7 +388,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -327,7 +415,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -462,7 +550,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -496,7 +586,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -530,7 +620,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +646,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -582,7 +672,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -613,7 +703,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -644,7 +736,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -675,7 +769,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +797,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -725,7 +821,7 @@ def get_draft(self) -> Callable[[platform.GetDraftRequest], platform.Draft]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -751,7 +847,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -777,7 +873,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -803,7 +899,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +925,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -859,7 +955,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -885,7 +981,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -912,7 +1008,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1034,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -964,7 +1060,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1068,7 @@ def delete_processor( return self._stubs["delete_processor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -984,7 +1080,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1001,7 +1097,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1018,7 +1114,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1037,7 +1133,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1056,7 +1152,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1073,7 +1169,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1098,7 +1194,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1124,7 +1220,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1153,7 +1249,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py index 9a9404671b30..f5a115d06522 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import platform from .base import DEFAULT_CLIENT_INFO, AppPlatformTransport from .grpc import AppPlatformGrpcTransport +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.visionai.v1alpha1.AppPlatform", + "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.visionai.v1alpha1.AppPlatform", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppPlatformGrpcAsyncIOTransport(AppPlatformTransport): """gRPC AsyncIO backend transport for AppPlatform. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def list_applications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_applications" not in self._stubs: - self._stubs["list_applications"] = self.grpc_channel.unary_unary( + self._stubs["list_applications"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListApplications", request_serializer=platform.ListApplicationsRequest.serialize, response_deserializer=platform.ListApplicationsResponse.deserialize, @@ -310,7 +395,7 @@ def get_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_application" not in self._stubs: - self._stubs["get_application"] = self.grpc_channel.unary_unary( + self._stubs["get_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetApplication", request_serializer=platform.GetApplicationRequest.serialize, response_deserializer=platform.Application.deserialize, @@ -339,7 +424,7 @@ def create_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application" not in self._stubs: - self._stubs["create_application"] = self.grpc_channel.unary_unary( + self._stubs["create_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplication", request_serializer=platform.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -367,7 +452,7 @@ def update_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application" not in self._stubs: - self._stubs["update_application"] = self.grpc_channel.unary_unary( + self._stubs["update_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplication", request_serializer=platform.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application" not in self._stubs: - self._stubs["delete_application"] = self.grpc_channel.unary_unary( + self._stubs["delete_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplication", request_serializer=platform.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def deploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_application" not in self._stubs: - self._stubs["deploy_application"] = self.grpc_channel.unary_unary( + self._stubs["deploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeployApplication", request_serializer=platform.DeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def undeploy_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_application" not in self._stubs: - self._stubs["undeploy_application"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_application"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UndeployApplication", request_serializer=platform.UndeployApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,9 @@ def add_application_stream_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_application_stream_input" not in self._stubs: - self._stubs["add_application_stream_input"] = self.grpc_channel.unary_unary( + self._stubs[ + "add_application_stream_input" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/AddApplicationStreamInput", request_serializer=platform.AddApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +604,7 @@ def remove_application_stream_input( if "remove_application_stream_input" not in self._stubs: self._stubs[ "remove_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/RemoveApplicationStreamInput", request_serializer=platform.RemoveApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +639,7 @@ def update_application_stream_input( if "update_application_stream_input" not in self._stubs: self._stubs[ "update_application_stream_input" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationStreamInput", request_serializer=platform.UpdateApplicationStreamInputRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +667,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListInstances", request_serializer=platform.ListInstancesRequest.serialize, response_deserializer=platform.ListInstancesResponse.deserialize, @@ -606,7 +693,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetInstance", request_serializer=platform.GetInstanceRequest.serialize, response_deserializer=platform.Instance.deserialize, @@ -638,7 +725,9 @@ def create_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_application_instances" not in self._stubs: - self._stubs["create_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateApplicationInstances", request_serializer=platform.CreateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -670,7 +759,9 @@ def delete_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_application_instances" not in self._stubs: - self._stubs["delete_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteApplicationInstances", request_serializer=platform.DeleteApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +793,9 @@ def update_application_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_application_instances" not in self._stubs: - self._stubs["update_application_instances"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_application_instances" + ] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateApplicationInstances", request_serializer=platform.UpdateApplicationInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +821,7 @@ def list_drafts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_drafts" not in self._stubs: - self._stubs["list_drafts"] = self.grpc_channel.unary_unary( + self._stubs["list_drafts"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListDrafts", request_serializer=platform.ListDraftsRequest.serialize, response_deserializer=platform.ListDraftsResponse.deserialize, @@ -754,7 +847,7 @@ def get_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_draft" not in self._stubs: - self._stubs["get_draft"] = self.grpc_channel.unary_unary( + self._stubs["get_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetDraft", request_serializer=platform.GetDraftRequest.serialize, response_deserializer=platform.Draft.deserialize, @@ -780,7 +873,7 @@ def create_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_draft" not in self._stubs: - self._stubs["create_draft"] = self.grpc_channel.unary_unary( + self._stubs["create_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateDraft", request_serializer=platform.CreateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -806,7 +899,7 @@ def update_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_draft" not in self._stubs: - self._stubs["update_draft"] = self.grpc_channel.unary_unary( + self._stubs["update_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateDraft", request_serializer=platform.UpdateDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -832,7 +925,7 @@ def delete_draft( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_draft" not in self._stubs: - self._stubs["delete_draft"] = self.grpc_channel.unary_unary( + self._stubs["delete_draft"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteDraft", request_serializer=platform.DeleteDraftRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -860,7 +953,7 @@ def list_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_processors" not in self._stubs: - self._stubs["list_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListProcessors", request_serializer=platform.ListProcessorsRequest.serialize, response_deserializer=platform.ListProcessorsResponse.deserialize, @@ -890,7 +983,7 @@ def list_prebuilt_processors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_prebuilt_processors" not in self._stubs: - self._stubs["list_prebuilt_processors"] = self.grpc_channel.unary_unary( + self._stubs["list_prebuilt_processors"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/ListPrebuiltProcessors", request_serializer=platform.ListPrebuiltProcessorsRequest.serialize, response_deserializer=platform.ListPrebuiltProcessorsResponse.deserialize, @@ -916,7 +1009,7 @@ def get_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_processor" not in self._stubs: - self._stubs["get_processor"] = self.grpc_channel.unary_unary( + self._stubs["get_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/GetProcessor", request_serializer=platform.GetProcessorRequest.serialize, response_deserializer=platform.Processor.deserialize, @@ -945,7 +1038,7 @@ def create_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_processor" not in self._stubs: - self._stubs["create_processor"] = self.grpc_channel.unary_unary( + self._stubs["create_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/CreateProcessor", request_serializer=platform.CreateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -973,7 +1066,7 @@ def update_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_processor" not in self._stubs: - self._stubs["update_processor"] = self.grpc_channel.unary_unary( + self._stubs["update_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/UpdateProcessor", request_serializer=platform.UpdateProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1094,7 @@ def delete_processor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_processor" not in self._stubs: - self._stubs["delete_processor"] = self.grpc_channel.unary_unary( + self._stubs["delete_processor"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.AppPlatform/DeleteProcessor", request_serializer=platform.DeleteProcessorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1194,7 +1287,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1210,7 +1303,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1227,7 +1320,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1244,7 +1337,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1263,7 +1356,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1282,7 +1375,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1299,7 +1392,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1324,7 +1417,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1350,7 +1443,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1379,7 +1472,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py index 84a263cb72f5..cb7e4a563e90 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/app_platform/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -281,8 +289,11 @@ def post_update_processor(self, response): def pre_add_application_stream_input( self, request: platform.AddApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.AddApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.AddApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_application_stream_input Override in a subclass to manipulate the request or metadata @@ -304,8 +315,10 @@ def post_add_application_stream_input( def pre_create_application( self, request: platform.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -327,8 +340,11 @@ def post_create_application( def pre_create_application_instances( self, request: platform.CreateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_application_instances Override in a subclass to manipulate the request or metadata @@ -348,8 +364,10 @@ def post_create_application_instances( return response def pre_create_draft( - self, request: platform.CreateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.CreateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.CreateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_draft Override in a subclass to manipulate the request or metadata @@ -371,8 +389,10 @@ def post_create_draft( def pre_create_processor( self, request: platform.CreateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.CreateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.CreateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_processor Override in a subclass to manipulate the request or metadata @@ -394,8 +414,10 @@ def post_create_processor( def pre_delete_application( self, request: platform.DeleteApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_application Override in a subclass to manipulate the request or metadata @@ -417,8 +439,11 @@ def post_delete_application( def pre_delete_application_instances( self, request: platform.DeleteApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_application_instances Override in a subclass to manipulate the request or metadata @@ -438,8 +463,10 @@ def post_delete_application_instances( return response def pre_delete_draft( - self, request: platform.DeleteDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.DeleteDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.DeleteDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_draft Override in a subclass to manipulate the request or metadata @@ -461,8 +488,10 @@ def post_delete_draft( def pre_delete_processor( self, request: platform.DeleteProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeleteProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeleteProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_processor Override in a subclass to manipulate the request or metadata @@ -484,8 +513,10 @@ def post_delete_processor( def pre_deploy_application( self, request: platform.DeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.DeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.DeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for deploy_application Override in a subclass to manipulate the request or metadata @@ -507,8 +538,8 @@ def post_deploy_application( def pre_get_application( self, request: platform.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -528,8 +559,10 @@ def post_get_application( return response def pre_get_draft( - self, request: platform.GetDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_draft Override in a subclass to manipulate the request or metadata @@ -547,8 +580,10 @@ def post_get_draft(self, response: platform.Draft) -> platform.Draft: return response def pre_get_instance( - self, request: platform.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +601,10 @@ def post_get_instance(self, response: platform.Instance) -> platform.Instance: return response def pre_get_processor( - self, request: platform.GetProcessorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.GetProcessorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.GetProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_processor Override in a subclass to manipulate the request or metadata @@ -587,8 +624,10 @@ def post_get_processor(self, response: platform.Processor) -> platform.Processor def pre_list_applications( self, request: platform.ListApplicationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListApplicationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListApplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_applications Override in a subclass to manipulate the request or metadata @@ -608,8 +647,10 @@ def post_list_applications( return response def pre_list_drafts( - self, request: platform.ListDraftsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.ListDraftsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListDraftsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_drafts Override in a subclass to manipulate the request or metadata @@ -631,8 +672,8 @@ def post_list_drafts( def pre_list_instances( self, request: platform.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -654,8 +695,10 @@ def post_list_instances( def pre_list_prebuilt_processors( self, request: platform.ListPrebuiltProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.ListPrebuiltProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_prebuilt_processors Override in a subclass to manipulate the request or metadata @@ -677,8 +720,8 @@ def post_list_prebuilt_processors( def pre_list_processors( self, request: platform.ListProcessorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.ListProcessorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_processors Override in a subclass to manipulate the request or metadata @@ -700,8 +743,11 @@ def post_list_processors( def pre_remove_application_stream_input( self, request: platform.RemoveApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.RemoveApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.RemoveApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_application_stream_input Override in a subclass to manipulate the request or metadata @@ -723,8 +769,10 @@ def post_remove_application_stream_input( def pre_undeploy_application( self, request: platform.UndeployApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UndeployApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UndeployApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undeploy_application Override in a subclass to manipulate the request or metadata @@ -746,8 +794,10 @@ def post_undeploy_application( def pre_update_application( self, request: platform.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -769,8 +819,11 @@ def post_update_application( def pre_update_application_instances( self, request: platform.UpdateApplicationInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_instances Override in a subclass to manipulate the request or metadata @@ -792,8 +845,11 @@ def post_update_application_instances( def pre_update_application_stream_input( self, request: platform.UpdateApplicationStreamInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateApplicationStreamInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateApplicationStreamInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_application_stream_input Override in a subclass to manipulate the request or metadata @@ -813,8 +869,10 @@ def post_update_application_stream_input( return response def pre_update_draft( - self, request: platform.UpdateDraftRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, str]]]: + self, + request: platform.UpdateDraftRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[platform.UpdateDraftRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_draft Override in a subclass to manipulate the request or metadata @@ -836,8 +894,10 @@ def post_update_draft( def pre_update_processor( self, request: platform.UpdateProcessorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[platform.UpdateProcessorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + platform.UpdateProcessorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_processor Override in a subclass to manipulate the request or metadata @@ -859,8 +919,10 @@ def post_update_processor( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -882,8 +944,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -905,8 +969,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -926,8 +992,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -947,8 +1015,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -970,8 +1041,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -991,8 +1064,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1012,8 +1087,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1035,8 +1112,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1240,7 +1319,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add application stream input method over HTTP. @@ -1252,8 +1331,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1266,6 +1347,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseAddApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_add_application_stream_input( request, metadata ) @@ -1282,6 +1364,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.AddApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._AddApplicationStreamInput._get_response( @@ -1303,7 +1412,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_application_stream_input(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.visionai_v1alpha1.AppPlatformClient.add_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "AddApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplication( @@ -1341,7 +1472,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create application method over HTTP. @@ -1351,8 +1482,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1365,6 +1498,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -1381,6 +1515,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.CreateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateApplication._get_response( self._host, @@ -1400,7 +1561,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_application(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.visionai_v1alpha1.AppPlatformClient.create_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApplicationInstances( @@ -1439,7 +1622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create application instances method over HTTP. @@ -1451,8 +1634,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1465,6 +1650,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_application_instances( request, metadata ) @@ -1481,6 +1667,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.CreateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._CreateApplicationInstances._get_response( @@ -1502,7 +1715,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_application_instances(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.visionai_v1alpha1.AppPlatformClient.create_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDraft( @@ -1540,7 +1775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create draft method over HTTP. @@ -1550,8 +1785,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1564,6 +1801,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_create_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseCreateDraft._get_transcoded_request( @@ -1584,6 +1822,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.CreateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateDraft._get_response( self._host, @@ -1603,7 +1868,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_draft(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.visionai_v1alpha1.AppPlatformClient.create_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProcessor( @@ -1641,7 +1928,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create processor method over HTTP. @@ -1651,8 +1938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1665,6 +1954,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseCreateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_create_processor( request, metadata ) @@ -1681,6 +1971,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.CreateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CreateProcessor._get_response( self._host, @@ -1700,7 +2017,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_processor(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.visionai_v1alpha1.AppPlatformClient.create_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CreateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplication( @@ -1737,7 +2076,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application method over HTTP. @@ -1747,8 +2086,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1761,6 +2102,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplication._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application( request, metadata ) @@ -1773,6 +2115,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.DeleteApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteApplication._get_response( self._host, @@ -1791,7 +2160,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_application(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.visionai_v1alpha1.AppPlatformClient.delete_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplicationInstances( @@ -1830,7 +2221,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application instances method over HTTP. @@ -1842,8 +2233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1856,6 +2249,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application_instances( request, metadata ) @@ -1872,6 +2266,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.DeleteApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._DeleteApplicationInstances._get_response( @@ -1893,7 +2314,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_application_instances(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.visionai_v1alpha1.AppPlatformClient.delete_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDraft( @@ -1930,7 +2373,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete draft method over HTTP. @@ -1940,8 +2383,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1954,6 +2399,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_http_options() ) + request, metadata = self._interceptor.pre_delete_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseDeleteDraft._get_transcoded_request( @@ -1968,6 +2414,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.DeleteDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteDraft._get_response( self._host, @@ -1986,7 +2459,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_draft(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.visionai_v1alpha1.AppPlatformClient.delete_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProcessor( @@ -2023,7 +2518,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete processor method over HTTP. @@ -2033,8 +2528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2047,6 +2544,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeleteProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_processor( request, metadata ) @@ -2059,6 +2557,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.DeleteProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteProcessor._get_response( self._host, @@ -2077,7 +2602,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_processor(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.visionai_v1alpha1.AppPlatformClient.delete_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployApplication( @@ -2115,7 +2662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy application method over HTTP. @@ -2125,8 +2672,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2139,6 +2688,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseDeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_application( request, metadata ) @@ -2155,6 +2705,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.DeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeployApplication._get_response( self._host, @@ -2174,7 +2751,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_application(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.visionai_v1alpha1.AppPlatformClient.deploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication( @@ -2211,7 +2810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Application: r"""Call the get application method over HTTP. @@ -2221,8 +2820,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Application: @@ -2232,6 +2833,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseGetApplication._get_transcoded_request( http_options, request @@ -2242,6 +2844,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.GetApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetApplication._get_response( self._host, @@ -2262,7 +2891,29 @@ def __call__( pb_resp = platform.Application.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_application(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Application.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.visionai_v1alpha1.AppPlatformClient.get_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDraft(_BaseAppPlatformRestTransport._BaseGetDraft, AppPlatformRestStub): @@ -2297,7 +2948,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Draft: r"""Call the get draft method over HTTP. @@ -2307,8 +2958,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Draft: @@ -2318,6 +2971,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_http_options() ) + request, metadata = self._interceptor.pre_get_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetDraft._get_transcoded_request( @@ -2332,6 +2986,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetDraft._get_response( self._host, @@ -2352,7 +3033,29 @@ def __call__( pb_resp = platform.Draft.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_draft(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Draft.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.visionai_v1alpha1.AppPlatformClient.get_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2389,7 +3092,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Instance: r"""Call the get instance method over HTTP. @@ -2399,8 +3102,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Instance: @@ -2410,6 +3115,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetInstance._get_transcoded_request( @@ -2424,6 +3130,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetInstance", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetInstance._get_response( self._host, @@ -2444,7 +3177,29 @@ def __call__( pb_resp = platform.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Instance.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.visionai_v1alpha1.AppPlatformClient.get_instance", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProcessor( @@ -2481,7 +3236,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.Processor: r"""Call the get processor method over HTTP. @@ -2491,8 +3246,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.Processor: @@ -2504,6 +3261,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_get_processor(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetProcessor._get_transcoded_request( @@ -2518,6 +3276,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetProcessor._get_response( self._host, @@ -2538,7 +3323,29 @@ def __call__( pb_resp = platform.Processor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_processor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.Processor.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.visionai_v1alpha1.AppPlatformClient.get_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApplications( @@ -2575,7 +3382,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListApplicationsResponse: r"""Call the list applications method over HTTP. @@ -2586,8 +3393,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListApplicationsResponse: @@ -2599,6 +3408,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListApplications._get_http_options() ) + request, metadata = self._interceptor.pre_list_applications( request, metadata ) @@ -2611,6 +3421,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.ListApplications", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListApplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListApplications._get_response( self._host, @@ -2631,7 +3468,31 @@ def __call__( pb_resp = platform.ListApplicationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_applications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListApplicationsResponse.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.visionai_v1alpha1.AppPlatformClient.list_applications", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListApplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDrafts( @@ -2668,7 +3529,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListDraftsResponse: r"""Call the list drafts method over HTTP. @@ -2679,8 +3540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListDraftsResponse: @@ -2692,6 +3555,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_http_options() ) + request, metadata = self._interceptor.pre_list_drafts(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseListDrafts._get_transcoded_request( @@ -2706,6 +3570,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.ListDrafts", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListDrafts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListDrafts._get_response( self._host, @@ -2726,7 +3617,29 @@ def __call__( pb_resp = platform.ListDraftsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_drafts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListDraftsResponse.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.visionai_v1alpha1.AppPlatformClient.list_drafts", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListDrafts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -2763,7 +3676,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -2774,8 +3687,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListInstancesResponse: @@ -2787,6 +3702,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -2799,6 +3715,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.ListInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListInstances._get_response( self._host, @@ -2819,7 +3762,29 @@ def __call__( pb_resp = platform.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListInstancesResponse.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.visionai_v1alpha1.AppPlatformClient.list_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrebuiltProcessors( @@ -2857,7 +3822,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListPrebuiltProcessorsResponse: r"""Call the list prebuilt processors method over HTTP. @@ -2868,8 +3833,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListPrebuiltProcessorsResponse: @@ -2881,6 +3848,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListPrebuiltProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_prebuilt_processors( request, metadata ) @@ -2897,6 +3865,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.ListPrebuiltProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListPrebuiltProcessors._get_response( self._host, @@ -2918,7 +3913,31 @@ def __call__( pb_resp = platform.ListPrebuiltProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_prebuilt_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListPrebuiltProcessorsResponse.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.visionai_v1alpha1.AppPlatformClient.list_prebuilt_processors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListPrebuiltProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProcessors( @@ -2955,7 +3974,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> platform.ListProcessorsResponse: r"""Call the list processors method over HTTP. @@ -2966,8 +3985,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.platform.ListProcessorsResponse: @@ -2979,6 +4000,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListProcessors._get_http_options() ) + request, metadata = self._interceptor.pre_list_processors(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListProcessors._get_transcoded_request( http_options, request @@ -2989,6 +4011,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.ListProcessors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListProcessors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListProcessors._get_response( self._host, @@ -3009,7 +4058,29 @@ def __call__( pb_resp = platform.ListProcessorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_processors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = platform.ListProcessorsResponse.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.visionai_v1alpha1.AppPlatformClient.list_processors", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListProcessors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveApplicationStreamInput( @@ -3048,7 +4119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove application stream input method over HTTP. @@ -3060,8 +4131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3074,6 +4147,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseRemoveApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_remove_application_stream_input( request, metadata ) @@ -3090,6 +4164,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.RemoveApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._RemoveApplicationStreamInput._get_response( @@ -3111,7 +4212,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_application_stream_input(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.visionai_v1alpha1.AppPlatformClient.remove_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "RemoveApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployApplication( @@ -3149,7 +4272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy application method over HTTP. @@ -3160,8 +4283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3174,6 +4299,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUndeployApplication._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_application( request, metadata ) @@ -3190,6 +4316,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.UndeployApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UndeployApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UndeployApplication._get_response( self._host, @@ -3209,7 +4362,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_application(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.visionai_v1alpha1.AppPlatformClient.undeploy_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UndeployApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -3247,7 +4422,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application method over HTTP. @@ -3257,8 +4432,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3271,6 +4448,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -3287,6 +4465,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.UpdateApplication", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateApplication._get_response( self._host, @@ -3306,7 +4511,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application(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.visionai_v1alpha1.AppPlatformClient.update_application", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationInstances( @@ -3345,7 +4572,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application instances method over HTTP. @@ -3357,8 +4584,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3371,6 +4600,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationInstances._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_instances( request, metadata ) @@ -3387,6 +4617,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.UpdateApplicationInstances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationInstances._get_response( @@ -3408,7 +4665,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application_instances(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.visionai_v1alpha1.AppPlatformClient.update_application_instances", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplicationStreamInput( @@ -3447,7 +4726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application stream input method over HTTP. @@ -3459,8 +4738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3473,6 +4754,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateApplicationStreamInput._get_http_options() ) + request, metadata = self._interceptor.pre_update_application_stream_input( request, metadata ) @@ -3489,6 +4771,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.UpdateApplicationStreamInput", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppPlatformRestTransport._UpdateApplicationStreamInput._get_response( @@ -3510,7 +4819,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_application_stream_input(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.visionai_v1alpha1.AppPlatformClient.update_application_stream_input", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateApplicationStreamInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDraft( @@ -3548,7 +4879,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update draft method over HTTP. @@ -3558,8 +4889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3572,6 +4905,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_http_options() ) + request, metadata = self._interceptor.pre_update_draft(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseUpdateDraft._get_transcoded_request( @@ -3592,6 +4926,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.UpdateDraft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateDraft", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateDraft._get_response( self._host, @@ -3611,7 +4972,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_draft(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.visionai_v1alpha1.AppPlatformClient.update_draft", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateDraft", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProcessor( @@ -3649,7 +5032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update processor method over HTTP. @@ -3659,8 +5042,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3673,6 +5058,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseUpdateProcessor._get_http_options() ) + request, metadata = self._interceptor.pre_update_processor( request, metadata ) @@ -3689,6 +5075,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.UpdateProcessor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateProcessor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._UpdateProcessor._get_response( self._host, @@ -3708,7 +5121,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_processor(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.visionai_v1alpha1.AppPlatformClient.update_processor", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "UpdateProcessor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3972,7 +5407,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3982,8 +5417,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -3992,6 +5429,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetLocation._get_transcoded_request( @@ -4006,6 +5444,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetLocation._get_response( self._host, @@ -4025,6 +5490,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.visionai_v1alpha1.AppPlatformAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4065,7 +5551,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -4075,8 +5561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -4085,6 +5573,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -4097,6 +5586,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListLocations._get_response( self._host, @@ -4116,6 +5632,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.visionai_v1alpha1.AppPlatformAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4156,7 +5693,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -4166,8 +5703,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -4176,6 +5715,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4190,6 +5730,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetIamPolicy._get_response( self._host, @@ -4209,6 +5776,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.visionai_v1alpha1.AppPlatformAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4250,7 +5838,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -4260,8 +5848,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -4270,6 +5860,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4290,6 +5881,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._SetIamPolicy._get_response( self._host, @@ -4310,6 +5928,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.visionai_v1alpha1.AppPlatformAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4351,7 +5990,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -4361,8 +6000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -4371,6 +6012,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4387,6 +6029,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._TestIamPermissions._get_response( self._host, @@ -4407,6 +6076,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.visionai_v1alpha1.AppPlatformAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4448,7 +6138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -4458,13 +6148,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAppPlatformRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4481,6 +6174,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._CancelOperation._get_response( self._host, @@ -4537,7 +6257,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -4547,13 +6267,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAppPlatformRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4566,6 +6289,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._DeleteOperation._get_response( self._host, @@ -4621,7 +6371,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4631,8 +6381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -4641,6 +6393,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAppPlatformRestTransport._BaseGetOperation._get_transcoded_request( @@ -4655,6 +6408,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.AppPlatformClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._GetOperation._get_response( self._host, @@ -4674,6 +6454,27 @@ def __call__( 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.visionai_v1alpha1.AppPlatformAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4714,7 +6515,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4724,8 +6525,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4734,6 +6537,7 @@ def __call__( http_options = ( _BaseAppPlatformRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppPlatformRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4744,6 +6548,33 @@ def __call__( 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.visionai_v1alpha1.AppPlatformClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppPlatformRestTransport._ListOperations._get_response( self._host, @@ -4763,6 +6594,27 @@ def __call__( 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.visionai_v1alpha1.AppPlatformAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.AppPlatform", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py index 629dc53b632c..aec2f29da09b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .transports.grpc_asyncio import LiveVideoAnalyticsGrpcAsyncIOTransport +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 LiveVideoAnalyticsAsyncClient: """Service describing handlers for resources. The service @@ -273,6 +283,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + async def list_analyses( self, request: Optional[Union[lva_service.ListAnalysesRequest, dict]] = None, @@ -280,7 +312,7 @@ async def list_analyses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalysesAsyncPager: r"""Lists Analyses in a given project and location. @@ -325,8 +357,10 @@ async def sample_list_analyses(): 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, 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: google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesAsyncPager: @@ -401,7 +435,7 @@ async def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -442,8 +476,10 @@ async def sample_get_analysis(): 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, 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: google.cloud.visionai_v1alpha1.types.Analysis: @@ -506,7 +542,7 @@ async def create_analysis( analysis_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Analysis in a given project and location. @@ -565,8 +601,10 @@ async def sample_create_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -643,7 +681,7 @@ async def update_analysis( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Analysis. @@ -698,8 +736,10 @@ async def sample_update_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -775,7 +815,7 @@ async def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Analysis. @@ -820,8 +860,10 @@ async def sample_delete_analysis(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -899,7 +941,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -910,8 +952,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -952,7 +996,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -963,8 +1007,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1005,7 +1051,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1021,8 +1067,10 @@ async def delete_operation( 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, 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: None """ @@ -1059,7 +1107,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1074,8 +1122,10 @@ async def cancel_operation( 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, 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: None """ @@ -1112,7 +1162,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -1125,8 +1175,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1231,7 +1283,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -1245,8 +1297,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1351,7 +1405,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1366,8 +1420,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1411,7 +1467,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1422,8 +1478,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1464,7 +1522,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1475,8 +1533,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py index 69debadc828b..4fe984f02f39 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -619,6 +629,10 @@ def __init__( # 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( @@ -685,6 +699,29 @@ def __init__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "credentialsType": None, + }, + ) + def list_analyses( self, request: Optional[Union[lva_service.ListAnalysesRequest, dict]] = None, @@ -692,7 +729,7 @@ def list_analyses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalysesPager: r"""Lists Analyses in a given project and location. @@ -737,8 +774,10 @@ def sample_list_analyses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesPager: @@ -810,7 +849,7 @@ def get_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Gets details of a single Analysis. @@ -851,8 +890,10 @@ def sample_get_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1alpha1.types.Analysis: @@ -912,7 +953,7 @@ def create_analysis( analysis_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Analysis in a given project and location. @@ -971,8 +1012,10 @@ def sample_create_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1046,7 +1089,7 @@ def update_analysis( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Analysis. @@ -1101,8 +1144,10 @@ def sample_update_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1175,7 +1220,7 @@ def delete_analysis( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Analysis. @@ -1220,8 +1265,10 @@ def sample_delete_analysis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1309,7 +1356,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1320,8 +1367,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1362,7 +1411,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1373,8 +1422,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1415,7 +1466,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1431,8 +1482,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1469,7 +1522,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1484,8 +1537,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1522,7 +1577,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -1535,8 +1590,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1641,7 +1698,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -1655,8 +1712,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1761,7 +1820,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1776,8 +1835,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1819,7 +1880,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1830,8 +1891,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1872,7 +1935,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1883,8 +1946,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py index 86ab91db0b6a..38fe9ab3f6af 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = lva_service.ListAnalysesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = lva_service.ListAnalysesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py index 76d537ed3e38..3637d416107b 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport +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.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": 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.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcTransport(LiveVideoAnalyticsTransport): """gRPC backend transport for LiveVideoAnalytics. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -300,7 +388,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -327,7 +415,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,7 @@ def delete_analysis( return self._stubs["delete_analysis"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -399,7 +487,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -416,7 +504,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -433,7 +521,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -452,7 +540,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -471,7 +559,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -488,7 +576,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -513,7 +601,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -539,7 +627,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -568,7 +656,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py index 62d4d743c1e8..7bcc81ade48d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import lva_resources, lva_service from .base import DEFAULT_CLIENT_INFO, LiveVideoAnalyticsTransport from .grpc import LiveVideoAnalyticsGrpcTransport +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.visionai.v1alpha1.LiveVideoAnalytics", + "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.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LiveVideoAnalyticsGrpcAsyncIOTransport(LiveVideoAnalyticsTransport): """gRPC AsyncIO backend transport for LiveVideoAnalytics. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def list_analyses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analyses" not in self._stubs: - self._stubs["list_analyses"] = self.grpc_channel.unary_unary( + self._stubs["list_analyses"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/ListAnalyses", request_serializer=lva_service.ListAnalysesRequest.serialize, response_deserializer=lva_service.ListAnalysesResponse.deserialize, @@ -312,7 +397,7 @@ def get_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_analysis" not in self._stubs: - self._stubs["get_analysis"] = self.grpc_channel.unary_unary( + self._stubs["get_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/GetAnalysis", request_serializer=lva_service.GetAnalysisRequest.serialize, response_deserializer=lva_resources.Analysis.deserialize, @@ -341,7 +426,7 @@ def create_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_analysis" not in self._stubs: - self._stubs["create_analysis"] = self.grpc_channel.unary_unary( + self._stubs["create_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/CreateAnalysis", request_serializer=lva_service.CreateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -369,7 +454,7 @@ def update_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_analysis" not in self._stubs: - self._stubs["update_analysis"] = self.grpc_channel.unary_unary( + self._stubs["update_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/UpdateAnalysis", request_serializer=lva_service.UpdateAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def delete_analysis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_analysis" not in self._stubs: - self._stubs["delete_analysis"] = self.grpc_channel.unary_unary( + self._stubs["delete_analysis"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.LiveVideoAnalytics/DeleteAnalysis", request_serializer=lva_service.DeleteAnalysisRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -501,7 +586,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -518,7 +603,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -535,7 +620,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -554,7 +639,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -573,7 +658,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -590,7 +675,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -615,7 +700,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -641,7 +726,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -670,7 +755,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py index 14e008ef9d7a..9726c2f9f2da 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/live_video_analytics/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -113,8 +121,10 @@ def post_update_analysis(self, response): def pre_create_analysis( self, request: lva_service.CreateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.CreateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_analysis Override in a subclass to manipulate the request or metadata @@ -136,8 +146,10 @@ def post_create_analysis( def pre_delete_analysis( self, request: lva_service.DeleteAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.DeleteAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_analysis Override in a subclass to manipulate the request or metadata @@ -159,8 +171,8 @@ def post_delete_analysis( def pre_get_analysis( self, request: lva_service.GetAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lva_service.GetAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_analysis Override in a subclass to manipulate the request or metadata @@ -182,8 +194,10 @@ def post_get_analysis( def pre_list_analyses( self, request: lva_service.ListAnalysesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.ListAnalysesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.ListAnalysesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_analyses Override in a subclass to manipulate the request or metadata @@ -205,8 +219,10 @@ def post_list_analyses( def pre_update_analysis( self, request: lva_service.UpdateAnalysisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lva_service.UpdateAnalysisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_analysis Override in a subclass to manipulate the request or metadata @@ -228,8 +244,10 @@ def post_update_analysis( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -251,8 +269,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -274,8 +294,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -295,8 +317,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -316,8 +340,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -339,8 +366,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -360,8 +389,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -381,8 +412,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -404,8 +437,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -611,7 +646,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create analysis method over HTTP. @@ -621,8 +656,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -635,6 +672,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_create_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseCreateAnalysis._get_transcoded_request( http_options, request @@ -649,6 +687,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.CreateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CreateAnalysis._get_response( self._host, @@ -668,7 +733,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_analysis(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.visionai_v1alpha1.LiveVideoAnalyticsClient.create_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CreateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnalysis( @@ -706,7 +793,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete analysis method over HTTP. @@ -716,8 +803,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -730,6 +819,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseDeleteAnalysis._get_transcoded_request( http_options, request @@ -740,6 +830,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.DeleteAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteAnalysis._get_response( self._host, @@ -758,7 +875,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_analysis(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.visionai_v1alpha1.LiveVideoAnalyticsClient.delete_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnalysis( @@ -796,7 +935,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_resources.Analysis: r"""Call the get analysis method over HTTP. @@ -806,8 +945,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_resources.Analysis: @@ -819,6 +960,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_get_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetAnalysis._get_transcoded_request( http_options, request @@ -829,6 +971,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.GetAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetAnalysis._get_response( self._host, @@ -849,7 +1018,29 @@ def __call__( pb_resp = lva_resources.Analysis.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_resources.Analysis.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.visionai_v1alpha1.LiveVideoAnalyticsClient.get_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnalyses( @@ -887,7 +1078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lva_service.ListAnalysesResponse: r"""Call the list analyses method over HTTP. @@ -898,8 +1089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lva_service.ListAnalysesResponse: @@ -911,6 +1104,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_http_options() ) + request, metadata = self._interceptor.pre_list_analyses(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListAnalyses._get_transcoded_request( http_options, request @@ -921,6 +1115,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.ListAnalyses", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListAnalyses._get_response( self._host, @@ -941,7 +1162,31 @@ def __call__( pb_resp = lva_service.ListAnalysesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lva_service.ListAnalysesResponse.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.visionai_v1alpha1.LiveVideoAnalyticsClient.list_analyses", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListAnalyses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnalysis( @@ -980,7 +1225,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update analysis method over HTTP. @@ -990,8 +1235,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1004,6 +1251,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_http_options() ) + request, metadata = self._interceptor.pre_update_analysis(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseUpdateAnalysis._get_transcoded_request( http_options, request @@ -1018,6 +1266,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.UpdateAnalysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._UpdateAnalysis._get_response( self._host, @@ -1037,7 +1312,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_analysis(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.visionai_v1alpha1.LiveVideoAnalyticsClient.update_analysis", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "UpdateAnalysis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1119,7 +1416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1129,8 +1426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1139,6 +1438,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1149,6 +1449,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetLocation._get_response( self._host, @@ -1168,6 +1495,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1209,7 +1557,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1219,8 +1567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1229,6 +1579,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1239,6 +1590,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListLocations._get_response( self._host, @@ -1258,6 +1636,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1299,7 +1698,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1309,8 +1708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1319,6 +1720,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1329,6 +1731,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetIamPolicy._get_response( self._host, @@ -1348,6 +1777,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1390,7 +1840,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1400,8 +1850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -1410,6 +1862,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1424,6 +1877,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._SetIamPolicy._get_response( self._host, @@ -1444,6 +1924,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1486,7 +1987,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1496,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -1506,6 +2009,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1522,6 +2026,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( LiveVideoAnalyticsRestTransport._TestIamPermissions._get_response( @@ -1544,6 +2075,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1586,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1596,13 +2148,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1619,6 +2174,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._CancelOperation._get_response( self._host, @@ -1676,7 +2258,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1686,13 +2268,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1705,6 +2290,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._DeleteOperation._get_response( self._host, @@ -1761,7 +2373,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1771,8 +2383,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1781,6 +2395,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1791,6 +2406,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._GetOperation._get_response( self._host, @@ -1810,6 +2452,27 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1851,7 +2514,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1861,8 +2524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1871,6 +2536,7 @@ def __call__( http_options = ( _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLiveVideoAnalyticsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1881,6 +2547,33 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LiveVideoAnalyticsRestTransport._ListOperations._get_response( self._host, @@ -1900,6 +2593,27 @@ def __call__( 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.visionai_v1alpha1.LiveVideoAnalyticsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.LiveVideoAnalytics", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py index 0fea8f23bb26..4a4d31fef714 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .transports.grpc_asyncio import StreamingServiceGrpcAsyncIOTransport +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 StreamingServiceAsyncClient: """Streaming service for receiving and sending packets.""" @@ -264,13 +274,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1alpha1.StreamingServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[AsyncIterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.SendPacketsResponse]]: r"""Send packets to the series. @@ -316,8 +348,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]: @@ -352,7 +386,7 @@ def receive_packets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.ReceivePacketsResponse]]: r"""Receive packets from the series. @@ -399,8 +433,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]: @@ -435,7 +471,7 @@ def receive_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[streaming_service.ReceiveEventsResponse]]: r"""Receive events given the stream name. @@ -481,8 +517,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]: @@ -517,7 +555,7 @@ async def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -553,8 +591,10 @@ async def sample_acquire_lease(): 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, 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: google.cloud.visionai_v1alpha1.types.Lease: @@ -598,7 +638,7 @@ async def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -633,8 +673,10 @@ async def sample_renew_lease(): 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, 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: google.cloud.visionai_v1alpha1.types.Lease: @@ -678,7 +720,7 @@ async def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -713,8 +755,10 @@ async def sample_release_lease(): 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, 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: google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse: @@ -758,7 +802,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -769,8 +813,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -811,7 +857,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -822,8 +868,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -864,7 +912,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -880,8 +928,10 @@ async def delete_operation( 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, 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: None """ @@ -918,7 +968,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -933,8 +983,10 @@ async def cancel_operation( 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, 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: None """ @@ -971,7 +1023,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -984,8 +1036,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1090,7 +1144,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -1104,8 +1158,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1210,7 +1266,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1225,8 +1281,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1270,7 +1328,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1281,8 +1339,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1323,7 +1383,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1334,8 +1394,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py index 5a7b337ee0ce..0a371a4072da 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -589,6 +599,10 @@ def __init__( # 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( @@ -655,13 +669,36 @@ def __init__( 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.visionai_v1alpha1.StreamingServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "credentialsType": None, + }, + ) + def send_packets( self, requests: Optional[Iterator[streaming_service.SendPacketsRequest]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.SendPacketsResponse]: r"""Send packets to the series. @@ -707,8 +744,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]: @@ -739,7 +778,7 @@ def receive_packets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.ReceivePacketsResponse]: r"""Receive packets from the series. @@ -786,8 +825,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]: @@ -818,7 +859,7 @@ def receive_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[streaming_service.ReceiveEventsResponse]: r"""Receive events given the stream name. @@ -864,8 +905,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]: @@ -898,7 +941,7 @@ def acquire_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""AcquireLease acquires a lease. @@ -934,8 +977,10 @@ def sample_acquire_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Lease: @@ -977,7 +1022,7 @@ def renew_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""RenewLease renews a lease. @@ -1012,8 +1057,10 @@ def sample_renew_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Lease: @@ -1055,7 +1102,7 @@ def release_lease( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""RleaseLease releases a lease. @@ -1090,8 +1137,10 @@ def sample_release_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse: @@ -1146,7 +1195,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1157,8 +1206,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1199,7 +1250,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1210,8 +1261,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1252,7 +1305,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1268,8 +1321,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1306,7 +1361,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1321,8 +1376,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1359,7 +1416,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -1372,8 +1429,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1478,7 +1537,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -1492,8 +1551,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1598,7 +1659,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1613,8 +1674,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1656,7 +1719,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1667,8 +1730,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1709,7 +1774,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1720,8 +1785,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py index b5fb15898863..5ef98e1c674d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport +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.visionai.v1alpha1.StreamingService", + "rpcName": 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.visionai.v1alpha1.StreamingService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcTransport(StreamingServiceTransport): """gRPC backend transport for StreamingService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -288,7 +374,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -317,7 +403,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -343,7 +429,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -369,7 +455,7 @@ def renew_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -397,7 +483,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -405,7 +491,7 @@ def release_lease( return self._stubs["release_lease"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -417,7 +503,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -434,7 +520,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -451,7 +537,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -470,7 +556,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -489,7 +575,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -506,7 +592,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -531,7 +617,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -557,7 +643,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -586,7 +672,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py index 158936493ded..8a3bc5d3f369 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import streaming_service from .base import DEFAULT_CLIENT_INFO, StreamingServiceTransport from .grpc import StreamingServiceGrpcTransport +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.visionai.v1alpha1.StreamingService", + "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.visionai.v1alpha1.StreamingService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamingServiceGrpcAsyncIOTransport(StreamingServiceTransport): """gRPC AsyncIO backend transport for StreamingService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def send_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "send_packets" not in self._stubs: - self._stubs["send_packets"] = self.grpc_channel.stream_stream( + self._stubs["send_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/SendPackets", request_serializer=streaming_service.SendPacketsRequest.serialize, response_deserializer=streaming_service.SendPacketsResponse.deserialize, @@ -297,7 +382,7 @@ def receive_packets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_packets" not in self._stubs: - self._stubs["receive_packets"] = self.grpc_channel.stream_stream( + self._stubs["receive_packets"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceivePackets", request_serializer=streaming_service.ReceivePacketsRequest.serialize, response_deserializer=streaming_service.ReceivePacketsResponse.deserialize, @@ -326,7 +411,7 @@ def receive_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_events" not in self._stubs: - self._stubs["receive_events"] = self.grpc_channel.stream_stream( + self._stubs["receive_events"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.StreamingService/ReceiveEvents", request_serializer=streaming_service.ReceiveEventsRequest.serialize, response_deserializer=streaming_service.ReceiveEventsResponse.deserialize, @@ -354,7 +439,7 @@ def acquire_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acquire_lease" not in self._stubs: - self._stubs["acquire_lease"] = self.grpc_channel.unary_unary( + self._stubs["acquire_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/AcquireLease", request_serializer=streaming_service.AcquireLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -382,7 +467,7 @@ def renew_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/RenewLease", request_serializer=streaming_service.RenewLeaseRequest.serialize, response_deserializer=streaming_service.Lease.deserialize, @@ -411,7 +496,7 @@ def release_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "release_lease" not in self._stubs: - self._stubs["release_lease"] = self.grpc_channel.unary_unary( + self._stubs["release_lease"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamingService/ReleaseLease", request_serializer=streaming_service.ReleaseLeaseRequest.serialize, response_deserializer=streaming_service.ReleaseLeaseResponse.deserialize, @@ -504,7 +589,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -520,7 +605,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -537,7 +622,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -554,7 +639,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -573,7 +658,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -592,7 +677,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -609,7 +694,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -634,7 +719,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -660,7 +745,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -689,7 +774,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py index 91e8bc6e11c3..23b0d32277e5 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streaming_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -97,8 +105,10 @@ def post_renew_lease(self, response): def pre_acquire_lease( self, request: streaming_service.AcquireLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.AcquireLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for acquire_lease Override in a subclass to manipulate the request or metadata @@ -120,8 +130,10 @@ def post_acquire_lease( def pre_release_lease( self, request: streaming_service.ReleaseLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.ReleaseLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for release_lease Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def post_release_lease( def pre_renew_lease( self, request: streaming_service.RenewLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streaming_service.RenewLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streaming_service.RenewLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for renew_lease Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_renew_lease( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -189,8 +205,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -212,8 +230,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -233,8 +253,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -254,8 +276,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -277,8 +302,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -298,8 +325,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -319,8 +348,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -342,8 +373,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -484,7 +517,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the acquire lease method over HTTP. @@ -495,8 +528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.Lease: @@ -506,6 +541,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseAcquireLease._get_http_options() ) + request, metadata = self._interceptor.pre_acquire_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseAcquireLease._get_transcoded_request( http_options, request @@ -520,6 +556,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.AcquireLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "AcquireLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._AcquireLease._get_response( self._host, @@ -541,7 +604,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acquire_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.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.visionai_v1alpha1.StreamingServiceClient.acquire_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "AcquireLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReceiveEvents( @@ -556,7 +641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceiveEvents is not available over REST transport" @@ -574,7 +659,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method ReceivePackets is not available over REST transport" @@ -615,7 +700,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.ReleaseLeaseResponse: r"""Call the release lease method over HTTP. @@ -625,8 +710,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.ReleaseLeaseResponse: @@ -636,6 +723,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseReleaseLease._get_http_options() ) + request, metadata = self._interceptor.pre_release_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseReleaseLease._get_transcoded_request( http_options, request @@ -650,6 +738,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.ReleaseLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ReleaseLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ReleaseLease._get_response( self._host, @@ -671,7 +786,31 @@ def __call__( pb_resp = streaming_service.ReleaseLeaseResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_release_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.ReleaseLeaseResponse.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.visionai_v1alpha1.StreamingServiceClient.release_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ReleaseLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenewLease( @@ -709,7 +848,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streaming_service.Lease: r"""Call the renew lease method over HTTP. @@ -719,8 +858,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streaming_service.Lease: @@ -730,6 +871,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseRenewLease._get_http_options() ) + request, metadata = self._interceptor.pre_renew_lease(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseRenewLease._get_transcoded_request( http_options, request @@ -744,6 +886,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.RenewLease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "RenewLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._RenewLease._get_response( self._host, @@ -765,7 +934,29 @@ def __call__( pb_resp = streaming_service.Lease.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_renew_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streaming_service.Lease.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.visionai_v1alpha1.StreamingServiceClient.renew_lease", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "RenewLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SendPackets( @@ -780,7 +971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method SendPackets is not available over REST transport" @@ -882,7 +1073,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -892,8 +1083,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -902,6 +1095,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -912,6 +1106,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetLocation._get_response( self._host, @@ -931,6 +1152,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.visionai_v1alpha1.StreamingServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -971,7 +1213,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -981,8 +1223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -991,6 +1235,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1001,6 +1246,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListLocations._get_response( self._host, @@ -1020,6 +1292,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.visionai_v1alpha1.StreamingServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1060,7 +1353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1070,8 +1363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1080,6 +1375,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1090,6 +1386,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1109,6 +1432,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.visionai_v1alpha1.StreamingServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1150,7 +1494,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1160,8 +1504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -1170,6 +1516,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1184,6 +1531,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1204,6 +1578,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.visionai_v1alpha1.StreamingServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1246,7 +1641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1256,8 +1651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -1266,6 +1663,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1282,6 +1680,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -1302,6 +1727,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.visionai_v1alpha1.StreamingServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1344,7 +1790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1354,13 +1800,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamingServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1377,6 +1826,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._CancelOperation._get_response( self._host, @@ -1434,7 +1910,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1444,13 +1920,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamingServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1463,6 +1942,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1518,7 +2024,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1528,8 +2034,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1538,6 +2046,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1548,6 +2057,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._GetOperation._get_response( self._host, @@ -1567,6 +2103,27 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1607,7 +2164,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1617,8 +2174,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1627,6 +2186,7 @@ def __call__( http_options = ( _BaseStreamingServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamingServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1637,6 +2197,33 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamingServiceRestTransport._ListOperations._get_response( self._host, @@ -1656,6 +2243,27 @@ def __call__( 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.visionai_v1alpha1.StreamingServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamingService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py index 469f645d47e3..ae65b1a4a69f 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .transports.grpc_asyncio import StreamsServiceGrpcAsyncIOTransport +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 StreamsServiceAsyncClient: """Service describing handlers for resources. @@ -282,6 +292,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1alpha1.StreamsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -289,7 +321,7 @@ async def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersAsyncPager: r"""Lists Clusters in a given project and location. @@ -334,8 +366,10 @@ async def sample_list_clusters(): 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, 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersAsyncPager: @@ -410,7 +444,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -451,8 +485,10 @@ async def sample_get_cluster(): 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, 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: google.cloud.visionai_v1alpha1.types.Cluster: @@ -515,7 +551,7 @@ async def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Cluster in a given project and location. @@ -574,8 +610,10 @@ async def sample_create_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -652,7 +690,7 @@ async def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Cluster. @@ -707,8 +745,10 @@ async def sample_update_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -784,7 +824,7 @@ async def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Cluster. @@ -829,8 +869,10 @@ async def sample_delete_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -909,7 +951,7 @@ async def list_streams( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListStreamsAsyncPager: r"""Lists Streams in a given project and location. @@ -954,8 +996,10 @@ async def sample_list_streams(): 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, 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsAsyncPager: @@ -1030,7 +1074,7 @@ async def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1071,8 +1115,10 @@ async def sample_get_stream(): 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, 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: google.cloud.visionai_v1alpha1.types.Stream: @@ -1139,7 +1185,7 @@ async def create_stream( stream_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Stream in a given project and location. @@ -1197,8 +1243,10 @@ async def sample_create_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1276,7 +1324,7 @@ async def update_stream( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Stream. @@ -1331,8 +1379,10 @@ async def sample_update_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1409,7 +1459,7 @@ async def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Stream. @@ -1454,8 +1504,10 @@ async def sample_delete_stream(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1536,7 +1588,7 @@ async def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -1579,8 +1631,10 @@ async def sample_generate_stream_hls_token(): 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, 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: google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse: @@ -1641,7 +1695,7 @@ async def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsAsyncPager: r"""Lists Events in a given project and location. @@ -1686,8 +1740,10 @@ async def sample_list_events(): 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, 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsAsyncPager: @@ -1762,7 +1818,7 @@ async def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -1803,8 +1859,10 @@ async def sample_get_event(): 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, 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: google.cloud.visionai_v1alpha1.types.Event: @@ -1865,7 +1923,7 @@ async def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Event in a given project and location. @@ -1923,8 +1981,10 @@ async def sample_create_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2001,7 +2061,7 @@ async def update_event( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Event. @@ -2056,8 +2116,10 @@ async def sample_update_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2133,7 +2195,7 @@ async def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Event. @@ -2178,8 +2240,10 @@ async def sample_delete_event(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2258,7 +2322,7 @@ async def list_series( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSeriesAsyncPager: r"""Lists Series in a given project and location. @@ -2303,8 +2367,10 @@ async def sample_list_series(): 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, 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesAsyncPager: @@ -2379,7 +2445,7 @@ async def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2420,8 +2486,10 @@ async def sample_get_series(): 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, 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: google.cloud.visionai_v1alpha1.types.Series: @@ -2482,7 +2550,7 @@ async def create_series( series_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Series in a given project and location. @@ -2545,8 +2613,10 @@ async def sample_create_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2623,7 +2693,7 @@ async def update_series( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Event. @@ -2683,8 +2753,10 @@ async def sample_update_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2760,7 +2832,7 @@ async def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Series. @@ -2805,8 +2877,10 @@ async def sample_delete_series(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2889,7 +2963,7 @@ async def materialize_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Materialize a channel. @@ -2950,8 +3024,10 @@ async def sample_materialize_channel(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3026,7 +3102,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3037,8 +3113,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3079,7 +3157,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3090,8 +3168,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3132,7 +3212,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3148,8 +3228,10 @@ async def delete_operation( 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, 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: None """ @@ -3186,7 +3268,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3201,8 +3283,10 @@ async def cancel_operation( 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, 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: None """ @@ -3239,7 +3323,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3252,8 +3336,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3358,7 +3444,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3372,8 +3458,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3478,7 +3566,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3493,8 +3581,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3538,7 +3628,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3549,8 +3639,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -3591,7 +3683,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3602,8 +3694,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py index 6fb97f6dde84..282450c55c96 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -694,6 +704,10 @@ def __init__( # 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( @@ -759,6 +773,29 @@ def __init__( 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.visionai_v1alpha1.StreamsServiceClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[streams_service.ListClustersRequest, dict]] = None, @@ -766,7 +803,7 @@ def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersPager: r"""Lists Clusters in a given project and location. @@ -811,8 +848,10 @@ def sample_list_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersPager: @@ -884,7 +923,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Gets details of a single Cluster. @@ -925,8 +964,10 @@ def sample_get_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Cluster: @@ -986,7 +1027,7 @@ def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Cluster in a given project and location. @@ -1045,8 +1086,10 @@ def sample_create_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1120,7 +1163,7 @@ def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Cluster. @@ -1175,8 +1218,10 @@ def sample_update_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1249,7 +1294,7 @@ def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Cluster. @@ -1294,8 +1339,10 @@ def sample_delete_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1371,7 +1418,7 @@ def list_streams( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListStreamsPager: r"""Lists Streams in a given project and location. @@ -1416,8 +1463,10 @@ def sample_list_streams(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsPager: @@ -1489,7 +1538,7 @@ def get_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Gets details of a single Stream. @@ -1530,8 +1579,10 @@ def sample_get_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.visionai_v1alpha1.types.Stream: @@ -1595,7 +1646,7 @@ def create_stream( stream_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Stream in a given project and location. @@ -1653,8 +1704,10 @@ def sample_create_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1729,7 +1782,7 @@ def update_stream( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Stream. @@ -1784,8 +1837,10 @@ def sample_update_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1859,7 +1914,7 @@ def delete_stream( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Stream. @@ -1904,8 +1959,10 @@ def sample_delete_stream(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1983,7 +2040,7 @@ def generate_stream_hls_token( stream: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Generate the JWT auth token required to get the stream HLS contents. @@ -2026,8 +2083,10 @@ def sample_generate_stream_hls_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse: @@ -2087,7 +2146,7 @@ def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsPager: r"""Lists Events in a given project and location. @@ -2132,8 +2191,10 @@ def sample_list_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsPager: @@ -2205,7 +2266,7 @@ def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Gets details of a single Event. @@ -2246,8 +2307,10 @@ def sample_get_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Event: @@ -2305,7 +2368,7 @@ def create_event( event_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Event in a given project and location. @@ -2363,8 +2426,10 @@ def sample_create_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2438,7 +2503,7 @@ def update_event( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Event. @@ -2493,8 +2558,10 @@ def sample_update_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2567,7 +2634,7 @@ def delete_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Event. @@ -2612,8 +2679,10 @@ def sample_delete_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2689,7 +2758,7 @@ def list_series( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSeriesPager: r"""Lists Series in a given project and location. @@ -2734,8 +2803,10 @@ def sample_list_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesPager: @@ -2807,7 +2878,7 @@ def get_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Gets details of a single Series. @@ -2848,8 +2919,10 @@ def sample_get_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Series: @@ -2907,7 +2980,7 @@ def create_series( series_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Series in a given project and location. @@ -2970,8 +3043,10 @@ def sample_create_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3045,7 +3120,7 @@ def update_series( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Event. @@ -3105,8 +3180,10 @@ def sample_update_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3179,7 +3256,7 @@ def delete_series( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Series. @@ -3224,8 +3301,10 @@ def sample_delete_series(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3305,7 +3384,7 @@ def materialize_channel( channel_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Materialize a channel. @@ -3366,8 +3445,10 @@ def sample_materialize_channel(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3452,7 +3533,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3463,8 +3544,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3505,7 +3588,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3516,8 +3599,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3558,7 +3643,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3574,8 +3659,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3612,7 +3699,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3627,8 +3714,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3665,7 +3754,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3678,8 +3767,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3784,7 +3875,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3798,8 +3889,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3904,7 +3997,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3919,8 +4012,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3962,7 +4057,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3973,8 +4068,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -4015,7 +4112,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4026,8 +4123,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py index c0ab1d98b91c..def302553769 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListClustersRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListClustersRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListStreamsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListStreamsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListEventsRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListEventsRequest(request) @@ -527,7 +539,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -541,8 +553,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = streams_service.ListSeriesRequest(request) @@ -601,7 +615,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -615,8 +629,10 @@ def __init__( 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, 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`. """ self._method = method self._request = streams_service.ListSeriesRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py index bae38d26de2a..d5c734d99926 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import ( common, @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport +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.visionai.v1alpha1.StreamsService", + "rpcName": 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.visionai.v1alpha1.StreamsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcTransport(StreamsServiceTransport): """gRPC backend transport for StreamsService. @@ -192,7 +273,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +342,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -282,7 +370,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -308,7 +396,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -335,7 +423,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -361,7 +449,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +503,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -441,7 +529,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -467,7 +555,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +581,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +607,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -549,7 +637,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -577,7 +665,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -603,7 +691,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -629,7 +717,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -655,7 +743,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -681,7 +769,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -709,7 +797,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -735,7 +823,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -761,7 +849,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -787,7 +875,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -813,7 +901,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -841,7 +929,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -849,7 +937,7 @@ def materialize_channel( return self._stubs["materialize_channel"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -861,7 +949,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -878,7 +966,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -895,7 +983,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -914,7 +1002,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -933,7 +1021,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -950,7 +1038,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -975,7 +1063,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1001,7 +1089,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1030,7 +1118,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py index 0de5b218f55c..b9e2433caf30 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import ( common, @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, StreamsServiceTransport from .grpc import StreamsServiceGrpcTransport +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.visionai.v1alpha1.StreamsService", + "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.visionai.v1alpha1.StreamsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StreamsServiceGrpcAsyncIOTransport(StreamsServiceTransport): """gRPC AsyncIO backend transport for StreamsService. @@ -239,10 +321,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +350,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -293,7 +378,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListClusters", request_serializer=streams_service.ListClustersRequest.serialize, response_deserializer=streams_service.ListClustersResponse.deserialize, @@ -319,7 +404,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetCluster", request_serializer=streams_service.GetClusterRequest.serialize, response_deserializer=common.Cluster.deserialize, @@ -348,7 +433,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateCluster", request_serializer=streams_service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +461,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateCluster", request_serializer=streams_service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +489,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteCluster", request_serializer=streams_service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +518,7 @@ def list_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_streams" not in self._stubs: - self._stubs["list_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_streams"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListStreams", request_serializer=streams_service.ListStreamsRequest.serialize, response_deserializer=streams_service.ListStreamsResponse.deserialize, @@ -461,7 +546,7 @@ def get_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_stream" not in self._stubs: - self._stubs["get_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetStream", request_serializer=streams_service.GetStreamRequest.serialize, response_deserializer=streams_resources.Stream.deserialize, @@ -489,7 +574,7 @@ def create_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_stream" not in self._stubs: - self._stubs["create_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateStream", request_serializer=streams_service.CreateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +602,7 @@ def update_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_stream" not in self._stubs: - self._stubs["update_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateStream", request_serializer=streams_service.UpdateStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def delete_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_stream" not in self._stubs: - self._stubs["delete_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_stream"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteStream", request_serializer=streams_service.DeleteStreamRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -575,7 +660,7 @@ def generate_stream_hls_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stream_hls_token" not in self._stubs: - self._stubs["generate_stream_hls_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_stream_hls_token"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GenerateStreamHlsToken", request_serializer=streams_service.GenerateStreamHlsTokenRequest.serialize, response_deserializer=streams_service.GenerateStreamHlsTokenResponse.deserialize, @@ -604,7 +689,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListEvents", request_serializer=streams_service.ListEventsRequest.serialize, response_deserializer=streams_service.ListEventsResponse.deserialize, @@ -632,7 +717,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetEvent", request_serializer=streams_service.GetEventRequest.serialize, response_deserializer=streams_resources.Event.deserialize, @@ -660,7 +745,7 @@ def create_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event" not in self._stubs: - self._stubs["create_event"] = self.grpc_channel.unary_unary( + self._stubs["create_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateEvent", request_serializer=streams_service.CreateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -688,7 +773,7 @@ def update_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event" not in self._stubs: - self._stubs["update_event"] = self.grpc_channel.unary_unary( + self._stubs["update_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateEvent", request_serializer=streams_service.UpdateEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -716,7 +801,7 @@ def delete_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event" not in self._stubs: - self._stubs["delete_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_event"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteEvent", request_serializer=streams_service.DeleteEventRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -745,7 +830,7 @@ def list_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_series" not in self._stubs: - self._stubs["list_series"] = self.grpc_channel.unary_unary( + self._stubs["list_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/ListSeries", request_serializer=streams_service.ListSeriesRequest.serialize, response_deserializer=streams_service.ListSeriesResponse.deserialize, @@ -773,7 +858,7 @@ def get_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_series" not in self._stubs: - self._stubs["get_series"] = self.grpc_channel.unary_unary( + self._stubs["get_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/GetSeries", request_serializer=streams_service.GetSeriesRequest.serialize, response_deserializer=streams_resources.Series.deserialize, @@ -801,7 +886,7 @@ def create_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_series" not in self._stubs: - self._stubs["create_series"] = self.grpc_channel.unary_unary( + self._stubs["create_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/CreateSeries", request_serializer=streams_service.CreateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -829,7 +914,7 @@ def update_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_series" not in self._stubs: - self._stubs["update_series"] = self.grpc_channel.unary_unary( + self._stubs["update_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/UpdateSeries", request_serializer=streams_service.UpdateSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -857,7 +942,7 @@ def delete_series( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_series" not in self._stubs: - self._stubs["delete_series"] = self.grpc_channel.unary_unary( + self._stubs["delete_series"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/DeleteSeries", request_serializer=streams_service.DeleteSeriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -885,7 +970,7 @@ def materialize_channel( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "materialize_channel" not in self._stubs: - self._stubs["materialize_channel"] = self.grpc_channel.unary_unary( + self._stubs["materialize_channel"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.StreamsService/MaterializeChannel", request_serializer=streams_service.MaterializeChannelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1058,7 +1143,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1074,7 +1159,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1091,7 +1176,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1108,7 +1193,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1127,7 +1212,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1146,7 +1231,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1163,7 +1248,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1188,7 +1273,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1214,7 +1299,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1243,7 +1328,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py index ae70720f44ab..460b0d633a66 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/streams_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ 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, @@ -253,8 +261,10 @@ def post_update_stream(self, response): def pre_create_cluster( self, request: streams_service.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -276,8 +286,10 @@ def post_create_cluster( def pre_create_event( self, request: streams_service.CreateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_event Override in a subclass to manipulate the request or metadata @@ -299,8 +311,10 @@ def post_create_event( def pre_create_series( self, request: streams_service.CreateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_series Override in a subclass to manipulate the request or metadata @@ -322,8 +336,10 @@ def post_create_series( def pre_create_stream( self, request: streams_service.CreateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.CreateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.CreateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_stream Override in a subclass to manipulate the request or metadata @@ -345,8 +361,10 @@ def post_create_stream( def pre_delete_cluster( self, request: streams_service.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -368,8 +386,10 @@ def post_delete_cluster( def pre_delete_event( self, request: streams_service.DeleteEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_event Override in a subclass to manipulate the request or metadata @@ -391,8 +411,10 @@ def post_delete_event( def pre_delete_series( self, request: streams_service.DeleteSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_series Override in a subclass to manipulate the request or metadata @@ -414,8 +436,10 @@ def post_delete_series( def pre_delete_stream( self, request: streams_service.DeleteStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.DeleteStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.DeleteStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_stream Override in a subclass to manipulate the request or metadata @@ -437,9 +461,10 @@ def post_delete_stream( def pre_generate_stream_hls_token( self, request: streams_service.GenerateStreamHlsTokenRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - streams_service.GenerateStreamHlsTokenRequest, Sequence[Tuple[str, str]] + streams_service.GenerateStreamHlsTokenRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stream_hls_token @@ -462,8 +487,10 @@ def post_generate_stream_hls_token( def pre_get_cluster( self, request: streams_service.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -483,8 +510,10 @@ def post_get_cluster(self, response: common.Cluster) -> common.Cluster: def pre_get_event( self, request: streams_service.GetEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -506,8 +535,10 @@ def post_get_event( def pre_get_series( self, request: streams_service.GetSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_series Override in a subclass to manipulate the request or metadata @@ -529,8 +560,10 @@ def post_get_series( def pre_get_stream( self, request: streams_service.GetStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.GetStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.GetStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_stream Override in a subclass to manipulate the request or metadata @@ -552,8 +585,10 @@ def post_get_stream( def pre_list_clusters( self, request: streams_service.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -575,8 +610,10 @@ def post_list_clusters( def pre_list_events( self, request: streams_service.ListEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -598,8 +635,10 @@ def post_list_events( def pre_list_series( self, request: streams_service.ListSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_series Override in a subclass to manipulate the request or metadata @@ -621,8 +660,10 @@ def post_list_series( def pre_list_streams( self, request: streams_service.ListStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.ListStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.ListStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_streams Override in a subclass to manipulate the request or metadata @@ -644,8 +685,11 @@ def post_list_streams( def pre_materialize_channel( self, request: streams_service.MaterializeChannelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.MaterializeChannelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.MaterializeChannelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for materialize_channel Override in a subclass to manipulate the request or metadata @@ -667,8 +711,10 @@ def post_materialize_channel( def pre_update_cluster( self, request: streams_service.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -690,8 +736,10 @@ def post_update_cluster( def pre_update_event( self, request: streams_service.UpdateEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_event Override in a subclass to manipulate the request or metadata @@ -713,8 +761,10 @@ def post_update_event( def pre_update_series( self, request: streams_service.UpdateSeriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateSeriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateSeriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_series Override in a subclass to manipulate the request or metadata @@ -736,8 +786,10 @@ def post_update_series( def pre_update_stream( self, request: streams_service.UpdateStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[streams_service.UpdateStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + streams_service.UpdateStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_stream Override in a subclass to manipulate the request or metadata @@ -759,8 +811,10 @@ def post_update_stream( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -782,8 +836,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -805,8 +861,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -826,8 +884,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -847,8 +907,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -870,8 +933,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -891,8 +956,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -912,8 +979,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -935,8 +1004,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1143,7 +1214,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -1153,8 +1224,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1167,6 +1240,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1181,6 +1255,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.CreateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateCluster._get_response( self._host, @@ -1200,7 +1301,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.visionai_v1alpha1.StreamsServiceClient.create_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEvent( @@ -1238,7 +1361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create event method over HTTP. @@ -1248,8 +1371,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1262,6 +1387,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateEvent._get_transcoded_request( http_options, request @@ -1276,6 +1402,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.CreateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateEvent._get_response( self._host, @@ -1295,7 +1448,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event(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.visionai_v1alpha1.StreamsServiceClient.create_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSeries( @@ -1333,7 +1508,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create series method over HTTP. @@ -1343,8 +1518,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1357,6 +1534,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_create_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateSeries._get_transcoded_request( http_options, request @@ -1371,6 +1549,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.CreateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateSeries._get_response( self._host, @@ -1390,7 +1595,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_series(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.visionai_v1alpha1.StreamsServiceClient.create_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateStream( @@ -1428,7 +1655,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create stream method over HTTP. @@ -1438,8 +1665,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1452,6 +1681,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseCreateStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseCreateStream._get_transcoded_request( http_options, request @@ -1466,6 +1696,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.CreateStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CreateStream._get_response( self._host, @@ -1485,7 +1742,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_stream(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.visionai_v1alpha1.StreamsServiceClient.create_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CreateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -1522,7 +1801,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -1532,8 +1811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1546,6 +1827,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -1556,6 +1838,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteCluster._get_response( self._host, @@ -1574,7 +1883,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.visionai_v1alpha1.StreamsServiceClient.delete_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEvent( @@ -1611,7 +1942,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete event method over HTTP. @@ -1621,8 +1952,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1635,6 +1968,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteEvent._get_transcoded_request( http_options, request @@ -1645,6 +1979,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.DeleteEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteEvent._get_response( self._host, @@ -1663,7 +2024,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_event(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.visionai_v1alpha1.StreamsServiceClient.delete_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSeries( @@ -1700,7 +2083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete series method over HTTP. @@ -1710,8 +2093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1724,6 +2109,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_http_options() ) + request, metadata = self._interceptor.pre_delete_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteSeries._get_transcoded_request( http_options, request @@ -1734,6 +2120,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.DeleteSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteSeries._get_response( self._host, @@ -1752,7 +2165,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_series(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.visionai_v1alpha1.StreamsServiceClient.delete_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteStream( @@ -1789,7 +2224,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete stream method over HTTP. @@ -1799,8 +2234,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1813,6 +2250,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseDeleteStream._get_transcoded_request( http_options, request @@ -1823,6 +2261,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.DeleteStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteStream._get_response( self._host, @@ -1841,7 +2306,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_stream(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.visionai_v1alpha1.StreamsServiceClient.delete_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStreamHlsToken( @@ -1880,7 +2367,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.GenerateStreamHlsTokenResponse: r"""Call the generate stream hls token method over HTTP. @@ -1891,8 +2378,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.GenerateStreamHlsTokenResponse: @@ -1904,6 +2393,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGenerateStreamHlsToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stream_hls_token( request, metadata ) @@ -1920,6 +2410,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.GenerateStreamHlsToken", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StreamsServiceRestTransport._GenerateStreamHlsToken._get_response( @@ -1943,7 +2460,31 @@ def __call__( pb_resp = streams_service.GenerateStreamHlsTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stream_hls_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + streams_service.GenerateStreamHlsTokenResponse.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.visionai_v1alpha1.StreamsServiceClient.generate_stream_hls_token", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GenerateStreamHlsToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -1980,7 +2521,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.Cluster: r"""Call the get cluster method over HTTP. @@ -1990,8 +2531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.Cluster: @@ -2003,6 +2546,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -2015,6 +2559,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.GetCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetCluster._get_response( self._host, @@ -2035,7 +2606,29 @@ def __call__( pb_resp = common.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.Cluster.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.visionai_v1alpha1.StreamsServiceClient.get_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEvent( @@ -2072,7 +2665,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Event: r"""Call the get event method over HTTP. @@ -2082,8 +2675,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Event: @@ -2093,6 +2688,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetEvent._get_transcoded_request( @@ -2107,6 +2703,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.GetEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetEvent._get_response( self._host, @@ -2127,7 +2750,29 @@ def __call__( pb_resp = streams_resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Event.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.visionai_v1alpha1.StreamsServiceClient.get_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSeries( @@ -2164,7 +2809,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Series: r"""Call the get series method over HTTP. @@ -2174,8 +2819,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Series: @@ -2185,6 +2832,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_http_options() ) + request, metadata = self._interceptor.pre_get_series(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetSeries._get_transcoded_request( @@ -2199,6 +2847,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.GetSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetSeries._get_response( self._host, @@ -2219,7 +2894,29 @@ def __call__( pb_resp = streams_resources.Series.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Series.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.visionai_v1alpha1.StreamsServiceClient.get_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStream( @@ -2256,7 +2953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_resources.Stream: r"""Call the get stream method over HTTP. @@ -2266,8 +2963,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_resources.Stream: @@ -2283,6 +2982,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_stream(request, metadata) transcoded_request = ( _BaseStreamsServiceRestTransport._BaseGetStream._get_transcoded_request( @@ -2297,6 +2997,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.GetStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetStream._get_response( self._host, @@ -2317,7 +3044,29 @@ def __call__( pb_resp = streams_resources.Stream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_resources.Stream.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.visionai_v1alpha1.StreamsServiceClient.get_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -2354,7 +3103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -2365,8 +3114,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListClustersResponse: @@ -2378,6 +3129,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -2388,6 +3140,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.ListClusters", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListClusters._get_response( self._host, @@ -2408,7 +3187,31 @@ def __call__( pb_resp = streams_service.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListClustersResponse.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.visionai_v1alpha1.StreamsServiceClient.list_clusters", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -2445,7 +3248,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListEventsResponse: r"""Call the list events method over HTTP. @@ -2456,8 +3259,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListEventsResponse: @@ -2469,6 +3274,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListEvents._get_transcoded_request( http_options, request @@ -2481,6 +3287,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.ListEvents", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListEvents._get_response( self._host, @@ -2501,7 +3334,31 @@ def __call__( pb_resp = streams_service.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListEventsResponse.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.visionai_v1alpha1.StreamsServiceClient.list_events", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSeries( @@ -2538,7 +3395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListSeriesResponse: r"""Call the list series method over HTTP. @@ -2549,8 +3406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListSeriesResponse: @@ -2562,6 +3421,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListSeries._get_http_options() ) + request, metadata = self._interceptor.pre_list_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListSeries._get_transcoded_request( http_options, request @@ -2574,6 +3434,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.StreamsServiceClient.ListSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListSeries._get_response( self._host, @@ -2594,7 +3481,31 @@ def __call__( pb_resp = streams_service.ListSeriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_series(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListSeriesResponse.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.visionai_v1alpha1.StreamsServiceClient.list_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListStreams( @@ -2631,7 +3542,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> streams_service.ListStreamsResponse: r"""Call the list streams method over HTTP. @@ -2642,8 +3553,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.streams_service.ListStreamsResponse: @@ -2655,6 +3568,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_streams(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListStreams._get_transcoded_request( http_options, request @@ -2665,6 +3579,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.ListStreams", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListStreams._get_response( self._host, @@ -2685,7 +3626,31 @@ def __call__( pb_resp = streams_service.ListStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = streams_service.ListStreamsResponse.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.visionai_v1alpha1.StreamsServiceClient.list_streams", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MaterializeChannel( @@ -2723,7 +3688,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the materialize channel method over HTTP. @@ -2733,8 +3698,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2747,6 +3714,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseMaterializeChannel._get_http_options() ) + request, metadata = self._interceptor.pre_materialize_channel( request, metadata ) @@ -2763,6 +3731,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.MaterializeChannel", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "MaterializeChannel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._MaterializeChannel._get_response( self._host, @@ -2782,7 +3777,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_materialize_channel(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.visionai_v1alpha1.StreamsServiceClient.materialize_channel", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "MaterializeChannel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -2820,7 +3837,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -2830,8 +3847,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2844,6 +3863,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -2858,6 +3878,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateCluster._get_response( self._host, @@ -2877,7 +3924,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.visionai_v1alpha1.StreamsServiceClient.update_cluster", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEvent( @@ -2915,7 +3984,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update event method over HTTP. @@ -2925,8 +3994,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2939,6 +4010,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_event(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateEvent._get_transcoded_request( http_options, request @@ -2953,6 +4025,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.UpdateEvent", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateEvent._get_response( self._host, @@ -2972,7 +4071,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event(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.visionai_v1alpha1.StreamsServiceClient.update_event", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSeries( @@ -3010,7 +4131,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update series method over HTTP. @@ -3020,8 +4141,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3034,6 +4157,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_http_options() ) + request, metadata = self._interceptor.pre_update_series(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateSeries._get_transcoded_request( http_options, request @@ -3048,6 +4172,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.UpdateSeries", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateSeries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateSeries._get_response( self._host, @@ -3067,7 +4218,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_series(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.visionai_v1alpha1.StreamsServiceClient.update_series", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateSeries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateStream( @@ -3105,7 +4278,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update stream method over HTTP. @@ -3115,8 +4288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3129,6 +4304,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseUpdateStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_stream(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseUpdateStream._get_transcoded_request( http_options, request @@ -3143,6 +4319,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.UpdateStream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._UpdateStream._get_response( self._host, @@ -3162,7 +4365,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_stream(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.visionai_v1alpha1.StreamsServiceClient.update_stream", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "UpdateStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3392,7 +4617,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3402,8 +4627,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -3412,6 +4639,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3422,6 +4650,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetLocation._get_response( self._host, @@ -3441,6 +4696,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.visionai_v1alpha1.StreamsServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3481,7 +4757,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3491,8 +4767,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -3501,6 +4779,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3511,6 +4790,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListLocations._get_response( self._host, @@ -3530,6 +4836,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.visionai_v1alpha1.StreamsServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3570,7 +4897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -3580,8 +4907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -3590,6 +4919,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3600,6 +4930,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -3619,6 +4976,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.visionai_v1alpha1.StreamsServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3660,7 +5038,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -3670,8 +5048,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -3680,6 +5060,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3694,6 +5075,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -3714,6 +5122,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.visionai_v1alpha1.StreamsServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3755,7 +5184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -3765,8 +5194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -3775,6 +5206,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3791,6 +5223,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -3811,6 +5270,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.visionai_v1alpha1.StreamsServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3852,7 +5332,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3862,13 +5342,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3885,6 +5368,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._CancelOperation._get_response( self._host, @@ -3941,7 +5451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3951,13 +5461,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStreamsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3970,6 +5483,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._DeleteOperation._get_response( self._host, @@ -4025,7 +5565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4035,8 +5575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -4045,6 +5587,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -4055,6 +5598,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._GetOperation._get_response( self._host, @@ -4074,6 +5644,27 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4114,7 +5705,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4124,8 +5715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4134,6 +5727,7 @@ def __call__( http_options = ( _BaseStreamsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStreamsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4144,6 +5738,33 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StreamsServiceRestTransport._ListOperations._get_response( self._host, @@ -4163,6 +5784,27 @@ def __call__( 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.visionai_v1alpha1.StreamsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.StreamsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py index e10cfafa89bd..55d6da6c15aa 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -62,6 +63,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WarehouseTransport from .transports.grpc_asyncio import WarehouseGrpcAsyncIOTransport +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 WarehouseAsyncClient: """Service that manages media content + metadata for streaming.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.visionai_v1alpha1.WarehouseAsyncClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "credentialsType": None, + }, + ) + async def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -278,7 +310,7 @@ async def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -340,8 +372,10 @@ async def sample_create_asset(): 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, 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -412,7 +446,7 @@ async def update_asset( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -462,8 +496,10 @@ async def sample_update_asset(): 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, 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -533,7 +569,7 @@ async def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -576,8 +612,10 @@ async def sample_get_asset(): 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, 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -643,7 +681,7 @@ async def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Lists an list of assets inside corpus. @@ -688,8 +726,10 @@ async def sample_list_assets(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsAsyncPager: @@ -764,7 +804,7 @@ async def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes asset inside corpus. @@ -811,8 +851,10 @@ async def sample_delete_asset(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -892,7 +934,7 @@ async def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a corpus inside a project. @@ -948,8 +990,10 @@ async def sample_create_corpus(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1023,7 +1067,7 @@ async def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -1066,8 +1110,10 @@ async def sample_get_corpus(): 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, 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: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1131,7 +1177,7 @@ async def update_corpus( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -1182,8 +1228,10 @@ async def sample_update_corpus(): 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, 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: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1250,7 +1298,7 @@ async def list_corpora( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCorporaAsyncPager: r"""Lists all corpora in a project. @@ -1294,8 +1342,10 @@ async def sample_list_corpora(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaAsyncPager: @@ -1370,7 +1420,7 @@ async def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a corpus only if its empty. Returns empty response. @@ -1411,8 +1461,10 @@ async def sample_delete_corpus(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1465,7 +1517,7 @@ async def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -1518,8 +1570,10 @@ async def sample_create_data_schema(): 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, 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1584,7 +1638,7 @@ async def update_data_schema( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -1636,8 +1690,10 @@ async def sample_update_data_schema(): 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, 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1703,7 +1759,7 @@ async def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -1747,8 +1803,10 @@ async def sample_get_data_schema(): 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, 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -1810,7 +1868,7 @@ async def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes data schema inside corpus. @@ -1850,8 +1908,10 @@ async def sample_delete_data_schema(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1903,7 +1963,7 @@ async def list_data_schemas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSchemasAsyncPager: r"""Lists a list of data schemas inside corpus. @@ -1948,8 +2008,10 @@ async def sample_list_data_schemas(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasAsyncPager: @@ -2026,7 +2088,7 @@ async def create_annotation( annotation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -2088,8 +2150,10 @@ async def sample_create_annotation(): 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, 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2155,7 +2219,7 @@ async def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -2200,8 +2264,10 @@ async def sample_get_annotation(): 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, 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2263,7 +2329,7 @@ async def list_annotations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnnotationsAsyncPager: r"""Lists a list of annotations inside asset. @@ -2308,8 +2374,10 @@ async def sample_list_annotations(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsAsyncPager: @@ -2385,7 +2453,7 @@ async def update_annotation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -2435,8 +2503,10 @@ async def sample_update_annotation(): 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, 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2502,7 +2572,7 @@ async def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes annotation inside asset. @@ -2543,8 +2613,10 @@ async def sample_delete_annotation(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2595,7 +2667,7 @@ def ingest_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[warehouse.IngestAssetResponse]]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -2649,8 +2721,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]: @@ -2683,7 +2757,7 @@ async def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Generates clips for downloading. The api takes in a time range, and generates a clip of the first content available after @@ -2723,8 +2797,10 @@ async def sample_clip_asset(): 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, 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: google.cloud.visionai_v1alpha1.types.ClipAssetResponse: @@ -2768,7 +2844,7 @@ async def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -2807,8 +2883,10 @@ async def sample_generate_hls_uri(): 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, 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: google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse: @@ -2857,7 +2935,7 @@ async def create_search_config( search_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -2936,8 +3014,10 @@ async def sample_create_search_config(): 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, 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3004,7 +3084,7 @@ async def update_search_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -3072,8 +3152,10 @@ async def sample_update_search_config(): 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, 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3139,7 +3221,7 @@ async def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -3183,8 +3265,10 @@ async def sample_get_search_config(): 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, 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3246,7 +3330,7 @@ async def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a search configuration inside a corpus. @@ -3291,8 +3375,10 @@ async def sample_delete_search_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3344,7 +3430,7 @@ async def list_search_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchConfigsAsyncPager: r"""Lists all search configurations inside a corpus. @@ -3390,8 +3476,10 @@ async def sample_list_search_configs(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsAsyncPager: @@ -3465,7 +3553,7 @@ async def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsAsyncPager: r"""Search media asset. @@ -3502,8 +3590,10 @@ async def sample_search_assets(): 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, 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsAsyncPager: @@ -3563,7 +3653,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3574,8 +3664,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3616,7 +3708,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3627,8 +3719,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3669,7 +3763,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3685,8 +3779,10 @@ async def delete_operation( 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, 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: None """ @@ -3723,7 +3819,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3738,8 +3834,10 @@ async def cancel_operation( 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, 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: None """ @@ -3776,7 +3874,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3789,8 +3887,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3895,7 +3995,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3909,8 +4009,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4015,7 +4117,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -4030,8 +4132,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -4075,7 +4179,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4086,8 +4190,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -4128,7 +4234,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4139,8 +4245,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py index 7555baa994df..86ac74731ecd 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.location import locations_pb2 # type: ignore @@ -686,6 +696,10 @@ def __init__( # 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( @@ -748,6 +762,29 @@ def __init__( 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.visionai_v1alpha1.WarehouseClient`.", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "credentialsType": None, + }, + ) + def create_asset( self, request: Optional[Union[warehouse.CreateAssetRequest, dict]] = None, @@ -757,7 +794,7 @@ def create_asset( asset_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Creates an asset inside corpus. @@ -819,8 +856,10 @@ def sample_create_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -888,7 +927,7 @@ def update_asset( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Updates an asset inside corpus. @@ -938,8 +977,10 @@ def sample_update_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -1006,7 +1047,7 @@ def get_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Reads an asset inside corpus. @@ -1049,8 +1090,10 @@ def sample_get_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Asset: @@ -1113,7 +1156,7 @@ def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Lists an list of assets inside corpus. @@ -1158,8 +1201,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsPager: @@ -1231,7 +1276,7 @@ def delete_asset( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes asset inside corpus. @@ -1278,8 +1323,10 @@ def sample_delete_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1356,7 +1403,7 @@ def create_corpus( corpus: Optional[warehouse.Corpus] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a corpus inside a project. @@ -1412,8 +1459,10 @@ def sample_create_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1484,7 +1533,7 @@ def get_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Gets corpus details inside a project. @@ -1527,8 +1576,10 @@ def sample_get_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1589,7 +1640,7 @@ def update_corpus( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Updates a corpus in a project. @@ -1640,8 +1691,10 @@ def sample_update_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Corpus: @@ -1705,7 +1758,7 @@ def list_corpora( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCorporaPager: r"""Lists all corpora in a project. @@ -1749,8 +1802,10 @@ def sample_list_corpora(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaPager: @@ -1822,7 +1877,7 @@ def delete_corpus( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a corpus only if its empty. Returns empty response. @@ -1863,8 +1918,10 @@ def sample_delete_corpus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1914,7 +1971,7 @@ def create_data_schema( data_schema: Optional[warehouse.DataSchema] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Creates data schema inside corpus. @@ -1967,8 +2024,10 @@ def sample_create_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2030,7 +2089,7 @@ def update_data_schema( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Updates data schema inside corpus. @@ -2082,8 +2141,10 @@ def sample_update_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2146,7 +2207,7 @@ def get_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Gets data schema inside corpus. @@ -2190,8 +2251,10 @@ def sample_get_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.DataSchema: @@ -2250,7 +2313,7 @@ def delete_data_schema( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes data schema inside corpus. @@ -2290,8 +2353,10 @@ def sample_delete_data_schema(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2340,7 +2405,7 @@ def list_data_schemas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSchemasPager: r"""Lists a list of data schemas inside corpus. @@ -2385,8 +2450,10 @@ def sample_list_data_schemas(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasPager: @@ -2460,7 +2527,7 @@ def create_annotation( annotation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Creates annotation inside asset. @@ -2522,8 +2589,10 @@ def sample_create_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2586,7 +2655,7 @@ def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Reads annotation inside asset. @@ -2631,8 +2700,10 @@ def sample_get_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2691,7 +2762,7 @@ def list_annotations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnnotationsPager: r"""Lists a list of annotations inside asset. @@ -2736,8 +2807,10 @@ def sample_list_annotations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsPager: @@ -2810,7 +2883,7 @@ def update_annotation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Updates annotation inside asset. @@ -2860,8 +2933,10 @@ def sample_update_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.Annotation: @@ -2924,7 +2999,7 @@ def delete_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes annotation inside asset. @@ -2965,8 +3040,10 @@ def sample_delete_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3014,7 +3091,7 @@ def ingest_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[warehouse.IngestAssetResponse]: r"""Ingests data for the asset. It is not allowed to ingest a data chunk which is already expired according @@ -3068,8 +3145,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]: @@ -3100,7 +3179,7 @@ def clip_asset( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Generates clips for downloading. The api takes in a time range, and generates a clip of the first content available after @@ -3140,8 +3219,10 @@ def sample_clip_asset(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.ClipAssetResponse: @@ -3183,7 +3264,7 @@ def generate_hls_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Generates a uri for an HLS manifest. The api takes in a collection of time ranges, and generates a URI for an @@ -3222,8 +3303,10 @@ def sample_generate_hls_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse: @@ -3270,7 +3353,7 @@ def create_search_config( search_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Creates a search configuration inside a corpus. @@ -3349,8 +3432,10 @@ def sample_create_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3414,7 +3499,7 @@ def update_search_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Updates a search configuration inside a corpus. @@ -3482,8 +3567,10 @@ def sample_update_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3546,7 +3633,7 @@ def get_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Gets a search configuration inside a corpus. @@ -3590,8 +3677,10 @@ def sample_get_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.types.SearchConfig: @@ -3650,7 +3739,7 @@ def delete_search_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a search configuration inside a corpus. @@ -3695,8 +3784,10 @@ def sample_delete_search_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3745,7 +3836,7 @@ def list_search_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchConfigsPager: r"""Lists all search configurations inside a corpus. @@ -3791,8 +3882,10 @@ def sample_list_search_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsPager: @@ -3863,7 +3956,7 @@ def search_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAssetsPager: r"""Search media asset. @@ -3900,8 +3993,10 @@ def sample_search_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsPager: @@ -3972,7 +4067,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3983,8 +4078,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4025,7 +4122,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4036,8 +4133,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4078,7 +4177,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4094,8 +4193,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4132,7 +4233,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4147,8 +4248,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4185,7 +4288,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -4198,8 +4301,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4304,7 +4409,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -4318,8 +4423,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4424,7 +4531,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -4439,8 +4546,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -4482,7 +4591,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4493,8 +4602,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -4535,7 +4646,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4546,8 +4657,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py index e0e0be75096d..0400da1a5a5a 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListAssetsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListAssetsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListCorporaRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListCorporaRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListDataSchemasRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListDataSchemasRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListAnnotationsRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListAnnotationsRequest(request) @@ -675,7 +691,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -689,8 +705,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.ListSearchConfigsRequest(request) @@ -749,7 +767,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -763,8 +781,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.ListSearchConfigsRequest(request) @@ -827,7 +847,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -841,8 +861,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = warehouse.SearchAssetsRequest(request) @@ -901,7 +923,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -915,8 +937,10 @@ def __init__( 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, 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`. """ self._method = method self._request = warehouse.SearchAssetsRequest(request) diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py index b46c7394f0f3..6188aa7e2b2d 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,12 +28,90 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport +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.visionai.v1alpha1.Warehouse", + "rpcName": 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.visionai.v1alpha1.Warehouse", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcTransport(WarehouseTransport): """gRPC backend transport for Warehouse. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def create_asset(self) -> Callable[[warehouse.CreateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -295,7 +383,7 @@ def update_asset(self) -> Callable[[warehouse.UpdateAssetRequest], warehouse.Ass # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -319,7 +407,7 @@ def get_asset(self) -> Callable[[warehouse.GetAssetRequest], warehouse.Asset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -345,7 +433,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -371,7 +459,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +485,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +509,7 @@ def get_corpus(self) -> Callable[[warehouse.GetCorpusRequest], warehouse.Corpus] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -447,7 +535,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -473,7 +561,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -500,7 +588,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -526,7 +614,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -552,7 +640,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -578,7 +666,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -604,7 +692,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -632,7 +720,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -658,7 +746,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -684,7 +772,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -712,7 +800,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -738,7 +826,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -764,7 +852,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -794,7 +882,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -824,7 +912,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -852,7 +940,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -893,7 +981,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -933,7 +1021,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -959,7 +1047,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -988,7 +1076,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1016,7 +1104,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1042,7 +1130,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1050,7 +1138,7 @@ def search_assets( return self._stubs["search_assets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1062,7 +1150,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1079,7 +1167,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1096,7 +1184,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1115,7 +1203,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1134,7 +1222,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1151,7 +1239,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1176,7 +1264,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1202,7 +1290,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1231,7 +1319,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py index d7163df8de8e..199f14d1cedc 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -27,14 +30,93 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.visionai_v1alpha1.types import warehouse from .base import DEFAULT_CLIENT_INFO, WarehouseTransport from .grpc import WarehouseGrpcTransport +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.visionai.v1alpha1.Warehouse", + "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.visionai.v1alpha1.Warehouse", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WarehouseGrpcAsyncIOTransport(WarehouseTransport): """gRPC AsyncIO backend transport for Warehouse. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def create_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_asset" not in self._stubs: - self._stubs["create_asset"] = self.grpc_channel.unary_unary( + self._stubs["create_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAsset", request_serializer=warehouse.CreateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -309,7 +394,7 @@ def update_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_asset" not in self._stubs: - self._stubs["update_asset"] = self.grpc_channel.unary_unary( + self._stubs["update_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAsset", request_serializer=warehouse.UpdateAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -335,7 +420,7 @@ def get_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_asset" not in self._stubs: - self._stubs["get_asset"] = self.grpc_channel.unary_unary( + self._stubs["get_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAsset", request_serializer=warehouse.GetAssetRequest.serialize, response_deserializer=warehouse.Asset.deserialize, @@ -363,7 +448,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAssets", request_serializer=warehouse.ListAssetsRequest.serialize, response_deserializer=warehouse.ListAssetsResponse.deserialize, @@ -389,7 +474,7 @@ def delete_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_asset" not in self._stubs: - self._stubs["delete_asset"] = self.grpc_channel.unary_unary( + self._stubs["delete_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAsset", request_serializer=warehouse.DeleteAssetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +500,7 @@ def create_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_corpus" not in self._stubs: - self._stubs["create_corpus"] = self.grpc_channel.unary_unary( + self._stubs["create_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateCorpus", request_serializer=warehouse.CreateCorpusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +526,7 @@ def get_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_corpus" not in self._stubs: - self._stubs["get_corpus"] = self.grpc_channel.unary_unary( + self._stubs["get_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetCorpus", request_serializer=warehouse.GetCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -467,7 +552,7 @@ def update_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_corpus" not in self._stubs: - self._stubs["update_corpus"] = self.grpc_channel.unary_unary( + self._stubs["update_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateCorpus", request_serializer=warehouse.UpdateCorpusRequest.serialize, response_deserializer=warehouse.Corpus.deserialize, @@ -495,7 +580,7 @@ def list_corpora( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_corpora" not in self._stubs: - self._stubs["list_corpora"] = self.grpc_channel.unary_unary( + self._stubs["list_corpora"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListCorpora", request_serializer=warehouse.ListCorporaRequest.serialize, response_deserializer=warehouse.ListCorporaResponse.deserialize, @@ -522,7 +607,7 @@ def delete_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_corpus" not in self._stubs: - self._stubs["delete_corpus"] = self.grpc_channel.unary_unary( + self._stubs["delete_corpus"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteCorpus", request_serializer=warehouse.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -548,7 +633,7 @@ def create_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_schema" not in self._stubs: - self._stubs["create_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["create_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateDataSchema", request_serializer=warehouse.CreateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -574,7 +659,7 @@ def update_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_schema" not in self._stubs: - self._stubs["update_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["update_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateDataSchema", request_serializer=warehouse.UpdateDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -600,7 +685,7 @@ def get_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_schema" not in self._stubs: - self._stubs["get_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["get_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetDataSchema", request_serializer=warehouse.GetDataSchemaRequest.serialize, response_deserializer=warehouse.DataSchema.deserialize, @@ -626,7 +711,7 @@ def delete_data_schema( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_schema" not in self._stubs: - self._stubs["delete_data_schema"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_schema"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteDataSchema", request_serializer=warehouse.DeleteDataSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -654,7 +739,7 @@ def list_data_schemas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_schemas" not in self._stubs: - self._stubs["list_data_schemas"] = self.grpc_channel.unary_unary( + self._stubs["list_data_schemas"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListDataSchemas", request_serializer=warehouse.ListDataSchemasRequest.serialize, response_deserializer=warehouse.ListDataSchemasResponse.deserialize, @@ -680,7 +765,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateAnnotation", request_serializer=warehouse.CreateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -706,7 +791,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetAnnotation", request_serializer=warehouse.GetAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -734,7 +819,7 @@ def list_annotations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_annotations" not in self._stubs: - self._stubs["list_annotations"] = self.grpc_channel.unary_unary( + self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListAnnotations", request_serializer=warehouse.ListAnnotationsRequest.serialize, response_deserializer=warehouse.ListAnnotationsResponse.deserialize, @@ -760,7 +845,7 @@ def update_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_annotation" not in self._stubs: - self._stubs["update_annotation"] = self.grpc_channel.unary_unary( + self._stubs["update_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateAnnotation", request_serializer=warehouse.UpdateAnnotationRequest.serialize, response_deserializer=warehouse.Annotation.deserialize, @@ -786,7 +871,7 @@ def delete_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_annotation" not in self._stubs: - self._stubs["delete_annotation"] = self.grpc_channel.unary_unary( + self._stubs["delete_annotation"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteAnnotation", request_serializer=warehouse.DeleteAnnotationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -818,7 +903,7 @@ def ingest_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "ingest_asset" not in self._stubs: - self._stubs["ingest_asset"] = self.grpc_channel.stream_stream( + self._stubs["ingest_asset"] = self._logged_channel.stream_stream( "/google.cloud.visionai.v1alpha1.Warehouse/IngestAsset", request_serializer=warehouse.IngestAssetRequest.serialize, response_deserializer=warehouse.IngestAssetResponse.deserialize, @@ -848,7 +933,7 @@ def clip_asset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "clip_asset" not in self._stubs: - self._stubs["clip_asset"] = self.grpc_channel.unary_unary( + self._stubs["clip_asset"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ClipAsset", request_serializer=warehouse.ClipAssetRequest.serialize, response_deserializer=warehouse.ClipAssetResponse.deserialize, @@ -878,7 +963,7 @@ def generate_hls_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_hls_uri" not in self._stubs: - self._stubs["generate_hls_uri"] = self.grpc_channel.unary_unary( + self._stubs["generate_hls_uri"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GenerateHlsUri", request_serializer=warehouse.GenerateHlsUriRequest.serialize, response_deserializer=warehouse.GenerateHlsUriResponse.deserialize, @@ -921,7 +1006,7 @@ def create_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_config" not in self._stubs: - self._stubs["create_search_config"] = self.grpc_channel.unary_unary( + self._stubs["create_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/CreateSearchConfig", request_serializer=warehouse.CreateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -963,7 +1048,7 @@ def update_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_config" not in self._stubs: - self._stubs["update_search_config"] = self.grpc_channel.unary_unary( + self._stubs["update_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/UpdateSearchConfig", request_serializer=warehouse.UpdateSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -991,7 +1076,7 @@ def get_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_config" not in self._stubs: - self._stubs["get_search_config"] = self.grpc_channel.unary_unary( + self._stubs["get_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/GetSearchConfig", request_serializer=warehouse.GetSearchConfigRequest.serialize, response_deserializer=warehouse.SearchConfig.deserialize, @@ -1020,7 +1105,7 @@ def delete_search_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_config" not in self._stubs: - self._stubs["delete_search_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_config"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/DeleteSearchConfig", request_serializer=warehouse.DeleteSearchConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1049,7 +1134,7 @@ def list_search_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_configs" not in self._stubs: - self._stubs["list_search_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_search_configs"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/ListSearchConfigs", request_serializer=warehouse.ListSearchConfigsRequest.serialize, response_deserializer=warehouse.ListSearchConfigsResponse.deserialize, @@ -1077,7 +1162,7 @@ def search_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assets" not in self._stubs: - self._stubs["search_assets"] = self.grpc_channel.unary_unary( + self._stubs["search_assets"] = self._logged_channel.unary_unary( "/google.cloud.visionai.v1alpha1.Warehouse/SearchAssets", request_serializer=warehouse.SearchAssetsRequest.serialize, response_deserializer=warehouse.SearchAssetsResponse.deserialize, @@ -1335,7 +1420,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1351,7 +1436,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1368,7 +1453,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1385,7 +1470,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1404,7 +1489,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1423,7 +1508,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1440,7 +1525,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1465,7 +1550,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1491,7 +1576,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1520,7 +1605,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py index e76919d84250..dbc0337847e6 100644 --- a/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py +++ b/packages/google-cloud-visionai/google/cloud/visionai_v1alpha1/services/warehouse/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -280,8 +288,10 @@ def post_update_search_config(self, response): """ def pre_clip_asset( - self, request: warehouse.ClipAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ClipAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ClipAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for clip_asset Override in a subclass to manipulate the request or metadata @@ -303,8 +313,10 @@ def post_clip_asset( def pre_create_annotation( self, request: warehouse.CreateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_annotation Override in a subclass to manipulate the request or metadata @@ -324,8 +336,10 @@ def post_create_annotation( return response def pre_create_asset( - self, request: warehouse.CreateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.CreateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_asset Override in a subclass to manipulate the request or metadata @@ -345,8 +359,8 @@ def post_create_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_create_corpus( self, request: warehouse.CreateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.CreateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_corpus Override in a subclass to manipulate the request or metadata @@ -368,8 +382,10 @@ def post_create_corpus( def pre_create_data_schema( self, request: warehouse.CreateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_schema Override in a subclass to manipulate the request or metadata @@ -391,8 +407,10 @@ def post_create_data_schema( def pre_create_search_config( self, request: warehouse.CreateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.CreateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_search_config Override in a subclass to manipulate the request or metadata @@ -414,8 +432,10 @@ def post_create_search_config( def pre_delete_annotation( self, request: warehouse.DeleteAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_annotation Override in a subclass to manipulate the request or metadata @@ -424,8 +444,10 @@ def pre_delete_annotation( return request, metadata def pre_delete_asset( - self, request: warehouse.DeleteAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.DeleteAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_asset Override in a subclass to manipulate the request or metadata @@ -447,8 +469,8 @@ def post_delete_asset( def pre_delete_corpus( self, request: warehouse.DeleteCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.DeleteCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_corpus Override in a subclass to manipulate the request or metadata @@ -459,8 +481,10 @@ def pre_delete_corpus( def pre_delete_data_schema( self, request: warehouse.DeleteDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_schema Override in a subclass to manipulate the request or metadata @@ -471,8 +495,10 @@ def pre_delete_data_schema( def pre_delete_search_config( self, request: warehouse.DeleteSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.DeleteSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_search_config Override in a subclass to manipulate the request or metadata @@ -483,8 +509,10 @@ def pre_delete_search_config( def pre_generate_hls_uri( self, request: warehouse.GenerateHlsUriRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GenerateHlsUriRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_hls_uri Override in a subclass to manipulate the request or metadata @@ -506,8 +534,8 @@ def post_generate_hls_uri( def pre_get_annotation( self, request: warehouse.GetAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_annotation Override in a subclass to manipulate the request or metadata @@ -527,8 +555,10 @@ def post_get_annotation( return response def pre_get_asset( - self, request: warehouse.GetAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_asset Override in a subclass to manipulate the request or metadata @@ -546,8 +576,10 @@ def post_get_asset(self, response: warehouse.Asset) -> warehouse.Asset: return response def pre_get_corpus( - self, request: warehouse.GetCorpusRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.GetCorpusRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_corpus Override in a subclass to manipulate the request or metadata @@ -567,8 +599,8 @@ def post_get_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_get_data_schema( self, request: warehouse.GetDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.GetDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_data_schema Override in a subclass to manipulate the request or metadata @@ -590,8 +622,10 @@ def post_get_data_schema( def pre_get_search_config( self, request: warehouse.GetSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.GetSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.GetSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_search_config Override in a subclass to manipulate the request or metadata @@ -613,8 +647,10 @@ def post_get_search_config( def pre_list_annotations( self, request: warehouse.ListAnnotationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListAnnotationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListAnnotationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_annotations Override in a subclass to manipulate the request or metadata @@ -634,8 +670,10 @@ def post_list_annotations( return response def pre_list_assets( - self, request: warehouse.ListAssetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListAssetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -655,8 +693,10 @@ def post_list_assets( return response def pre_list_corpora( - self, request: warehouse.ListCorporaRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.ListCorporaRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.ListCorporaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_corpora Override in a subclass to manipulate the request or metadata @@ -678,8 +718,10 @@ def post_list_corpora( def pre_list_data_schemas( self, request: warehouse.ListDataSchemasRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListDataSchemasRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListDataSchemasRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_schemas Override in a subclass to manipulate the request or metadata @@ -701,8 +743,10 @@ def post_list_data_schemas( def pre_list_search_configs( self, request: warehouse.ListSearchConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.ListSearchConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_search_configs Override in a subclass to manipulate the request or metadata @@ -724,8 +768,8 @@ def post_list_search_configs( def pre_search_assets( self, request: warehouse.SearchAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.SearchAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_assets Override in a subclass to manipulate the request or metadata @@ -747,8 +791,10 @@ def post_search_assets( def pre_update_annotation( self, request: warehouse.UpdateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateAnnotationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_annotation Override in a subclass to manipulate the request or metadata @@ -768,8 +814,10 @@ def post_update_annotation( return response def pre_update_asset( - self, request: warehouse.UpdateAssetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, str]]]: + self, + request: warehouse.UpdateAssetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateAssetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_asset Override in a subclass to manipulate the request or metadata @@ -789,8 +837,8 @@ def post_update_asset(self, response: warehouse.Asset) -> warehouse.Asset: def pre_update_corpus( self, request: warehouse.UpdateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[warehouse.UpdateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_corpus Override in a subclass to manipulate the request or metadata @@ -810,8 +858,10 @@ def post_update_corpus(self, response: warehouse.Corpus) -> warehouse.Corpus: def pre_update_data_schema( self, request: warehouse.UpdateDataSchemaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateDataSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_schema Override in a subclass to manipulate the request or metadata @@ -833,8 +883,10 @@ def post_update_data_schema( def pre_update_search_config( self, request: warehouse.UpdateSearchConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + warehouse.UpdateSearchConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_search_config Override in a subclass to manipulate the request or metadata @@ -856,8 +908,10 @@ def post_update_search_config( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -879,8 +933,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -902,8 +958,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -923,8 +981,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -944,8 +1004,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -967,8 +1030,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -988,8 +1053,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1009,8 +1076,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1032,8 +1101,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1234,7 +1305,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ClipAssetResponse: r"""Call the clip asset method over HTTP. @@ -1244,8 +1315,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ClipAssetResponse: @@ -1255,6 +1328,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseClipAsset._get_http_options() ) + request, metadata = self._interceptor.pre_clip_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseClipAsset._get_transcoded_request( @@ -1273,6 +1347,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ClipAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ClipAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ClipAsset._get_response( self._host, @@ -1294,7 +1395,29 @@ def __call__( pb_resp = warehouse.ClipAssetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clip_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ClipAssetResponse.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.visionai_v1alpha1.WarehouseClient.clip_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ClipAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAnnotation( @@ -1332,7 +1455,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the create annotation method over HTTP. @@ -1342,8 +1465,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -1356,6 +1481,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_create_annotation( request, metadata ) @@ -1372,6 +1498,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.CreateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAnnotation._get_response( self._host, @@ -1393,7 +1546,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1alpha1.WarehouseClient.create_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAsset(_BaseWarehouseRestTransport._BaseCreateAsset, WarehouseRestStub): @@ -1429,7 +1604,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the create asset method over HTTP. @@ -1440,8 +1615,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -1458,6 +1635,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_create_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateAsset._get_transcoded_request( @@ -1476,6 +1654,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.CreateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateAsset._get_response( self._host, @@ -1497,7 +1702,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1alpha1.WarehouseClient.create_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCorpus( @@ -1535,7 +1762,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create corpus method over HTTP. @@ -1545,8 +1772,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1559,6 +1788,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_create_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseCreateCorpus._get_transcoded_request( @@ -1577,6 +1807,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.CreateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateCorpus._get_response( self._host, @@ -1596,7 +1853,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_corpus(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.visionai_v1alpha1.WarehouseClient.create_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataSchema( @@ -1634,7 +1913,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the create data schema method over HTTP. @@ -1644,8 +1923,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -1658,6 +1939,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_schema( request, metadata ) @@ -1674,6 +1956,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.CreateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateDataSchema._get_response( self._host, @@ -1695,7 +2004,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1alpha1.WarehouseClient.create_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchConfig( @@ -1733,7 +2064,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the create search config method over HTTP. @@ -1744,8 +2075,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -1758,6 +2091,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseCreateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_config( request, metadata ) @@ -1774,6 +2108,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.CreateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CreateSearchConfig._get_response( self._host, @@ -1795,7 +2156,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1alpha1.WarehouseClient.create_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CreateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnnotation( @@ -1832,7 +2215,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete annotation method over HTTP. @@ -1843,13 +2226,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_annotation( request, metadata ) @@ -1862,6 +2248,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.DeleteAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAnnotation._get_response( self._host, @@ -1909,7 +2322,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete asset method over HTTP. @@ -1919,8 +2332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1933,6 +2348,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteAsset._get_transcoded_request( @@ -1947,6 +2363,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.DeleteAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteAsset._get_response( self._host, @@ -1965,7 +2408,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_asset(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.visionai_v1alpha1.WarehouseClient.delete_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCorpus( @@ -2002,7 +2467,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete corpus method over HTTP. @@ -2012,13 +2477,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_delete_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseDeleteCorpus._get_transcoded_request( @@ -2033,6 +2501,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.DeleteCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteCorpus._get_response( self._host, @@ -2082,7 +2577,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete data schema method over HTTP. @@ -2092,13 +2587,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_schema( request, metadata ) @@ -2111,6 +2609,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.DeleteDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteDataSchema._get_response( self._host, @@ -2160,7 +2685,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete search config method over HTTP. @@ -2171,13 +2696,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_config( request, metadata ) @@ -2190,6 +2718,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.DeleteSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteSearchConfig._get_response( self._host, @@ -2240,7 +2795,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.GenerateHlsUriResponse: r"""Call the generate hls uri method over HTTP. @@ -2251,8 +2806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.GenerateHlsUriResponse: @@ -2264,6 +2821,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGenerateHlsUri._get_http_options() ) + request, metadata = self._interceptor.pre_generate_hls_uri( request, metadata ) @@ -2286,6 +2844,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GenerateHlsUri", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GenerateHlsUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GenerateHlsUri._get_response( self._host, @@ -2307,7 +2892,31 @@ def __call__( pb_resp = warehouse.GenerateHlsUriResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_hls_uri(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.GenerateHlsUriResponse.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.visionai_v1alpha1.WarehouseClient.generate_hls_uri", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GenerateHlsUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotation( @@ -2344,7 +2953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the get annotation method over HTTP. @@ -2355,8 +2964,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -2369,6 +2980,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAnnotation._get_transcoded_request( @@ -2383,6 +2995,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAnnotation._get_response( self._host, @@ -2403,7 +3042,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1alpha1.WarehouseClient.get_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAsset(_BaseWarehouseRestTransport._BaseGetAsset, WarehouseRestStub): @@ -2438,7 +3099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the get asset method over HTTP. @@ -2448,8 +3109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -2464,6 +3127,7 @@ def __call__( """ http_options = _BaseWarehouseRestTransport._BaseGetAsset._get_http_options() + request, metadata = self._interceptor.pre_get_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetAsset._get_transcoded_request( @@ -2478,6 +3142,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetAsset._get_response( self._host, @@ -2498,7 +3189,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1alpha1.WarehouseClient.get_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCorpus(_BaseWarehouseRestTransport._BaseGetCorpus, WarehouseRestStub): @@ -2533,7 +3246,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the get corpus method over HTTP. @@ -2543,8 +3256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Corpus: @@ -2558,6 +3273,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_get_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetCorpus._get_transcoded_request( @@ -2572,6 +3288,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetCorpus._get_response( self._host, @@ -2592,7 +3335,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.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.visionai_v1alpha1.WarehouseClient.get_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSchema( @@ -2629,7 +3394,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the get data schema method over HTTP. @@ -2639,8 +3404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -2653,6 +3420,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_schema(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetDataSchema._get_transcoded_request( @@ -2667,6 +3435,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetDataSchema._get_response( self._host, @@ -2687,7 +3482,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1alpha1.WarehouseClient.get_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchConfig( @@ -2724,7 +3541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the get search config method over HTTP. @@ -2734,8 +3551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -2748,6 +3567,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_config( request, metadata ) @@ -2762,6 +3582,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetSearchConfig._get_response( self._host, @@ -2782,7 +3629,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1alpha1.WarehouseClient.get_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _IngestAsset(_BaseWarehouseRestTransport._BaseIngestAsset, WarehouseRestStub): @@ -2795,7 +3664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method IngestAsset is not available over REST transport" @@ -2835,7 +3704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAnnotationsResponse: r"""Call the list annotations method over HTTP. @@ -2846,8 +3715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListAnnotationsResponse: @@ -2859,6 +3730,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAnnotations._get_http_options() ) + request, metadata = self._interceptor.pre_list_annotations( request, metadata ) @@ -2873,6 +3745,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListAnnotations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAnnotations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAnnotations._get_response( self._host, @@ -2893,7 +3792,31 @@ def __call__( pb_resp = warehouse.ListAnnotationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_annotations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAnnotationsResponse.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.visionai_v1alpha1.WarehouseClient.list_annotations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAnnotations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets(_BaseWarehouseRestTransport._BaseListAssets, WarehouseRestStub): @@ -2928,7 +3851,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2938,8 +3861,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListAssetsResponse: @@ -2949,6 +3874,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListAssets._get_transcoded_request( @@ -2963,6 +3889,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListAssets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListAssets._get_response( self._host, @@ -2983,7 +3936,29 @@ def __call__( pb_resp = warehouse.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListAssetsResponse.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.visionai_v1alpha1.WarehouseClient.list_assets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCorpora(_BaseWarehouseRestTransport._BaseListCorpora, WarehouseRestStub): @@ -3018,7 +3993,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListCorporaResponse: r"""Call the list corpora method over HTTP. @@ -3028,8 +4003,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListCorporaResponse: @@ -3039,6 +4016,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListCorpora._get_http_options() ) + request, metadata = self._interceptor.pre_list_corpora(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListCorpora._get_transcoded_request( @@ -3053,6 +4031,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListCorpora", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListCorpora", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListCorpora._get_response( self._host, @@ -3073,7 +4078,29 @@ def __call__( pb_resp = warehouse.ListCorporaResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_corpora(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListCorporaResponse.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.visionai_v1alpha1.WarehouseClient.list_corpora", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListCorpora", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSchemas( @@ -3110,7 +4137,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListDataSchemasResponse: r"""Call the list data schemas method over HTTP. @@ -3120,8 +4147,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListDataSchemasResponse: @@ -3131,6 +4160,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListDataSchemas._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_schemas( request, metadata ) @@ -3145,6 +4175,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListDataSchemas", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListDataSchemas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListDataSchemas._get_response( self._host, @@ -3165,7 +4222,31 @@ def __call__( pb_resp = warehouse.ListDataSchemasResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_schemas(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListDataSchemasResponse.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.visionai_v1alpha1.WarehouseClient.list_data_schemas", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListDataSchemas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchConfigs( @@ -3202,7 +4283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.ListSearchConfigsResponse: r"""Call the list search configs method over HTTP. @@ -3213,8 +4294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.ListSearchConfigsResponse: @@ -3226,6 +4309,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListSearchConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_configs( request, metadata ) @@ -3238,6 +4322,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.ListSearchConfigs", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListSearchConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListSearchConfigs._get_response( self._host, @@ -3258,7 +4369,31 @@ def __call__( pb_resp = warehouse.ListSearchConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.ListSearchConfigsResponse.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.visionai_v1alpha1.WarehouseClient.list_search_configs", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListSearchConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAssets( @@ -3296,7 +4431,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchAssetsResponse: r"""Call the search assets method over HTTP. @@ -3306,8 +4441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchAssetsResponse: @@ -3317,6 +4454,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_http_options() ) + request, metadata = self._interceptor.pre_search_assets(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSearchAssets._get_transcoded_request( @@ -3335,6 +4473,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.SearchAssets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SearchAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SearchAssets._get_response( self._host, @@ -3356,7 +4521,29 @@ def __call__( pb_resp = warehouse.SearchAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchAssetsResponse.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.visionai_v1alpha1.WarehouseClient.search_assets", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SearchAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnnotation( @@ -3394,7 +4581,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Annotation: r"""Call the update annotation method over HTTP. @@ -3405,8 +4592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Annotation: @@ -3419,6 +4608,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_update_annotation( request, metadata ) @@ -3435,6 +4625,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.UpdateAnnotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAnnotation._get_response( self._host, @@ -3456,7 +4673,29 @@ def __call__( pb_resp = warehouse.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Annotation.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.visionai_v1alpha1.WarehouseClient.update_annotation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAsset(_BaseWarehouseRestTransport._BaseUpdateAsset, WarehouseRestStub): @@ -3492,7 +4731,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Asset: r"""Call the update asset method over HTTP. @@ -3502,8 +4741,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Asset: @@ -3520,6 +4761,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_http_options() ) + request, metadata = self._interceptor.pre_update_asset(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateAsset._get_transcoded_request( @@ -3538,6 +4780,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.UpdateAsset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAsset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateAsset._get_response( self._host, @@ -3559,7 +4828,29 @@ def __call__( pb_resp = warehouse.Asset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_asset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Asset.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.visionai_v1alpha1.WarehouseClient.update_asset", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateAsset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCorpus( @@ -3597,7 +4888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.Corpus: r"""Call the update corpus method over HTTP. @@ -3607,8 +4898,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.Corpus: @@ -3622,6 +4915,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_update_corpus(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseUpdateCorpus._get_transcoded_request( @@ -3640,6 +4934,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.UpdateCorpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateCorpus._get_response( self._host, @@ -3661,7 +4982,29 @@ def __call__( pb_resp = warehouse.Corpus.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.Corpus.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.visionai_v1alpha1.WarehouseClient.update_corpus", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataSchema( @@ -3699,7 +5042,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.DataSchema: r"""Call the update data schema method over HTTP. @@ -3709,8 +5052,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.DataSchema: @@ -3723,6 +5068,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateDataSchema._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_schema( request, metadata ) @@ -3739,6 +5085,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.UpdateDataSchema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateDataSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateDataSchema._get_response( self._host, @@ -3760,7 +5133,29 @@ def __call__( pb_resp = warehouse.DataSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_schema(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.DataSchema.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.visionai_v1alpha1.WarehouseClient.update_data_schema", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateDataSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchConfig( @@ -3798,7 +5193,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> warehouse.SearchConfig: r"""Call the update search config method over HTTP. @@ -3809,8 +5204,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.warehouse.SearchConfig: @@ -3823,6 +5220,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseUpdateSearchConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_config( request, metadata ) @@ -3839,6 +5237,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.UpdateSearchConfig", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateSearchConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._UpdateSearchConfig._get_response( self._host, @@ -3860,7 +5285,29 @@ def __call__( pb_resp = warehouse.SearchConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = warehouse.SearchConfig.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.visionai_v1alpha1.WarehouseClient.update_search_config", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "UpdateSearchConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4129,7 +5576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -4139,8 +5586,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -4149,6 +5598,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetLocation._get_transcoded_request( @@ -4163,6 +5613,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetLocation._get_response( self._host, @@ -4182,6 +5659,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.visionai_v1alpha1.WarehouseAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4222,7 +5720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -4232,8 +5730,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -4242,6 +5742,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListLocations._get_transcoded_request( @@ -4256,6 +5757,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListLocations._get_response( self._host, @@ -4275,6 +5803,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.visionai_v1alpha1.WarehouseAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4315,7 +5864,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -4325,8 +5874,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -4335,6 +5886,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4349,6 +5901,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetIamPolicy._get_response( self._host, @@ -4368,6 +5947,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.visionai_v1alpha1.WarehouseAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4409,7 +6009,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -4419,8 +6019,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -4429,6 +6031,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4447,6 +6050,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._SetIamPolicy._get_response( self._host, @@ -4467,6 +6097,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.visionai_v1alpha1.WarehouseAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4508,7 +6159,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -4518,8 +6169,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -4528,6 +6181,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4544,6 +6198,33 @@ def __call__( 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.visionai_v1alpha1.WarehouseClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._TestIamPermissions._get_response( self._host, @@ -4564,6 +6245,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.visionai_v1alpha1.WarehouseAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4605,7 +6307,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -4615,13 +6317,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4642,6 +6347,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.CancelOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._CancelOperation._get_response( self._host, @@ -4698,7 +6430,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -4708,13 +6440,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWarehouseRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4729,6 +6464,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._DeleteOperation._get_response( self._host, @@ -4784,7 +6546,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4794,8 +6556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -4804,6 +6568,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseGetOperation._get_transcoded_request( @@ -4818,6 +6583,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._GetOperation._get_response( self._host, @@ -4837,6 +6629,27 @@ def __call__( 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.visionai_v1alpha1.WarehouseAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4877,7 +6690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4887,8 +6700,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4897,6 +6712,7 @@ def __call__( http_options = ( _BaseWarehouseRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWarehouseRestTransport._BaseListOperations._get_transcoded_request( @@ -4911,6 +6727,33 @@ def __call__( ) ) + 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.visionai_v1alpha1.WarehouseClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WarehouseRestTransport._ListOperations._get_response( self._host, @@ -4930,6 +6773,27 @@ def __call__( 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.visionai_v1alpha1.WarehouseAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.visionai.v1alpha1.Warehouse", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json index 884707596fd2..55144efe90c6 100644 --- a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json +++ b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-visionai", - "version": "0.1.5" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1375,7 +1375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1455,7 +1455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Application", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Application", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Draft", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Draft", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Instance", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Instance", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Processor", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Processor", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListApplicationsPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListDraftsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListInstancesPager", @@ -2824,7 +2824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse", @@ -2904,7 +2904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ListPrebuiltProcessorsResponse", @@ -2985,7 +2985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsAsyncPager", @@ -3065,7 +3065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.app_platform.pagers.ListProcessorsPager", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3226,7 +3226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3307,7 +3307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3387,7 +3387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3472,7 +3472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3637,7 +3637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3802,7 +3802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3886,7 +3886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3971,7 +3971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4055,7 +4055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4140,7 +4140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4224,7 +4224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4301,7 +4301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.HealthCheckResponse", @@ -4377,7 +4377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.HealthCheckResponse", @@ -4462,7 +4462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4546,7 +4546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4635,7 +4635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4723,7 +4723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4812,7 +4812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4900,7 +4900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4989,7 +4989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5077,7 +5077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5158,7 +5158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5238,7 +5238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5319,7 +5319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5399,7 +5399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5480,7 +5480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5560,7 +5560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5641,7 +5641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Analysis", @@ -5721,7 +5721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Analysis", @@ -5802,7 +5802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Operator", @@ -5882,7 +5882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Operator", @@ -5963,7 +5963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Process", @@ -6043,7 +6043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Process", @@ -6124,7 +6124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesAsyncPager", @@ -6204,7 +6204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListAnalysesPager", @@ -6285,7 +6285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsAsyncPager", @@ -6365,7 +6365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListOperatorsPager", @@ -6446,7 +6446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesAsyncPager", @@ -6526,7 +6526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListProcessesPager", @@ -6607,7 +6607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsAsyncPager", @@ -6687,7 +6687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.live_video_analytics.pagers.ListPublicOperatorsPager", @@ -6772,7 +6772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ResolveOperatorInfoResponse", @@ -6856,7 +6856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ResolveOperatorInfoResponse", @@ -6941,7 +6941,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7025,7 +7025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7110,7 +7110,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7194,7 +7194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7279,7 +7279,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7363,7 +7363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7440,7 +7440,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -7516,7 +7516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -7593,7 +7593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]", @@ -7669,7 +7669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceiveEventsResponse]", @@ -7746,7 +7746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]", @@ -7822,7 +7822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.ReceivePacketsResponse]", @@ -7899,7 +7899,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ReleaseLeaseResponse", @@ -7975,7 +7975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ReleaseLeaseResponse", @@ -8052,7 +8052,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -8128,7 +8128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Lease", @@ -8205,7 +8205,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.SendPacketsResponse]", @@ -8281,7 +8281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.SendPacketsResponse]", @@ -8370,7 +8370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8458,7 +8458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8547,7 +8547,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8635,7 +8635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8724,7 +8724,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8812,7 +8812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8901,7 +8901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8989,7 +8989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9070,7 +9070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9150,7 +9150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9231,7 +9231,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9311,7 +9311,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9392,7 +9392,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9472,7 +9472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9553,7 +9553,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9633,7 +9633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9714,7 +9714,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse", @@ -9794,7 +9794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateStreamHlsTokenResponse", @@ -9875,7 +9875,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Cluster", @@ -9955,7 +9955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Cluster", @@ -10036,7 +10036,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Event", @@ -10116,7 +10116,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Event", @@ -10197,7 +10197,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Series", @@ -10277,7 +10277,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Series", @@ -10362,7 +10362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10446,7 +10446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10527,7 +10527,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Stream", @@ -10607,7 +10607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Stream", @@ -10688,7 +10688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListClustersAsyncPager", @@ -10768,7 +10768,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListClustersPager", @@ -10849,7 +10849,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListEventsAsyncPager", @@ -10929,7 +10929,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListEventsPager", @@ -11010,7 +11010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesAsyncPager", @@ -11090,7 +11090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListSeriesPager", @@ -11171,7 +11171,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsAsyncPager", @@ -11251,7 +11251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.streams_service.pagers.ListStreamsPager", @@ -11340,7 +11340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11428,7 +11428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11513,7 +11513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11597,7 +11597,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11682,7 +11682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11766,7 +11766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11851,7 +11851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11935,7 +11935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12020,7 +12020,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12104,7 +12104,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12185,7 +12185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.AddCollectionItemResponse", @@ -12265,7 +12265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.AddCollectionItemResponse", @@ -12342,7 +12342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12418,7 +12418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12495,7 +12495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12571,7 +12571,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12648,7 +12648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ClipAssetResponse", @@ -12724,7 +12724,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.ClipAssetResponse", @@ -12813,7 +12813,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -12901,7 +12901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -12990,7 +12990,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -13078,7 +13078,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -13167,7 +13167,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13255,7 +13255,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13340,7 +13340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13424,7 +13424,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13509,7 +13509,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -13593,7 +13593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -13682,7 +13682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13770,7 +13770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13859,7 +13859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13947,7 +13947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14036,7 +14036,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -14124,7 +14124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -14213,7 +14213,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -14301,7 +14301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -14382,7 +14382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -14459,7 +14459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -14537,7 +14537,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -14617,7 +14617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14698,7 +14698,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -14778,7 +14778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -14859,7 +14859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -14936,7 +14936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -15014,7 +15014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -15091,7 +15091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -15169,7 +15169,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15249,7 +15249,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15330,7 +15330,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15410,7 +15410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15491,7 +15491,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -15568,7 +15568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -15646,7 +15646,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_hypernym" @@ -15723,7 +15723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_hypernym" @@ -15797,7 +15797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -15873,7 +15873,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -15950,7 +15950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateHlsUriResponse", @@ -16026,7 +16026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateHlsUriResponse", @@ -16103,7 +16103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse", @@ -16179,7 +16179,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.GenerateRetrievalUrlResponse", @@ -16260,7 +16260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -16340,7 +16340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -16421,7 +16421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -16501,7 +16501,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -16582,7 +16582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -16662,7 +16662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -16743,7 +16743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -16823,7 +16823,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -16904,7 +16904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -16984,7 +16984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -17065,7 +17065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.IndexEndpoint", @@ -17145,7 +17145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.IndexEndpoint", @@ -17226,7 +17226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Index", @@ -17306,7 +17306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Index", @@ -17387,7 +17387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -17467,7 +17467,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -17548,7 +17548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -17628,7 +17628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -17705,7 +17705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -17781,7 +17781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -17858,7 +17858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -17934,7 +17934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -18011,7 +18011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.IngestAssetResponse]", @@ -18087,7 +18087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1.types.IngestAssetResponse]", @@ -18168,7 +18168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsAsyncPager", @@ -18248,7 +18248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAnnotationsPager", @@ -18329,7 +18329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsAsyncPager", @@ -18409,7 +18409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListAssetsPager", @@ -18490,7 +18490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsAsyncPager", @@ -18570,7 +18570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCollectionsPager", @@ -18651,7 +18651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaAsyncPager", @@ -18731,7 +18731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListCorporaPager", @@ -18812,7 +18812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasAsyncPager", @@ -18892,7 +18892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListDataSchemasPager", @@ -18973,7 +18973,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsAsyncPager", @@ -19053,7 +19053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexEndpointsPager", @@ -19134,7 +19134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesAsyncPager", @@ -19214,7 +19214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListIndexesPager", @@ -19295,7 +19295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsAsyncPager", @@ -19375,7 +19375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchConfigsPager", @@ -19456,7 +19456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsAsyncPager", @@ -19536,7 +19536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ListSearchHypernymsPager", @@ -19617,7 +19617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.RemoveCollectionItemResponse", @@ -19697,7 +19697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.RemoveCollectionItemResponse", @@ -19774,7 +19774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -19850,7 +19850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -19927,7 +19927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsAsyncPager", @@ -20003,7 +20003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchAssetsPager", @@ -20080,7 +20080,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointAsyncPager", @@ -20156,7 +20156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.SearchIndexEndpointPager", @@ -20233,7 +20233,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -20309,7 +20309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -20394,7 +20394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -20478,7 +20478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Annotation", @@ -20563,7 +20563,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -20647,7 +20647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Asset", @@ -20732,7 +20732,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -20816,7 +20816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Collection", @@ -20901,7 +20901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -20985,7 +20985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.Corpus", @@ -21070,7 +21070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -21154,7 +21154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.DataSchema", @@ -21239,7 +21239,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21323,7 +21323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -21408,7 +21408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21492,7 +21492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -21577,7 +21577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -21661,7 +21661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchConfig", @@ -21746,7 +21746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -21830,7 +21830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.types.SearchHypernym", @@ -21907,7 +21907,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -21983,7 +21983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -22064,7 +22064,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsAsyncPager", @@ -22144,7 +22144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewCollectionItemsPager", @@ -22225,7 +22225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsAsyncPager", @@ -22305,7 +22305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1.services.warehouse.pagers.ViewIndexedAssetsPager", diff --git a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json index e7ec36afcf34..11704c120259 100644 --- a/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json +++ b/packages/google-cloud-visionai/samples/generated_samples/snippet_metadata_google.cloud.visionai.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-visionai", - "version": "0.1.5" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1375,7 +1375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1455,7 +1455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Application", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Application", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Draft", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Draft", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Instance", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Instance", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Processor", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Processor", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListApplicationsPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListDraftsPager", @@ -2663,7 +2663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesAsyncPager", @@ -2743,7 +2743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListInstancesPager", @@ -2824,7 +2824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse", @@ -2904,7 +2904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ListPrebuiltProcessorsResponse", @@ -2985,7 +2985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsAsyncPager", @@ -3065,7 +3065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.app_platform.pagers.ListProcessorsPager", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3226,7 +3226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3307,7 +3307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3387,7 +3387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3472,7 +3472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3637,7 +3637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3802,7 +3802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3886,7 +3886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3971,7 +3971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4055,7 +4055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4140,7 +4140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4224,7 +4224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4313,7 +4313,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4401,7 +4401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4482,7 +4482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4562,7 +4562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4643,7 +4643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Analysis", @@ -4723,7 +4723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Analysis", @@ -4804,7 +4804,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesAsyncPager", @@ -4884,7 +4884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.live_video_analytics.pagers.ListAnalysesPager", @@ -4969,7 +4969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5053,7 +5053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5130,7 +5130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5206,7 +5206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5283,7 +5283,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]", @@ -5359,7 +5359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceiveEventsResponse]", @@ -5436,7 +5436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]", @@ -5512,7 +5512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.ReceivePacketsResponse]", @@ -5589,7 +5589,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse", @@ -5665,7 +5665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ReleaseLeaseResponse", @@ -5742,7 +5742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5818,7 +5818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Lease", @@ -5895,7 +5895,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]", @@ -5971,7 +5971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.SendPacketsResponse]", @@ -6060,7 +6060,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6148,7 +6148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6237,7 +6237,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6325,7 +6325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6502,7 +6502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6591,7 +6591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6679,7 +6679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6760,7 +6760,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6840,7 +6840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6921,7 +6921,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7001,7 +7001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7082,7 +7082,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7162,7 +7162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7243,7 +7243,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7323,7 +7323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7404,7 +7404,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse", @@ -7484,7 +7484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateStreamHlsTokenResponse", @@ -7565,7 +7565,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Cluster", @@ -7645,7 +7645,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Cluster", @@ -7726,7 +7726,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Event", @@ -7806,7 +7806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Event", @@ -7887,7 +7887,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Series", @@ -7967,7 +7967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Series", @@ -8048,7 +8048,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Stream", @@ -8128,7 +8128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Stream", @@ -8209,7 +8209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersAsyncPager", @@ -8289,7 +8289,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListClustersPager", @@ -8370,7 +8370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsAsyncPager", @@ -8450,7 +8450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListEventsPager", @@ -8531,7 +8531,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesAsyncPager", @@ -8611,7 +8611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListSeriesPager", @@ -8692,7 +8692,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsAsyncPager", @@ -8772,7 +8772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.streams_service.pagers.ListStreamsPager", @@ -8861,7 +8861,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8949,7 +8949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9034,7 +9034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9118,7 +9118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9203,7 +9203,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9287,7 +9287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9372,7 +9372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9456,7 +9456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9541,7 +9541,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9625,7 +9625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9702,7 +9702,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ClipAssetResponse", @@ -9778,7 +9778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.ClipAssetResponse", @@ -9867,7 +9867,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -9955,7 +9955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -10044,7 +10044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -10132,7 +10132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -10217,7 +10217,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10301,7 +10301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10386,7 +10386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -10470,7 +10470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -10559,7 +10559,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -10647,7 +10647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -10728,7 +10728,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -10805,7 +10805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_annotation" @@ -10883,7 +10883,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10963,7 +10963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11044,7 +11044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -11121,7 +11121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -11199,7 +11199,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -11276,7 +11276,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_schema" @@ -11354,7 +11354,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -11431,7 +11431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_search_config" @@ -11505,7 +11505,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse", @@ -11581,7 +11581,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.GenerateHlsUriResponse", @@ -11662,7 +11662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -11742,7 +11742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -11823,7 +11823,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -11903,7 +11903,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -11984,7 +11984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -12064,7 +12064,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -12145,7 +12145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -12225,7 +12225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -12306,7 +12306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -12386,7 +12386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -12463,7 +12463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]", @@ -12539,7 +12539,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.visionai_v1alpha1.types.IngestAssetResponse]", @@ -12620,7 +12620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsAsyncPager", @@ -12700,7 +12700,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAnnotationsPager", @@ -12781,7 +12781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsAsyncPager", @@ -12861,7 +12861,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListAssetsPager", @@ -12942,7 +12942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaAsyncPager", @@ -13022,7 +13022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListCorporaPager", @@ -13103,7 +13103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasAsyncPager", @@ -13183,7 +13183,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListDataSchemasPager", @@ -13264,7 +13264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsAsyncPager", @@ -13344,7 +13344,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.ListSearchConfigsPager", @@ -13421,7 +13421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsAsyncPager", @@ -13497,7 +13497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.services.warehouse.pagers.SearchAssetsPager", @@ -13582,7 +13582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -13666,7 +13666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Annotation", @@ -13751,7 +13751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -13835,7 +13835,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Asset", @@ -13920,7 +13920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -14004,7 +14004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.Corpus", @@ -14089,7 +14089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -14173,7 +14173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.DataSchema", @@ -14258,7 +14258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", @@ -14342,7 +14342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.visionai_v1alpha1.types.SearchConfig", diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py index a4f2a3935988..ba5aa943954c 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_app_platform.py @@ -10916,6 +10916,7 @@ def test_list_applications_rest_required_fields( response_value._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_applications(request) @@ -10971,6 +10972,7 @@ def test_list_applications_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_applications(**mock_args) @@ -11163,6 +11165,7 @@ def test_get_application_rest_required_fields( response_value._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_application(request) @@ -11210,6 +11213,7 @@ def test_get_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11361,6 +11365,7 @@ def test_create_application_rest_required_fields( response_value._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_application(request) @@ -11425,6 +11430,7 @@ def test_create_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11565,6 +11571,7 @@ def test_update_application_rest_required_fields( response_value._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_application(request) @@ -11621,6 +11628,7 @@ def test_update_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11765,6 +11773,7 @@ def test_delete_application_rest_required_fields( response_value._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_application(request) @@ -11818,6 +11827,7 @@ def test_delete_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11955,6 +11965,7 @@ def test_deploy_application_rest_required_fields( response_value._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.deploy_application(request) @@ -12000,6 +12011,7 @@ def test_deploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.deploy_application(**mock_args) @@ -12137,6 +12149,7 @@ def test_undeploy_application_rest_required_fields( response_value._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.undeploy_application(request) @@ -12182,6 +12195,7 @@ def test_undeploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undeploy_application(**mock_args) @@ -12320,6 +12334,7 @@ def test_add_application_stream_input_rest_required_fields( response_value._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.add_application_stream_input(request) @@ -12365,6 +12380,7 @@ def test_add_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_application_stream_input(**mock_args) @@ -12503,6 +12519,7 @@ def test_remove_application_stream_input_rest_required_fields( response_value._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.remove_application_stream_input(request) @@ -12550,6 +12567,7 @@ def test_remove_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_application_stream_input(**mock_args) @@ -12688,6 +12706,7 @@ def test_update_application_stream_input_rest_required_fields( response_value._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_application_stream_input(request) @@ -12735,6 +12754,7 @@ def test_update_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_stream_input(**mock_args) @@ -12875,6 +12895,7 @@ def test_list_instances_rest_required_fields( response_value._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_instances(request) @@ -12932,6 +12953,7 @@ def test_list_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instances(**mock_args) @@ -13124,6 +13146,7 @@ def test_get_instance_rest_required_fields(request_type=platform.GetInstanceRequ response_value._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_instance(request) @@ -13171,6 +13194,7 @@ def test_get_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -13309,6 +13333,7 @@ def test_create_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13362,6 +13387,7 @@ def test_create_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13504,6 +13530,7 @@ def test_delete_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13557,6 +13584,7 @@ def test_delete_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13695,6 +13723,7 @@ def test_update_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13745,6 +13774,7 @@ def test_update_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13888,6 +13918,7 @@ def test_list_drafts_rest_required_fields(request_type=platform.ListDraftsReques response_value._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_drafts(request) @@ -13945,6 +13976,7 @@ def test_list_drafts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_drafts(**mock_args) @@ -14137,6 +14169,7 @@ def test_get_draft_rest_required_fields(request_type=platform.GetDraftRequest): response_value._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_draft(request) @@ -14184,6 +14217,7 @@ def test_get_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14329,6 +14363,7 @@ def test_create_draft_rest_required_fields(request_type=platform.CreateDraftRequ response_value._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_draft(request) @@ -14396,6 +14431,7 @@ def test_create_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14532,6 +14568,7 @@ def test_update_draft_rest_required_fields(request_type=platform.UpdateDraftRequ response_value._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_draft(request) @@ -14589,6 +14626,7 @@ def test_update_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14722,6 +14760,7 @@ def test_delete_draft_rest_required_fields(request_type=platform.DeleteDraftRequ response_value._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_draft(request) @@ -14767,6 +14806,7 @@ def test_delete_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14907,6 +14947,7 @@ def test_list_processors_rest_required_fields( response_value._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_processors(request) @@ -14962,6 +15003,7 @@ def test_list_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processors(**mock_args) @@ -15159,6 +15201,7 @@ def test_list_prebuilt_processors_rest_required_fields( response_value._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_prebuilt_processors(request) @@ -15204,6 +15247,7 @@ def test_list_prebuilt_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_prebuilt_processors(**mock_args) @@ -15333,6 +15377,7 @@ def test_get_processor_rest_required_fields(request_type=platform.GetProcessorRe response_value._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_processor(request) @@ -15380,6 +15425,7 @@ def test_get_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15528,6 +15574,7 @@ def test_create_processor_rest_required_fields( response_value._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_processor(request) @@ -15593,6 +15640,7 @@ def test_create_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15731,6 +15779,7 @@ def test_update_processor_rest_required_fields( response_value._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_processor(request) @@ -15787,6 +15836,7 @@ def test_update_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15924,6 +15974,7 @@ def test_delete_processor_rest_required_fields( response_value._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_processor(request) @@ -15969,6 +16020,7 @@ def test_delete_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -17436,6 +17488,7 @@ def test_list_applications_rest_bad_request( 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_applications(request) @@ -17472,6 +17525,7 @@ def test_list_applications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_applications(request) # Establish that the response is the type that we expect. @@ -17513,6 +17567,7 @@ def test_list_applications_rest_interceptors(null_interceptor): 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 = platform.ListApplicationsResponse.to_json( platform.ListApplicationsResponse() ) @@ -17557,6 +17612,7 @@ def test_get_application_rest_bad_request(request_type=platform.GetApplicationRe 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_application(request) @@ -17596,6 +17652,7 @@ def test_get_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -17638,6 +17695,7 @@ def test_get_application_rest_interceptors(null_interceptor): 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 = platform.Application.to_json(platform.Application()) req.return_value.content = return_value @@ -17682,6 +17740,7 @@ def test_create_application_rest_bad_request( 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_application(request) @@ -17930,6 +17989,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -17971,6 +18031,7 @@ def test_create_application_rest_interceptors(null_interceptor): 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 @@ -18019,6 +18080,7 @@ def test_update_application_rest_bad_request( 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_application(request) @@ -18271,6 +18333,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -18312,6 +18375,7 @@ def test_update_application_rest_interceptors(null_interceptor): 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 @@ -18356,6 +18420,7 @@ def test_delete_application_rest_bad_request( 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_application(request) @@ -18386,6 +18451,7 @@ def test_delete_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -18427,6 +18493,7 @@ def test_delete_application_rest_interceptors(null_interceptor): 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 @@ -18471,6 +18538,7 @@ def test_deploy_application_rest_bad_request( 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.deploy_application(request) @@ -18501,6 +18569,7 @@ def test_deploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.deploy_application(request) # Establish that the response is the type that we expect. @@ -18542,6 +18611,7 @@ def test_deploy_application_rest_interceptors(null_interceptor): 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 @@ -18586,6 +18656,7 @@ def test_undeploy_application_rest_bad_request( 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.undeploy_application(request) @@ -18616,6 +18687,7 @@ def test_undeploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undeploy_application(request) # Establish that the response is the type that we expect. @@ -18657,6 +18729,7 @@ def test_undeploy_application_rest_interceptors(null_interceptor): 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 @@ -18701,6 +18774,7 @@ def test_add_application_stream_input_rest_bad_request( 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.add_application_stream_input(request) @@ -18731,6 +18805,7 @@ def test_add_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18772,6 +18847,7 @@ def test_add_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -18816,6 +18892,7 @@ def test_remove_application_stream_input_rest_bad_request( 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.remove_application_stream_input(request) @@ -18846,6 +18923,7 @@ def test_remove_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18887,6 +18965,7 @@ def test_remove_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -18931,6 +19010,7 @@ def test_update_application_stream_input_rest_bad_request( 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_application_stream_input(request) @@ -18961,6 +19041,7 @@ def test_update_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -19002,6 +19083,7 @@ def test_update_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -19044,6 +19126,7 @@ def test_list_instances_rest_bad_request(request_type=platform.ListInstancesRequ 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_instances(request) @@ -19080,6 +19163,7 @@ def test_list_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instances(request) # Establish that the response is the type that we expect. @@ -19119,6 +19203,7 @@ def test_list_instances_rest_interceptors(null_interceptor): 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 = platform.ListInstancesResponse.to_json( platform.ListInstancesResponse() ) @@ -19165,6 +19250,7 @@ def test_get_instance_rest_bad_request(request_type=platform.GetInstanceRequest) 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_instance(request) @@ -19206,6 +19292,7 @@ def test_get_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -19248,6 +19335,7 @@ def test_get_instance_rest_interceptors(null_interceptor): 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 = platform.Instance.to_json(platform.Instance()) req.return_value.content = return_value @@ -19292,6 +19380,7 @@ def test_create_application_instances_rest_bad_request( 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_application_instances(request) @@ -19322,6 +19411,7 @@ def test_create_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19363,6 +19453,7 @@ def test_create_application_instances_rest_interceptors(null_interceptor): 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 @@ -19407,6 +19498,7 @@ def test_delete_application_instances_rest_bad_request( 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_application_instances(request) @@ -19437,6 +19529,7 @@ def test_delete_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19478,6 +19571,7 @@ def test_delete_application_instances_rest_interceptors(null_interceptor): 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 @@ -19522,6 +19616,7 @@ def test_update_application_instances_rest_bad_request( 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_application_instances(request) @@ -19552,6 +19647,7 @@ def test_update_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19593,6 +19689,7 @@ def test_update_application_instances_rest_interceptors(null_interceptor): 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 @@ -19635,6 +19732,7 @@ def test_list_drafts_rest_bad_request(request_type=platform.ListDraftsRequest): 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_drafts(request) @@ -19671,6 +19769,7 @@ def test_list_drafts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_drafts(request) # Establish that the response is the type that we expect. @@ -19710,6 +19809,7 @@ def test_list_drafts_rest_interceptors(null_interceptor): 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 = platform.ListDraftsResponse.to_json( platform.ListDraftsResponse() ) @@ -19756,6 +19856,7 @@ def test_get_draft_rest_bad_request(request_type=platform.GetDraftRequest): 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_draft(request) @@ -19795,6 +19896,7 @@ def test_get_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -19835,6 +19937,7 @@ def test_get_draft_rest_interceptors(null_interceptor): 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 = platform.Draft.to_json(platform.Draft()) req.return_value.content = return_value @@ -19877,6 +19980,7 @@ def test_create_draft_rest_bad_request(request_type=platform.CreateDraftRequest) 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_draft(request) @@ -20112,6 +20216,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20151,6 +20256,7 @@ def test_create_draft_rest_interceptors(null_interceptor): 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 @@ -20197,6 +20303,7 @@ def test_update_draft_rest_bad_request(request_type=platform.UpdateDraftRequest) 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_draft(request) @@ -20436,6 +20543,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20475,6 +20583,7 @@ def test_update_draft_rest_interceptors(null_interceptor): 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 @@ -20519,6 +20628,7 @@ def test_delete_draft_rest_bad_request(request_type=platform.DeleteDraftRequest) 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_draft(request) @@ -20551,6 +20661,7 @@ def test_delete_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20590,6 +20701,7 @@ def test_delete_draft_rest_interceptors(null_interceptor): 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 @@ -20632,6 +20744,7 @@ def test_list_processors_rest_bad_request(request_type=platform.ListProcessorsRe 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_processors(request) @@ -20668,6 +20781,7 @@ def test_list_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processors(request) # Establish that the response is the type that we expect. @@ -20707,6 +20821,7 @@ def test_list_processors_rest_interceptors(null_interceptor): 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 = platform.ListProcessorsResponse.to_json( platform.ListProcessorsResponse() ) @@ -20753,6 +20868,7 @@ def test_list_prebuilt_processors_rest_bad_request( 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_prebuilt_processors(request) @@ -20786,6 +20902,7 @@ def test_list_prebuilt_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_prebuilt_processors(request) # Establish that the response is the type that we expect. @@ -20825,6 +20942,7 @@ def test_list_prebuilt_processors_rest_interceptors(null_interceptor): 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 = platform.ListPrebuiltProcessorsResponse.to_json( platform.ListPrebuiltProcessorsResponse() ) @@ -20869,6 +20987,7 @@ def test_get_processor_rest_bad_request(request_type=platform.GetProcessorReques 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_processor(request) @@ -20917,6 +21036,7 @@ def test_get_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -20968,6 +21088,7 @@ def test_get_processor_rest_interceptors(null_interceptor): 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 = platform.Processor.to_json(platform.Processor()) req.return_value.content = return_value @@ -21012,6 +21133,7 @@ def test_create_processor_rest_bad_request( 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_processor(request) @@ -21173,6 +21295,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21214,6 +21337,7 @@ def test_create_processor_rest_interceptors(null_interceptor): 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 @@ -21260,6 +21384,7 @@ def test_update_processor_rest_bad_request( 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_processor(request) @@ -21423,6 +21548,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21464,6 +21590,7 @@ def test_update_processor_rest_interceptors(null_interceptor): 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 @@ -21508,6 +21635,7 @@ def test_delete_processor_rest_bad_request( 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_processor(request) @@ -21538,6 +21666,7 @@ def test_delete_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21579,6 +21708,7 @@ def test_delete_processor_rest_interceptors(null_interceptor): 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 @@ -21625,6 +21755,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -21655,6 +21786,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -21685,6 +21817,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -21715,6 +21848,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -21745,6 +21879,7 @@ def test_get_operation_rest_bad_request( 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) @@ -21775,6 +21910,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -21805,6 +21941,7 @@ def test_list_operations_rest_bad_request( 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) @@ -21835,6 +21972,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py index 34a0899a352f..f5e23a74b0a9 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_health_check_service.py @@ -1582,6 +1582,7 @@ def test_health_check_rest_bad_request(request_type=health_service.HealthCheckRe 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.health_check(request) @@ -1618,6 +1619,7 @@ def test_health_check_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.health_check(request) # Establish that the response is the type that we expect. @@ -1659,6 +1661,7 @@ def test_health_check_rest_interceptors(null_interceptor): 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 = health_service.HealthCheckResponse.to_json( health_service.HealthCheckResponse() ) @@ -1707,6 +1710,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -1737,6 +1741,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -1767,6 +1772,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -1797,6 +1803,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -1827,6 +1834,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1857,6 +1865,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1887,6 +1896,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1917,6 +1927,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py index 6c6bab1fa57e..c6edd81d5f4a 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_live_video_analytics.py @@ -8119,6 +8119,7 @@ def test_list_public_operators_rest_required_fields( response_value._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_public_operators(request) @@ -8174,6 +8175,7 @@ def test_list_public_operators_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_public_operators(**mock_args) @@ -8374,6 +8376,7 @@ def test_resolve_operator_info_rest_required_fields( response_value._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.resolve_operator_info(request) @@ -8428,6 +8431,7 @@ def test_resolve_operator_info_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resolve_operator_info(**mock_args) @@ -8569,6 +8573,7 @@ def test_list_operators_rest_required_fields( response_value._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_operators(request) @@ -8624,6 +8629,7 @@ def test_list_operators_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_operators(**mock_args) @@ -8813,6 +8819,7 @@ def test_get_operator_rest_required_fields(request_type=lva_service.GetOperatorR response_value._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_operator(request) @@ -8860,6 +8867,7 @@ def test_get_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_operator(**mock_args) @@ -9006,6 +9014,7 @@ def test_create_operator_rest_required_fields( response_value._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_operator(request) @@ -9071,6 +9080,7 @@ def test_create_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_operator(**mock_args) @@ -9207,6 +9217,7 @@ def test_update_operator_rest_required_fields( response_value._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_operator(request) @@ -9266,6 +9277,7 @@ def test_update_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_operator(**mock_args) @@ -9401,6 +9413,7 @@ def test_delete_operator_rest_required_fields( response_value._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_operator(request) @@ -9446,6 +9459,7 @@ def test_delete_operator_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_operator(**mock_args) @@ -9585,6 +9599,7 @@ def test_list_analyses_rest_required_fields( response_value._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_analyses(request) @@ -9642,6 +9657,7 @@ def test_list_analyses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analyses(**mock_args) @@ -9834,6 +9850,7 @@ def test_get_analysis_rest_required_fields(request_type=lva_service.GetAnalysisR response_value._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_analysis(request) @@ -9881,6 +9898,7 @@ def test_get_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -10028,6 +10046,7 @@ def test_create_analysis_rest_required_fields( response_value._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_analysis(request) @@ -10095,6 +10114,7 @@ def test_create_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -10232,6 +10252,7 @@ def test_update_analysis_rest_required_fields( response_value._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_analysis(request) @@ -10293,6 +10314,7 @@ def test_update_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -10428,6 +10450,7 @@ def test_delete_analysis_rest_required_fields( response_value._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_analysis(request) @@ -10473,6 +10496,7 @@ def test_delete_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -10613,6 +10637,7 @@ def test_list_processes_rest_required_fields( response_value._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_processes(request) @@ -10670,6 +10695,7 @@ def test_list_processes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processes(**mock_args) @@ -10862,6 +10888,7 @@ def test_get_process_rest_required_fields(request_type=lva_service.GetProcessReq response_value._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_process(request) @@ -10909,6 +10936,7 @@ def test_get_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_process(**mock_args) @@ -11056,6 +11084,7 @@ def test_create_process_rest_required_fields( response_value._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_process(request) @@ -11123,6 +11152,7 @@ def test_create_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_process(**mock_args) @@ -11260,6 +11290,7 @@ def test_update_process_rest_required_fields( response_value._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_process(request) @@ -11321,6 +11352,7 @@ def test_update_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_process(**mock_args) @@ -11456,6 +11488,7 @@ def test_delete_process_rest_required_fields( response_value._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_process(request) @@ -11501,6 +11534,7 @@ def test_delete_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_process(**mock_args) @@ -11636,6 +11670,7 @@ def test_batch_run_process_rest_required_fields( response_value._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.batch_run_process(request) @@ -11690,6 +11725,7 @@ def test_batch_run_process_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_run_process(**mock_args) @@ -12733,6 +12769,7 @@ def test_list_public_operators_rest_bad_request( 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_public_operators(request) @@ -12768,6 +12805,7 @@ def test_list_public_operators_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_public_operators(request) # Establish that the response is the type that we expect. @@ -12808,6 +12846,7 @@ def test_list_public_operators_rest_interceptors(null_interceptor): 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 = lva_service.ListPublicOperatorsResponse.to_json( lva_service.ListPublicOperatorsResponse() ) @@ -12854,6 +12893,7 @@ def test_resolve_operator_info_rest_bad_request( 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.resolve_operator_info(request) @@ -12887,6 +12927,7 @@ def test_resolve_operator_info_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resolve_operator_info(request) # Establish that the response is the type that we expect. @@ -12926,6 +12967,7 @@ def test_resolve_operator_info_rest_interceptors(null_interceptor): 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 = lva_service.ResolveOperatorInfoResponse.to_json( lva_service.ResolveOperatorInfoResponse() ) @@ -12970,6 +13012,7 @@ def test_list_operators_rest_bad_request(request_type=lva_service.ListOperatorsR 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_operators(request) @@ -13006,6 +13049,7 @@ def test_list_operators_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_operators(request) # Establish that the response is the type that we expect. @@ -13047,6 +13091,7 @@ def test_list_operators_rest_interceptors(null_interceptor): 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 = lva_service.ListOperatorsResponse.to_json( lva_service.ListOperatorsResponse() ) @@ -13091,6 +13136,7 @@ def test_get_operator_rest_bad_request(request_type=lva_service.GetOperatorReque 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_operator(request) @@ -13127,6 +13173,7 @@ def test_get_operator_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_operator(request) # Establish that the response is the type that we expect. @@ -13166,6 +13213,7 @@ def test_get_operator_rest_interceptors(null_interceptor): 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 = lva_resources.Operator.to_json(lva_resources.Operator()) req.return_value.content = return_value @@ -13210,6 +13258,7 @@ def test_create_operator_rest_bad_request( 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_operator(request) @@ -13341,6 +13390,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_operator(request) # Establish that the response is the type that we expect. @@ -13382,6 +13432,7 @@ def test_create_operator_rest_interceptors(null_interceptor): 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 @@ -13428,6 +13479,7 @@ def test_update_operator_rest_bad_request( 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_operator(request) @@ -13561,6 +13613,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_operator(request) # Establish that the response is the type that we expect. @@ -13602,6 +13655,7 @@ def test_update_operator_rest_interceptors(null_interceptor): 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 @@ -13646,6 +13700,7 @@ def test_delete_operator_rest_bad_request( 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_operator(request) @@ -13676,6 +13731,7 @@ def test_delete_operator_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_operator(request) # Establish that the response is the type that we expect. @@ -13717,6 +13773,7 @@ def test_delete_operator_rest_interceptors(null_interceptor): 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 @@ -13759,6 +13816,7 @@ def test_list_analyses_rest_bad_request(request_type=lva_service.ListAnalysesReq 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_analyses(request) @@ -13795,6 +13853,7 @@ def test_list_analyses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analyses(request) # Establish that the response is the type that we expect. @@ -13836,6 +13895,7 @@ def test_list_analyses_rest_interceptors(null_interceptor): 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 = lva_service.ListAnalysesResponse.to_json( lva_service.ListAnalysesResponse() ) @@ -13882,6 +13942,7 @@ def test_get_analysis_rest_bad_request(request_type=lva_service.GetAnalysisReque 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_analysis(request) @@ -13920,6 +13981,7 @@ def test_get_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -13959,6 +14021,7 @@ def test_get_analysis_rest_interceptors(null_interceptor): 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 = lva_resources.Analysis.to_json(lva_resources.Analysis()) req.return_value.content = return_value @@ -14003,6 +14066,7 @@ def test_create_analysis_rest_bad_request( 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_analysis(request) @@ -14124,6 +14188,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -14165,6 +14230,7 @@ def test_create_analysis_rest_interceptors(null_interceptor): 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 @@ -14213,6 +14279,7 @@ def test_update_analysis_rest_bad_request( 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_analysis(request) @@ -14338,6 +14405,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -14379,6 +14447,7 @@ def test_update_analysis_rest_interceptors(null_interceptor): 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 @@ -14425,6 +14494,7 @@ def test_delete_analysis_rest_bad_request( 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_analysis(request) @@ -14457,6 +14527,7 @@ def test_delete_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -14498,6 +14569,7 @@ def test_delete_analysis_rest_interceptors(null_interceptor): 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 @@ -14540,6 +14612,7 @@ def test_list_processes_rest_bad_request(request_type=lva_service.ListProcessesR 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_processes(request) @@ -14576,6 +14649,7 @@ def test_list_processes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processes(request) # Establish that the response is the type that we expect. @@ -14617,6 +14691,7 @@ def test_list_processes_rest_interceptors(null_interceptor): 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 = lva_service.ListProcessesResponse.to_json( lva_service.ListProcessesResponse() ) @@ -14663,6 +14738,7 @@ def test_get_process_rest_bad_request(request_type=lva_service.GetProcessRequest 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_process(request) @@ -14706,6 +14782,7 @@ def test_get_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_process(request) # Establish that the response is the type that we expect. @@ -14750,6 +14827,7 @@ def test_get_process_rest_interceptors(null_interceptor): 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 = lva_resources.Process.to_json(lva_resources.Process()) req.return_value.content = return_value @@ -14792,6 +14870,7 @@ def test_create_process_rest_bad_request(request_type=lva_service.CreateProcessR 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_process(request) @@ -14904,6 +14983,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_process(request) # Establish that the response is the type that we expect. @@ -14945,6 +15025,7 @@ def test_create_process_rest_interceptors(null_interceptor): 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 @@ -14991,6 +15072,7 @@ def test_update_process_rest_bad_request(request_type=lva_service.UpdateProcessR 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_process(request) @@ -15107,6 +15189,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_process(request) # Establish that the response is the type that we expect. @@ -15148,6 +15231,7 @@ def test_update_process_rest_interceptors(null_interceptor): 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 @@ -15192,6 +15276,7 @@ def test_delete_process_rest_bad_request(request_type=lva_service.DeleteProcessR 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_process(request) @@ -15224,6 +15309,7 @@ def test_delete_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_process(request) # Establish that the response is the type that we expect. @@ -15265,6 +15351,7 @@ def test_delete_process_rest_interceptors(null_interceptor): 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 @@ -15309,6 +15396,7 @@ def test_batch_run_process_rest_bad_request( 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.batch_run_process(request) @@ -15339,6 +15427,7 @@ def test_batch_run_process_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_run_process(request) # Establish that the response is the type that we expect. @@ -15380,6 +15469,7 @@ def test_batch_run_process_rest_interceptors(null_interceptor): 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 @@ -15426,6 +15516,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -15456,6 +15547,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -15486,6 +15578,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -15516,6 +15609,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -15546,6 +15640,7 @@ def test_get_operation_rest_bad_request( 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) @@ -15576,6 +15671,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -15606,6 +15702,7 @@ def test_list_operations_rest_bad_request( 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) @@ -15636,6 +15733,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py index 62269285098d..b8b8816d3d45 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streaming_service.py @@ -2810,6 +2810,7 @@ def test_acquire_lease_rest_bad_request( 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.acquire_lease(request) @@ -2850,6 +2851,7 @@ def test_acquire_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.acquire_lease(request) # Establish that the response is the type that we expect. @@ -2893,6 +2895,7 @@ def test_acquire_lease_rest_interceptors(null_interceptor): 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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -2937,6 +2940,7 @@ def test_renew_lease_rest_bad_request(request_type=streaming_service.RenewLeaseR 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.renew_lease(request) @@ -2977,6 +2981,7 @@ def test_renew_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.renew_lease(request) # Establish that the response is the type that we expect. @@ -3020,6 +3025,7 @@ def test_renew_lease_rest_interceptors(null_interceptor): 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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -3066,6 +3072,7 @@ def test_release_lease_rest_bad_request( 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.release_lease(request) @@ -3101,6 +3108,7 @@ def test_release_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.release_lease(request) # Establish that the response is the type that we expect. @@ -3140,6 +3148,7 @@ def test_release_lease_rest_interceptors(null_interceptor): 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 = streaming_service.ReleaseLeaseResponse.to_json( streaming_service.ReleaseLeaseResponse() ) @@ -3188,6 +3197,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -3218,6 +3228,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -3248,6 +3259,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -3278,6 +3290,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -3308,6 +3321,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3338,6 +3352,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -3368,6 +3383,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3398,6 +3414,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py index 06dc3aa187db..eca3241f3257 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_streams_service.py @@ -9758,6 +9758,7 @@ def test_list_clusters_rest_required_fields( response_value._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_clusters(request) @@ -9813,6 +9814,7 @@ def test_list_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clusters(**mock_args) @@ -10006,6 +10008,7 @@ def test_get_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10051,6 +10054,7 @@ def test_get_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10197,6 +10201,7 @@ def test_create_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10262,6 +10267,7 @@ def test_create_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10398,6 +10404,7 @@ def test_update_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10457,6 +10464,7 @@ def test_update_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10592,6 +10600,7 @@ def test_delete_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10635,6 +10644,7 @@ def test_delete_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10774,6 +10784,7 @@ def test_list_streams_rest_required_fields( response_value._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_streams(request) @@ -10831,6 +10842,7 @@ def test_list_streams_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_streams(**mock_args) @@ -11025,6 +11037,7 @@ def test_get_stream_rest_required_fields(request_type=streams_service.GetStreamR response_value._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_stream(request) @@ -11072,6 +11085,7 @@ def test_get_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11219,6 +11233,7 @@ def test_create_stream_rest_required_fields( response_value._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_stream(request) @@ -11286,6 +11301,7 @@ def test_create_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11423,6 +11439,7 @@ def test_update_stream_rest_required_fields( response_value._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_stream(request) @@ -11484,6 +11501,7 @@ def test_update_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11619,6 +11637,7 @@ def test_delete_stream_rest_required_fields( response_value._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_stream(request) @@ -11664,6 +11683,7 @@ def test_delete_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11805,6 +11825,7 @@ def test_get_stream_thumbnail_rest_required_fields( response_value._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_stream_thumbnail(request) @@ -11859,6 +11880,7 @@ def test_get_stream_thumbnail_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream_thumbnail(**mock_args) @@ -11999,6 +12021,7 @@ def test_generate_stream_hls_token_rest_required_fields( response_value._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.generate_stream_hls_token(request) @@ -12046,6 +12069,7 @@ def test_generate_stream_hls_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.generate_stream_hls_token(**mock_args) @@ -12186,6 +12210,7 @@ def test_list_events_rest_required_fields( response_value._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_events(request) @@ -12243,6 +12268,7 @@ def test_list_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_events(**mock_args) @@ -12437,6 +12463,7 @@ def test_get_event_rest_required_fields(request_type=streams_service.GetEventReq response_value._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_event(request) @@ -12484,6 +12511,7 @@ def test_get_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12631,6 +12659,7 @@ def test_create_event_rest_required_fields( response_value._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_event(request) @@ -12698,6 +12727,7 @@ def test_create_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12835,6 +12865,7 @@ def test_update_event_rest_required_fields( response_value._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_event(request) @@ -12896,6 +12927,7 @@ def test_update_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -13031,6 +13063,7 @@ def test_delete_event_rest_required_fields( response_value._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_event(request) @@ -13076,6 +13109,7 @@ def test_delete_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -13216,6 +13250,7 @@ def test_list_series_rest_required_fields( response_value._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_series(request) @@ -13273,6 +13308,7 @@ def test_list_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13467,6 +13503,7 @@ def test_get_series_rest_required_fields(request_type=streams_service.GetSeriesR response_value._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_series(request) @@ -13514,6 +13551,7 @@ def test_get_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13661,6 +13699,7 @@ def test_create_series_rest_required_fields( response_value._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_series(request) @@ -13728,6 +13767,7 @@ def test_create_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13865,6 +13905,7 @@ def test_update_series_rest_required_fields( response_value._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_series(request) @@ -13926,6 +13967,7 @@ def test_update_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -14061,6 +14103,7 @@ def test_delete_series_rest_required_fields( response_value._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_series(request) @@ -14106,6 +14149,7 @@ def test_delete_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -14257,6 +14301,7 @@ def test_materialize_channel_rest_required_fields( response_value._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.materialize_channel(request) @@ -14324,6 +14369,7 @@ def test_materialize_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.materialize_channel(**mock_args) @@ -15604,6 +15650,7 @@ def test_list_clusters_rest_bad_request( 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_clusters(request) @@ -15640,6 +15687,7 @@ def test_list_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clusters(request) # Establish that the response is the type that we expect. @@ -15681,6 +15729,7 @@ def test_list_clusters_rest_interceptors(null_interceptor): 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 = streams_service.ListClustersResponse.to_json( streams_service.ListClustersResponse() ) @@ -15725,6 +15774,7 @@ def test_get_cluster_rest_bad_request(request_type=streams_service.GetClusterReq 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_cluster(request) @@ -15763,6 +15813,7 @@ def test_get_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15806,6 +15857,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): 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 = common.Cluster.to_json(common.Cluster()) req.return_value.content = return_value @@ -15850,6 +15902,7 @@ def test_create_cluster_rest_bad_request( 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_cluster(request) @@ -15957,6 +16010,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15998,6 +16052,7 @@ def test_create_cluster_rest_interceptors(null_interceptor): 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 @@ -16044,6 +16099,7 @@ def test_update_cluster_rest_bad_request( 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_cluster(request) @@ -16153,6 +16209,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -16194,6 +16251,7 @@ def test_update_cluster_rest_interceptors(null_interceptor): 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 @@ -16238,6 +16296,7 @@ def test_delete_cluster_rest_bad_request( 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_cluster(request) @@ -16268,6 +16327,7 @@ def test_delete_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -16309,6 +16369,7 @@ def test_delete_cluster_rest_interceptors(null_interceptor): 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 @@ -16351,6 +16412,7 @@ def test_list_streams_rest_bad_request(request_type=streams_service.ListStreamsR 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_streams(request) @@ -16387,6 +16449,7 @@ def test_list_streams_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_streams(request) # Establish that the response is the type that we expect. @@ -16428,6 +16491,7 @@ def test_list_streams_rest_interceptors(null_interceptor): 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 = streams_service.ListStreamsResponse.to_json( streams_service.ListStreamsResponse() ) @@ -16474,6 +16538,7 @@ def test_get_stream_rest_bad_request(request_type=streams_service.GetStreamReque 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_stream(request) @@ -16514,6 +16579,7 @@ def test_get_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16557,6 +16623,7 @@ def test_get_stream_rest_interceptors(null_interceptor): 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 = streams_resources.Stream.to_json(streams_resources.Stream()) req.return_value.content = return_value @@ -16601,6 +16668,7 @@ def test_create_stream_rest_bad_request( 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_stream(request) @@ -16708,6 +16776,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16749,6 +16818,7 @@ def test_create_stream_rest_interceptors(null_interceptor): 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 @@ -16797,6 +16867,7 @@ def test_update_stream_rest_bad_request( 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_stream(request) @@ -16908,6 +16979,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16949,6 +17021,7 @@ def test_update_stream_rest_interceptors(null_interceptor): 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 @@ -16995,6 +17068,7 @@ def test_delete_stream_rest_bad_request( 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_stream(request) @@ -17027,6 +17101,7 @@ def test_delete_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -17068,6 +17143,7 @@ def test_delete_stream_rest_interceptors(null_interceptor): 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 @@ -17114,6 +17190,7 @@ def test_get_stream_thumbnail_rest_bad_request( 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_stream_thumbnail(request) @@ -17146,6 +17223,7 @@ def test_get_stream_thumbnail_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream_thumbnail(request) # Establish that the response is the type that we expect. @@ -17187,6 +17265,7 @@ def test_get_stream_thumbnail_rest_interceptors(null_interceptor): 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 @@ -17233,6 +17312,7 @@ def test_generate_stream_hls_token_rest_bad_request( 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.generate_stream_hls_token(request) @@ -17270,6 +17350,7 @@ def test_generate_stream_hls_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_stream_hls_token(request) # Establish that the response is the type that we expect. @@ -17310,6 +17391,7 @@ def test_generate_stream_hls_token_rest_interceptors(null_interceptor): 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 = streams_service.GenerateStreamHlsTokenResponse.to_json( streams_service.GenerateStreamHlsTokenResponse() ) @@ -17354,6 +17436,7 @@ def test_list_events_rest_bad_request(request_type=streams_service.ListEventsReq 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_events(request) @@ -17390,6 +17473,7 @@ def test_list_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_events(request) # Establish that the response is the type that we expect. @@ -17431,6 +17515,7 @@ def test_list_events_rest_interceptors(null_interceptor): 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 = streams_service.ListEventsResponse.to_json( streams_service.ListEventsResponse() ) @@ -17477,6 +17562,7 @@ def test_get_event_rest_bad_request(request_type=streams_service.GetEventRequest 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_event(request) @@ -17515,6 +17601,7 @@ def test_get_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17556,6 +17643,7 @@ def test_get_event_rest_interceptors(null_interceptor): 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 = streams_resources.Event.to_json(streams_resources.Event()) req.return_value.content = return_value @@ -17598,6 +17686,7 @@ def test_create_event_rest_bad_request(request_type=streams_service.CreateEventR 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_event(request) @@ -17704,6 +17793,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17745,6 +17835,7 @@ def test_create_event_rest_interceptors(null_interceptor): 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 @@ -17791,6 +17882,7 @@ def test_update_event_rest_bad_request(request_type=streams_service.UpdateEventR 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_event(request) @@ -17901,6 +17993,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17942,6 +18035,7 @@ def test_update_event_rest_interceptors(null_interceptor): 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 @@ -17986,6 +18080,7 @@ def test_delete_event_rest_bad_request(request_type=streams_service.DeleteEventR 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_event(request) @@ -18018,6 +18113,7 @@ def test_delete_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -18059,6 +18155,7 @@ def test_delete_event_rest_interceptors(null_interceptor): 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 @@ -18101,6 +18198,7 @@ def test_list_series_rest_bad_request(request_type=streams_service.ListSeriesReq 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_series(request) @@ -18137,6 +18235,7 @@ def test_list_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18178,6 +18277,7 @@ def test_list_series_rest_interceptors(null_interceptor): 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 = streams_service.ListSeriesResponse.to_json( streams_service.ListSeriesResponse() ) @@ -18224,6 +18324,7 @@ def test_get_series_rest_bad_request(request_type=streams_service.GetSeriesReque 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_series(request) @@ -18263,6 +18364,7 @@ def test_get_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18305,6 +18407,7 @@ def test_get_series_rest_interceptors(null_interceptor): 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 = streams_resources.Series.to_json(streams_resources.Series()) req.return_value.content = return_value @@ -18349,6 +18452,7 @@ def test_create_series_rest_bad_request( 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_series(request) @@ -18455,6 +18559,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18496,6 +18601,7 @@ def test_create_series_rest_interceptors(null_interceptor): 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 @@ -18544,6 +18650,7 @@ def test_update_series_rest_bad_request( 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_series(request) @@ -18654,6 +18761,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18695,6 +18803,7 @@ def test_update_series_rest_interceptors(null_interceptor): 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 @@ -18741,6 +18850,7 @@ def test_delete_series_rest_bad_request( 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_series(request) @@ -18773,6 +18883,7 @@ def test_delete_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18814,6 +18925,7 @@ def test_delete_series_rest_interceptors(null_interceptor): 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 @@ -18858,6 +18970,7 @@ def test_materialize_channel_rest_bad_request( 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.materialize_channel(request) @@ -18964,6 +19077,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.materialize_channel(request) # Establish that the response is the type that we expect. @@ -19005,6 +19119,7 @@ def test_materialize_channel_rest_interceptors(null_interceptor): 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 @@ -19051,6 +19166,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -19081,6 +19197,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -19111,6 +19228,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -19141,6 +19259,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -19171,6 +19290,7 @@ def test_get_operation_rest_bad_request( 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) @@ -19201,6 +19321,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -19231,6 +19352,7 @@ def test_list_operations_rest_bad_request( 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) @@ -19261,6 +19383,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py index 2752c79dc795..dc4f95362624 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1/test_warehouse.py @@ -23752,6 +23752,7 @@ def test_create_asset_rest_required_fields(request_type=warehouse.CreateAssetReq response_value._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_asset(request) @@ -23809,6 +23810,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -23938,6 +23940,7 @@ def test_update_asset_rest_required_fields(request_type=warehouse.UpdateAssetReq response_value._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_asset(request) @@ -23988,6 +23991,7 @@ def test_update_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -24118,6 +24122,7 @@ def test_get_asset_rest_required_fields(request_type=warehouse.GetAssetRequest): response_value._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_asset(request) @@ -24165,6 +24170,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -24302,6 +24308,7 @@ def test_list_assets_rest_required_fields(request_type=warehouse.ListAssetsReque response_value._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_assets(request) @@ -24358,6 +24365,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_assets(**mock_args) @@ -24551,6 +24559,7 @@ def test_delete_asset_rest_required_fields(request_type=warehouse.DeleteAssetReq response_value._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_asset(request) @@ -24596,6 +24605,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -24727,6 +24737,7 @@ def test_upload_asset_rest_required_fields(request_type=warehouse.UploadAssetReq response_value._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.upload_asset(request) @@ -24852,6 +24863,7 @@ def test_generate_retrieval_url_rest_required_fields( response_value._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.generate_retrieval_url(request) @@ -24971,6 +24983,7 @@ def test_analyze_asset_rest_required_fields(request_type=warehouse.AnalyzeAssetR response_value._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.analyze_asset(request) @@ -25090,6 +25103,7 @@ def test_index_asset_rest_required_fields(request_type=warehouse.IndexAssetReque response_value._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.index_asset(request) @@ -25215,6 +25229,7 @@ def test_remove_index_asset_rest_required_fields( response_value._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.remove_index_asset(request) @@ -25346,6 +25361,7 @@ def test_view_indexed_assets_rest_required_fields( response_value._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.view_indexed_assets(request) @@ -25402,6 +25418,7 @@ def test_view_indexed_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.view_indexed_assets(**mock_args) @@ -25600,6 +25617,7 @@ def test_create_index_rest_required_fields(request_type=warehouse.CreateIndexReq response_value._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_index(request) @@ -25655,6 +25673,7 @@ def test_create_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index(**mock_args) @@ -25785,6 +25804,7 @@ def test_update_index_rest_required_fields(request_type=warehouse.UpdateIndexReq response_value._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_index(request) @@ -25841,6 +25861,7 @@ def test_update_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index(**mock_args) @@ -25971,6 +25992,7 @@ def test_get_index_rest_required_fields(request_type=warehouse.GetIndexRequest): response_value._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_index(request) @@ -26018,6 +26040,7 @@ def test_get_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index(**mock_args) @@ -26154,6 +26177,7 @@ def test_list_indexes_rest_required_fields(request_type=warehouse.ListIndexesReq response_value._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_indexes(request) @@ -26209,6 +26233,7 @@ def test_list_indexes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_indexes(**mock_args) @@ -26402,6 +26427,7 @@ def test_delete_index_rest_required_fields(request_type=warehouse.DeleteIndexReq response_value._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_index(request) @@ -26447,6 +26473,7 @@ def test_delete_index_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index(**mock_args) @@ -26578,6 +26605,7 @@ def test_create_corpus_rest_required_fields(request_type=warehouse.CreateCorpusR response_value._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_corpus(request) @@ -26630,6 +26658,7 @@ def test_create_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -26759,6 +26788,7 @@ def test_get_corpus_rest_required_fields(request_type=warehouse.GetCorpusRequest response_value._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_corpus(request) @@ -26804,6 +26834,7 @@ def test_get_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -26930,6 +26961,7 @@ def test_update_corpus_rest_required_fields(request_type=warehouse.UpdateCorpusR response_value._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_corpus(request) @@ -26978,6 +27010,7 @@ def test_update_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -27116,6 +27149,7 @@ def test_list_corpora_rest_required_fields(request_type=warehouse.ListCorporaReq response_value._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_corpora(request) @@ -27170,6 +27204,7 @@ def test_list_corpora_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpora(**mock_args) @@ -27356,6 +27391,7 @@ def test_delete_corpus_rest_required_fields(request_type=warehouse.DeleteCorpusR response_value._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_corpus(request) @@ -27399,6 +27435,7 @@ def test_delete_corpus_rest_flattened(): 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"} client.delete_corpus(**mock_args) @@ -27531,6 +27568,7 @@ def test_analyze_corpus_rest_required_fields( response_value._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.analyze_corpus(request) @@ -27655,6 +27693,7 @@ def test_create_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -27711,6 +27750,7 @@ def test_create_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -27845,6 +27885,7 @@ def test_update_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -27895,6 +27936,7 @@ def test_update_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -28027,6 +28069,7 @@ def test_get_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -28074,6 +28117,7 @@ def test_get_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -28206,6 +28250,7 @@ def test_delete_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -28251,6 +28296,7 @@ def test_delete_data_schema_rest_flattened(): 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"} client.delete_data_schema(**mock_args) @@ -28391,6 +28437,7 @@ def test_list_data_schemas_rest_required_fields( response_value._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_data_schemas(request) @@ -28446,6 +28493,7 @@ def test_list_data_schemas_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schemas(**mock_args) @@ -28645,6 +28693,7 @@ def test_create_annotation_rest_required_fields( response_value._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_annotation(request) @@ -28702,6 +28751,7 @@ def test_create_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -28835,6 +28885,7 @@ def test_get_annotation_rest_required_fields( response_value._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_annotation(request) @@ -28882,6 +28933,7 @@ def test_get_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -28979,6 +29031,7 @@ def test_list_annotations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotations(**mock_args) @@ -29173,6 +29226,7 @@ def test_update_annotation_rest_required_fields( response_value._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_annotation(request) @@ -29223,6 +29277,7 @@ def test_update_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -29354,6 +29409,7 @@ def test_delete_annotation_rest_required_fields( response_value._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_annotation(request) @@ -29399,6 +29455,7 @@ def test_delete_annotation_rest_flattened(): 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"} client.delete_annotation(**mock_args) @@ -29540,6 +29597,7 @@ def test_clip_asset_rest_required_fields(request_type=warehouse.ClipAssetRequest response_value._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.clip_asset(request) @@ -29670,6 +29728,7 @@ def test_generate_hls_uri_rest_required_fields( response_value._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.generate_hls_uri(request) @@ -29789,6 +29848,7 @@ def test_import_assets_rest_required_fields(request_type=warehouse.ImportAssetsR response_value._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.import_assets(request) @@ -29922,6 +29982,7 @@ def test_create_search_config_rest_required_fields( response_value._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_search_config(request) @@ -29986,6 +30047,7 @@ def test_create_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -30121,6 +30183,7 @@ def test_update_search_config_rest_required_fields( response_value._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_search_config(request) @@ -30171,6 +30234,7 @@ def test_update_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -30305,6 +30369,7 @@ def test_get_search_config_rest_required_fields( response_value._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_search_config(request) @@ -30352,6 +30417,7 @@ def test_get_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -30484,6 +30550,7 @@ def test_delete_search_config_rest_required_fields( response_value._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_search_config(request) @@ -30529,6 +30596,7 @@ def test_delete_search_config_rest_flattened(): 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"} client.delete_search_config(**mock_args) @@ -30671,6 +30739,7 @@ def test_list_search_configs_rest_required_fields( response_value._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_search_configs(request) @@ -30726,6 +30795,7 @@ def test_list_search_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_configs(**mock_args) @@ -30930,6 +31000,7 @@ def test_create_search_hypernym_rest_required_fields( response_value._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_search_hypernym(request) @@ -30987,6 +31058,7 @@ def test_create_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_hypernym(**mock_args) @@ -31123,6 +31195,7 @@ def test_update_search_hypernym_rest_required_fields( response_value._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_search_hypernym(request) @@ -31173,6 +31246,7 @@ def test_update_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_hypernym(**mock_args) @@ -31309,6 +31383,7 @@ def test_get_search_hypernym_rest_required_fields( response_value._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_search_hypernym(request) @@ -31356,6 +31431,7 @@ def test_get_search_hypernym_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_hypernym(**mock_args) @@ -31489,6 +31565,7 @@ def test_delete_search_hypernym_rest_required_fields( response_value._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_search_hypernym(request) @@ -31534,6 +31611,7 @@ def test_delete_search_hypernym_rest_flattened(): 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"} client.delete_search_hypernym(**mock_args) @@ -31677,6 +31755,7 @@ def test_list_search_hypernyms_rest_required_fields( response_value._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_search_hypernyms(request) @@ -31732,6 +31811,7 @@ def test_list_search_hypernyms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_hypernyms(**mock_args) @@ -31927,6 +32007,7 @@ def test_search_assets_rest_required_fields(request_type=warehouse.SearchAssetsR response_value._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.search_assets(request) @@ -32115,6 +32196,7 @@ def test_search_index_endpoint_rest_required_fields( response_value._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.search_index_endpoint(request) @@ -32308,6 +32390,7 @@ def test_create_index_endpoint_rest_required_fields( response_value._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_index_endpoint(request) @@ -32361,6 +32444,7 @@ def test_create_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index_endpoint(**mock_args) @@ -32498,6 +32582,7 @@ def test_get_index_endpoint_rest_required_fields( response_value._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_index_endpoint(request) @@ -32545,6 +32630,7 @@ def test_get_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index_endpoint(**mock_args) @@ -32688,6 +32774,7 @@ def test_list_index_endpoints_rest_required_fields( response_value._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_index_endpoints(request) @@ -32742,6 +32829,7 @@ def test_list_index_endpoints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index_endpoints(**mock_args) @@ -32940,6 +33028,7 @@ def test_update_index_endpoint_rest_required_fields( response_value._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_index_endpoint(request) @@ -32996,6 +33085,7 @@ def test_update_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index_endpoint(**mock_args) @@ -33134,6 +33224,7 @@ def test_delete_index_endpoint_rest_required_fields( response_value._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_index_endpoint(request) @@ -33179,6 +33270,7 @@ def test_delete_index_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_index_endpoint(**mock_args) @@ -33310,6 +33402,7 @@ def test_deploy_index_rest_required_fields(request_type=warehouse.DeployIndexReq response_value._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.deploy_index(request) @@ -33439,6 +33532,7 @@ def test_undeploy_index_rest_required_fields( response_value._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.undeploy_index(request) @@ -33564,6 +33658,7 @@ def test_create_collection_rest_required_fields( response_value._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_collection(request) @@ -33619,6 +33714,7 @@ def test_create_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collection(**mock_args) @@ -33755,6 +33851,7 @@ def test_delete_collection_rest_required_fields( response_value._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_collection(request) @@ -33800,6 +33897,7 @@ def test_delete_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collection(**mock_args) @@ -33931,6 +34029,7 @@ def test_get_collection_rest_required_fields( response_value._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_collection(request) @@ -33978,6 +34077,7 @@ def test_get_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collection(**mock_args) @@ -34109,6 +34209,7 @@ def test_update_collection_rest_required_fields( response_value._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_collection(request) @@ -34159,6 +34260,7 @@ def test_update_collection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collection(**mock_args) @@ -34300,6 +34402,7 @@ def test_list_collections_rest_required_fields( response_value._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_collections(request) @@ -34355,6 +34458,7 @@ def test_list_collections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collections(**mock_args) @@ -34549,6 +34653,7 @@ def test_add_collection_item_rest_required_fields( response_value._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.add_collection_item(request) @@ -34598,6 +34703,7 @@ def test_add_collection_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_collection_item(**mock_args) @@ -34730,6 +34836,7 @@ def test_remove_collection_item_rest_required_fields( response_value._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.remove_collection_item(request) @@ -34779,6 +34886,7 @@ def test_remove_collection_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_collection_item(**mock_args) @@ -34922,6 +35030,7 @@ def test_view_collection_items_rest_required_fields( response_value._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.view_collection_items(request) @@ -34977,6 +35086,7 @@ def test_view_collection_items_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.view_collection_items(**mock_args) @@ -38305,6 +38415,7 @@ def test_create_asset_rest_bad_request(request_type=warehouse.CreateAssetRequest 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_asset(request) @@ -38412,6 +38523,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -38448,6 +38560,7 @@ def test_create_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38494,6 +38607,7 @@ def test_update_asset_rest_bad_request(request_type=warehouse.UpdateAssetRequest 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_asset(request) @@ -38605,6 +38719,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -38641,6 +38756,7 @@ def test_update_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38685,6 +38801,7 @@ def test_get_asset_rest_bad_request(request_type=warehouse.GetAssetRequest): 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_asset(request) @@ -38722,6 +38839,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -38758,6 +38876,7 @@ def test_get_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -38800,6 +38919,7 @@ def test_list_assets_rest_bad_request(request_type=warehouse.ListAssetsRequest): 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_assets(request) @@ -38835,6 +38955,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -38871,6 +38992,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = warehouse.ListAssetsResponse.to_json( warehouse.ListAssetsResponse() ) @@ -38917,6 +39039,7 @@ def test_delete_asset_rest_bad_request(request_type=warehouse.DeleteAssetRequest 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_asset(request) @@ -38949,6 +39072,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -38986,6 +39110,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): 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 @@ -39030,6 +39155,7 @@ def test_upload_asset_rest_bad_request(request_type=warehouse.UploadAssetRequest 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.upload_asset(request) @@ -39062,6 +39188,7 @@ def test_upload_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.upload_asset(request) # Establish that the response is the type that we expect. @@ -39099,6 +39226,7 @@ def test_upload_asset_rest_interceptors(null_interceptor): 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 @@ -39145,6 +39273,7 @@ def test_generate_retrieval_url_rest_bad_request( 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.generate_retrieval_url(request) @@ -39182,6 +39311,7 @@ def test_generate_retrieval_url_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_retrieval_url(request) # Establish that the response is the type that we expect. @@ -39220,6 +39350,7 @@ def test_generate_retrieval_url_rest_interceptors(null_interceptor): 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 = warehouse.GenerateRetrievalUrlResponse.to_json( warehouse.GenerateRetrievalUrlResponse() ) @@ -39266,6 +39397,7 @@ def test_analyze_asset_rest_bad_request(request_type=warehouse.AnalyzeAssetReque 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.analyze_asset(request) @@ -39298,6 +39430,7 @@ def test_analyze_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.analyze_asset(request) # Establish that the response is the type that we expect. @@ -39335,6 +39468,7 @@ def test_analyze_asset_rest_interceptors(null_interceptor): 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 @@ -39379,6 +39513,7 @@ def test_index_asset_rest_bad_request(request_type=warehouse.IndexAssetRequest): 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.index_asset(request) @@ -39411,6 +39546,7 @@ def test_index_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.index_asset(request) # Establish that the response is the type that we expect. @@ -39448,6 +39584,7 @@ def test_index_asset_rest_interceptors(null_interceptor): 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 @@ -39494,6 +39631,7 @@ def test_remove_index_asset_rest_bad_request( 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.remove_index_asset(request) @@ -39526,6 +39664,7 @@ def test_remove_index_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_index_asset(request) # Establish that the response is the type that we expect. @@ -39565,6 +39704,7 @@ def test_remove_index_asset_rest_interceptors(null_interceptor): 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 @@ -39611,6 +39751,7 @@ def test_view_indexed_assets_rest_bad_request( 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.view_indexed_assets(request) @@ -39648,6 +39789,7 @@ def test_view_indexed_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.view_indexed_assets(request) # Establish that the response is the type that we expect. @@ -39686,6 +39828,7 @@ def test_view_indexed_assets_rest_interceptors(null_interceptor): 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 = warehouse.ViewIndexedAssetsResponse.to_json( warehouse.ViewIndexedAssetsResponse() ) @@ -39730,6 +39873,7 @@ def test_create_index_rest_bad_request(request_type=warehouse.CreateIndexRequest 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_index(request) @@ -39839,6 +39983,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_index(request) # Establish that the response is the type that we expect. @@ -39876,6 +40021,7 @@ def test_create_index_rest_interceptors(null_interceptor): 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 @@ -39922,6 +40068,7 @@ def test_update_index_rest_bad_request(request_type=warehouse.UpdateIndexRequest 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_index(request) @@ -40035,6 +40182,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_index(request) # Establish that the response is the type that we expect. @@ -40072,6 +40220,7 @@ def test_update_index_rest_interceptors(null_interceptor): 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 @@ -40116,6 +40265,7 @@ def test_get_index_rest_bad_request(request_type=warehouse.GetIndexRequest): 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_index(request) @@ -40159,6 +40309,7 @@ def test_get_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_index(request) # Establish that the response is the type that we expect. @@ -40200,6 +40351,7 @@ def test_get_index_rest_interceptors(null_interceptor): 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 = warehouse.Index.to_json(warehouse.Index()) req.return_value.content = return_value @@ -40242,6 +40394,7 @@ def test_list_indexes_rest_bad_request(request_type=warehouse.ListIndexesRequest 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_indexes(request) @@ -40277,6 +40430,7 @@ def test_list_indexes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_indexes(request) # Establish that the response is the type that we expect. @@ -40313,6 +40467,7 @@ def test_list_indexes_rest_interceptors(null_interceptor): 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 = warehouse.ListIndexesResponse.to_json( warehouse.ListIndexesResponse() ) @@ -40359,6 +40514,7 @@ def test_delete_index_rest_bad_request(request_type=warehouse.DeleteIndexRequest 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_index(request) @@ -40391,6 +40547,7 @@ def test_delete_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_index(request) # Establish that the response is the type that we expect. @@ -40428,6 +40585,7 @@ def test_delete_index_rest_interceptors(null_interceptor): 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 @@ -40470,6 +40628,7 @@ def test_create_corpus_rest_bad_request(request_type=warehouse.CreateCorpusReque 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_corpus(request) @@ -40577,6 +40736,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -40614,6 +40774,7 @@ def test_create_corpus_rest_interceptors(null_interceptor): 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 @@ -40656,6 +40817,7 @@ def test_get_corpus_rest_bad_request(request_type=warehouse.GetCorpusRequest): 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_corpus(request) @@ -40696,6 +40858,7 @@ def test_get_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -40737,6 +40900,7 @@ def test_get_corpus_rest_interceptors(null_interceptor): 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 = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -40781,6 +40945,7 @@ def test_update_corpus_rest_bad_request(request_type=warehouse.UpdateCorpusReque 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_corpus(request) @@ -40900,6 +41065,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -40941,6 +41107,7 @@ def test_update_corpus_rest_interceptors(null_interceptor): 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 = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -40983,6 +41150,7 @@ def test_list_corpora_rest_bad_request(request_type=warehouse.ListCorporaRequest 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_corpora(request) @@ -41018,6 +41186,7 @@ def test_list_corpora_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpora(request) # Establish that the response is the type that we expect. @@ -41054,6 +41223,7 @@ def test_list_corpora_rest_interceptors(null_interceptor): 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 = warehouse.ListCorporaResponse.to_json( warehouse.ListCorporaResponse() ) @@ -41098,6 +41268,7 @@ def test_delete_corpus_rest_bad_request(request_type=warehouse.DeleteCorpusReque 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_corpus(request) @@ -41128,6 +41299,7 @@ def test_delete_corpus_rest_call_success(request_type): 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_corpus(request) # Establish that the response is the type that we expect. @@ -41160,6 +41332,7 @@ def test_delete_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteCorpusRequest() metadata = [ @@ -41198,6 +41371,7 @@ def test_analyze_corpus_rest_bad_request(request_type=warehouse.AnalyzeCorpusReq 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.analyze_corpus(request) @@ -41228,6 +41402,7 @@ def test_analyze_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.analyze_corpus(request) # Establish that the response is the type that we expect. @@ -41265,6 +41440,7 @@ def test_analyze_corpus_rest_interceptors(null_interceptor): 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 @@ -41309,6 +41485,7 @@ def test_create_data_schema_rest_bad_request( 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_data_schema(request) @@ -41430,6 +41607,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -41469,6 +41647,7 @@ def test_create_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41517,6 +41696,7 @@ def test_update_data_schema_rest_bad_request( 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_data_schema(request) @@ -41642,6 +41822,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -41681,6 +41862,7 @@ def test_update_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41725,6 +41907,7 @@ def test_get_data_schema_rest_bad_request(request_type=warehouse.GetDataSchemaRe 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_data_schema(request) @@ -41763,6 +41946,7 @@ def test_get_data_schema_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -41800,6 +41984,7 @@ def test_get_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -41846,6 +42031,7 @@ def test_delete_data_schema_rest_bad_request( 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_data_schema(request) @@ -41878,6 +42064,7 @@ def test_delete_data_schema_rest_call_success(request_type): 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_data_schema(request) # Establish that the response is the type that we expect. @@ -41912,6 +42099,7 @@ def test_delete_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteDataSchemaRequest() metadata = [ @@ -41952,6 +42140,7 @@ def test_list_data_schemas_rest_bad_request( 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_data_schemas(request) @@ -41987,6 +42176,7 @@ def test_list_data_schemas_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schemas(request) # Establish that the response is the type that we expect. @@ -42025,6 +42215,7 @@ def test_list_data_schemas_rest_interceptors(null_interceptor): 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 = warehouse.ListDataSchemasResponse.to_json( warehouse.ListDataSchemasResponse() ) @@ -42073,6 +42264,7 @@ def test_create_annotation_rest_bad_request( 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_annotation(request) @@ -42214,6 +42406,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -42252,6 +42445,7 @@ def test_create_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42296,6 +42490,7 @@ def test_get_annotation_rest_bad_request(request_type=warehouse.GetAnnotationReq 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_annotation(request) @@ -42333,6 +42528,7 @@ def test_get_annotation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -42369,6 +42565,7 @@ def test_get_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42415,6 +42612,7 @@ def test_list_annotations_rest_bad_request( 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_annotations(request) @@ -42452,6 +42650,7 @@ def test_list_annotations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotations(request) # Establish that the response is the type that we expect. @@ -42490,6 +42689,7 @@ def test_list_annotations_rest_interceptors(null_interceptor): 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 = warehouse.ListAnnotationsResponse.to_json( warehouse.ListAnnotationsResponse() ) @@ -42540,6 +42740,7 @@ def test_update_annotation_rest_bad_request( 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_annotation(request) @@ -42683,6 +42884,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -42721,6 +42923,7 @@ def test_update_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -42767,6 +42970,7 @@ def test_delete_annotation_rest_bad_request( 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_annotation(request) @@ -42799,6 +43003,7 @@ def test_delete_annotation_rest_call_success(request_type): 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_annotation(request) # Establish that the response is the type that we expect. @@ -42833,6 +43038,7 @@ def test_delete_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteAnnotationRequest() metadata = [ @@ -42885,6 +43091,7 @@ def test_clip_asset_rest_bad_request(request_type=warehouse.ClipAssetRequest): 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.clip_asset(request) @@ -42920,6 +43127,7 @@ def test_clip_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.clip_asset(request) # Establish that the response is the type that we expect. @@ -42955,6 +43163,7 @@ def test_clip_asset_rest_interceptors(null_interceptor): 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 = warehouse.ClipAssetResponse.to_json( warehouse.ClipAssetResponse() ) @@ -43003,6 +43212,7 @@ def test_generate_hls_uri_rest_bad_request( 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.generate_hls_uri(request) @@ -43040,6 +43250,7 @@ def test_generate_hls_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_hls_uri(request) # Establish that the response is the type that we expect. @@ -43078,6 +43289,7 @@ def test_generate_hls_uri_rest_interceptors(null_interceptor): 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 = warehouse.GenerateHlsUriResponse.to_json( warehouse.GenerateHlsUriResponse() ) @@ -43122,6 +43334,7 @@ def test_import_assets_rest_bad_request(request_type=warehouse.ImportAssetsReque 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.import_assets(request) @@ -43152,6 +43365,7 @@ def test_import_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_assets(request) # Establish that the response is the type that we expect. @@ -43189,6 +43403,7 @@ def test_import_assets_rest_interceptors(null_interceptor): 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 @@ -43233,6 +43448,7 @@ def test_create_search_config_rest_bad_request( 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_search_config(request) @@ -43368,6 +43584,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -43406,6 +43623,7 @@ def test_create_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43454,6 +43672,7 @@ def test_update_search_config_rest_bad_request( 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_search_config(request) @@ -43593,6 +43812,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -43631,6 +43851,7 @@ def test_update_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43677,6 +43898,7 @@ def test_get_search_config_rest_bad_request( 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_search_config(request) @@ -43714,6 +43936,7 @@ def test_get_search_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -43752,6 +43975,7 @@ def test_get_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -43798,6 +44022,7 @@ def test_delete_search_config_rest_bad_request( 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_search_config(request) @@ -43830,6 +44055,7 @@ def test_delete_search_config_rest_call_success(request_type): 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_search_config(request) # Establish that the response is the type that we expect. @@ -43864,6 +44090,7 @@ def test_delete_search_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteSearchConfigRequest() metadata = [ @@ -43904,6 +44131,7 @@ def test_list_search_configs_rest_bad_request( 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_search_configs(request) @@ -43939,6 +44167,7 @@ def test_list_search_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_configs(request) # Establish that the response is the type that we expect. @@ -43977,6 +44206,7 @@ def test_list_search_configs_rest_interceptors(null_interceptor): 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 = warehouse.ListSearchConfigsResponse.to_json( warehouse.ListSearchConfigsResponse() ) @@ -44023,6 +44253,7 @@ def test_create_search_hypernym_rest_bad_request( 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_search_hypernym(request) @@ -44132,6 +44363,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44172,6 +44404,7 @@ def test_create_search_hypernym_rest_interceptors(null_interceptor): 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 = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44220,6 +44453,7 @@ def test_update_search_hypernym_rest_bad_request( 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_search_hypernym(request) @@ -44333,6 +44567,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44373,6 +44608,7 @@ def test_update_search_hypernym_rest_interceptors(null_interceptor): 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 = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44419,6 +44655,7 @@ def test_get_search_hypernym_rest_bad_request( 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_search_hypernym(request) @@ -44458,6 +44695,7 @@ def test_get_search_hypernym_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44498,6 +44736,7 @@ def test_get_search_hypernym_rest_interceptors(null_interceptor): 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 = warehouse.SearchHypernym.to_json(warehouse.SearchHypernym()) req.return_value.content = return_value @@ -44544,6 +44783,7 @@ def test_delete_search_hypernym_rest_bad_request( 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_search_hypernym(request) @@ -44576,6 +44816,7 @@ def test_delete_search_hypernym_rest_call_success(request_type): 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_search_hypernym(request) # Establish that the response is the type that we expect. @@ -44610,6 +44851,7 @@ def test_delete_search_hypernym_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteSearchHypernymRequest() metadata = [ @@ -44650,6 +44892,7 @@ def test_list_search_hypernyms_rest_bad_request( 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_search_hypernyms(request) @@ -44685,6 +44928,7 @@ def test_list_search_hypernyms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_hypernyms(request) # Establish that the response is the type that we expect. @@ -44723,6 +44967,7 @@ def test_list_search_hypernyms_rest_interceptors(null_interceptor): 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 = warehouse.ListSearchHypernymsResponse.to_json( warehouse.ListSearchHypernymsResponse() ) @@ -44767,6 +45012,7 @@ def test_search_assets_rest_bad_request(request_type=warehouse.SearchAssetsReque 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.search_assets(request) @@ -44802,6 +45048,7 @@ def test_search_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_assets(request) # Establish that the response is the type that we expect. @@ -44838,6 +45085,7 @@ def test_search_assets_rest_interceptors(null_interceptor): 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 = warehouse.SearchAssetsResponse.to_json( warehouse.SearchAssetsResponse() ) @@ -44886,6 +45134,7 @@ def test_search_index_endpoint_rest_bad_request( 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.search_index_endpoint(request) @@ -44923,6 +45172,7 @@ def test_search_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_index_endpoint(request) # Establish that the response is the type that we expect. @@ -44961,6 +45211,7 @@ def test_search_index_endpoint_rest_interceptors(null_interceptor): 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 = warehouse.SearchIndexEndpointResponse.to_json( warehouse.SearchIndexEndpointResponse() ) @@ -45007,6 +45258,7 @@ def test_create_index_endpoint_rest_bad_request( 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_index_endpoint(request) @@ -45116,6 +45368,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45155,6 +45408,7 @@ def test_create_index_endpoint_rest_interceptors(null_interceptor): 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 @@ -45199,6 +45453,7 @@ def test_get_index_endpoint_rest_bad_request( 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_index_endpoint(request) @@ -45239,6 +45494,7 @@ def test_get_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45282,6 +45538,7 @@ def test_get_index_endpoint_rest_interceptors(null_interceptor): 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 = warehouse.IndexEndpoint.to_json(warehouse.IndexEndpoint()) req.return_value.content = return_value @@ -45326,6 +45583,7 @@ def test_list_index_endpoints_rest_bad_request( 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_index_endpoints(request) @@ -45361,6 +45619,7 @@ def test_list_index_endpoints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_index_endpoints(request) # Establish that the response is the type that we expect. @@ -45399,6 +45658,7 @@ def test_list_index_endpoints_rest_interceptors(null_interceptor): 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 = warehouse.ListIndexEndpointsResponse.to_json( warehouse.ListIndexEndpointsResponse() ) @@ -45449,6 +45709,7 @@ def test_update_index_endpoint_rest_bad_request( 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_index_endpoint(request) @@ -45562,6 +45823,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45601,6 +45863,7 @@ def test_update_index_endpoint_rest_interceptors(null_interceptor): 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 @@ -45645,6 +45908,7 @@ def test_delete_index_endpoint_rest_bad_request( 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_index_endpoint(request) @@ -45675,6 +45939,7 @@ def test_delete_index_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_index_endpoint(request) # Establish that the response is the type that we expect. @@ -45714,6 +45979,7 @@ def test_delete_index_endpoint_rest_interceptors(null_interceptor): 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 @@ -45758,6 +46024,7 @@ def test_deploy_index_rest_bad_request(request_type=warehouse.DeployIndexRequest 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.deploy_index(request) @@ -45790,6 +46057,7 @@ def test_deploy_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.deploy_index(request) # Establish that the response is the type that we expect. @@ -45827,6 +46095,7 @@ def test_deploy_index_rest_interceptors(null_interceptor): 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 @@ -45871,6 +46140,7 @@ def test_undeploy_index_rest_bad_request(request_type=warehouse.UndeployIndexReq 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.undeploy_index(request) @@ -45903,6 +46173,7 @@ def test_undeploy_index_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undeploy_index(request) # Establish that the response is the type that we expect. @@ -45940,6 +46211,7 @@ def test_undeploy_index_rest_interceptors(null_interceptor): 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 @@ -45984,6 +46256,7 @@ def test_create_collection_rest_bad_request( 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_collection(request) @@ -46086,6 +46359,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_collection(request) # Establish that the response is the type that we expect. @@ -46125,6 +46399,7 @@ def test_create_collection_rest_interceptors(null_interceptor): 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 @@ -46171,6 +46446,7 @@ def test_delete_collection_rest_bad_request( 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_collection(request) @@ -46203,6 +46479,7 @@ def test_delete_collection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collection(request) # Establish that the response is the type that we expect. @@ -46242,6 +46519,7 @@ def test_delete_collection_rest_interceptors(null_interceptor): 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 @@ -46286,6 +46564,7 @@ def test_get_collection_rest_bad_request(request_type=warehouse.GetCollectionReq 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_collection(request) @@ -46325,6 +46604,7 @@ def test_get_collection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collection(request) # Establish that the response is the type that we expect. @@ -46363,6 +46643,7 @@ def test_get_collection_rest_interceptors(null_interceptor): 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 = warehouse.Collection.to_json(warehouse.Collection()) req.return_value.content = return_value @@ -46411,6 +46692,7 @@ def test_update_collection_rest_bad_request( 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_collection(request) @@ -46524,6 +46806,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_collection(request) # Establish that the response is the type that we expect. @@ -46564,6 +46847,7 @@ def test_update_collection_rest_interceptors(null_interceptor): 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 = warehouse.Collection.to_json(warehouse.Collection()) req.return_value.content = return_value @@ -46608,6 +46892,7 @@ def test_list_collections_rest_bad_request( 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_collections(request) @@ -46643,6 +46928,7 @@ def test_list_collections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collections(request) # Establish that the response is the type that we expect. @@ -46681,6 +46967,7 @@ def test_list_collections_rest_interceptors(null_interceptor): 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 = warehouse.ListCollectionsResponse.to_json( warehouse.ListCollectionsResponse() ) @@ -46731,6 +47018,7 @@ def test_add_collection_item_rest_bad_request( 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.add_collection_item(request) @@ -46768,6 +47056,7 @@ def test_add_collection_item_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_collection_item(request) # Establish that the response is the type that we expect. @@ -46805,6 +47094,7 @@ def test_add_collection_item_rest_interceptors(null_interceptor): 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 = warehouse.AddCollectionItemResponse.to_json( warehouse.AddCollectionItemResponse() ) @@ -46855,6 +47145,7 @@ def test_remove_collection_item_rest_bad_request( 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.remove_collection_item(request) @@ -46892,6 +47183,7 @@ def test_remove_collection_item_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_collection_item(request) # Establish that the response is the type that we expect. @@ -46929,6 +47221,7 @@ def test_remove_collection_item_rest_interceptors(null_interceptor): 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 = warehouse.RemoveCollectionItemResponse.to_json( warehouse.RemoveCollectionItemResponse() ) @@ -46977,6 +47270,7 @@ def test_view_collection_items_rest_bad_request( 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.view_collection_items(request) @@ -47014,6 +47308,7 @@ def test_view_collection_items_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.view_collection_items(request) # Establish that the response is the type that we expect. @@ -47052,6 +47347,7 @@ def test_view_collection_items_rest_interceptors(null_interceptor): 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 = warehouse.ViewCollectionItemsResponse.to_json( warehouse.ViewCollectionItemsResponse() ) @@ -47100,6 +47396,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -47130,6 +47427,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -47160,6 +47458,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -47190,6 +47489,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -47220,6 +47520,7 @@ def test_get_operation_rest_bad_request( 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) @@ -47250,6 +47551,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -47280,6 +47582,7 @@ def test_list_operations_rest_bad_request( 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) @@ -47310,6 +47613,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py index 77864a31401b..8eaf46dc641f 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_app_platform.py @@ -10895,6 +10895,7 @@ def test_list_applications_rest_required_fields( response_value._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_applications(request) @@ -10950,6 +10951,7 @@ def test_list_applications_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_applications(**mock_args) @@ -11142,6 +11144,7 @@ def test_get_application_rest_required_fields( response_value._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_application(request) @@ -11189,6 +11192,7 @@ def test_get_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11340,6 +11344,7 @@ def test_create_application_rest_required_fields( response_value._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_application(request) @@ -11404,6 +11409,7 @@ def test_create_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11544,6 +11550,7 @@ def test_update_application_rest_required_fields( response_value._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_application(request) @@ -11600,6 +11607,7 @@ def test_update_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11744,6 +11752,7 @@ def test_delete_application_rest_required_fields( response_value._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_application(request) @@ -11797,6 +11806,7 @@ def test_delete_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application(**mock_args) @@ -11934,6 +11944,7 @@ def test_deploy_application_rest_required_fields( response_value._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.deploy_application(request) @@ -11979,6 +11990,7 @@ def test_deploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.deploy_application(**mock_args) @@ -12116,6 +12128,7 @@ def test_undeploy_application_rest_required_fields( response_value._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.undeploy_application(request) @@ -12161,6 +12174,7 @@ def test_undeploy_application_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undeploy_application(**mock_args) @@ -12299,6 +12313,7 @@ def test_add_application_stream_input_rest_required_fields( response_value._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.add_application_stream_input(request) @@ -12344,6 +12359,7 @@ def test_add_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_application_stream_input(**mock_args) @@ -12482,6 +12498,7 @@ def test_remove_application_stream_input_rest_required_fields( response_value._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.remove_application_stream_input(request) @@ -12529,6 +12546,7 @@ def test_remove_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_application_stream_input(**mock_args) @@ -12667,6 +12685,7 @@ def test_update_application_stream_input_rest_required_fields( response_value._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_application_stream_input(request) @@ -12714,6 +12733,7 @@ def test_update_application_stream_input_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_stream_input(**mock_args) @@ -12854,6 +12874,7 @@ def test_list_instances_rest_required_fields( response_value._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_instances(request) @@ -12911,6 +12932,7 @@ def test_list_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instances(**mock_args) @@ -13103,6 +13125,7 @@ def test_get_instance_rest_required_fields(request_type=platform.GetInstanceRequ response_value._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_instance(request) @@ -13150,6 +13173,7 @@ def test_get_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -13288,6 +13312,7 @@ def test_create_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13341,6 +13366,7 @@ def test_create_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13483,6 +13509,7 @@ def test_delete_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13536,6 +13563,7 @@ def test_delete_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13674,6 +13702,7 @@ def test_update_application_instances_rest_required_fields( response_value._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_application_instances(request) @@ -13724,6 +13753,7 @@ def test_update_application_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_application_instances(**mock_args) @@ -13867,6 +13897,7 @@ def test_list_drafts_rest_required_fields(request_type=platform.ListDraftsReques response_value._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_drafts(request) @@ -13924,6 +13955,7 @@ def test_list_drafts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_drafts(**mock_args) @@ -14116,6 +14148,7 @@ def test_get_draft_rest_required_fields(request_type=platform.GetDraftRequest): response_value._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_draft(request) @@ -14163,6 +14196,7 @@ def test_get_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14308,6 +14342,7 @@ def test_create_draft_rest_required_fields(request_type=platform.CreateDraftRequ response_value._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_draft(request) @@ -14375,6 +14410,7 @@ def test_create_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14511,6 +14547,7 @@ def test_update_draft_rest_required_fields(request_type=platform.UpdateDraftRequ response_value._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_draft(request) @@ -14568,6 +14605,7 @@ def test_update_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14701,6 +14739,7 @@ def test_delete_draft_rest_required_fields(request_type=platform.DeleteDraftRequ response_value._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_draft(request) @@ -14746,6 +14785,7 @@ def test_delete_draft_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_draft(**mock_args) @@ -14886,6 +14926,7 @@ def test_list_processors_rest_required_fields( response_value._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_processors(request) @@ -14941,6 +14982,7 @@ def test_list_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processors(**mock_args) @@ -15139,6 +15181,7 @@ def test_list_prebuilt_processors_rest_required_fields( response_value._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_prebuilt_processors(request) @@ -15184,6 +15227,7 @@ def test_list_prebuilt_processors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_prebuilt_processors(**mock_args) @@ -15313,6 +15357,7 @@ def test_get_processor_rest_required_fields(request_type=platform.GetProcessorRe response_value._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_processor(request) @@ -15360,6 +15405,7 @@ def test_get_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15509,6 +15555,7 @@ def test_create_processor_rest_required_fields( response_value._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_processor(request) @@ -15574,6 +15621,7 @@ def test_create_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15713,6 +15761,7 @@ def test_update_processor_rest_required_fields( response_value._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_processor(request) @@ -15769,6 +15818,7 @@ def test_update_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -15906,6 +15956,7 @@ def test_delete_processor_rest_required_fields( response_value._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_processor(request) @@ -15951,6 +16002,7 @@ def test_delete_processor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_processor(**mock_args) @@ -17414,6 +17466,7 @@ def test_list_applications_rest_bad_request( 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_applications(request) @@ -17450,6 +17503,7 @@ def test_list_applications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_applications(request) # Establish that the response is the type that we expect. @@ -17491,6 +17545,7 @@ def test_list_applications_rest_interceptors(null_interceptor): 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 = platform.ListApplicationsResponse.to_json( platform.ListApplicationsResponse() ) @@ -17535,6 +17590,7 @@ def test_get_application_rest_bad_request(request_type=platform.GetApplicationRe 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_application(request) @@ -17573,6 +17629,7 @@ def test_get_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -17614,6 +17671,7 @@ def test_get_application_rest_interceptors(null_interceptor): 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 = platform.Application.to_json(platform.Application()) req.return_value.content = return_value @@ -17658,6 +17716,7 @@ def test_create_application_rest_bad_request( 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_application(request) @@ -17885,6 +17944,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -17926,6 +17986,7 @@ def test_create_application_rest_interceptors(null_interceptor): 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 @@ -17974,6 +18035,7 @@ def test_update_application_rest_bad_request( 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_application(request) @@ -18205,6 +18267,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -18246,6 +18309,7 @@ def test_update_application_rest_interceptors(null_interceptor): 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 @@ -18290,6 +18354,7 @@ def test_delete_application_rest_bad_request( 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_application(request) @@ -18320,6 +18385,7 @@ def test_delete_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application(request) # Establish that the response is the type that we expect. @@ -18361,6 +18427,7 @@ def test_delete_application_rest_interceptors(null_interceptor): 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 @@ -18405,6 +18472,7 @@ def test_deploy_application_rest_bad_request( 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.deploy_application(request) @@ -18435,6 +18503,7 @@ def test_deploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.deploy_application(request) # Establish that the response is the type that we expect. @@ -18476,6 +18545,7 @@ def test_deploy_application_rest_interceptors(null_interceptor): 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 @@ -18520,6 +18590,7 @@ def test_undeploy_application_rest_bad_request( 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.undeploy_application(request) @@ -18550,6 +18621,7 @@ def test_undeploy_application_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undeploy_application(request) # Establish that the response is the type that we expect. @@ -18591,6 +18663,7 @@ def test_undeploy_application_rest_interceptors(null_interceptor): 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 @@ -18635,6 +18708,7 @@ def test_add_application_stream_input_rest_bad_request( 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.add_application_stream_input(request) @@ -18665,6 +18739,7 @@ def test_add_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18706,6 +18781,7 @@ def test_add_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -18750,6 +18826,7 @@ def test_remove_application_stream_input_rest_bad_request( 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.remove_application_stream_input(request) @@ -18780,6 +18857,7 @@ def test_remove_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18821,6 +18899,7 @@ def test_remove_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -18865,6 +18944,7 @@ def test_update_application_stream_input_rest_bad_request( 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_application_stream_input(request) @@ -18895,6 +18975,7 @@ def test_update_application_stream_input_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_stream_input(request) # Establish that the response is the type that we expect. @@ -18936,6 +19017,7 @@ def test_update_application_stream_input_rest_interceptors(null_interceptor): 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 @@ -18978,6 +19060,7 @@ def test_list_instances_rest_bad_request(request_type=platform.ListInstancesRequ 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_instances(request) @@ -19014,6 +19097,7 @@ def test_list_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instances(request) # Establish that the response is the type that we expect. @@ -19053,6 +19137,7 @@ def test_list_instances_rest_interceptors(null_interceptor): 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 = platform.ListInstancesResponse.to_json( platform.ListInstancesResponse() ) @@ -19099,6 +19184,7 @@ def test_get_instance_rest_bad_request(request_type=platform.GetInstanceRequest) 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_instance(request) @@ -19139,6 +19225,7 @@ def test_get_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -19180,6 +19267,7 @@ def test_get_instance_rest_interceptors(null_interceptor): 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 = platform.Instance.to_json(platform.Instance()) req.return_value.content = return_value @@ -19224,6 +19312,7 @@ def test_create_application_instances_rest_bad_request( 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_application_instances(request) @@ -19254,6 +19343,7 @@ def test_create_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19295,6 +19385,7 @@ def test_create_application_instances_rest_interceptors(null_interceptor): 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 @@ -19339,6 +19430,7 @@ def test_delete_application_instances_rest_bad_request( 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_application_instances(request) @@ -19369,6 +19461,7 @@ def test_delete_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19410,6 +19503,7 @@ def test_delete_application_instances_rest_interceptors(null_interceptor): 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 @@ -19454,6 +19548,7 @@ def test_update_application_instances_rest_bad_request( 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_application_instances(request) @@ -19484,6 +19579,7 @@ def test_update_application_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_application_instances(request) # Establish that the response is the type that we expect. @@ -19525,6 +19621,7 @@ def test_update_application_instances_rest_interceptors(null_interceptor): 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 @@ -19567,6 +19664,7 @@ def test_list_drafts_rest_bad_request(request_type=platform.ListDraftsRequest): 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_drafts(request) @@ -19603,6 +19701,7 @@ def test_list_drafts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_drafts(request) # Establish that the response is the type that we expect. @@ -19642,6 +19741,7 @@ def test_list_drafts_rest_interceptors(null_interceptor): 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 = platform.ListDraftsResponse.to_json( platform.ListDraftsResponse() ) @@ -19688,6 +19788,7 @@ def test_get_draft_rest_bad_request(request_type=platform.GetDraftRequest): 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_draft(request) @@ -19727,6 +19828,7 @@ def test_get_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -19767,6 +19869,7 @@ def test_get_draft_rest_interceptors(null_interceptor): 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 = platform.Draft.to_json(platform.Draft()) req.return_value.content = return_value @@ -19809,6 +19912,7 @@ def test_create_draft_rest_bad_request(request_type=platform.CreateDraftRequest) 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_draft(request) @@ -20024,6 +20128,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20063,6 +20168,7 @@ def test_create_draft_rest_interceptors(null_interceptor): 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 @@ -20109,6 +20215,7 @@ def test_update_draft_rest_bad_request(request_type=platform.UpdateDraftRequest) 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_draft(request) @@ -20328,6 +20435,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20367,6 +20475,7 @@ def test_update_draft_rest_interceptors(null_interceptor): 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 @@ -20411,6 +20520,7 @@ def test_delete_draft_rest_bad_request(request_type=platform.DeleteDraftRequest) 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_draft(request) @@ -20443,6 +20553,7 @@ def test_delete_draft_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_draft(request) # Establish that the response is the type that we expect. @@ -20482,6 +20593,7 @@ def test_delete_draft_rest_interceptors(null_interceptor): 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 @@ -20524,6 +20636,7 @@ def test_list_processors_rest_bad_request(request_type=platform.ListProcessorsRe 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_processors(request) @@ -20560,6 +20673,7 @@ def test_list_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processors(request) # Establish that the response is the type that we expect. @@ -20599,6 +20713,7 @@ def test_list_processors_rest_interceptors(null_interceptor): 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 = platform.ListProcessorsResponse.to_json( platform.ListProcessorsResponse() ) @@ -20645,6 +20760,7 @@ def test_list_prebuilt_processors_rest_bad_request( 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_prebuilt_processors(request) @@ -20678,6 +20794,7 @@ def test_list_prebuilt_processors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_prebuilt_processors(request) # Establish that the response is the type that we expect. @@ -20717,6 +20834,7 @@ def test_list_prebuilt_processors_rest_interceptors(null_interceptor): 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 = platform.ListPrebuiltProcessorsResponse.to_json( platform.ListPrebuiltProcessorsResponse() ) @@ -20761,6 +20879,7 @@ def test_get_processor_rest_bad_request(request_type=platform.GetProcessorReques 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_processor(request) @@ -20806,6 +20925,7 @@ def test_get_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -20854,6 +20974,7 @@ def test_get_processor_rest_interceptors(null_interceptor): 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 = platform.Processor.to_json(platform.Processor()) req.return_value.content = return_value @@ -20898,6 +21019,7 @@ def test_create_processor_rest_bad_request( 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_processor(request) @@ -21054,6 +21176,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21095,6 +21218,7 @@ def test_create_processor_rest_interceptors(null_interceptor): 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 @@ -21141,6 +21265,7 @@ def test_update_processor_rest_bad_request( 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_processor(request) @@ -21299,6 +21424,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21340,6 +21466,7 @@ def test_update_processor_rest_interceptors(null_interceptor): 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 @@ -21384,6 +21511,7 @@ def test_delete_processor_rest_bad_request( 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_processor(request) @@ -21414,6 +21542,7 @@ def test_delete_processor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_processor(request) # Establish that the response is the type that we expect. @@ -21455,6 +21584,7 @@ def test_delete_processor_rest_interceptors(null_interceptor): 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 @@ -21499,6 +21629,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -21529,6 +21660,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -21557,6 +21689,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -21587,6 +21720,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -21617,6 +21751,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -21647,6 +21782,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -21677,6 +21813,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -21707,6 +21844,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -21737,6 +21875,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -21767,6 +21906,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -21797,6 +21937,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -21827,6 +21968,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -21857,6 +21999,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -21887,6 +22030,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -21917,6 +22061,7 @@ def test_get_operation_rest_bad_request( 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) @@ -21947,6 +22092,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -21977,6 +22123,7 @@ def test_list_operations_rest_bad_request( 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) @@ -22007,6 +22154,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py index 8a600b491bca..55b59f6ba866 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_live_video_analytics.py @@ -3097,6 +3097,7 @@ def test_list_analyses_rest_required_fields( response_value._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_analyses(request) @@ -3154,6 +3155,7 @@ def test_list_analyses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analyses(**mock_args) @@ -3346,6 +3348,7 @@ def test_get_analysis_rest_required_fields(request_type=lva_service.GetAnalysisR response_value._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_analysis(request) @@ -3393,6 +3396,7 @@ def test_get_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -3540,6 +3544,7 @@ def test_create_analysis_rest_required_fields( response_value._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_analysis(request) @@ -3607,6 +3612,7 @@ def test_create_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -3744,6 +3750,7 @@ def test_update_analysis_rest_required_fields( response_value._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_analysis(request) @@ -3805,6 +3812,7 @@ def test_update_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -3940,6 +3948,7 @@ def test_delete_analysis_rest_required_fields( response_value._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_analysis(request) @@ -3985,6 +3994,7 @@ def test_delete_analysis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_analysis(**mock_args) @@ -4395,6 +4405,7 @@ def test_list_analyses_rest_bad_request(request_type=lva_service.ListAnalysesReq 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_analyses(request) @@ -4431,6 +4442,7 @@ def test_list_analyses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analyses(request) # Establish that the response is the type that we expect. @@ -4472,6 +4484,7 @@ def test_list_analyses_rest_interceptors(null_interceptor): 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 = lva_service.ListAnalysesResponse.to_json( lva_service.ListAnalysesResponse() ) @@ -4518,6 +4531,7 @@ def test_get_analysis_rest_bad_request(request_type=lva_service.GetAnalysisReque 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_analysis(request) @@ -4555,6 +4569,7 @@ def test_get_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -4593,6 +4608,7 @@ def test_get_analysis_rest_interceptors(null_interceptor): 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 = lva_resources.Analysis.to_json(lva_resources.Analysis()) req.return_value.content = return_value @@ -4637,6 +4653,7 @@ def test_create_analysis_rest_bad_request( 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_analysis(request) @@ -4753,6 +4770,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -4794,6 +4812,7 @@ def test_create_analysis_rest_interceptors(null_interceptor): 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 @@ -4842,6 +4861,7 @@ def test_update_analysis_rest_bad_request( 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_analysis(request) @@ -4962,6 +4982,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -5003,6 +5024,7 @@ def test_update_analysis_rest_interceptors(null_interceptor): 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 @@ -5049,6 +5071,7 @@ def test_delete_analysis_rest_bad_request( 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_analysis(request) @@ -5081,6 +5104,7 @@ def test_delete_analysis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_analysis(request) # Establish that the response is the type that we expect. @@ -5122,6 +5146,7 @@ def test_delete_analysis_rest_interceptors(null_interceptor): 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 @@ -5166,6 +5191,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -5196,6 +5222,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -5224,6 +5251,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -5254,6 +5282,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -5284,6 +5313,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -5314,6 +5344,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -5344,6 +5375,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -5374,6 +5406,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -5404,6 +5437,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -5434,6 +5468,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -5464,6 +5499,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -5494,6 +5530,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -5524,6 +5561,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -5554,6 +5592,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -5584,6 +5623,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5614,6 +5654,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5644,6 +5685,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5674,6 +5716,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py index ac651edcc7bd..df8edcc41a1f 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streaming_service.py @@ -2810,6 +2810,7 @@ def test_acquire_lease_rest_bad_request( 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.acquire_lease(request) @@ -2850,6 +2851,7 @@ def test_acquire_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.acquire_lease(request) # Establish that the response is the type that we expect. @@ -2893,6 +2895,7 @@ def test_acquire_lease_rest_interceptors(null_interceptor): 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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -2937,6 +2940,7 @@ def test_renew_lease_rest_bad_request(request_type=streaming_service.RenewLeaseR 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.renew_lease(request) @@ -2977,6 +2981,7 @@ def test_renew_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.renew_lease(request) # Establish that the response is the type that we expect. @@ -3020,6 +3025,7 @@ def test_renew_lease_rest_interceptors(null_interceptor): 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 = streaming_service.Lease.to_json(streaming_service.Lease()) req.return_value.content = return_value @@ -3066,6 +3072,7 @@ def test_release_lease_rest_bad_request( 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.release_lease(request) @@ -3101,6 +3108,7 @@ def test_release_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.release_lease(request) # Establish that the response is the type that we expect. @@ -3140,6 +3148,7 @@ def test_release_lease_rest_interceptors(null_interceptor): 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 = streaming_service.ReleaseLeaseResponse.to_json( streaming_service.ReleaseLeaseResponse() ) @@ -3186,6 +3195,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -3216,6 +3226,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -3244,6 +3255,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -3274,6 +3286,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -3304,6 +3317,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -3334,6 +3348,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -3364,6 +3379,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -3394,6 +3410,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -3424,6 +3441,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -3454,6 +3472,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -3484,6 +3503,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -3514,6 +3534,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -3544,6 +3565,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -3574,6 +3596,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -3604,6 +3627,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3634,6 +3658,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -3664,6 +3689,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3694,6 +3720,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py index cf5b594e35b5..0d9ea2219caf 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_streams_service.py @@ -9400,6 +9400,7 @@ def test_list_clusters_rest_required_fields( response_value._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_clusters(request) @@ -9455,6 +9456,7 @@ def test_list_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clusters(**mock_args) @@ -9649,6 +9651,7 @@ def test_get_cluster_rest_required_fields( response_value._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_cluster(request) @@ -9694,6 +9697,7 @@ def test_get_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -9841,6 +9845,7 @@ def test_create_cluster_rest_required_fields( response_value._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_cluster(request) @@ -9906,6 +9911,7 @@ def test_create_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10043,6 +10049,7 @@ def test_update_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10102,6 +10109,7 @@ def test_update_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10237,6 +10245,7 @@ def test_delete_cluster_rest_required_fields( response_value._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_cluster(request) @@ -10280,6 +10289,7 @@ def test_delete_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -10420,6 +10430,7 @@ def test_list_streams_rest_required_fields( response_value._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_streams(request) @@ -10477,6 +10488,7 @@ def test_list_streams_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_streams(**mock_args) @@ -10671,6 +10683,7 @@ def test_get_stream_rest_required_fields(request_type=streams_service.GetStreamR response_value._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_stream(request) @@ -10718,6 +10731,7 @@ def test_get_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -10865,6 +10879,7 @@ def test_create_stream_rest_required_fields( response_value._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_stream(request) @@ -10932,6 +10947,7 @@ def test_create_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11069,6 +11085,7 @@ def test_update_stream_rest_required_fields( response_value._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_stream(request) @@ -11130,6 +11147,7 @@ def test_update_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11265,6 +11283,7 @@ def test_delete_stream_rest_required_fields( response_value._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_stream(request) @@ -11310,6 +11329,7 @@ def test_delete_stream_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_stream(**mock_args) @@ -11449,6 +11469,7 @@ def test_generate_stream_hls_token_rest_required_fields( response_value._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.generate_stream_hls_token(request) @@ -11496,6 +11517,7 @@ def test_generate_stream_hls_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.generate_stream_hls_token(**mock_args) @@ -11636,6 +11658,7 @@ def test_list_events_rest_required_fields( response_value._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_events(request) @@ -11693,6 +11716,7 @@ def test_list_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_events(**mock_args) @@ -11887,6 +11911,7 @@ def test_get_event_rest_required_fields(request_type=streams_service.GetEventReq response_value._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_event(request) @@ -11934,6 +11959,7 @@ def test_get_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12081,6 +12107,7 @@ def test_create_event_rest_required_fields( response_value._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_event(request) @@ -12148,6 +12175,7 @@ def test_create_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12285,6 +12313,7 @@ def test_update_event_rest_required_fields( response_value._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_event(request) @@ -12346,6 +12375,7 @@ def test_update_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12481,6 +12511,7 @@ def test_delete_event_rest_required_fields( response_value._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_event(request) @@ -12526,6 +12557,7 @@ def test_delete_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -12666,6 +12698,7 @@ def test_list_series_rest_required_fields( response_value._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_series(request) @@ -12723,6 +12756,7 @@ def test_list_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -12917,6 +12951,7 @@ def test_get_series_rest_required_fields(request_type=streams_service.GetSeriesR response_value._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_series(request) @@ -12964,6 +12999,7 @@ def test_get_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13111,6 +13147,7 @@ def test_create_series_rest_required_fields( response_value._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_series(request) @@ -13178,6 +13215,7 @@ def test_create_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13315,6 +13353,7 @@ def test_update_series_rest_required_fields( response_value._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_series(request) @@ -13376,6 +13415,7 @@ def test_update_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13511,6 +13551,7 @@ def test_delete_series_rest_required_fields( response_value._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_series(request) @@ -13556,6 +13597,7 @@ def test_delete_series_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_series(**mock_args) @@ -13707,6 +13749,7 @@ def test_materialize_channel_rest_required_fields( response_value._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.materialize_channel(request) @@ -13774,6 +13817,7 @@ def test_materialize_channel_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.materialize_channel(**mock_args) @@ -15004,6 +15048,7 @@ def test_list_clusters_rest_bad_request( 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_clusters(request) @@ -15040,6 +15085,7 @@ def test_list_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clusters(request) # Establish that the response is the type that we expect. @@ -15081,6 +15127,7 @@ def test_list_clusters_rest_interceptors(null_interceptor): 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 = streams_service.ListClustersResponse.to_json( streams_service.ListClustersResponse() ) @@ -15125,6 +15172,7 @@ def test_get_cluster_rest_bad_request(request_type=streams_service.GetClusterReq 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_cluster(request) @@ -15163,6 +15211,7 @@ def test_get_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15206,6 +15255,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): 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 = common.Cluster.to_json(common.Cluster()) req.return_value.content = return_value @@ -15250,6 +15300,7 @@ def test_create_cluster_rest_bad_request( 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_cluster(request) @@ -15357,6 +15408,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15398,6 +15450,7 @@ def test_create_cluster_rest_interceptors(null_interceptor): 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 @@ -15444,6 +15497,7 @@ def test_update_cluster_rest_bad_request( 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_cluster(request) @@ -15553,6 +15607,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15594,6 +15649,7 @@ def test_update_cluster_rest_interceptors(null_interceptor): 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 @@ -15638,6 +15694,7 @@ def test_delete_cluster_rest_bad_request( 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_cluster(request) @@ -15668,6 +15725,7 @@ def test_delete_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -15709,6 +15767,7 @@ def test_delete_cluster_rest_interceptors(null_interceptor): 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 @@ -15751,6 +15810,7 @@ def test_list_streams_rest_bad_request(request_type=streams_service.ListStreamsR 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_streams(request) @@ -15787,6 +15847,7 @@ def test_list_streams_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_streams(request) # Establish that the response is the type that we expect. @@ -15828,6 +15889,7 @@ def test_list_streams_rest_interceptors(null_interceptor): 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 = streams_service.ListStreamsResponse.to_json( streams_service.ListStreamsResponse() ) @@ -15874,6 +15936,7 @@ def test_get_stream_rest_bad_request(request_type=streams_service.GetStreamReque 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_stream(request) @@ -15914,6 +15977,7 @@ def test_get_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -15957,6 +16021,7 @@ def test_get_stream_rest_interceptors(null_interceptor): 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 = streams_resources.Stream.to_json(streams_resources.Stream()) req.return_value.content = return_value @@ -16001,6 +16066,7 @@ def test_create_stream_rest_bad_request( 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_stream(request) @@ -16108,6 +16174,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16149,6 +16216,7 @@ def test_create_stream_rest_interceptors(null_interceptor): 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 @@ -16197,6 +16265,7 @@ def test_update_stream_rest_bad_request( 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_stream(request) @@ -16308,6 +16377,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16349,6 +16419,7 @@ def test_update_stream_rest_interceptors(null_interceptor): 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 @@ -16395,6 +16466,7 @@ def test_delete_stream_rest_bad_request( 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_stream(request) @@ -16427,6 +16499,7 @@ def test_delete_stream_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_stream(request) # Establish that the response is the type that we expect. @@ -16468,6 +16541,7 @@ def test_delete_stream_rest_interceptors(null_interceptor): 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 @@ -16514,6 +16588,7 @@ def test_generate_stream_hls_token_rest_bad_request( 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.generate_stream_hls_token(request) @@ -16551,6 +16626,7 @@ def test_generate_stream_hls_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_stream_hls_token(request) # Establish that the response is the type that we expect. @@ -16591,6 +16667,7 @@ def test_generate_stream_hls_token_rest_interceptors(null_interceptor): 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 = streams_service.GenerateStreamHlsTokenResponse.to_json( streams_service.GenerateStreamHlsTokenResponse() ) @@ -16635,6 +16712,7 @@ def test_list_events_rest_bad_request(request_type=streams_service.ListEventsReq 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_events(request) @@ -16671,6 +16749,7 @@ def test_list_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_events(request) # Establish that the response is the type that we expect. @@ -16712,6 +16791,7 @@ def test_list_events_rest_interceptors(null_interceptor): 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 = streams_service.ListEventsResponse.to_json( streams_service.ListEventsResponse() ) @@ -16758,6 +16838,7 @@ def test_get_event_rest_bad_request(request_type=streams_service.GetEventRequest 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_event(request) @@ -16796,6 +16877,7 @@ def test_get_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -16837,6 +16919,7 @@ def test_get_event_rest_interceptors(null_interceptor): 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 = streams_resources.Event.to_json(streams_resources.Event()) req.return_value.content = return_value @@ -16879,6 +16962,7 @@ def test_create_event_rest_bad_request(request_type=streams_service.CreateEventR 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_event(request) @@ -16985,6 +17069,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17026,6 +17111,7 @@ def test_create_event_rest_interceptors(null_interceptor): 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 @@ -17072,6 +17158,7 @@ def test_update_event_rest_bad_request(request_type=streams_service.UpdateEventR 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_event(request) @@ -17182,6 +17269,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17223,6 +17311,7 @@ def test_update_event_rest_interceptors(null_interceptor): 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 @@ -17267,6 +17356,7 @@ def test_delete_event_rest_bad_request(request_type=streams_service.DeleteEventR 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_event(request) @@ -17299,6 +17389,7 @@ def test_delete_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -17340,6 +17431,7 @@ def test_delete_event_rest_interceptors(null_interceptor): 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 @@ -17382,6 +17474,7 @@ def test_list_series_rest_bad_request(request_type=streams_service.ListSeriesReq 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_series(request) @@ -17418,6 +17511,7 @@ def test_list_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -17459,6 +17553,7 @@ def test_list_series_rest_interceptors(null_interceptor): 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 = streams_service.ListSeriesResponse.to_json( streams_service.ListSeriesResponse() ) @@ -17505,6 +17600,7 @@ def test_get_series_rest_bad_request(request_type=streams_service.GetSeriesReque 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_series(request) @@ -17544,6 +17640,7 @@ def test_get_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -17586,6 +17683,7 @@ def test_get_series_rest_interceptors(null_interceptor): 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 = streams_resources.Series.to_json(streams_resources.Series()) req.return_value.content = return_value @@ -17630,6 +17728,7 @@ def test_create_series_rest_bad_request( 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_series(request) @@ -17736,6 +17835,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -17777,6 +17877,7 @@ def test_create_series_rest_interceptors(null_interceptor): 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 @@ -17825,6 +17926,7 @@ def test_update_series_rest_bad_request( 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_series(request) @@ -17935,6 +18037,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -17976,6 +18079,7 @@ def test_update_series_rest_interceptors(null_interceptor): 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 @@ -18022,6 +18126,7 @@ def test_delete_series_rest_bad_request( 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_series(request) @@ -18054,6 +18159,7 @@ def test_delete_series_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_series(request) # Establish that the response is the type that we expect. @@ -18095,6 +18201,7 @@ def test_delete_series_rest_interceptors(null_interceptor): 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 @@ -18139,6 +18246,7 @@ def test_materialize_channel_rest_bad_request( 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.materialize_channel(request) @@ -18245,6 +18353,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.materialize_channel(request) # Establish that the response is the type that we expect. @@ -18286,6 +18395,7 @@ def test_materialize_channel_rest_interceptors(null_interceptor): 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 @@ -18330,6 +18440,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -18360,6 +18471,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -18388,6 +18500,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -18418,6 +18531,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -18448,6 +18562,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -18478,6 +18593,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -18508,6 +18624,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -18538,6 +18655,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -18568,6 +18686,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -18598,6 +18717,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -18628,6 +18748,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -18658,6 +18779,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -18688,6 +18810,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -18718,6 +18841,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -18748,6 +18872,7 @@ def test_get_operation_rest_bad_request( 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) @@ -18778,6 +18903,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -18808,6 +18934,7 @@ def test_list_operations_rest_bad_request( 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) @@ -18838,6 +18965,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py index 6423d63b2d59..5f200dcb68dd 100644 --- a/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py +++ b/packages/google-cloud-visionai/tests/unit/gapic/visionai_v1alpha1/test_warehouse.py @@ -11562,6 +11562,7 @@ def test_create_asset_rest_required_fields(request_type=warehouse.CreateAssetReq response_value._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_asset(request) @@ -11619,6 +11620,7 @@ def test_create_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -11748,6 +11750,7 @@ def test_update_asset_rest_required_fields(request_type=warehouse.UpdateAssetReq response_value._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_asset(request) @@ -11798,6 +11801,7 @@ def test_update_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -11928,6 +11932,7 @@ def test_get_asset_rest_required_fields(request_type=warehouse.GetAssetRequest): response_value._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_asset(request) @@ -11975,6 +11980,7 @@ def test_get_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -12111,6 +12117,7 @@ def test_list_assets_rest_required_fields(request_type=warehouse.ListAssetsReque response_value._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_assets(request) @@ -12166,6 +12173,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_assets(**mock_args) @@ -12359,6 +12367,7 @@ def test_delete_asset_rest_required_fields(request_type=warehouse.DeleteAssetReq response_value._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_asset(request) @@ -12404,6 +12413,7 @@ def test_delete_asset_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_asset(**mock_args) @@ -12535,6 +12545,7 @@ def test_create_corpus_rest_required_fields(request_type=warehouse.CreateCorpusR response_value._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_corpus(request) @@ -12587,6 +12598,7 @@ def test_create_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -12717,6 +12729,7 @@ def test_get_corpus_rest_required_fields(request_type=warehouse.GetCorpusRequest response_value._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_corpus(request) @@ -12762,6 +12775,7 @@ def test_get_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -12889,6 +12903,7 @@ def test_update_corpus_rest_required_fields(request_type=warehouse.UpdateCorpusR response_value._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_corpus(request) @@ -12937,6 +12952,7 @@ def test_update_corpus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpus(**mock_args) @@ -13074,6 +13090,7 @@ def test_list_corpora_rest_required_fields(request_type=warehouse.ListCorporaReq response_value._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_corpora(request) @@ -13127,6 +13144,7 @@ def test_list_corpora_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_corpora(**mock_args) @@ -13314,6 +13332,7 @@ def test_delete_corpus_rest_required_fields(request_type=warehouse.DeleteCorpusR response_value._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_corpus(request) @@ -13357,6 +13376,7 @@ def test_delete_corpus_rest_flattened(): 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"} client.delete_corpus(**mock_args) @@ -13493,6 +13513,7 @@ def test_create_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -13549,6 +13570,7 @@ def test_create_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -13683,6 +13705,7 @@ def test_update_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -13733,6 +13756,7 @@ def test_update_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -13865,6 +13889,7 @@ def test_get_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -13912,6 +13937,7 @@ def test_get_data_schema_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schema(**mock_args) @@ -14044,6 +14070,7 @@ def test_delete_data_schema_rest_required_fields( response_value._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_data_schema(request) @@ -14089,6 +14116,7 @@ def test_delete_data_schema_rest_flattened(): 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"} client.delete_data_schema(**mock_args) @@ -14229,6 +14257,7 @@ def test_list_data_schemas_rest_required_fields( response_value._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_data_schemas(request) @@ -14284,6 +14313,7 @@ def test_list_data_schemas_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_data_schemas(**mock_args) @@ -14483,6 +14513,7 @@ def test_create_annotation_rest_required_fields( response_value._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_annotation(request) @@ -14540,6 +14571,7 @@ def test_create_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -14673,6 +14705,7 @@ def test_get_annotation_rest_required_fields( response_value._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_annotation(request) @@ -14720,6 +14753,7 @@ def test_get_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -14817,6 +14851,7 @@ def test_list_annotations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotations(**mock_args) @@ -15011,6 +15046,7 @@ def test_update_annotation_rest_required_fields( response_value._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_annotation(request) @@ -15061,6 +15097,7 @@ def test_update_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -15192,6 +15229,7 @@ def test_delete_annotation_rest_required_fields( response_value._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_annotation(request) @@ -15237,6 +15275,7 @@ def test_delete_annotation_rest_flattened(): 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"} client.delete_annotation(**mock_args) @@ -15378,6 +15417,7 @@ def test_clip_asset_rest_required_fields(request_type=warehouse.ClipAssetRequest response_value._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.clip_asset(request) @@ -15508,6 +15548,7 @@ def test_generate_hls_uri_rest_required_fields( response_value._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.generate_hls_uri(request) @@ -15649,6 +15690,7 @@ def test_create_search_config_rest_required_fields( response_value._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_search_config(request) @@ -15713,6 +15755,7 @@ def test_create_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -15848,6 +15891,7 @@ def test_update_search_config_rest_required_fields( response_value._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_search_config(request) @@ -15898,6 +15942,7 @@ def test_update_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -16032,6 +16077,7 @@ def test_get_search_config_rest_required_fields( response_value._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_search_config(request) @@ -16079,6 +16125,7 @@ def test_get_search_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_config(**mock_args) @@ -16211,6 +16258,7 @@ def test_delete_search_config_rest_required_fields( response_value._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_search_config(request) @@ -16256,6 +16304,7 @@ def test_delete_search_config_rest_flattened(): 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"} client.delete_search_config(**mock_args) @@ -16398,6 +16447,7 @@ def test_list_search_configs_rest_required_fields( response_value._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_search_configs(request) @@ -16453,6 +16503,7 @@ def test_list_search_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_search_configs(**mock_args) @@ -16648,6 +16699,7 @@ def test_search_assets_rest_required_fields(request_type=warehouse.SearchAssetsR response_value._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.search_assets(request) @@ -18264,6 +18316,7 @@ def test_create_asset_rest_bad_request(request_type=warehouse.CreateAssetRequest 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_asset(request) @@ -18370,6 +18423,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -18406,6 +18460,7 @@ def test_create_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18452,6 +18507,7 @@ def test_update_asset_rest_bad_request(request_type=warehouse.UpdateAssetRequest 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_asset(request) @@ -18562,6 +18618,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -18598,6 +18655,7 @@ def test_update_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18642,6 +18700,7 @@ def test_get_asset_rest_bad_request(request_type=warehouse.GetAssetRequest): 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_asset(request) @@ -18679,6 +18738,7 @@ def test_get_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -18715,6 +18775,7 @@ def test_get_asset_rest_interceptors(null_interceptor): 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 = warehouse.Asset.to_json(warehouse.Asset()) req.return_value.content = return_value @@ -18757,6 +18818,7 @@ def test_list_assets_rest_bad_request(request_type=warehouse.ListAssetsRequest): 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_assets(request) @@ -18792,6 +18854,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -18828,6 +18891,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = warehouse.ListAssetsResponse.to_json( warehouse.ListAssetsResponse() ) @@ -18874,6 +18938,7 @@ def test_delete_asset_rest_bad_request(request_type=warehouse.DeleteAssetRequest 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_asset(request) @@ -18906,6 +18971,7 @@ def test_delete_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_asset(request) # Establish that the response is the type that we expect. @@ -18943,6 +19009,7 @@ def test_delete_asset_rest_interceptors(null_interceptor): 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 @@ -18985,6 +19052,7 @@ def test_create_corpus_rest_bad_request(request_type=warehouse.CreateCorpusReque 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_corpus(request) @@ -19088,6 +19156,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -19125,6 +19194,7 @@ def test_create_corpus_rest_interceptors(null_interceptor): 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 @@ -19167,6 +19237,7 @@ def test_get_corpus_rest_bad_request(request_type=warehouse.GetCorpusRequest): 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_corpus(request) @@ -19204,6 +19275,7 @@ def test_get_corpus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -19242,6 +19314,7 @@ def test_get_corpus_rest_interceptors(null_interceptor): 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 = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -19286,6 +19359,7 @@ def test_update_corpus_rest_bad_request(request_type=warehouse.UpdateCorpusReque 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_corpus(request) @@ -19398,6 +19472,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpus(request) # Establish that the response is the type that we expect. @@ -19436,6 +19511,7 @@ def test_update_corpus_rest_interceptors(null_interceptor): 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 = warehouse.Corpus.to_json(warehouse.Corpus()) req.return_value.content = return_value @@ -19478,6 +19554,7 @@ def test_list_corpora_rest_bad_request(request_type=warehouse.ListCorporaRequest 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_corpora(request) @@ -19513,6 +19590,7 @@ def test_list_corpora_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_corpora(request) # Establish that the response is the type that we expect. @@ -19549,6 +19627,7 @@ def test_list_corpora_rest_interceptors(null_interceptor): 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 = warehouse.ListCorporaResponse.to_json( warehouse.ListCorporaResponse() ) @@ -19593,6 +19672,7 @@ def test_delete_corpus_rest_bad_request(request_type=warehouse.DeleteCorpusReque 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_corpus(request) @@ -19623,6 +19703,7 @@ def test_delete_corpus_rest_call_success(request_type): 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_corpus(request) # Establish that the response is the type that we expect. @@ -19655,6 +19736,7 @@ def test_delete_corpus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteCorpusRequest() metadata = [ @@ -19695,6 +19777,7 @@ def test_create_data_schema_rest_bad_request( 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_data_schema(request) @@ -19808,6 +19891,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -19847,6 +19931,7 @@ def test_create_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -19895,6 +19980,7 @@ def test_update_data_schema_rest_bad_request( 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_data_schema(request) @@ -20012,6 +20098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -20051,6 +20138,7 @@ def test_update_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -20095,6 +20183,7 @@ def test_get_data_schema_rest_bad_request(request_type=warehouse.GetDataSchemaRe 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_data_schema(request) @@ -20133,6 +20222,7 @@ def test_get_data_schema_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schema(request) # Establish that the response is the type that we expect. @@ -20170,6 +20260,7 @@ def test_get_data_schema_rest_interceptors(null_interceptor): 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 = warehouse.DataSchema.to_json(warehouse.DataSchema()) req.return_value.content = return_value @@ -20216,6 +20307,7 @@ def test_delete_data_schema_rest_bad_request( 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_data_schema(request) @@ -20248,6 +20340,7 @@ def test_delete_data_schema_rest_call_success(request_type): 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_data_schema(request) # Establish that the response is the type that we expect. @@ -20282,6 +20375,7 @@ def test_delete_data_schema_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteDataSchemaRequest() metadata = [ @@ -20322,6 +20416,7 @@ def test_list_data_schemas_rest_bad_request( 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_data_schemas(request) @@ -20357,6 +20452,7 @@ def test_list_data_schemas_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_data_schemas(request) # Establish that the response is the type that we expect. @@ -20395,6 +20491,7 @@ def test_list_data_schemas_rest_interceptors(null_interceptor): 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 = warehouse.ListDataSchemasResponse.to_json( warehouse.ListDataSchemasResponse() ) @@ -20443,6 +20540,7 @@ def test_create_annotation_rest_bad_request( 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_annotation(request) @@ -20578,6 +20676,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -20616,6 +20715,7 @@ def test_create_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -20660,6 +20760,7 @@ def test_get_annotation_rest_bad_request(request_type=warehouse.GetAnnotationReq 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_annotation(request) @@ -20697,6 +20798,7 @@ def test_get_annotation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -20733,6 +20835,7 @@ def test_get_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -20779,6 +20882,7 @@ def test_list_annotations_rest_bad_request( 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_annotations(request) @@ -20816,6 +20920,7 @@ def test_list_annotations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotations(request) # Establish that the response is the type that we expect. @@ -20854,6 +20959,7 @@ def test_list_annotations_rest_interceptors(null_interceptor): 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 = warehouse.ListAnnotationsResponse.to_json( warehouse.ListAnnotationsResponse() ) @@ -20904,6 +21010,7 @@ def test_update_annotation_rest_bad_request( 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_annotation(request) @@ -21041,6 +21148,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -21079,6 +21187,7 @@ def test_update_annotation_rest_interceptors(null_interceptor): 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 = warehouse.Annotation.to_json(warehouse.Annotation()) req.return_value.content = return_value @@ -21125,6 +21234,7 @@ def test_delete_annotation_rest_bad_request( 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_annotation(request) @@ -21157,6 +21267,7 @@ def test_delete_annotation_rest_call_success(request_type): 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_annotation(request) # Establish that the response is the type that we expect. @@ -21191,6 +21302,7 @@ def test_delete_annotation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteAnnotationRequest() metadata = [ @@ -21243,6 +21355,7 @@ def test_clip_asset_rest_bad_request(request_type=warehouse.ClipAssetRequest): 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.clip_asset(request) @@ -21278,6 +21391,7 @@ def test_clip_asset_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.clip_asset(request) # Establish that the response is the type that we expect. @@ -21313,6 +21427,7 @@ def test_clip_asset_rest_interceptors(null_interceptor): 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 = warehouse.ClipAssetResponse.to_json( warehouse.ClipAssetResponse() ) @@ -21361,6 +21476,7 @@ def test_generate_hls_uri_rest_bad_request( 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.generate_hls_uri(request) @@ -21398,6 +21514,7 @@ def test_generate_hls_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_hls_uri(request) # Establish that the response is the type that we expect. @@ -21436,6 +21553,7 @@ def test_generate_hls_uri_rest_interceptors(null_interceptor): 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 = warehouse.GenerateHlsUriResponse.to_json( warehouse.GenerateHlsUriResponse() ) @@ -21482,6 +21600,7 @@ def test_create_search_config_rest_bad_request( 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_search_config(request) @@ -21617,6 +21736,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -21655,6 +21775,7 @@ def test_create_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -21703,6 +21824,7 @@ def test_update_search_config_rest_bad_request( 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_search_config(request) @@ -21842,6 +21964,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -21880,6 +22003,7 @@ def test_update_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -21926,6 +22050,7 @@ def test_get_search_config_rest_bad_request( 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_search_config(request) @@ -21963,6 +22088,7 @@ def test_get_search_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_config(request) # Establish that the response is the type that we expect. @@ -22001,6 +22127,7 @@ def test_get_search_config_rest_interceptors(null_interceptor): 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 = warehouse.SearchConfig.to_json(warehouse.SearchConfig()) req.return_value.content = return_value @@ -22047,6 +22174,7 @@ def test_delete_search_config_rest_bad_request( 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_search_config(request) @@ -22079,6 +22207,7 @@ def test_delete_search_config_rest_call_success(request_type): 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_search_config(request) # Establish that the response is the type that we expect. @@ -22113,6 +22242,7 @@ def test_delete_search_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = warehouse.DeleteSearchConfigRequest() metadata = [ @@ -22153,6 +22283,7 @@ def test_list_search_configs_rest_bad_request( 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_search_configs(request) @@ -22188,6 +22319,7 @@ def test_list_search_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_search_configs(request) # Establish that the response is the type that we expect. @@ -22226,6 +22358,7 @@ def test_list_search_configs_rest_interceptors(null_interceptor): 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 = warehouse.ListSearchConfigsResponse.to_json( warehouse.ListSearchConfigsResponse() ) @@ -22270,6 +22403,7 @@ def test_search_assets_rest_bad_request(request_type=warehouse.SearchAssetsReque 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.search_assets(request) @@ -22305,6 +22439,7 @@ def test_search_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_assets(request) # Establish that the response is the type that we expect. @@ -22341,6 +22476,7 @@ def test_search_assets_rest_interceptors(null_interceptor): 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 = warehouse.SearchAssetsResponse.to_json( warehouse.SearchAssetsResponse() ) @@ -22387,6 +22523,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -22417,6 +22554,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -22445,6 +22583,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -22475,6 +22614,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -22505,6 +22645,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -22535,6 +22676,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -22565,6 +22707,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -22595,6 +22738,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -22625,6 +22769,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -22655,6 +22800,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -22685,6 +22831,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -22715,6 +22862,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -22745,6 +22893,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -22775,6 +22924,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -22805,6 +22955,7 @@ def test_get_operation_rest_bad_request( 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) @@ -22835,6 +22986,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -22865,6 +23017,7 @@ def test_list_operations_rest_bad_request( 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) @@ -22895,6 +23048,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py index 39254fae861a..14a30782cf03 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VmMigrationTransport from .transports.grpc_asyncio import VmMigrationGrpcAsyncIOTransport +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 VmMigrationAsyncClient: """VM Migration Service""" @@ -288,6 +298,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vmmigration_v1.VmMigrationAsyncClient`.", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "credentialsType": None, + }, + ) + async def list_sources( self, request: Optional[Union[vmmigration.ListSourcesRequest, dict]] = None, @@ -295,7 +327,7 @@ async def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesAsyncPager: r"""Lists Sources in a given project and location. @@ -341,8 +373,10 @@ async def sample_list_sources(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesAsyncPager: @@ -417,7 +451,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Gets details of a single Source. @@ -459,8 +493,10 @@ async def sample_get_source(): 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, 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: google.cloud.vmmigration_v1.types.Source: @@ -525,7 +561,7 @@ async def create_source( source_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Source in a given project and location. @@ -582,8 +618,10 @@ async def sample_create_source(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -659,7 +697,7 @@ async def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Source. @@ -715,8 +753,10 @@ async def sample_update_source(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -791,7 +831,7 @@ async def delete_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Source. @@ -837,8 +877,10 @@ async def sample_delete_source(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -917,7 +959,7 @@ async def fetch_inventory( source: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the @@ -965,8 +1007,10 @@ async def sample_fetch_inventory(): 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, 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: google.cloud.vmmigration_v1.types.FetchInventoryResponse: @@ -1029,7 +1073,7 @@ async def list_utilization_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUtilizationReportsAsyncPager: r"""Lists Utilization Reports of the given Source. @@ -1075,8 +1119,10 @@ async def sample_list_utilization_reports(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsAsyncPager: @@ -1151,7 +1197,7 @@ async def get_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Gets a single Utilization Report. @@ -1195,8 +1241,10 @@ async def sample_get_utilization_report(): 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, 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: google.cloud.vmmigration_v1.types.UtilizationReport: @@ -1262,7 +1310,7 @@ async def create_utilization_report( utilization_report_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new UtilizationReport. @@ -1328,8 +1376,10 @@ async def sample_create_utilization_report(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1406,7 +1456,7 @@ async def delete_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Utilization Report. @@ -1454,8 +1504,10 @@ async def sample_delete_utilization_report(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1536,7 +1588,7 @@ async def list_datacenter_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatacenterConnectorsAsyncPager: r"""Lists DatacenterConnectors in a given Source. @@ -1582,8 +1634,10 @@ async def sample_list_datacenter_connectors(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsAsyncPager: @@ -1660,7 +1714,7 @@ async def get_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Gets details of a single DatacenterConnector. @@ -1704,8 +1758,10 @@ async def sample_get_datacenter_connector(): 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, 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: google.cloud.vmmigration_v1.types.DatacenterConnector: @@ -1775,7 +1831,7 @@ async def create_datacenter_connector( datacenter_connector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new DatacenterConnector in a given Source. @@ -1838,8 +1894,10 @@ async def sample_create_datacenter_connector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1921,7 +1979,7 @@ async def delete_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single DatacenterConnector. @@ -1969,8 +2027,10 @@ async def sample_delete_datacenter_connector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2048,7 +2108,7 @@ async def upgrade_appliance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version. @@ -2090,8 +2150,10 @@ async def sample_upgrade_appliance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2153,7 +2215,7 @@ async def create_migrating_vm( migrating_vm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new MigratingVm in a given Source. @@ -2210,8 +2272,10 @@ async def sample_create_migrating_vm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2286,7 +2350,7 @@ async def list_migrating_vms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigratingVmsAsyncPager: r"""Lists MigratingVms in a given Source. @@ -2332,8 +2396,10 @@ async def sample_list_migrating_vms(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsAsyncPager: @@ -2408,7 +2474,7 @@ async def get_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Gets details of a single MigratingVm. @@ -2452,8 +2518,10 @@ async def sample_get_migrating_vm(): 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, 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: google.cloud.vmmigration_v1.types.MigratingVm: @@ -2516,7 +2584,7 @@ async def update_migrating_vm( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single MigratingVm. @@ -2572,8 +2640,10 @@ async def sample_update_migrating_vm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2648,7 +2718,7 @@ async def delete_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single MigratingVm. @@ -2696,8 +2766,10 @@ async def sample_delete_migrating_vm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2776,7 +2848,7 @@ async def start_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication @@ -2826,8 +2898,10 @@ async def sample_start_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2900,7 +2974,7 @@ async def resume_migration( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and @@ -2946,8 +3020,10 @@ async def sample_resume_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3006,7 +3082,7 @@ async def pause_migration( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task @@ -3050,8 +3126,10 @@ async def sample_pause_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3111,7 +3189,7 @@ async def finalize_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable @@ -3161,8 +3239,10 @@ async def sample_finalize_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3238,7 +3318,7 @@ async def create_clone_job( clone_job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a Clone of a specific migrating VM. @@ -3295,8 +3375,10 @@ async def sample_create_clone_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3383,7 +3465,7 @@ async def cancel_clone_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates the cancellation of a running clone job. @@ -3429,8 +3511,10 @@ async def sample_cancel_clone_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3502,7 +3586,7 @@ async def list_clone_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCloneJobsAsyncPager: r"""Lists CloneJobs of a given migrating VM. @@ -3548,8 +3632,10 @@ async def sample_list_clone_jobs(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsAsyncPager: @@ -3624,7 +3710,7 @@ async def get_clone_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CloneJob: r"""Gets details of a single CloneJob. @@ -3666,8 +3752,10 @@ async def sample_get_clone_job(): 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, 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: google.cloud.vmmigration_v1.types.CloneJob: @@ -3742,7 +3830,7 @@ async def create_cutover_job( cutover_job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job @@ -3801,8 +3889,10 @@ async def sample_create_cutover_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3879,7 +3969,7 @@ async def cancel_cutover_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates the cancellation of a running cutover job. @@ -3925,8 +4015,10 @@ async def sample_cancel_cutover_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3998,7 +4090,7 @@ async def list_cutover_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCutoverJobsAsyncPager: r"""Lists CutoverJobs of a given migrating VM. @@ -4044,8 +4136,10 @@ async def sample_list_cutover_jobs(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsAsyncPager: @@ -4120,7 +4214,7 @@ async def get_cutover_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CutoverJob: r"""Gets details of a single CutoverJob. @@ -4162,8 +4256,10 @@ async def sample_get_cutover_job(): 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, 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: google.cloud.vmmigration_v1.types.CutoverJob: @@ -4228,7 +4324,7 @@ async def list_groups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGroupsAsyncPager: r"""Lists Groups in a given project and location. @@ -4274,8 +4370,10 @@ async def sample_list_groups(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsAsyncPager: @@ -4350,7 +4448,7 @@ async def get_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Group: r"""Gets details of a single Group. @@ -4392,8 +4490,10 @@ async def sample_get_group(): 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, 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: google.cloud.vmmigration_v1.types.Group: @@ -4457,7 +4557,7 @@ async def create_group( group_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Group in a given project and location. @@ -4514,8 +4614,10 @@ async def sample_create_group(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4591,7 +4693,7 @@ async def update_group( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Group. @@ -4647,8 +4749,10 @@ async def sample_update_group(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4723,7 +4827,7 @@ async def delete_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Group. @@ -4769,8 +4873,10 @@ async def sample_delete_group(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4849,7 +4955,7 @@ async def add_group_migration( group: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds a MigratingVm to a Group. @@ -4897,8 +5003,10 @@ async def sample_add_group_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4970,7 +5078,7 @@ async def remove_group_migration( group: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Removes a MigratingVm from a Group. @@ -5016,8 +5124,10 @@ async def sample_remove_group_migration(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5089,7 +5199,7 @@ async def list_target_projects( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTargetProjectsAsyncPager: r"""Lists TargetProjects in a given project. @@ -5138,8 +5248,10 @@ async def sample_list_target_projects(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsAsyncPager: @@ -5214,7 +5326,7 @@ async def get_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Gets details of a single TargetProject. @@ -5259,8 +5371,10 @@ async def sample_get_target_project(): 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, 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: google.cloud.vmmigration_v1.types.TargetProject: @@ -5324,7 +5438,7 @@ async def create_target_project( target_project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new TargetProject in a given project. @@ -5384,8 +5498,10 @@ async def sample_create_target_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5461,7 +5577,7 @@ async def update_target_project( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single TargetProject. @@ -5520,8 +5636,10 @@ async def sample_update_target_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5596,7 +5714,7 @@ async def delete_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single TargetProject. @@ -5645,8 +5763,10 @@ async def sample_delete_target_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5725,7 +5845,7 @@ async def list_replication_cycles( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReplicationCyclesAsyncPager: r"""Lists ReplicationCycles in a given MigratingVM. @@ -5771,8 +5891,10 @@ async def sample_list_replication_cycles(): 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, 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesAsyncPager: @@ -5847,7 +5969,7 @@ async def get_replication_cycle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Gets details of a single ReplicationCycle. @@ -5891,8 +6013,10 @@ async def sample_get_replication_cycle(): 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, 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: google.cloud.vmmigration_v1.types.ReplicationCycle: @@ -5953,7 +6077,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5964,8 +6088,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -6006,7 +6132,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -6017,8 +6143,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -6059,7 +6187,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -6075,8 +6203,10 @@ async def delete_operation( 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, 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: None """ @@ -6113,7 +6243,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -6128,8 +6258,10 @@ async def cancel_operation( 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, 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: None """ @@ -6166,7 +6298,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -6177,8 +6309,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -6219,7 +6353,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -6230,8 +6364,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py index c7e43a649594..ca8e099c82d6 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -782,6 +792,10 @@ def __init__( # 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( @@ -844,6 +858,29 @@ def __init__( 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.vmmigration_v1.VmMigrationClient`.", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "credentialsType": None, + }, + ) + def list_sources( self, request: Optional[Union[vmmigration.ListSourcesRequest, dict]] = None, @@ -851,7 +888,7 @@ def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesPager: r"""Lists Sources in a given project and location. @@ -897,8 +934,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesPager: @@ -970,7 +1009,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Gets details of a single Source. @@ -1012,8 +1051,10 @@ def sample_get_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.Source: @@ -1075,7 +1116,7 @@ def create_source( source_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Source in a given project and location. @@ -1132,8 +1173,10 @@ def sample_create_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1206,7 +1249,7 @@ def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Source. @@ -1262,8 +1305,10 @@ def sample_update_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1335,7 +1380,7 @@ def delete_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Source. @@ -1381,8 +1426,10 @@ def sample_delete_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1458,7 +1505,7 @@ def fetch_inventory( source: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the @@ -1506,8 +1553,10 @@ def sample_fetch_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.FetchInventoryResponse: @@ -1567,7 +1616,7 @@ def list_utilization_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUtilizationReportsPager: r"""Lists Utilization Reports of the given Source. @@ -1613,8 +1662,10 @@ def sample_list_utilization_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsPager: @@ -1686,7 +1737,7 @@ def get_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Gets a single Utilization Report. @@ -1730,8 +1781,10 @@ def sample_get_utilization_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.UtilizationReport: @@ -1794,7 +1847,7 @@ def create_utilization_report( utilization_report_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new UtilizationReport. @@ -1860,8 +1913,10 @@ def sample_create_utilization_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1937,7 +1992,7 @@ def delete_utilization_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Utilization Report. @@ -1985,8 +2040,10 @@ def sample_delete_utilization_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2066,7 +2123,7 @@ def list_datacenter_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatacenterConnectorsPager: r"""Lists DatacenterConnectors in a given Source. @@ -2112,8 +2169,10 @@ def sample_list_datacenter_connectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsPager: @@ -2189,7 +2248,7 @@ def get_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Gets details of a single DatacenterConnector. @@ -2233,8 +2292,10 @@ def sample_get_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.DatacenterConnector: @@ -2301,7 +2362,7 @@ def create_datacenter_connector( datacenter_connector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new DatacenterConnector in a given Source. @@ -2364,8 +2425,10 @@ def sample_create_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2446,7 +2509,7 @@ def delete_datacenter_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single DatacenterConnector. @@ -2494,8 +2557,10 @@ def sample_delete_datacenter_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2572,7 +2637,7 @@ def upgrade_appliance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version. @@ -2614,8 +2679,10 @@ def sample_upgrade_appliance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2675,7 +2742,7 @@ def create_migrating_vm( migrating_vm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new MigratingVm in a given Source. @@ -2732,8 +2799,10 @@ def sample_create_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2805,7 +2874,7 @@ def list_migrating_vms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigratingVmsPager: r"""Lists MigratingVms in a given Source. @@ -2851,8 +2920,10 @@ def sample_list_migrating_vms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsPager: @@ -2924,7 +2995,7 @@ def get_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Gets details of a single MigratingVm. @@ -2968,8 +3039,10 @@ def sample_get_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.MigratingVm: @@ -3029,7 +3102,7 @@ def update_migrating_vm( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single MigratingVm. @@ -3085,8 +3158,10 @@ def sample_update_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3158,7 +3233,7 @@ def delete_migrating_vm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single MigratingVm. @@ -3206,8 +3281,10 @@ def sample_delete_migrating_vm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3283,7 +3360,7 @@ def start_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication @@ -3333,8 +3410,10 @@ def sample_start_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3404,7 +3483,7 @@ def resume_migration( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and @@ -3450,8 +3529,10 @@ def sample_resume_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3508,7 +3589,7 @@ def pause_migration( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task @@ -3552,8 +3633,10 @@ def sample_pause_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3611,7 +3694,7 @@ def finalize_migration( migrating_vm: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable @@ -3661,8 +3744,10 @@ def sample_finalize_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3735,7 +3820,7 @@ def create_clone_job( clone_job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates a Clone of a specific migrating VM. @@ -3792,8 +3877,10 @@ def sample_create_clone_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3877,7 +3964,7 @@ def cancel_clone_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates the cancellation of a running clone job. @@ -3923,8 +4010,10 @@ def sample_cancel_clone_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3993,7 +4082,7 @@ def list_clone_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCloneJobsPager: r"""Lists CloneJobs of a given migrating VM. @@ -4039,8 +4128,10 @@ def sample_list_clone_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsPager: @@ -4112,7 +4203,7 @@ def get_clone_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CloneJob: r"""Gets details of a single CloneJob. @@ -4154,8 +4245,10 @@ def sample_get_clone_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.CloneJob: @@ -4227,7 +4320,7 @@ def create_cutover_job( cutover_job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job @@ -4286,8 +4379,10 @@ def sample_create_cutover_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4361,7 +4456,7 @@ def cancel_cutover_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates the cancellation of a running cutover job. @@ -4407,8 +4502,10 @@ def sample_cancel_cutover_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4477,7 +4574,7 @@ def list_cutover_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCutoverJobsPager: r"""Lists CutoverJobs of a given migrating VM. @@ -4523,8 +4620,10 @@ def sample_list_cutover_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsPager: @@ -4596,7 +4695,7 @@ def get_cutover_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CutoverJob: r"""Gets details of a single CutoverJob. @@ -4638,8 +4737,10 @@ def sample_get_cutover_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.CutoverJob: @@ -4701,7 +4802,7 @@ def list_groups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGroupsPager: r"""Lists Groups in a given project and location. @@ -4747,8 +4848,10 @@ def sample_list_groups(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsPager: @@ -4820,7 +4923,7 @@ def get_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Group: r"""Gets details of a single Group. @@ -4862,8 +4965,10 @@ def sample_get_group(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.Group: @@ -4924,7 +5029,7 @@ def create_group( group_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Group in a given project and location. @@ -4981,8 +5086,10 @@ def sample_create_group(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5055,7 +5162,7 @@ def update_group( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Group. @@ -5111,8 +5218,10 @@ def sample_update_group(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5184,7 +5293,7 @@ def delete_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Group. @@ -5230,8 +5339,10 @@ def sample_delete_group(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5307,7 +5418,7 @@ def add_group_migration( group: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds a MigratingVm to a Group. @@ -5355,8 +5466,10 @@ def sample_add_group_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5425,7 +5538,7 @@ def remove_group_migration( group: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Removes a MigratingVm from a Group. @@ -5471,8 +5584,10 @@ def sample_remove_group_migration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5541,7 +5656,7 @@ def list_target_projects( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTargetProjectsPager: r"""Lists TargetProjects in a given project. @@ -5590,8 +5705,10 @@ def sample_list_target_projects(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsPager: @@ -5663,7 +5780,7 @@ def get_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Gets details of a single TargetProject. @@ -5708,8 +5825,10 @@ def sample_get_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.TargetProject: @@ -5770,7 +5889,7 @@ def create_target_project( target_project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new TargetProject in a given project. @@ -5830,8 +5949,10 @@ def sample_create_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5904,7 +6025,7 @@ def update_target_project( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single TargetProject. @@ -5963,8 +6084,10 @@ def sample_update_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6036,7 +6159,7 @@ def delete_target_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single TargetProject. @@ -6085,8 +6208,10 @@ def sample_delete_target_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6162,7 +6287,7 @@ def list_replication_cycles( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReplicationCyclesPager: r"""Lists ReplicationCycles in a given MigratingVM. @@ -6208,8 +6333,10 @@ def sample_list_replication_cycles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesPager: @@ -6281,7 +6408,7 @@ def get_replication_cycle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Gets details of a single ReplicationCycle. @@ -6325,8 +6452,10 @@ def sample_get_replication_cycle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmmigration_v1.types.ReplicationCycle: @@ -6397,7 +6526,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -6408,8 +6537,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -6450,7 +6581,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -6461,8 +6592,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -6503,7 +6636,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -6519,8 +6652,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -6557,7 +6692,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -6572,8 +6707,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -6610,7 +6747,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -6621,8 +6758,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -6663,7 +6802,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -6674,8 +6813,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py index 83940db79a3f..8ba44e197d7d 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListSourcesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListSourcesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListUtilizationReportsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListUtilizationReportsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListDatacenterConnectorsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListDatacenterConnectorsRequest(request) @@ -525,7 +537,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -539,8 +551,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListMigratingVmsRequest(request) @@ -599,7 +613,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -613,8 +627,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListMigratingVmsRequest(request) @@ -677,7 +693,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -691,8 +707,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListCloneJobsRequest(request) @@ -751,7 +769,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -765,8 +783,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListCloneJobsRequest(request) @@ -829,7 +849,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -843,8 +863,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListCutoverJobsRequest(request) @@ -903,7 +925,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -917,8 +939,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListCutoverJobsRequest(request) @@ -981,7 +1005,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -995,8 +1019,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListGroupsRequest(request) @@ -1055,7 +1081,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1069,8 +1095,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListGroupsRequest(request) @@ -1133,7 +1161,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1147,8 +1175,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListTargetProjectsRequest(request) @@ -1207,7 +1237,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1221,8 +1251,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListTargetProjectsRequest(request) @@ -1285,7 +1317,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1299,8 +1331,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmmigration.ListReplicationCyclesRequest(request) @@ -1359,7 +1393,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1373,8 +1407,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmmigration.ListReplicationCyclesRequest(request) diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py index fb43a9ee7153..3cabc8d8399d 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vmmigration_v1.types import vmmigration from .base import DEFAULT_CLIENT_INFO, VmMigrationTransport +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.vmmigration.v1.VmMigration", + "rpcName": 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.vmmigration.v1.VmMigration", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmMigrationGrpcTransport(VmMigrationTransport): """gRPC backend transport for VmMigration. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListSources", request_serializer=vmmigration.ListSourcesRequest.serialize, response_deserializer=vmmigration.ListSourcesResponse.deserialize, @@ -298,7 +386,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetSource", request_serializer=vmmigration.GetSourceRequest.serialize, response_deserializer=vmmigration.Source.deserialize, @@ -324,7 +412,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateSource", request_serializer=vmmigration.CreateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +438,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateSource", request_serializer=vmmigration.UpdateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def delete_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_source" not in self._stubs: - self._stubs["delete_source"] = self.grpc_channel.unary_unary( + self._stubs["delete_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteSource", request_serializer=vmmigration.DeleteSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -410,7 +498,7 @@ def fetch_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_inventory" not in self._stubs: - self._stubs["fetch_inventory"] = self.grpc_channel.unary_unary( + self._stubs["fetch_inventory"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FetchInventory", request_serializer=vmmigration.FetchInventoryRequest.serialize, response_deserializer=vmmigration.FetchInventoryResponse.deserialize, @@ -439,7 +527,7 @@ def list_utilization_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_utilization_reports" not in self._stubs: - self._stubs["list_utilization_reports"] = self.grpc_channel.unary_unary( + self._stubs["list_utilization_reports"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListUtilizationReports", request_serializer=vmmigration.ListUtilizationReportsRequest.serialize, response_deserializer=vmmigration.ListUtilizationReportsResponse.deserialize, @@ -467,7 +555,7 @@ def get_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_utilization_report" not in self._stubs: - self._stubs["get_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["get_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetUtilizationReport", request_serializer=vmmigration.GetUtilizationReportRequest.serialize, response_deserializer=vmmigration.UtilizationReport.deserialize, @@ -495,7 +583,7 @@ def create_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_utilization_report" not in self._stubs: - self._stubs["create_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["create_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateUtilizationReport", request_serializer=vmmigration.CreateUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +611,7 @@ def delete_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_utilization_report" not in self._stubs: - self._stubs["delete_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["delete_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteUtilizationReport", request_serializer=vmmigration.DeleteUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +640,9 @@ def list_datacenter_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datacenter_connectors" not in self._stubs: - self._stubs["list_datacenter_connectors"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_datacenter_connectors" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListDatacenterConnectors", request_serializer=vmmigration.ListDatacenterConnectorsRequest.serialize, response_deserializer=vmmigration.ListDatacenterConnectorsResponse.deserialize, @@ -580,7 +670,7 @@ def get_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_datacenter_connector" not in self._stubs: - self._stubs["get_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_datacenter_connector"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetDatacenterConnector", request_serializer=vmmigration.GetDatacenterConnectorRequest.serialize, response_deserializer=vmmigration.DatacenterConnector.deserialize, @@ -608,7 +698,9 @@ def create_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_datacenter_connector" not in self._stubs: - self._stubs["create_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateDatacenterConnector", request_serializer=vmmigration.CreateDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -636,7 +728,9 @@ def delete_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_datacenter_connector" not in self._stubs: - self._stubs["delete_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteDatacenterConnector", request_serializer=vmmigration.DeleteDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -663,7 +757,7 @@ def upgrade_appliance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_appliance" not in self._stubs: - self._stubs["upgrade_appliance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_appliance"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpgradeAppliance", request_serializer=vmmigration.UpgradeApplianceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -689,7 +783,7 @@ def create_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migrating_vm" not in self._stubs: - self._stubs["create_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["create_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateMigratingVm", request_serializer=vmmigration.CreateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -717,7 +811,7 @@ def list_migrating_vms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migrating_vms" not in self._stubs: - self._stubs["list_migrating_vms"] = self.grpc_channel.unary_unary( + self._stubs["list_migrating_vms"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListMigratingVms", request_serializer=vmmigration.ListMigratingVmsRequest.serialize, response_deserializer=vmmigration.ListMigratingVmsResponse.deserialize, @@ -743,7 +837,7 @@ def get_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migrating_vm" not in self._stubs: - self._stubs["get_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["get_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetMigratingVm", request_serializer=vmmigration.GetMigratingVmRequest.serialize, response_deserializer=vmmigration.MigratingVm.deserialize, @@ -769,7 +863,7 @@ def update_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_migrating_vm" not in self._stubs: - self._stubs["update_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["update_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateMigratingVm", request_serializer=vmmigration.UpdateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -795,7 +889,7 @@ def delete_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migrating_vm" not in self._stubs: - self._stubs["delete_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["delete_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteMigratingVm", request_serializer=vmmigration.DeleteMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +917,7 @@ def start_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration" not in self._stubs: - self._stubs["start_migration"] = self.grpc_channel.unary_unary( + self._stubs["start_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/StartMigration", request_serializer=vmmigration.StartMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -854,7 +948,7 @@ def resume_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_migration" not in self._stubs: - self._stubs["resume_migration"] = self.grpc_channel.unary_unary( + self._stubs["resume_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ResumeMigration", request_serializer=vmmigration.ResumeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -883,7 +977,7 @@ def pause_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_migration" not in self._stubs: - self._stubs["pause_migration"] = self.grpc_channel.unary_unary( + self._stubs["pause_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/PauseMigration", request_serializer=vmmigration.PauseMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -911,7 +1005,7 @@ def finalize_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "finalize_migration" not in self._stubs: - self._stubs["finalize_migration"] = self.grpc_channel.unary_unary( + self._stubs["finalize_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FinalizeMigration", request_serializer=vmmigration.FinalizeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -937,7 +1031,7 @@ def create_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clone_job" not in self._stubs: - self._stubs["create_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["create_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCloneJob", request_serializer=vmmigration.CreateCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -963,7 +1057,7 @@ def cancel_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_clone_job" not in self._stubs: - self._stubs["cancel_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCloneJob", request_serializer=vmmigration.CancelCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -991,7 +1085,7 @@ def list_clone_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clone_jobs" not in self._stubs: - self._stubs["list_clone_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_clone_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCloneJobs", request_serializer=vmmigration.ListCloneJobsRequest.serialize, response_deserializer=vmmigration.ListCloneJobsResponse.deserialize, @@ -1017,7 +1111,7 @@ def get_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clone_job" not in self._stubs: - self._stubs["get_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["get_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCloneJob", request_serializer=vmmigration.GetCloneJobRequest.serialize, response_deserializer=vmmigration.CloneJob.deserialize, @@ -1045,7 +1139,7 @@ def create_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cutover_job" not in self._stubs: - self._stubs["create_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["create_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCutoverJob", request_serializer=vmmigration.CreateCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1071,7 +1165,7 @@ def cancel_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_cutover_job" not in self._stubs: - self._stubs["cancel_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCutoverJob", request_serializer=vmmigration.CancelCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1099,7 +1193,7 @@ def list_cutover_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cutover_jobs" not in self._stubs: - self._stubs["list_cutover_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_cutover_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCutoverJobs", request_serializer=vmmigration.ListCutoverJobsRequest.serialize, response_deserializer=vmmigration.ListCutoverJobsResponse.deserialize, @@ -1125,7 +1219,7 @@ def get_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cutover_job" not in self._stubs: - self._stubs["get_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["get_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCutoverJob", request_serializer=vmmigration.GetCutoverJobRequest.serialize, response_deserializer=vmmigration.CutoverJob.deserialize, @@ -1151,7 +1245,7 @@ def list_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_groups" not in self._stubs: - self._stubs["list_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_groups"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListGroups", request_serializer=vmmigration.ListGroupsRequest.serialize, response_deserializer=vmmigration.ListGroupsResponse.deserialize, @@ -1175,7 +1269,7 @@ def get_group(self) -> Callable[[vmmigration.GetGroupRequest], vmmigration.Group # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_group" not in self._stubs: - self._stubs["get_group"] = self.grpc_channel.unary_unary( + self._stubs["get_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetGroup", request_serializer=vmmigration.GetGroupRequest.serialize, response_deserializer=vmmigration.Group.deserialize, @@ -1201,7 +1295,7 @@ def create_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_group" not in self._stubs: - self._stubs["create_group"] = self.grpc_channel.unary_unary( + self._stubs["create_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateGroup", request_serializer=vmmigration.CreateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1227,7 +1321,7 @@ def update_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_group" not in self._stubs: - self._stubs["update_group"] = self.grpc_channel.unary_unary( + self._stubs["update_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateGroup", request_serializer=vmmigration.UpdateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1253,7 +1347,7 @@ def delete_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_group" not in self._stubs: - self._stubs["delete_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteGroup", request_serializer=vmmigration.DeleteGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1279,7 +1373,7 @@ def add_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_group_migration" not in self._stubs: - self._stubs["add_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["add_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/AddGroupMigration", request_serializer=vmmigration.AddGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1305,7 +1399,7 @@ def remove_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_group_migration" not in self._stubs: - self._stubs["remove_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["remove_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/RemoveGroupMigration", request_serializer=vmmigration.RemoveGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1336,7 +1430,7 @@ def list_target_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_target_projects" not in self._stubs: - self._stubs["list_target_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_target_projects"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListTargetProjects", request_serializer=vmmigration.ListTargetProjectsRequest.serialize, response_deserializer=vmmigration.ListTargetProjectsResponse.deserialize, @@ -1365,7 +1459,7 @@ def get_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_target_project" not in self._stubs: - self._stubs["get_target_project"] = self.grpc_channel.unary_unary( + self._stubs["get_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetTargetProject", request_serializer=vmmigration.GetTargetProjectRequest.serialize, response_deserializer=vmmigration.TargetProject.deserialize, @@ -1394,7 +1488,7 @@ def create_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_target_project" not in self._stubs: - self._stubs["create_target_project"] = self.grpc_channel.unary_unary( + self._stubs["create_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateTargetProject", request_serializer=vmmigration.CreateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1423,7 +1517,7 @@ def update_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_target_project" not in self._stubs: - self._stubs["update_target_project"] = self.grpc_channel.unary_unary( + self._stubs["update_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateTargetProject", request_serializer=vmmigration.UpdateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1452,7 +1546,7 @@ def delete_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_target_project" not in self._stubs: - self._stubs["delete_target_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteTargetProject", request_serializer=vmmigration.DeleteTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1481,7 +1575,7 @@ def list_replication_cycles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replication_cycles" not in self._stubs: - self._stubs["list_replication_cycles"] = self.grpc_channel.unary_unary( + self._stubs["list_replication_cycles"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListReplicationCycles", request_serializer=vmmigration.ListReplicationCyclesRequest.serialize, response_deserializer=vmmigration.ListReplicationCyclesResponse.deserialize, @@ -1509,7 +1603,7 @@ def get_replication_cycle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replication_cycle" not in self._stubs: - self._stubs["get_replication_cycle"] = self.grpc_channel.unary_unary( + self._stubs["get_replication_cycle"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetReplicationCycle", request_serializer=vmmigration.GetReplicationCycleRequest.serialize, response_deserializer=vmmigration.ReplicationCycle.deserialize, @@ -1517,7 +1611,7 @@ def get_replication_cycle( return self._stubs["get_replication_cycle"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1529,7 +1623,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1546,7 +1640,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1563,7 +1657,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1582,7 +1676,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1601,7 +1695,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1618,7 +1712,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py index aa1c2979d7d5..2a87d0a2372f 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vmmigration_v1.types import vmmigration from .base import DEFAULT_CLIENT_INFO, VmMigrationTransport from .grpc import VmMigrationGrpcTransport +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.vmmigration.v1.VmMigration", + "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.vmmigration.v1.VmMigration", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmMigrationGrpcAsyncIOTransport(VmMigrationTransport): """gRPC AsyncIO backend transport for VmMigration. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListSources", request_serializer=vmmigration.ListSourcesRequest.serialize, response_deserializer=vmmigration.ListSourcesResponse.deserialize, @@ -310,7 +395,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetSource", request_serializer=vmmigration.GetSourceRequest.serialize, response_deserializer=vmmigration.Source.deserialize, @@ -338,7 +423,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateSource", request_serializer=vmmigration.CreateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -366,7 +451,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateSource", request_serializer=vmmigration.UpdateSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +479,7 @@ def delete_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_source" not in self._stubs: - self._stubs["delete_source"] = self.grpc_channel.unary_unary( + self._stubs["delete_source"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteSource", request_serializer=vmmigration.DeleteSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def fetch_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_inventory" not in self._stubs: - self._stubs["fetch_inventory"] = self.grpc_channel.unary_unary( + self._stubs["fetch_inventory"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FetchInventory", request_serializer=vmmigration.FetchInventoryRequest.serialize, response_deserializer=vmmigration.FetchInventoryResponse.deserialize, @@ -458,7 +543,7 @@ def list_utilization_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_utilization_reports" not in self._stubs: - self._stubs["list_utilization_reports"] = self.grpc_channel.unary_unary( + self._stubs["list_utilization_reports"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListUtilizationReports", request_serializer=vmmigration.ListUtilizationReportsRequest.serialize, response_deserializer=vmmigration.ListUtilizationReportsResponse.deserialize, @@ -487,7 +572,7 @@ def get_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_utilization_report" not in self._stubs: - self._stubs["get_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["get_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetUtilizationReport", request_serializer=vmmigration.GetUtilizationReportRequest.serialize, response_deserializer=vmmigration.UtilizationReport.deserialize, @@ -516,7 +601,7 @@ def create_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_utilization_report" not in self._stubs: - self._stubs["create_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["create_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateUtilizationReport", request_serializer=vmmigration.CreateUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def delete_utilization_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_utilization_report" not in self._stubs: - self._stubs["delete_utilization_report"] = self.grpc_channel.unary_unary( + self._stubs["delete_utilization_report"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteUtilizationReport", request_serializer=vmmigration.DeleteUtilizationReportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +659,9 @@ def list_datacenter_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datacenter_connectors" not in self._stubs: - self._stubs["list_datacenter_connectors"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_datacenter_connectors" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListDatacenterConnectors", request_serializer=vmmigration.ListDatacenterConnectorsRequest.serialize, response_deserializer=vmmigration.ListDatacenterConnectorsResponse.deserialize, @@ -603,7 +690,7 @@ def get_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_datacenter_connector" not in self._stubs: - self._stubs["get_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_datacenter_connector"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetDatacenterConnector", request_serializer=vmmigration.GetDatacenterConnectorRequest.serialize, response_deserializer=vmmigration.DatacenterConnector.deserialize, @@ -632,7 +719,9 @@ def create_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_datacenter_connector" not in self._stubs: - self._stubs["create_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateDatacenterConnector", request_serializer=vmmigration.CreateDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +750,9 @@ def delete_datacenter_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_datacenter_connector" not in self._stubs: - self._stubs["delete_datacenter_connector"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_datacenter_connector" + ] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteDatacenterConnector", request_serializer=vmmigration.DeleteDatacenterConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -690,7 +781,7 @@ def upgrade_appliance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_appliance" not in self._stubs: - self._stubs["upgrade_appliance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_appliance"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpgradeAppliance", request_serializer=vmmigration.UpgradeApplianceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -718,7 +809,7 @@ def create_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migrating_vm" not in self._stubs: - self._stubs["create_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["create_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateMigratingVm", request_serializer=vmmigration.CreateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -747,7 +838,7 @@ def list_migrating_vms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migrating_vms" not in self._stubs: - self._stubs["list_migrating_vms"] = self.grpc_channel.unary_unary( + self._stubs["list_migrating_vms"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListMigratingVms", request_serializer=vmmigration.ListMigratingVmsRequest.serialize, response_deserializer=vmmigration.ListMigratingVmsResponse.deserialize, @@ -775,7 +866,7 @@ def get_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migrating_vm" not in self._stubs: - self._stubs["get_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["get_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetMigratingVm", request_serializer=vmmigration.GetMigratingVmRequest.serialize, response_deserializer=vmmigration.MigratingVm.deserialize, @@ -803,7 +894,7 @@ def update_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_migrating_vm" not in self._stubs: - self._stubs["update_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["update_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateMigratingVm", request_serializer=vmmigration.UpdateMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -831,7 +922,7 @@ def delete_migrating_vm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migrating_vm" not in self._stubs: - self._stubs["delete_migrating_vm"] = self.grpc_channel.unary_unary( + self._stubs["delete_migrating_vm"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteMigratingVm", request_serializer=vmmigration.DeleteMigratingVmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -861,7 +952,7 @@ def start_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration" not in self._stubs: - self._stubs["start_migration"] = self.grpc_channel.unary_unary( + self._stubs["start_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/StartMigration", request_serializer=vmmigration.StartMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -894,7 +985,7 @@ def resume_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_migration" not in self._stubs: - self._stubs["resume_migration"] = self.grpc_channel.unary_unary( + self._stubs["resume_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ResumeMigration", request_serializer=vmmigration.ResumeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -925,7 +1016,7 @@ def pause_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_migration" not in self._stubs: - self._stubs["pause_migration"] = self.grpc_channel.unary_unary( + self._stubs["pause_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/PauseMigration", request_serializer=vmmigration.PauseMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -955,7 +1046,7 @@ def finalize_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "finalize_migration" not in self._stubs: - self._stubs["finalize_migration"] = self.grpc_channel.unary_unary( + self._stubs["finalize_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/FinalizeMigration", request_serializer=vmmigration.FinalizeMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -983,7 +1074,7 @@ def create_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_clone_job" not in self._stubs: - self._stubs["create_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["create_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCloneJob", request_serializer=vmmigration.CreateCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1011,7 +1102,7 @@ def cancel_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_clone_job" not in self._stubs: - self._stubs["cancel_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCloneJob", request_serializer=vmmigration.CancelCloneJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1039,7 +1130,7 @@ def list_clone_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clone_jobs" not in self._stubs: - self._stubs["list_clone_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_clone_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCloneJobs", request_serializer=vmmigration.ListCloneJobsRequest.serialize, response_deserializer=vmmigration.ListCloneJobsResponse.deserialize, @@ -1065,7 +1156,7 @@ def get_clone_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_clone_job" not in self._stubs: - self._stubs["get_clone_job"] = self.grpc_channel.unary_unary( + self._stubs["get_clone_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCloneJob", request_serializer=vmmigration.GetCloneJobRequest.serialize, response_deserializer=vmmigration.CloneJob.deserialize, @@ -1095,7 +1186,7 @@ def create_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cutover_job" not in self._stubs: - self._stubs["create_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["create_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateCutoverJob", request_serializer=vmmigration.CreateCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1123,7 +1214,7 @@ def cancel_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_cutover_job" not in self._stubs: - self._stubs["cancel_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CancelCutoverJob", request_serializer=vmmigration.CancelCutoverJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1152,7 +1243,7 @@ def list_cutover_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cutover_jobs" not in self._stubs: - self._stubs["list_cutover_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_cutover_jobs"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListCutoverJobs", request_serializer=vmmigration.ListCutoverJobsRequest.serialize, response_deserializer=vmmigration.ListCutoverJobsResponse.deserialize, @@ -1180,7 +1271,7 @@ def get_cutover_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cutover_job" not in self._stubs: - self._stubs["get_cutover_job"] = self.grpc_channel.unary_unary( + self._stubs["get_cutover_job"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetCutoverJob", request_serializer=vmmigration.GetCutoverJobRequest.serialize, response_deserializer=vmmigration.CutoverJob.deserialize, @@ -1208,7 +1299,7 @@ def list_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_groups" not in self._stubs: - self._stubs["list_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_groups"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListGroups", request_serializer=vmmigration.ListGroupsRequest.serialize, response_deserializer=vmmigration.ListGroupsResponse.deserialize, @@ -1234,7 +1325,7 @@ def get_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_group" not in self._stubs: - self._stubs["get_group"] = self.grpc_channel.unary_unary( + self._stubs["get_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetGroup", request_serializer=vmmigration.GetGroupRequest.serialize, response_deserializer=vmmigration.Group.deserialize, @@ -1262,7 +1353,7 @@ def create_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_group" not in self._stubs: - self._stubs["create_group"] = self.grpc_channel.unary_unary( + self._stubs["create_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateGroup", request_serializer=vmmigration.CreateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1290,7 +1381,7 @@ def update_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_group" not in self._stubs: - self._stubs["update_group"] = self.grpc_channel.unary_unary( + self._stubs["update_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateGroup", request_serializer=vmmigration.UpdateGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1318,7 +1409,7 @@ def delete_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_group" not in self._stubs: - self._stubs["delete_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_group"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteGroup", request_serializer=vmmigration.DeleteGroupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1346,7 +1437,7 @@ def add_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_group_migration" not in self._stubs: - self._stubs["add_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["add_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/AddGroupMigration", request_serializer=vmmigration.AddGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1374,7 +1465,7 @@ def remove_group_migration( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_group_migration" not in self._stubs: - self._stubs["remove_group_migration"] = self.grpc_channel.unary_unary( + self._stubs["remove_group_migration"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/RemoveGroupMigration", request_serializer=vmmigration.RemoveGroupMigrationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1406,7 +1497,7 @@ def list_target_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_target_projects" not in self._stubs: - self._stubs["list_target_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_target_projects"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListTargetProjects", request_serializer=vmmigration.ListTargetProjectsRequest.serialize, response_deserializer=vmmigration.ListTargetProjectsResponse.deserialize, @@ -1437,7 +1528,7 @@ def get_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_target_project" not in self._stubs: - self._stubs["get_target_project"] = self.grpc_channel.unary_unary( + self._stubs["get_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetTargetProject", request_serializer=vmmigration.GetTargetProjectRequest.serialize, response_deserializer=vmmigration.TargetProject.deserialize, @@ -1468,7 +1559,7 @@ def create_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_target_project" not in self._stubs: - self._stubs["create_target_project"] = self.grpc_channel.unary_unary( + self._stubs["create_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/CreateTargetProject", request_serializer=vmmigration.CreateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1499,7 +1590,7 @@ def update_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_target_project" not in self._stubs: - self._stubs["update_target_project"] = self.grpc_channel.unary_unary( + self._stubs["update_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/UpdateTargetProject", request_serializer=vmmigration.UpdateTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1530,7 +1621,7 @@ def delete_target_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_target_project" not in self._stubs: - self._stubs["delete_target_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_target_project"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/DeleteTargetProject", request_serializer=vmmigration.DeleteTargetProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1559,7 +1650,7 @@ def list_replication_cycles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replication_cycles" not in self._stubs: - self._stubs["list_replication_cycles"] = self.grpc_channel.unary_unary( + self._stubs["list_replication_cycles"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/ListReplicationCycles", request_serializer=vmmigration.ListReplicationCyclesRequest.serialize, response_deserializer=vmmigration.ListReplicationCyclesResponse.deserialize, @@ -1588,7 +1679,7 @@ def get_replication_cycle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replication_cycle" not in self._stubs: - self._stubs["get_replication_cycle"] = self.grpc_channel.unary_unary( + self._stubs["get_replication_cycle"] = self._logged_channel.unary_unary( "/google.cloud.vmmigration.v1.VmMigration/GetReplicationCycle", request_serializer=vmmigration.GetReplicationCycleRequest.serialize, response_deserializer=vmmigration.ReplicationCycle.deserialize, @@ -1866,7 +1957,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1882,7 +1973,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1899,7 +1990,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1916,7 +2007,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1935,7 +2026,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1954,7 +2045,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1971,7 +2062,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py index 6e410a960e70..2c6f5d8aa46f 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/services/vm_migration/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -441,8 +449,10 @@ def post_upgrade_appliance(self, response): def pre_add_group_migration( self, request: vmmigration.AddGroupMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.AddGroupMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.AddGroupMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_group_migration Override in a subclass to manipulate the request or metadata @@ -464,8 +474,10 @@ def post_add_group_migration( def pre_cancel_clone_job( self, request: vmmigration.CancelCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CancelCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CancelCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_clone_job Override in a subclass to manipulate the request or metadata @@ -487,8 +499,10 @@ def post_cancel_clone_job( def pre_cancel_cutover_job( self, request: vmmigration.CancelCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CancelCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CancelCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_cutover_job Override in a subclass to manipulate the request or metadata @@ -510,8 +524,10 @@ def post_cancel_cutover_job( def pre_create_clone_job( self, request: vmmigration.CreateCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_clone_job Override in a subclass to manipulate the request or metadata @@ -533,8 +549,10 @@ def post_create_clone_job( def pre_create_cutover_job( self, request: vmmigration.CreateCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cutover_job Override in a subclass to manipulate the request or metadata @@ -556,8 +574,11 @@ def post_create_cutover_job( def pre_create_datacenter_connector( self, request: vmmigration.CreateDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -579,8 +600,8 @@ def post_create_datacenter_connector( def pre_create_group( self, request: vmmigration.CreateGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.CreateGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_group Override in a subclass to manipulate the request or metadata @@ -602,8 +623,10 @@ def post_create_group( def pre_create_migrating_vm( self, request: vmmigration.CreateMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_migrating_vm Override in a subclass to manipulate the request or metadata @@ -625,8 +648,10 @@ def post_create_migrating_vm( def pre_create_source( self, request: vmmigration.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -648,8 +673,10 @@ def post_create_source( def pre_create_target_project( self, request: vmmigration.CreateTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_target_project Override in a subclass to manipulate the request or metadata @@ -671,8 +698,11 @@ def post_create_target_project( def pre_create_utilization_report( self, request: vmmigration.CreateUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.CreateUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.CreateUtilizationReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_utilization_report Override in a subclass to manipulate the request or metadata @@ -694,8 +724,11 @@ def post_create_utilization_report( def pre_delete_datacenter_connector( self, request: vmmigration.DeleteDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -717,8 +750,8 @@ def post_delete_datacenter_connector( def pre_delete_group( self, request: vmmigration.DeleteGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.DeleteGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_group Override in a subclass to manipulate the request or metadata @@ -740,8 +773,10 @@ def post_delete_group( def pre_delete_migrating_vm( self, request: vmmigration.DeleteMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_migrating_vm Override in a subclass to manipulate the request or metadata @@ -763,8 +798,10 @@ def post_delete_migrating_vm( def pre_delete_source( self, request: vmmigration.DeleteSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_source Override in a subclass to manipulate the request or metadata @@ -786,8 +823,10 @@ def post_delete_source( def pre_delete_target_project( self, request: vmmigration.DeleteTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_target_project Override in a subclass to manipulate the request or metadata @@ -809,8 +848,11 @@ def post_delete_target_project( def pre_delete_utilization_report( self, request: vmmigration.DeleteUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.DeleteUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.DeleteUtilizationReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_utilization_report Override in a subclass to manipulate the request or metadata @@ -832,8 +874,10 @@ def post_delete_utilization_report( def pre_fetch_inventory( self, request: vmmigration.FetchInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.FetchInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.FetchInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for fetch_inventory Override in a subclass to manipulate the request or metadata @@ -855,8 +899,10 @@ def post_fetch_inventory( def pre_finalize_migration( self, request: vmmigration.FinalizeMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.FinalizeMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.FinalizeMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for finalize_migration Override in a subclass to manipulate the request or metadata @@ -878,8 +924,8 @@ def post_finalize_migration( def pre_get_clone_job( self, request: vmmigration.GetCloneJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetCloneJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetCloneJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_clone_job Override in a subclass to manipulate the request or metadata @@ -901,8 +947,10 @@ def post_get_clone_job( def pre_get_cutover_job( self, request: vmmigration.GetCutoverJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetCutoverJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetCutoverJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cutover_job Override in a subclass to manipulate the request or metadata @@ -924,8 +972,11 @@ def post_get_cutover_job( def pre_get_datacenter_connector( self, request: vmmigration.GetDatacenterConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetDatacenterConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetDatacenterConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_datacenter_connector Override in a subclass to manipulate the request or metadata @@ -945,8 +996,10 @@ def post_get_datacenter_connector( return response def pre_get_group( - self, request: vmmigration.GetGroupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmmigration.GetGroupRequest, Sequence[Tuple[str, str]]]: + self, + request: vmmigration.GetGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_group Override in a subclass to manipulate the request or metadata @@ -966,8 +1019,10 @@ def post_get_group(self, response: vmmigration.Group) -> vmmigration.Group: def pre_get_migrating_vm( self, request: vmmigration.GetMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_migrating_vm Override in a subclass to manipulate the request or metadata @@ -989,8 +1044,10 @@ def post_get_migrating_vm( def pre_get_replication_cycle( self, request: vmmigration.GetReplicationCycleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetReplicationCycleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetReplicationCycleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_replication_cycle Override in a subclass to manipulate the request or metadata @@ -1010,8 +1067,10 @@ def post_get_replication_cycle( return response def pre_get_source( - self, request: vmmigration.GetSourceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmmigration.GetSourceRequest, Sequence[Tuple[str, str]]]: + self, + request: vmmigration.GetSourceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -1031,8 +1090,10 @@ def post_get_source(self, response: vmmigration.Source) -> vmmigration.Source: def pre_get_target_project( self, request: vmmigration.GetTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_target_project Override in a subclass to manipulate the request or metadata @@ -1054,8 +1115,10 @@ def post_get_target_project( def pre_get_utilization_report( self, request: vmmigration.GetUtilizationReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.GetUtilizationReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.GetUtilizationReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_utilization_report Override in a subclass to manipulate the request or metadata @@ -1077,8 +1140,10 @@ def post_get_utilization_report( def pre_list_clone_jobs( self, request: vmmigration.ListCloneJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListCloneJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListCloneJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clone_jobs Override in a subclass to manipulate the request or metadata @@ -1100,8 +1165,10 @@ def post_list_clone_jobs( def pre_list_cutover_jobs( self, request: vmmigration.ListCutoverJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListCutoverJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListCutoverJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_cutover_jobs Override in a subclass to manipulate the request or metadata @@ -1123,8 +1190,11 @@ def post_list_cutover_jobs( def pre_list_datacenter_connectors( self, request: vmmigration.ListDatacenterConnectorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListDatacenterConnectorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListDatacenterConnectorsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_datacenter_connectors Override in a subclass to manipulate the request or metadata @@ -1146,8 +1216,8 @@ def post_list_datacenter_connectors( def pre_list_groups( self, request: vmmigration.ListGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.ListGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_groups Override in a subclass to manipulate the request or metadata @@ -1169,8 +1239,10 @@ def post_list_groups( def pre_list_migrating_vms( self, request: vmmigration.ListMigratingVmsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListMigratingVmsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListMigratingVmsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_migrating_vms Override in a subclass to manipulate the request or metadata @@ -1192,8 +1264,11 @@ def post_list_migrating_vms( def pre_list_replication_cycles( self, request: vmmigration.ListReplicationCyclesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListReplicationCyclesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListReplicationCyclesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_replication_cycles Override in a subclass to manipulate the request or metadata @@ -1215,8 +1290,8 @@ def post_list_replication_cycles( def pre_list_sources( self, request: vmmigration.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.ListSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -1238,8 +1313,10 @@ def post_list_sources( def pre_list_target_projects( self, request: vmmigration.ListTargetProjectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListTargetProjectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListTargetProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_target_projects Override in a subclass to manipulate the request or metadata @@ -1261,8 +1338,11 @@ def post_list_target_projects( def pre_list_utilization_reports( self, request: vmmigration.ListUtilizationReportsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ListUtilizationReportsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ListUtilizationReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_utilization_reports Override in a subclass to manipulate the request or metadata @@ -1284,8 +1364,10 @@ def post_list_utilization_reports( def pre_pause_migration( self, request: vmmigration.PauseMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.PauseMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.PauseMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_migration Override in a subclass to manipulate the request or metadata @@ -1307,8 +1389,10 @@ def post_pause_migration( def pre_remove_group_migration( self, request: vmmigration.RemoveGroupMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.RemoveGroupMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.RemoveGroupMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_group_migration Override in a subclass to manipulate the request or metadata @@ -1330,8 +1414,10 @@ def post_remove_group_migration( def pre_resume_migration( self, request: vmmigration.ResumeMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.ResumeMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.ResumeMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_migration Override in a subclass to manipulate the request or metadata @@ -1353,8 +1439,10 @@ def post_resume_migration( def pre_start_migration( self, request: vmmigration.StartMigrationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.StartMigrationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.StartMigrationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_migration Override in a subclass to manipulate the request or metadata @@ -1376,8 +1464,8 @@ def post_start_migration( def pre_update_group( self, request: vmmigration.UpdateGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmmigration.UpdateGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_group Override in a subclass to manipulate the request or metadata @@ -1399,8 +1487,10 @@ def post_update_group( def pre_update_migrating_vm( self, request: vmmigration.UpdateMigratingVmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateMigratingVmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateMigratingVmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_migrating_vm Override in a subclass to manipulate the request or metadata @@ -1422,8 +1512,10 @@ def post_update_migrating_vm( def pre_update_source( self, request: vmmigration.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -1445,8 +1537,10 @@ def post_update_source( def pre_update_target_project( self, request: vmmigration.UpdateTargetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpdateTargetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpdateTargetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_target_project Override in a subclass to manipulate the request or metadata @@ -1468,8 +1562,10 @@ def post_update_target_project( def pre_upgrade_appliance( self, request: vmmigration.UpgradeApplianceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmmigration.UpgradeApplianceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmmigration.UpgradeApplianceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for upgrade_appliance Override in a subclass to manipulate the request or metadata @@ -1491,8 +1587,10 @@ def post_upgrade_appliance( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -1514,8 +1612,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -1537,8 +1637,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1558,8 +1660,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1579,8 +1683,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1602,8 +1708,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1798,7 +1906,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add group migration method over HTTP. @@ -1809,8 +1917,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1823,6 +1933,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseAddGroupMigration._get_http_options() ) + request, metadata = self._interceptor.pre_add_group_migration( request, metadata ) @@ -1839,6 +1950,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.AddGroupMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "AddGroupMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._AddGroupMigration._get_response( self._host, @@ -1858,7 +1996,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_group_migration(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.vmmigration_v1.VmMigrationClient.add_group_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "AddGroupMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelCloneJob( @@ -1896,7 +2056,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the cancel clone job method over HTTP. @@ -1907,8 +2067,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1921,6 +2083,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCancelCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_clone_job( request, metadata ) @@ -1937,6 +2100,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CancelCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelCloneJob._get_response( self._host, @@ -1956,7 +2146,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_clone_job(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.vmmigration_v1.VmMigrationClient.cancel_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelCutoverJob( @@ -1994,7 +2206,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the cancel cutover job method over HTTP. @@ -2005,8 +2217,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2019,6 +2233,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCancelCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_cutover_job( request, metadata ) @@ -2035,6 +2250,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CancelCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelCutoverJob._get_response( self._host, @@ -2054,7 +2296,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_cutover_job(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.vmmigration_v1.VmMigrationClient.cancel_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCloneJob( @@ -2092,7 +2356,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create clone job method over HTTP. @@ -2103,8 +2367,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2117,6 +2383,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_clone_job( request, metadata ) @@ -2133,6 +2400,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateCloneJob._get_response( self._host, @@ -2152,7 +2446,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_clone_job(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.vmmigration_v1.VmMigrationClient.create_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCutoverJob( @@ -2190,7 +2506,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cutover job method over HTTP. @@ -2201,8 +2517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2215,6 +2533,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_cutover_job( request, metadata ) @@ -2231,6 +2550,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateCutoverJob._get_response( self._host, @@ -2250,7 +2596,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cutover_job(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.vmmigration_v1.VmMigrationClient.create_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDatacenterConnector( @@ -2289,7 +2657,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create datacenter connector method over HTTP. @@ -2301,8 +2669,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2315,6 +2685,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_create_datacenter_connector( request, metadata ) @@ -2331,6 +2702,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmMigrationRestTransport._CreateDatacenterConnector._get_response( @@ -2352,7 +2750,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_datacenter_connector(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.vmmigration_v1.VmMigrationClient.create_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGroup( @@ -2390,7 +2810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create group method over HTTP. @@ -2401,8 +2821,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2415,6 +2837,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateGroup._get_http_options() ) + request, metadata = self._interceptor.pre_create_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseCreateGroup._get_transcoded_request( @@ -2435,6 +2858,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.CreateGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateGroup._get_response( self._host, @@ -2454,7 +2904,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_group(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.vmmigration_v1.VmMigrationClient.create_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMigratingVm( @@ -2492,7 +2964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create migrating vm method over HTTP. @@ -2503,8 +2975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2517,6 +2991,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_create_migrating_vm( request, metadata ) @@ -2533,6 +3008,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateMigratingVm._get_response( self._host, @@ -2552,7 +3054,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_migrating_vm(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.vmmigration_v1.VmMigrationClient.create_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -2590,7 +3114,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create source method over HTTP. @@ -2601,8 +3125,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2615,6 +3141,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseCreateSource._get_transcoded_request( @@ -2635,6 +3162,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.CreateSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateSource._get_response( self._host, @@ -2654,7 +3208,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_source(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.vmmigration_v1.VmMigrationClient.create_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTargetProject( @@ -2692,7 +3268,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create target project method over HTTP. @@ -2703,8 +3279,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2717,6 +3295,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_create_target_project( request, metadata ) @@ -2733,6 +3312,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateTargetProject._get_response( self._host, @@ -2752,7 +3358,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_target_project(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.vmmigration_v1.VmMigrationClient.create_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUtilizationReport( @@ -2790,7 +3418,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create utilization report method over HTTP. @@ -2801,8 +3429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2815,6 +3445,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseCreateUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_create_utilization_report( request, metadata ) @@ -2831,6 +3462,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CreateUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CreateUtilizationReport._get_response( self._host, @@ -2850,7 +3508,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_utilization_report(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.vmmigration_v1.VmMigrationClient.create_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CreateUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDatacenterConnector( @@ -2888,7 +3568,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete datacenter connector method over HTTP. @@ -2900,8 +3580,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2914,6 +3596,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_datacenter_connector( request, metadata ) @@ -2926,6 +3609,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.DeleteDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmMigrationRestTransport._DeleteDatacenterConnector._get_response( @@ -2946,7 +3656,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_datacenter_connector(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.vmmigration_v1.VmMigrationClient.delete_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGroup( @@ -2983,7 +3715,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete group method over HTTP. @@ -2994,8 +3726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3008,6 +3742,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteGroup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseDeleteGroup._get_transcoded_request( @@ -3022,6 +3757,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.DeleteGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteGroup._get_response( self._host, @@ -3040,7 +3802,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_group(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.vmmigration_v1.VmMigrationClient.delete_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteMigratingVm( @@ -3077,7 +3861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete migrating vm method over HTTP. @@ -3088,8 +3872,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3102,6 +3888,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_delete_migrating_vm( request, metadata ) @@ -3114,6 +3901,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.DeleteMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteMigratingVm._get_response( self._host, @@ -3132,7 +3946,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_migrating_vm(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.vmmigration_v1.VmMigrationClient.delete_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSource( @@ -3169,7 +4005,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete source method over HTTP. @@ -3180,8 +4016,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3194,6 +4032,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteSource._get_http_options() ) + request, metadata = self._interceptor.pre_delete_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseDeleteSource._get_transcoded_request( @@ -3208,6 +4047,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.DeleteSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteSource._get_response( self._host, @@ -3226,7 +4092,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_source(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.vmmigration_v1.VmMigrationClient.delete_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTargetProject( @@ -3263,7 +4151,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete target project method over HTTP. @@ -3274,8 +4162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3288,6 +4178,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_delete_target_project( request, metadata ) @@ -3300,6 +4191,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.DeleteTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteTargetProject._get_response( self._host, @@ -3318,7 +4236,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_target_project(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.vmmigration_v1.VmMigrationClient.delete_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUtilizationReport( @@ -3355,7 +4295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete utilization report method over HTTP. @@ -3366,8 +4306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3380,6 +4322,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseDeleteUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_delete_utilization_report( request, metadata ) @@ -3392,6 +4335,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.DeleteUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteUtilizationReport._get_response( self._host, @@ -3410,7 +4380,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_utilization_report(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.vmmigration_v1.VmMigrationClient.delete_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchInventory( @@ -3447,7 +4439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.FetchInventoryResponse: r"""Call the fetch inventory method over HTTP. @@ -3458,8 +4450,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.FetchInventoryResponse: @@ -3471,6 +4465,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseFetchInventory._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_inventory(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseFetchInventory._get_transcoded_request( http_options, request @@ -3481,6 +4476,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.FetchInventory", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FetchInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._FetchInventory._get_response( self._host, @@ -3501,7 +4523,31 @@ def __call__( pb_resp = vmmigration.FetchInventoryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_inventory(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.FetchInventoryResponse.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.vmmigration_v1.VmMigrationClient.fetch_inventory", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FetchInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FinalizeMigration( @@ -3539,7 +4585,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the finalize migration method over HTTP. @@ -3550,8 +4596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3564,6 +4612,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseFinalizeMigration._get_http_options() ) + request, metadata = self._interceptor.pre_finalize_migration( request, metadata ) @@ -3580,6 +4629,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.FinalizeMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FinalizeMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._FinalizeMigration._get_response( self._host, @@ -3599,7 +4675,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_finalize_migration(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.vmmigration_v1.VmMigrationClient.finalize_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "FinalizeMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCloneJob( @@ -3636,7 +4734,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CloneJob: r"""Call the get clone job method over HTTP. @@ -3647,8 +4745,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.CloneJob: @@ -3671,6 +4771,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetCloneJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_clone_job(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetCloneJob._get_transcoded_request( @@ -3685,6 +4786,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetCloneJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCloneJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetCloneJob._get_response( self._host, @@ -3705,7 +4833,29 @@ def __call__( pb_resp = vmmigration.CloneJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_clone_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.CloneJob.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.vmmigration_v1.VmMigrationClient.get_clone_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCloneJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCutoverJob( @@ -3742,7 +4892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.CutoverJob: r"""Call the get cutover job method over HTTP. @@ -3753,8 +4903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.CutoverJob: @@ -3770,6 +4922,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetCutoverJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_cutover_job(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseGetCutoverJob._get_transcoded_request( http_options, request @@ -3782,6 +4935,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetCutoverJob", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCutoverJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetCutoverJob._get_response( self._host, @@ -3802,7 +4982,29 @@ def __call__( pb_resp = vmmigration.CutoverJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cutover_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.CutoverJob.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.vmmigration_v1.VmMigrationClient.get_cutover_job", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetCutoverJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDatacenterConnector( @@ -3839,7 +5041,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.DatacenterConnector: r"""Call the get datacenter connector method over HTTP. @@ -3850,8 +5052,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.DatacenterConnector: @@ -3868,6 +5072,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetDatacenterConnector._get_http_options() ) + request, metadata = self._interceptor.pre_get_datacenter_connector( request, metadata ) @@ -3880,6 +5085,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.GetDatacenterConnector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetDatacenterConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetDatacenterConnector._get_response( self._host, @@ -3900,7 +5132,29 @@ def __call__( pb_resp = vmmigration.DatacenterConnector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_datacenter_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.DatacenterConnector.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.vmmigration_v1.VmMigrationClient.get_datacenter_connector", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetDatacenterConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGroup(_BaseVmMigrationRestTransport._BaseGetGroup, VmMigrationRestStub): @@ -3935,7 +5189,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Group: r"""Call the get group method over HTTP. @@ -3946,8 +5200,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.Group: @@ -3960,6 +5216,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetGroup._get_http_options() ) + request, metadata = self._interceptor.pre_get_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetGroup._get_transcoded_request( @@ -3974,6 +5231,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetGroup._get_response( self._host, @@ -3994,7 +5278,29 @@ def __call__( pb_resp = vmmigration.Group.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.Group.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.vmmigration_v1.VmMigrationClient.get_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMigratingVm( @@ -4031,7 +5337,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.MigratingVm: r"""Call the get migrating vm method over HTTP. @@ -4042,8 +5348,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.MigratingVm: @@ -4056,6 +5364,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_get_migrating_vm( request, metadata ) @@ -4068,6 +5377,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.GetMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetMigratingVm._get_response( self._host, @@ -4088,7 +5424,29 @@ def __call__( pb_resp = vmmigration.MigratingVm.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_migrating_vm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.MigratingVm.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.vmmigration_v1.VmMigrationClient.get_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReplicationCycle( @@ -4125,7 +5483,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ReplicationCycle: r"""Call the get replication cycle method over HTTP. @@ -4136,8 +5494,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ReplicationCycle: @@ -4150,6 +5510,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetReplicationCycle._get_http_options() ) + request, metadata = self._interceptor.pre_get_replication_cycle( request, metadata ) @@ -4162,6 +5523,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.GetReplicationCycle", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetReplicationCycle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetReplicationCycle._get_response( self._host, @@ -4182,7 +5570,29 @@ def __call__( pb_resp = vmmigration.ReplicationCycle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_replication_cycle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ReplicationCycle.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.vmmigration_v1.VmMigrationClient.get_replication_cycle", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetReplicationCycle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource(_BaseVmMigrationRestTransport._BaseGetSource, VmMigrationRestStub): @@ -4217,7 +5627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.Source: r"""Call the get source method over HTTP. @@ -4228,8 +5638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.Source: @@ -4243,6 +5655,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetSource._get_transcoded_request( @@ -4257,6 +5670,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetSource._get_response( self._host, @@ -4277,7 +5717,29 @@ def __call__( pb_resp = vmmigration.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.Source.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.vmmigration_v1.VmMigrationClient.get_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTargetProject( @@ -4314,7 +5776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.TargetProject: r"""Call the get target project method over HTTP. @@ -4325,8 +5787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.TargetProject: @@ -4339,6 +5803,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_get_target_project( request, metadata ) @@ -4351,6 +5816,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.GetTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetTargetProject._get_response( self._host, @@ -4371,7 +5863,29 @@ def __call__( pb_resp = vmmigration.TargetProject.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_target_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.TargetProject.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.vmmigration_v1.VmMigrationClient.get_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUtilizationReport( @@ -4408,7 +5922,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.UtilizationReport: r"""Call the get utilization report method over HTTP. @@ -4419,8 +5933,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.UtilizationReport: @@ -4433,6 +5949,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetUtilizationReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_utilization_report( request, metadata ) @@ -4445,6 +5962,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.GetUtilizationReport", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetUtilizationReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetUtilizationReport._get_response( self._host, @@ -4465,7 +6009,29 @@ def __call__( pb_resp = vmmigration.UtilizationReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_utilization_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.UtilizationReport.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.vmmigration_v1.VmMigrationClient.get_utilization_report", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetUtilizationReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCloneJobs( @@ -4502,7 +6068,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListCloneJobsResponse: r"""Call the list clone jobs method over HTTP. @@ -4513,8 +6079,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListCloneJobsResponse: @@ -4526,6 +6094,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListCloneJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_clone_jobs(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListCloneJobs._get_transcoded_request( http_options, request @@ -4538,6 +6107,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.ListCloneJobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCloneJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListCloneJobs._get_response( self._host, @@ -4558,7 +6154,31 @@ def __call__( pb_resp = vmmigration.ListCloneJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clone_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListCloneJobsResponse.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.vmmigration_v1.VmMigrationClient.list_clone_jobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCloneJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCutoverJobs( @@ -4595,7 +6215,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListCutoverJobsResponse: r"""Call the list cutover jobs method over HTTP. @@ -4606,8 +6226,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListCutoverJobsResponse: @@ -4619,6 +6241,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListCutoverJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_cutover_jobs( request, metadata ) @@ -4631,6 +6254,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListCutoverJobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCutoverJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListCutoverJobs._get_response( self._host, @@ -4651,7 +6301,31 @@ def __call__( pb_resp = vmmigration.ListCutoverJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cutover_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListCutoverJobsResponse.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.vmmigration_v1.VmMigrationClient.list_cutover_jobs", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListCutoverJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatacenterConnectors( @@ -4688,7 +6362,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListDatacenterConnectorsResponse: r"""Call the list datacenter connectors method over HTTP. @@ -4700,8 +6374,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListDatacenterConnectorsResponse: @@ -4713,6 +6389,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListDatacenterConnectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_datacenter_connectors( request, metadata ) @@ -4725,6 +6402,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListDatacenterConnectors", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListDatacenterConnectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListDatacenterConnectors._get_response( self._host, @@ -4745,7 +6449,31 @@ def __call__( pb_resp = vmmigration.ListDatacenterConnectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_datacenter_connectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListDatacenterConnectorsResponse.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.vmmigration_v1.VmMigrationClient.list_datacenter_connectors", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListDatacenterConnectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGroups( @@ -4782,7 +6510,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListGroupsResponse: r"""Call the list groups method over HTTP. @@ -4793,8 +6521,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListGroupsResponse: @@ -4806,6 +6536,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListGroups._get_http_options() ) + request, metadata = self._interceptor.pre_list_groups(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseListGroups._get_transcoded_request( @@ -4820,6 +6551,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.ListGroups", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListGroups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListGroups._get_response( self._host, @@ -4840,7 +6598,29 @@ def __call__( pb_resp = vmmigration.ListGroupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_groups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListGroupsResponse.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.vmmigration_v1.VmMigrationClient.list_groups", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListGroups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMigratingVms( @@ -4877,7 +6657,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListMigratingVmsResponse: r"""Call the list migrating vms method over HTTP. @@ -4888,8 +6668,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListMigratingVmsResponse: @@ -4901,6 +6683,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListMigratingVms._get_http_options() ) + request, metadata = self._interceptor.pre_list_migrating_vms( request, metadata ) @@ -4913,6 +6696,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListMigratingVms", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListMigratingVms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListMigratingVms._get_response( self._host, @@ -4933,7 +6743,31 @@ def __call__( pb_resp = vmmigration.ListMigratingVmsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_migrating_vms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListMigratingVmsResponse.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.vmmigration_v1.VmMigrationClient.list_migrating_vms", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListMigratingVms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReplicationCycles( @@ -4970,7 +6804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListReplicationCyclesResponse: r"""Call the list replication cycles method over HTTP. @@ -4981,8 +6815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListReplicationCyclesResponse: @@ -4994,6 +6830,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListReplicationCycles._get_http_options() ) + request, metadata = self._interceptor.pre_list_replication_cycles( request, metadata ) @@ -5006,6 +6843,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListReplicationCycles", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListReplicationCycles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListReplicationCycles._get_response( self._host, @@ -5026,7 +6890,31 @@ def __call__( pb_resp = vmmigration.ListReplicationCyclesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_replication_cycles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListReplicationCyclesResponse.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.vmmigration_v1.VmMigrationClient.list_replication_cycles", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListReplicationCycles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -5063,7 +6951,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -5074,8 +6962,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListSourcesResponse: @@ -5087,6 +6977,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseListSources._get_transcoded_request( @@ -5101,6 +6992,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.ListSources", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListSources._get_response( self._host, @@ -5121,7 +7039,29 @@ def __call__( pb_resp = vmmigration.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListSourcesResponse.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.vmmigration_v1.VmMigrationClient.list_sources", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTargetProjects( @@ -5158,7 +7098,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListTargetProjectsResponse: r"""Call the list target projects method over HTTP. @@ -5169,8 +7109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListTargetProjectsResponse: @@ -5182,6 +7124,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListTargetProjects._get_http_options() ) + request, metadata = self._interceptor.pre_list_target_projects( request, metadata ) @@ -5194,6 +7137,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListTargetProjects", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListTargetProjects", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListTargetProjects._get_response( self._host, @@ -5214,7 +7184,31 @@ def __call__( pb_resp = vmmigration.ListTargetProjectsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_target_projects(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmmigration.ListTargetProjectsResponse.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.vmmigration_v1.VmMigrationClient.list_target_projects", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListTargetProjects", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUtilizationReports( @@ -5251,7 +7245,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmmigration.ListUtilizationReportsResponse: r"""Call the list utilization reports method over HTTP. @@ -5262,8 +7256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmmigration.ListUtilizationReportsResponse: @@ -5275,6 +7271,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListUtilizationReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_utilization_reports( request, metadata ) @@ -5287,6 +7284,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListUtilizationReports", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListUtilizationReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListUtilizationReports._get_response( self._host, @@ -5307,7 +7331,31 @@ def __call__( pb_resp = vmmigration.ListUtilizationReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_utilization_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmmigration.ListUtilizationReportsResponse.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.vmmigration_v1.VmMigrationClient.list_utilization_reports", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListUtilizationReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseMigration( @@ -5345,7 +7393,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the pause migration method over HTTP. @@ -5356,8 +7404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5370,6 +7420,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BasePauseMigration._get_http_options() ) + request, metadata = self._interceptor.pre_pause_migration(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BasePauseMigration._get_transcoded_request( http_options, request @@ -5384,6 +7435,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.PauseMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "PauseMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._PauseMigration._get_response( self._host, @@ -5403,7 +7481,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_migration(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.vmmigration_v1.VmMigrationClient.pause_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "PauseMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveGroupMigration( @@ -5441,7 +7541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove group migration method over HTTP. @@ -5452,8 +7552,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5466,6 +7568,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseRemoveGroupMigration._get_http_options() ) + request, metadata = self._interceptor.pre_remove_group_migration( request, metadata ) @@ -5482,6 +7585,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.RemoveGroupMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "RemoveGroupMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._RemoveGroupMigration._get_response( self._host, @@ -5501,7 +7631,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_group_migration(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.vmmigration_v1.VmMigrationClient.remove_group_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "RemoveGroupMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeMigration( @@ -5539,7 +7691,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the resume migration method over HTTP. @@ -5550,8 +7702,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5564,6 +7718,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseResumeMigration._get_http_options() ) + request, metadata = self._interceptor.pre_resume_migration( request, metadata ) @@ -5580,6 +7735,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ResumeMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ResumeMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ResumeMigration._get_response( self._host, @@ -5599,7 +7781,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_migration(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.vmmigration_v1.VmMigrationClient.resume_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ResumeMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartMigration( @@ -5637,7 +7841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start migration method over HTTP. @@ -5648,8 +7852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5662,6 +7868,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseStartMigration._get_http_options() ) + request, metadata = self._interceptor.pre_start_migration(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseStartMigration._get_transcoded_request( http_options, request @@ -5676,6 +7883,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.StartMigration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "StartMigration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._StartMigration._get_response( self._host, @@ -5695,7 +7929,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_migration(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.vmmigration_v1.VmMigrationClient.start_migration", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "StartMigration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGroup( @@ -5733,7 +7989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update group method over HTTP. @@ -5744,8 +8000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5758,6 +8016,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateGroup._get_http_options() ) + request, metadata = self._interceptor.pre_update_group(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseUpdateGroup._get_transcoded_request( @@ -5778,6 +8037,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.UpdateGroup", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateGroup._get_response( self._host, @@ -5797,7 +8083,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_group(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.vmmigration_v1.VmMigrationClient.update_group", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMigratingVm( @@ -5835,7 +8143,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update migrating vm method over HTTP. @@ -5846,8 +8154,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5860,6 +8170,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateMigratingVm._get_http_options() ) + request, metadata = self._interceptor.pre_update_migrating_vm( request, metadata ) @@ -5876,6 +8187,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.UpdateMigratingVm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateMigratingVm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateMigratingVm._get_response( self._host, @@ -5895,7 +8233,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_migrating_vm(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.vmmigration_v1.VmMigrationClient.update_migrating_vm", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateMigratingVm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -5933,7 +8293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update source method over HTTP. @@ -5944,8 +8304,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -5958,6 +8320,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseUpdateSource._get_transcoded_request( @@ -5978,6 +8341,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.UpdateSource", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateSource._get_response( self._host, @@ -5997,7 +8387,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_source(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.vmmigration_v1.VmMigrationClient.update_source", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTargetProject( @@ -6035,7 +8447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update target project method over HTTP. @@ -6046,8 +8458,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6060,6 +8474,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpdateTargetProject._get_http_options() ) + request, metadata = self._interceptor.pre_update_target_project( request, metadata ) @@ -6076,6 +8491,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.UpdateTargetProject", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateTargetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpdateTargetProject._get_response( self._host, @@ -6095,7 +8537,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_target_project(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.vmmigration_v1.VmMigrationClient.update_target_project", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpdateTargetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeAppliance( @@ -6133,7 +8597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the upgrade appliance method over HTTP. @@ -6144,8 +8608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6158,6 +8624,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseUpgradeAppliance._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_appliance( request, metadata ) @@ -6174,6 +8641,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.UpgradeAppliance", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpgradeAppliance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._UpgradeAppliance._get_response( self._host, @@ -6193,7 +8687,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upgrade_appliance(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.vmmigration_v1.VmMigrationClient.upgrade_appliance", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "UpgradeAppliance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -6633,7 +9149,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -6643,8 +9159,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -6653,6 +9171,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetLocation._get_transcoded_request( @@ -6667,6 +9186,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetLocation._get_response( self._host, @@ -6686,6 +9232,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.vmmigration_v1.VmMigrationAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6726,7 +9293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -6736,8 +9303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -6746,6 +9315,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -6758,6 +9328,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListLocations._get_response( self._host, @@ -6777,6 +9374,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.vmmigration_v1.VmMigrationAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6818,7 +9436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -6828,13 +9446,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseVmMigrationRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -6851,6 +9472,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.CancelOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._CancelOperation._get_response( self._host, @@ -6907,7 +9555,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -6917,13 +9565,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseVmMigrationRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -6936,6 +9587,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._DeleteOperation._get_response( self._host, @@ -6991,7 +9669,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -7001,8 +9679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -7011,6 +9691,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseVmMigrationRestTransport._BaseGetOperation._get_transcoded_request( @@ -7025,6 +9706,33 @@ def __call__( ) ) + 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.vmmigration_v1.VmMigrationClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._GetOperation._get_response( self._host, @@ -7044,6 +9752,27 @@ def __call__( 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.vmmigration_v1.VmMigrationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -7084,7 +9813,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -7094,8 +9823,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -7104,6 +9835,7 @@ def __call__( http_options = ( _BaseVmMigrationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVmMigrationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -7114,6 +9846,33 @@ def __call__( 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.vmmigration_v1.VmMigrationClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmMigrationRestTransport._ListOperations._get_response( self._host, @@ -7133,6 +9892,27 @@ def __call__( 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.vmmigration_v1.VmMigrationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmmigration.v1.VmMigration", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json index 12b93cb65ff3..cfb6d660b704 100644 --- a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json +++ b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vm-migration", - "version": "1.9.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1334,7 +1334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1511,7 +1511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1600,7 +1600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1688,7 +1688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1865,7 +1865,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2026,7 +2026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2187,7 +2187,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2348,7 +2348,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2509,7 +2509,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2670,7 +2670,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2831,7 +2831,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.FetchInventoryResponse", @@ -2992,7 +2992,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.FetchInventoryResponse", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3153,7 +3153,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CloneJob", @@ -3314,7 +3314,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CloneJob", @@ -3395,7 +3395,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CutoverJob", @@ -3475,7 +3475,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.CutoverJob", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.DatacenterConnector", @@ -3636,7 +3636,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.DatacenterConnector", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Group", @@ -3797,7 +3797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Group", @@ -3878,7 +3878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.MigratingVm", @@ -3958,7 +3958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.MigratingVm", @@ -4039,7 +4039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.ReplicationCycle", @@ -4119,7 +4119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.ReplicationCycle", @@ -4200,7 +4200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Source", @@ -4280,7 +4280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.Source", @@ -4361,7 +4361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.TargetProject", @@ -4441,7 +4441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.TargetProject", @@ -4522,7 +4522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.UtilizationReport", @@ -4602,7 +4602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.types.UtilizationReport", @@ -4683,7 +4683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsAsyncPager", @@ -4763,7 +4763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsPager", @@ -4844,7 +4844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsAsyncPager", @@ -4924,7 +4924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsPager", @@ -5005,7 +5005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsAsyncPager", @@ -5085,7 +5085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsPager", @@ -5166,7 +5166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsAsyncPager", @@ -5246,7 +5246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListGroupsPager", @@ -5327,7 +5327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsAsyncPager", @@ -5407,7 +5407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsPager", @@ -5488,7 +5488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesAsyncPager", @@ -5568,7 +5568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesPager", @@ -5649,7 +5649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesAsyncPager", @@ -5729,7 +5729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListSourcesPager", @@ -5810,7 +5810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsAsyncPager", @@ -5890,7 +5890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsPager", @@ -5971,7 +5971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsAsyncPager", @@ -6051,7 +6051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsPager", @@ -6128,7 +6128,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6204,7 +6204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6285,7 +6285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6365,7 +6365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6442,7 +6442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6518,7 +6518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6599,7 +6599,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6679,7 +6679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6764,7 +6764,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6848,7 +6848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6933,7 +6933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7017,7 +7017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7102,7 +7102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7186,7 +7186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7271,7 +7271,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7355,7 +7355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7432,7 +7432,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7508,7 +7508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py index 91ebe564e9e1..8ec167e7c6b2 100644 --- a/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py +++ b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py @@ -18739,6 +18739,7 @@ def test_list_sources_rest_required_fields(request_type=vmmigration.ListSourcesR response_value._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_sources(request) @@ -18805,6 +18806,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_sources(**mock_args) @@ -18994,6 +18996,7 @@ def test_get_source_rest_required_fields(request_type=vmmigration.GetSourceReque response_value._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_source(request) @@ -19039,6 +19042,7 @@ def test_get_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -19185,6 +19189,7 @@ def test_create_source_rest_required_fields( response_value._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_source(request) @@ -19252,6 +19257,7 @@ def test_create_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -19390,6 +19396,7 @@ def test_update_source_rest_required_fields( response_value._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_source(request) @@ -19446,6 +19453,7 @@ def test_update_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -19583,6 +19591,7 @@ def test_delete_source_rest_required_fields( response_value._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_source(request) @@ -19626,6 +19635,7 @@ def test_delete_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -19758,6 +19768,7 @@ def test_fetch_inventory_rest_required_fields( response_value._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.fetch_inventory(request) @@ -19805,6 +19816,7 @@ def test_fetch_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.fetch_inventory(**mock_args) @@ -19958,6 +19970,7 @@ def test_list_utilization_reports_rest_required_fields( response_value._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_utilization_reports(request) @@ -20027,6 +20040,7 @@ def test_list_utilization_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_utilization_reports(**mock_args) @@ -20230,6 +20244,7 @@ def test_get_utilization_report_rest_required_fields( response_value._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_utilization_report(request) @@ -20277,6 +20292,7 @@ def test_get_utilization_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_utilization_report(**mock_args) @@ -20432,6 +20448,7 @@ def test_create_utilization_report_rest_required_fields( response_value._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_utilization_report(request) @@ -20499,6 +20516,7 @@ def test_create_utilization_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_utilization_report(**mock_args) @@ -20640,6 +20658,7 @@ def test_delete_utilization_report_rest_required_fields( response_value._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_utilization_report(request) @@ -20685,6 +20704,7 @@ def test_delete_utilization_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_utilization_report(**mock_args) @@ -20837,6 +20857,7 @@ def test_list_datacenter_connectors_rest_required_fields( response_value._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_datacenter_connectors(request) @@ -20905,6 +20926,7 @@ def test_list_datacenter_connectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_datacenter_connectors(**mock_args) @@ -21106,6 +21128,7 @@ def test_get_datacenter_connector_rest_required_fields( response_value._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_datacenter_connector(request) @@ -21153,6 +21176,7 @@ def test_get_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_datacenter_connector(**mock_args) @@ -21308,6 +21332,7 @@ def test_create_datacenter_connector_rest_required_fields( response_value._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_datacenter_connector(request) @@ -21377,6 +21402,7 @@ def test_create_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_datacenter_connector(**mock_args) @@ -21520,6 +21546,7 @@ def test_delete_datacenter_connector_rest_required_fields( response_value._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_datacenter_connector(request) @@ -21565,6 +21592,7 @@ def test_delete_datacenter_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_datacenter_connector(**mock_args) @@ -21700,6 +21728,7 @@ def test_upgrade_appliance_rest_required_fields( response_value._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.upgrade_appliance(request) @@ -21839,6 +21868,7 @@ def test_create_migrating_vm_rest_required_fields( response_value._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_migrating_vm(request) @@ -21910,6 +21940,7 @@ def test_create_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_migrating_vm(**mock_args) @@ -22068,6 +22099,7 @@ def test_list_migrating_vms_rest_required_fields( response_value._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_migrating_vms(request) @@ -22137,6 +22169,7 @@ def test_list_migrating_vms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_migrating_vms(**mock_args) @@ -22337,6 +22370,7 @@ def test_get_migrating_vm_rest_required_fields( response_value._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_migrating_vm(request) @@ -22384,6 +22418,7 @@ def test_get_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_migrating_vm(**mock_args) @@ -22523,6 +22558,7 @@ def test_update_migrating_vm_rest_required_fields( response_value._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_migrating_vm(request) @@ -22583,6 +22619,7 @@ def test_update_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_migrating_vm(**mock_args) @@ -22724,6 +22761,7 @@ def test_delete_migrating_vm_rest_required_fields( response_value._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_migrating_vm(request) @@ -22769,6 +22807,7 @@ def test_delete_migrating_vm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_migrating_vm(**mock_args) @@ -22902,6 +22941,7 @@ def test_start_migration_rest_required_fields( response_value._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.start_migration(request) @@ -22947,6 +22987,7 @@ def test_start_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_migration(**mock_args) @@ -23082,6 +23123,7 @@ def test_resume_migration_rest_required_fields( response_value._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.resume_migration(request) @@ -23203,6 +23245,7 @@ def test_pause_migration_rest_required_fields( response_value._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.pause_migration(request) @@ -23328,6 +23371,7 @@ def test_finalize_migration_rest_required_fields( response_value._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.finalize_migration(request) @@ -23373,6 +23417,7 @@ def test_finalize_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.finalize_migration(**mock_args) @@ -23522,6 +23567,7 @@ def test_create_clone_job_rest_required_fields( response_value._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_clone_job(request) @@ -23593,6 +23639,7 @@ def test_create_clone_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clone_job(**mock_args) @@ -23734,6 +23781,7 @@ def test_cancel_clone_job_rest_required_fields( response_value._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_clone_job(request) @@ -23779,6 +23827,7 @@ def test_cancel_clone_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.cancel_clone_job(**mock_args) @@ -23926,6 +23975,7 @@ def test_list_clone_jobs_rest_required_fields( response_value._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_clone_jobs(request) @@ -23994,6 +24044,7 @@ def test_list_clone_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clone_jobs(**mock_args) @@ -24188,6 +24239,7 @@ def test_get_clone_job_rest_required_fields( response_value._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_clone_job(request) @@ -24235,6 +24287,7 @@ def test_get_clone_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clone_job(**mock_args) @@ -24386,6 +24439,7 @@ def test_create_cutover_job_rest_required_fields( response_value._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_cutover_job(request) @@ -24457,6 +24511,7 @@ def test_create_cutover_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cutover_job(**mock_args) @@ -24600,6 +24655,7 @@ def test_cancel_cutover_job_rest_required_fields( response_value._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_cutover_job(request) @@ -24645,6 +24701,7 @@ def test_cancel_cutover_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.cancel_cutover_job(**mock_args) @@ -24794,6 +24851,7 @@ def test_list_cutover_jobs_rest_required_fields( response_value._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_cutover_jobs(request) @@ -24862,6 +24920,7 @@ def test_list_cutover_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cutover_jobs(**mock_args) @@ -25058,6 +25117,7 @@ def test_get_cutover_job_rest_required_fields( response_value._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_cutover_job(request) @@ -25105,6 +25165,7 @@ def test_get_cutover_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cutover_job(**mock_args) @@ -25250,6 +25311,7 @@ def test_list_groups_rest_required_fields(request_type=vmmigration.ListGroupsReq response_value._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_groups(request) @@ -25316,6 +25378,7 @@ def test_list_groups_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_groups(**mock_args) @@ -25505,6 +25568,7 @@ def test_get_group_rest_required_fields(request_type=vmmigration.GetGroupRequest response_value._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_group(request) @@ -25550,6 +25614,7 @@ def test_get_group_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_group(**mock_args) @@ -25694,6 +25759,7 @@ def test_create_group_rest_required_fields(request_type=vmmigration.CreateGroupR response_value._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_group(request) @@ -25759,6 +25825,7 @@ def test_create_group_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_group(**mock_args) @@ -25893,6 +25960,7 @@ def test_update_group_rest_required_fields(request_type=vmmigration.UpdateGroupR response_value._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_group(request) @@ -25947,6 +26015,7 @@ def test_update_group_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_group(**mock_args) @@ -26080,6 +26149,7 @@ def test_delete_group_rest_required_fields(request_type=vmmigration.DeleteGroupR response_value._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_group(request) @@ -26123,6 +26193,7 @@ def test_delete_group_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_group(**mock_args) @@ -26259,6 +26330,7 @@ def test_add_group_migration_rest_required_fields( response_value._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.add_group_migration(request) @@ -26302,6 +26374,7 @@ def test_add_group_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_group_migration(**mock_args) @@ -26440,6 +26513,7 @@ def test_remove_group_migration_rest_required_fields( response_value._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.remove_group_migration(request) @@ -26483,6 +26557,7 @@ def test_remove_group_migration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_group_migration(**mock_args) @@ -26634,6 +26709,7 @@ def test_list_target_projects_rest_required_fields( response_value._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_target_projects(request) @@ -26700,6 +26776,7 @@ def test_list_target_projects_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_target_projects(**mock_args) @@ -26898,6 +26975,7 @@ def test_get_target_project_rest_required_fields( response_value._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_target_project(request) @@ -26945,6 +27023,7 @@ def test_get_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_target_project(**mock_args) @@ -27097,6 +27176,7 @@ def test_create_target_project_rest_required_fields( response_value._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_target_project(request) @@ -27162,6 +27242,7 @@ def test_create_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_target_project(**mock_args) @@ -27304,6 +27385,7 @@ def test_update_target_project_rest_required_fields( response_value._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_target_project(request) @@ -27360,6 +27442,7 @@ def test_update_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_target_project(**mock_args) @@ -27500,6 +27583,7 @@ def test_delete_target_project_rest_required_fields( response_value._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_target_project(request) @@ -27545,6 +27629,7 @@ def test_delete_target_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_target_project(**mock_args) @@ -27697,6 +27782,7 @@ def test_list_replication_cycles_rest_required_fields( response_value._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_replication_cycles(request) @@ -27765,6 +27851,7 @@ def test_list_replication_cycles_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_replication_cycles(**mock_args) @@ -27966,6 +28053,7 @@ def test_get_replication_cycle_rest_required_fields( response_value._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_replication_cycle(request) @@ -28013,6 +28101,7 @@ def test_get_replication_cycle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_replication_cycle(**mock_args) @@ -30481,6 +30570,7 @@ def test_list_sources_rest_bad_request(request_type=vmmigration.ListSourcesReque 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_sources(request) @@ -30517,6 +30607,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_sources(request) # Establish that the response is the type that we expect. @@ -30556,6 +30647,7 @@ def test_list_sources_rest_interceptors(null_interceptor): 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 = vmmigration.ListSourcesResponse.to_json( vmmigration.ListSourcesResponse() ) @@ -30600,6 +30692,7 @@ def test_get_source_rest_bad_request(request_type=vmmigration.GetSourceRequest): 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_source(request) @@ -30636,6 +30729,7 @@ def test_get_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -30675,6 +30769,7 @@ def test_get_source_rest_interceptors(null_interceptor): 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 = vmmigration.Source.to_json(vmmigration.Source()) req.return_value.content = return_value @@ -30717,6 +30812,7 @@ def test_create_source_rest_bad_request(request_type=vmmigration.CreateSourceReq 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_source(request) @@ -30852,6 +30948,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -30893,6 +30990,7 @@ def test_create_source_rest_interceptors(null_interceptor): 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 @@ -30937,6 +31035,7 @@ def test_update_source_rest_bad_request(request_type=vmmigration.UpdateSourceReq 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_source(request) @@ -31074,6 +31173,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -31115,6 +31215,7 @@ def test_update_source_rest_interceptors(null_interceptor): 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 @@ -31157,6 +31258,7 @@ def test_delete_source_rest_bad_request(request_type=vmmigration.DeleteSourceReq 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_source(request) @@ -31187,6 +31289,7 @@ def test_delete_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -31228,6 +31331,7 @@ def test_delete_source_rest_interceptors(null_interceptor): 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 @@ -31272,6 +31376,7 @@ def test_fetch_inventory_rest_bad_request( 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.fetch_inventory(request) @@ -31305,6 +31410,7 @@ def test_fetch_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.fetch_inventory(request) # Establish that the response is the type that we expect. @@ -31344,6 +31450,7 @@ def test_fetch_inventory_rest_interceptors(null_interceptor): 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 = vmmigration.FetchInventoryResponse.to_json( vmmigration.FetchInventoryResponse() ) @@ -31390,6 +31497,7 @@ def test_list_utilization_reports_rest_bad_request( 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_utilization_reports(request) @@ -31426,6 +31534,7 @@ def test_list_utilization_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_utilization_reports(request) # Establish that the response is the type that we expect. @@ -31467,6 +31576,7 @@ def test_list_utilization_reports_rest_interceptors(null_interceptor): 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 = vmmigration.ListUtilizationReportsResponse.to_json( vmmigration.ListUtilizationReportsResponse() ) @@ -31515,6 +31625,7 @@ def test_get_utilization_report_rest_bad_request( 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_utilization_report(request) @@ -31556,6 +31667,7 @@ def test_get_utilization_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_utilization_report(request) # Establish that the response is the type that we expect. @@ -31600,6 +31712,7 @@ def test_get_utilization_report_rest_interceptors(null_interceptor): 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 = vmmigration.UtilizationReport.to_json( vmmigration.UtilizationReport() ) @@ -31646,6 +31759,7 @@ def test_create_utilization_report_rest_bad_request( 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_utilization_report(request) @@ -31794,6 +31908,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_utilization_report(request) # Establish that the response is the type that we expect. @@ -31835,6 +31950,7 @@ def test_create_utilization_report_rest_interceptors(null_interceptor): 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 @@ -31881,6 +31997,7 @@ def test_delete_utilization_report_rest_bad_request( 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_utilization_report(request) @@ -31913,6 +32030,7 @@ def test_delete_utilization_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_utilization_report(request) # Establish that the response is the type that we expect. @@ -31954,6 +32072,7 @@ def test_delete_utilization_report_rest_interceptors(null_interceptor): 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 @@ -31998,6 +32117,7 @@ def test_list_datacenter_connectors_rest_bad_request( 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_datacenter_connectors(request) @@ -32034,6 +32154,7 @@ def test_list_datacenter_connectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_datacenter_connectors(request) # Establish that the response is the type that we expect. @@ -32075,6 +32196,7 @@ def test_list_datacenter_connectors_rest_interceptors(null_interceptor): 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 = vmmigration.ListDatacenterConnectorsResponse.to_json( vmmigration.ListDatacenterConnectorsResponse() ) @@ -32123,6 +32245,7 @@ def test_get_datacenter_connector_rest_bad_request( 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_datacenter_connector(request) @@ -32167,6 +32290,7 @@ def test_get_datacenter_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32217,6 +32341,7 @@ def test_get_datacenter_connector_rest_interceptors(null_interceptor): 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 = vmmigration.DatacenterConnector.to_json( vmmigration.DatacenterConnector() ) @@ -32263,6 +32388,7 @@ def test_create_datacenter_connector_rest_bad_request( 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_datacenter_connector(request) @@ -32403,6 +32529,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32444,6 +32571,7 @@ def test_create_datacenter_connector_rest_interceptors(null_interceptor): 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 @@ -32490,6 +32618,7 @@ def test_delete_datacenter_connector_rest_bad_request( 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_datacenter_connector(request) @@ -32522,6 +32651,7 @@ def test_delete_datacenter_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_datacenter_connector(request) # Establish that the response is the type that we expect. @@ -32563,6 +32693,7 @@ def test_delete_datacenter_connector_rest_interceptors(null_interceptor): 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 @@ -32609,6 +32740,7 @@ def test_upgrade_appliance_rest_bad_request( 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.upgrade_appliance(request) @@ -32641,6 +32773,7 @@ def test_upgrade_appliance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.upgrade_appliance(request) # Establish that the response is the type that we expect. @@ -32682,6 +32815,7 @@ def test_upgrade_appliance_rest_interceptors(null_interceptor): 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 @@ -32726,6 +32860,7 @@ def test_create_migrating_vm_rest_bad_request( 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_migrating_vm(request) @@ -32982,6 +33117,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33023,6 +33159,7 @@ def test_create_migrating_vm_rest_interceptors(null_interceptor): 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 @@ -33067,6 +33204,7 @@ def test_list_migrating_vms_rest_bad_request( 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_migrating_vms(request) @@ -33103,6 +33241,7 @@ def test_list_migrating_vms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_migrating_vms(request) # Establish that the response is the type that we expect. @@ -33144,6 +33283,7 @@ def test_list_migrating_vms_rest_interceptors(null_interceptor): 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 = vmmigration.ListMigratingVmsResponse.to_json( vmmigration.ListMigratingVmsResponse() ) @@ -33192,6 +33332,7 @@ def test_get_migrating_vm_rest_bad_request( 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_migrating_vm(request) @@ -33234,6 +33375,7 @@ def test_get_migrating_vm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33279,6 +33421,7 @@ def test_get_migrating_vm_rest_interceptors(null_interceptor): 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 = vmmigration.MigratingVm.to_json(vmmigration.MigratingVm()) req.return_value.content = return_value @@ -33327,6 +33470,7 @@ def test_update_migrating_vm_rest_bad_request( 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_migrating_vm(request) @@ -33587,6 +33731,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33628,6 +33773,7 @@ def test_update_migrating_vm_rest_interceptors(null_interceptor): 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 @@ -33674,6 +33820,7 @@ def test_delete_migrating_vm_rest_bad_request( 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_migrating_vm(request) @@ -33706,6 +33853,7 @@ def test_delete_migrating_vm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_migrating_vm(request) # Establish that the response is the type that we expect. @@ -33747,6 +33895,7 @@ def test_delete_migrating_vm_rest_interceptors(null_interceptor): 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 @@ -33793,6 +33942,7 @@ def test_start_migration_rest_bad_request( 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.start_migration(request) @@ -33825,6 +33975,7 @@ def test_start_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_migration(request) # Establish that the response is the type that we expect. @@ -33866,6 +34017,7 @@ def test_start_migration_rest_interceptors(null_interceptor): 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 @@ -33912,6 +34064,7 @@ def test_resume_migration_rest_bad_request( 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.resume_migration(request) @@ -33944,6 +34097,7 @@ def test_resume_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_migration(request) # Establish that the response is the type that we expect. @@ -33985,6 +34139,7 @@ def test_resume_migration_rest_interceptors(null_interceptor): 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 @@ -34031,6 +34186,7 @@ def test_pause_migration_rest_bad_request( 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.pause_migration(request) @@ -34063,6 +34219,7 @@ def test_pause_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_migration(request) # Establish that the response is the type that we expect. @@ -34104,6 +34261,7 @@ def test_pause_migration_rest_interceptors(null_interceptor): 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 @@ -34150,6 +34308,7 @@ def test_finalize_migration_rest_bad_request( 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.finalize_migration(request) @@ -34182,6 +34341,7 @@ def test_finalize_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.finalize_migration(request) # Establish that the response is the type that we expect. @@ -34223,6 +34383,7 @@ def test_finalize_migration_rest_interceptors(null_interceptor): 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 @@ -34269,6 +34430,7 @@ def test_create_clone_job_rest_bad_request( 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_clone_job(request) @@ -34435,6 +34597,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_clone_job(request) # Establish that the response is the type that we expect. @@ -34476,6 +34639,7 @@ def test_create_clone_job_rest_interceptors(null_interceptor): 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 @@ -34522,6 +34686,7 @@ def test_cancel_clone_job_rest_bad_request( 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.cancel_clone_job(request) @@ -34554,6 +34719,7 @@ def test_cancel_clone_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clone_job(request) # Establish that the response is the type that we expect. @@ -34595,6 +34761,7 @@ def test_cancel_clone_job_rest_interceptors(null_interceptor): 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 @@ -34641,6 +34808,7 @@ def test_list_clone_jobs_rest_bad_request( 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_clone_jobs(request) @@ -34679,6 +34847,7 @@ def test_list_clone_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clone_jobs(request) # Establish that the response is the type that we expect. @@ -34720,6 +34889,7 @@ def test_list_clone_jobs_rest_interceptors(null_interceptor): 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 = vmmigration.ListCloneJobsResponse.to_json( vmmigration.ListCloneJobsResponse() ) @@ -34766,6 +34936,7 @@ def test_get_clone_job_rest_bad_request(request_type=vmmigration.GetCloneJobRequ 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_clone_job(request) @@ -34804,6 +34975,7 @@ def test_get_clone_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clone_job(request) # Establish that the response is the type that we expect. @@ -34843,6 +35015,7 @@ def test_get_clone_job_rest_interceptors(null_interceptor): 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 = vmmigration.CloneJob.to_json(vmmigration.CloneJob()) req.return_value.content = return_value @@ -34889,6 +35062,7 @@ def test_create_cutover_job_rest_bad_request( 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_cutover_job(request) @@ -35082,6 +35256,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35123,6 +35298,7 @@ def test_create_cutover_job_rest_interceptors(null_interceptor): 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 @@ -35169,6 +35345,7 @@ def test_cancel_cutover_job_rest_bad_request( 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.cancel_cutover_job(request) @@ -35201,6 +35378,7 @@ def test_cancel_cutover_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35242,6 +35420,7 @@ def test_cancel_cutover_job_rest_interceptors(null_interceptor): 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 @@ -35288,6 +35467,7 @@ def test_list_cutover_jobs_rest_bad_request( 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_cutover_jobs(request) @@ -35326,6 +35506,7 @@ def test_list_cutover_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cutover_jobs(request) # Establish that the response is the type that we expect. @@ -35367,6 +35548,7 @@ def test_list_cutover_jobs_rest_interceptors(null_interceptor): 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 = vmmigration.ListCutoverJobsResponse.to_json( vmmigration.ListCutoverJobsResponse() ) @@ -35415,6 +35597,7 @@ def test_get_cutover_job_rest_bad_request( 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_cutover_job(request) @@ -35455,6 +35638,7 @@ def test_get_cutover_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cutover_job(request) # Establish that the response is the type that we expect. @@ -35498,6 +35682,7 @@ def test_get_cutover_job_rest_interceptors(null_interceptor): 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 = vmmigration.CutoverJob.to_json(vmmigration.CutoverJob()) req.return_value.content = return_value @@ -35540,6 +35725,7 @@ def test_list_groups_rest_bad_request(request_type=vmmigration.ListGroupsRequest 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_groups(request) @@ -35576,6 +35762,7 @@ def test_list_groups_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_groups(request) # Establish that the response is the type that we expect. @@ -35615,6 +35802,7 @@ def test_list_groups_rest_interceptors(null_interceptor): 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 = vmmigration.ListGroupsResponse.to_json( vmmigration.ListGroupsResponse() ) @@ -35659,6 +35847,7 @@ def test_get_group_rest_bad_request(request_type=vmmigration.GetGroupRequest): 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_group(request) @@ -35696,6 +35885,7 @@ def test_get_group_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_group(request) # Establish that the response is the type that we expect. @@ -35736,6 +35926,7 @@ def test_get_group_rest_interceptors(null_interceptor): 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 = vmmigration.Group.to_json(vmmigration.Group()) req.return_value.content = return_value @@ -35778,6 +35969,7 @@ def test_create_group_rest_bad_request(request_type=vmmigration.CreateGroupReque 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_group(request) @@ -35882,6 +36074,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_group(request) # Establish that the response is the type that we expect. @@ -35921,6 +36114,7 @@ def test_create_group_rest_interceptors(null_interceptor): 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 @@ -35965,6 +36159,7 @@ def test_update_group_rest_bad_request(request_type=vmmigration.UpdateGroupReque 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_group(request) @@ -36071,6 +36266,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_group(request) # Establish that the response is the type that we expect. @@ -36110,6 +36306,7 @@ def test_update_group_rest_interceptors(null_interceptor): 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 @@ -36152,6 +36349,7 @@ def test_delete_group_rest_bad_request(request_type=vmmigration.DeleteGroupReque 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_group(request) @@ -36182,6 +36380,7 @@ def test_delete_group_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_group(request) # Establish that the response is the type that we expect. @@ -36221,6 +36420,7 @@ def test_delete_group_rest_interceptors(null_interceptor): 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 @@ -36265,6 +36465,7 @@ def test_add_group_migration_rest_bad_request( 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.add_group_migration(request) @@ -36295,6 +36496,7 @@ def test_add_group_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_group_migration(request) # Establish that the response is the type that we expect. @@ -36336,6 +36538,7 @@ def test_add_group_migration_rest_interceptors(null_interceptor): 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 @@ -36380,6 +36583,7 @@ def test_remove_group_migration_rest_bad_request( 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.remove_group_migration(request) @@ -36410,6 +36614,7 @@ def test_remove_group_migration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_group_migration(request) # Establish that the response is the type that we expect. @@ -36451,6 +36656,7 @@ def test_remove_group_migration_rest_interceptors(null_interceptor): 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 @@ -36495,6 +36701,7 @@ def test_list_target_projects_rest_bad_request( 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_target_projects(request) @@ -36531,6 +36738,7 @@ def test_list_target_projects_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_target_projects(request) # Establish that the response is the type that we expect. @@ -36572,6 +36780,7 @@ def test_list_target_projects_rest_interceptors(null_interceptor): 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 = vmmigration.ListTargetProjectsResponse.to_json( vmmigration.ListTargetProjectsResponse() ) @@ -36618,6 +36827,7 @@ def test_get_target_project_rest_bad_request( 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_target_project(request) @@ -36655,6 +36865,7 @@ def test_get_target_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_target_project(request) # Establish that the response is the type that we expect. @@ -36697,6 +36908,7 @@ def test_get_target_project_rest_interceptors(null_interceptor): 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 = vmmigration.TargetProject.to_json(vmmigration.TargetProject()) req.return_value.content = return_value @@ -36741,6 +36953,7 @@ def test_create_target_project_rest_bad_request( 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_target_project(request) @@ -36845,6 +37058,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_target_project(request) # Establish that the response is the type that we expect. @@ -36886,6 +37100,7 @@ def test_create_target_project_rest_interceptors(null_interceptor): 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 @@ -36934,6 +37149,7 @@ def test_update_target_project_rest_bad_request( 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_target_project(request) @@ -37042,6 +37258,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_target_project(request) # Establish that the response is the type that we expect. @@ -37083,6 +37300,7 @@ def test_update_target_project_rest_interceptors(null_interceptor): 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 @@ -37127,6 +37345,7 @@ def test_delete_target_project_rest_bad_request( 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_target_project(request) @@ -37157,6 +37376,7 @@ def test_delete_target_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_target_project(request) # Establish that the response is the type that we expect. @@ -37198,6 +37418,7 @@ def test_delete_target_project_rest_interceptors(null_interceptor): 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 @@ -37244,6 +37465,7 @@ def test_list_replication_cycles_rest_bad_request( 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_replication_cycles(request) @@ -37282,6 +37504,7 @@ def test_list_replication_cycles_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_replication_cycles(request) # Establish that the response is the type that we expect. @@ -37323,6 +37546,7 @@ def test_list_replication_cycles_rest_interceptors(null_interceptor): 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 = vmmigration.ListReplicationCyclesResponse.to_json( vmmigration.ListReplicationCyclesResponse() ) @@ -37371,6 +37595,7 @@ def test_get_replication_cycle_rest_bad_request( 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_replication_cycle(request) @@ -37411,6 +37636,7 @@ def test_get_replication_cycle_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_replication_cycle(request) # Establish that the response is the type that we expect. @@ -37454,6 +37680,7 @@ def test_get_replication_cycle_rest_interceptors(null_interceptor): 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 = vmmigration.ReplicationCycle.to_json( vmmigration.ReplicationCycle() ) @@ -37500,6 +37727,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -37530,6 +37758,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -37558,6 +37787,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -37588,6 +37818,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -37618,6 +37849,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -37648,6 +37880,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -37678,6 +37911,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -37708,6 +37942,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -37738,6 +37973,7 @@ def test_get_operation_rest_bad_request( 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) @@ -37768,6 +38004,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -37798,6 +38035,7 @@ def test_list_operations_rest_bad_request( 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) @@ -37828,6 +38066,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-vm-migration/vmmigration-v1-py.tar.gz b/packages/google-cloud-vm-migration/vmmigration-v1-py.tar.gz index fb309dcb5b7736b1555e2e801972b2dc2d7a2731..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 65536 zcmV)hK%>7OiwFP!000001MFRGciT3y?q~f9tnwjtu1rg^g>=4eT{)6FB;4-ne?^$<&pR!h{9&|d{0PJNrq&~7rZlC%lu3oSOHFHPnb0q178o;1X6&AN4s?gO)LU2_N0Wnk6X0T73(FV4!SkKc zTF~M(btpiKG#g(!{@iEG*2w84xwyO`XQ26CS|26cd}>)Uhk2BY$XUO8(1HIC58?k| zx7Q&bhTVe}_=Fuyph1g}XXH$Mn?*9fhe0eMFJA1s9`o7$ix=|S%y2C;`o^hu4?6Ow zz+bx2H{HGKYwofoM2vmtsNqeZrw$G&Sd%VX(P1S=bJ$OkQrF$3iSDH99r&uvEFV8# z05cPBOy*3H@ozodb5|b!IrReMngbRAva-EFn707#zCgv;)kHVY7KV*tqJ9(X9+lmwr%C! zC)k#}Uy!$9TXKALPE4?#<3q3SJi}YITdjNL+aq$p9MD#HCv&M2DfXFJ&Q7uuolv2D zq0oK;dF2wNE2e z{%i6-n)7!uUR=xms-ZR0!KF&PX{6xNo&T0n(4PuP%4z#Y;ozVNv zUq%1`+6(d7Q=fhHd7wTA>T{?*57p;O_4&2>{3hfB4BH){N*udb4&obl0K$o~BuDtV z4YdvY`K=A3#Q+X4z%7k+OYH8FlK$A^}B+#xaq;o zK%UD4Cf{FoK7#~oq7c2Iu6?itfQgsXZ0Pp(? zSYGzkWX?28;!1lf*uq)5prSw_*cvQpU!NVHzCF`C?zeX({8&sA2$bOi>wzQJ_fcD{ z?`?rCiB{pf!vX;;QH?^5s9W)bQU&53mk{+G7r_|R1wiSj1oYmdddOu*0u11XD$y_q z^Eq~7M|mjp3LqxIOWf`VLgY9SeMNPWt}1ip_F_p;Jv&P-3XkbRbwI5n6zYR3^z zJ6WMq@CJL-j{RmY?APC98M>7sQL)9St%9R|G@Za9NAOR6F>QclSbd=bBWd3}5_Y2U z_POID#7)R?FoA^$q9edVg_6LcooE^^^U&aOd=4=hOwW6ugzrkFu?khf)jLTI_zJEK z3l#(bZ^F0$NUy})DBlwA4k|X+UREXex+=jpRSA0C$`rlI6#XQ{rHk8JY(HLdpDyG; zl5;0q=KN&q8wPO%HbD>Z92!=Bk{_;Z_%K-)eAK>T-1_NT^42hc+y8z`KEO<6525RX z4m}EQRIyM~R{=3_L5vTF$#TF?Z9A?_F2rFIvG9dBphGBOjBdO@O}zhDuFj1q9lbIj z8tAlk|Nm{5|8Q4+|F447N0d=L|35ewcANbFQ(P;@Uv5$!MMm}U9}b3x&Gmh<1^kNffEHL#ib1$cbo=vJwncVJF!hSnv!FC_SD`UVAKXi*$(^g@!#M zA2U@@X-p>i3|Z)jq(r*Sr_}dfI%yS7FxhUOzy_KAo!wQIZwhkVM0))*FsLIu@GE`&4^bGmBgf| ztAv;ib)>3U=*-?P>dIb(EcE+D9Tmnb@Jw1)I+xTnG1TiDslbkB4b4qRcI5T4+I6cD5kSf)i8A^#7Geb(p~P=9Go%{Z&kUu?wlm`u_09RYa}U1Eyk%uArbw<^5q&k; zmSceOw0^iWRUGO@ORuS4J6J#us2M4s*!p3D5L`D#0MU;DgQ&yy7zoPL13(mC1N}hW zHqeJs>*F2>hpCRIPsFBTY1-A{4>j;&Cb}uOR8^xU_M-4QzzY($LtPZS4dj9X+v6=t z-xh4&SUkd;{PuB^1~yQ~h{J1$jxeXL@ECP!h%dmMntBu=PYs0x_S95iCTT0nOyEyV z$w>sNp+FXcYHE=~p&F`49IB}RSHzX2rm(1{@H86LP$Gv%H5JJtQblF1jDT+ufVoIs zH~PA!3xJa?GiIJ(vR%^bn(|<=g%vzOUsw7V&(72rE{@*RmHp10)XvWYg0@Z^CZ%o@ ziYeLkqcN#M%}7W|uM-SOx!c767)@izDT7eLEj|kn*@E6psy^rNzgY5`X)hN zT7f1(-z4aB3N;D(CPCjM=$iz6lb~-B^mU{+3HnD&(8C@=aF0tnel)-(=;RtbCJ|Z?f`DR=&x~H(7Z}-DKsP ztb85ue}JrfEBT54|I+%UdDh~e@~ZayFL$ZoQ`#rhWNdiOzv-xY8($F~5ic-VFH$Y%&eII$eta;SKQKi3*8`Q2P~ zp8prWr=XmS4fDU(?+r5Z|KJdx|Jcm`U;k>}|I)nw<=1%siyoqcuH$w;apY^=hvNTaW+!K0fR@6aNhd{RaP^;%e}}!T(iBn*>CYNnQIPbX@WH@3bv zEE{Kv%)RlA?H~Adf;mK^3RQMobB zo(-)gEJ0RMoKmk;yE2pF1Xch*#xrMTIVyj9N~cC(`1l~xH zIsjYN#+iewmByY1nI+BC5@FODrclC#&Jx+i8xrQ43b`X z)HOUb>)TU{f8k|licWl$>{c;pxz0tiv0Trxlea?q@zOCjH&2~5E8YJLRk^OKts}i+ zpyIM*Yp~M=o6zIw6tnD`spf%?wmoGJj>>G5T8m}djjdA0<4Rg9OH|HSDQMf&IB|5Y zq*A$KZ~}|yk8_p&YdZ%L;x`DS>{Hq z-Y+o0UMU4ANlNGR!seyZddY;-4~+Sj;^pF%$Pm+Spk*Z@m60t&mzW0cE&5P-=mk+r z*YQoyn2(n)WPe_qAb;LzJx}MrWl3?KdqtgeXi=HTS4U-0PFj>?^3I|xlUokUlFpMV zi+n_t=D+hqL18|(s3Pvmio9%bRf0^hitae6}FmDRC5viVa{ zSd=48R1}(GL#{J!lUxwu(md$Lbtzzvi;KWJu3fb?7cHV5B)&!C6XpW(OF@T3@rImU z+$P)GRk^viF4x=DIkvcVU2h9>WknUS^RCKyt*DC$^SP_Aw8&}J=AcxAtN{yiNvdK+ zzDU*P47(!lqpH@KG=iozIT~5LG7p2*MY)!O^4Pq^Ig`SgG|`&e$NDB|HmMv&wlLka zAQw?wl_p!2Q&>}Br;FVD3*`kcD{b()9(U_E3 zTDr+RnmJS6Ti*zgYEEtF8<&W+wz>34X#q~KMvsfuQhKoaSV{>x1&))LAPF~E)k*En;57cdD%u|3gkuXc>g?6=yEixb z$(!@DiyQs?;?^#gZbB=4lU0~TT@RGOBTwKh4yt%pB z@9%yqNN;a()GT&;8~y$L0zw#a2VQ__VcSNSS5}t_=>qD^x#2j}KEes7oyae;n)|^W zKN86M5murYjX#kQ`S};g`uZbCrfTSrp-IKN0z8-&bWU>fIaYho|ti( zbbmlVuEA>md?kYfwjD+5!^bq}X$j;)_~70H8+xTh&5x}P`z3-DFdK3}B@XMd9gp0ze6L=UQr6!^pIEbH63oW8O z2F^z*(Kvi$C#B-YEA%}X%?L5A-` zD2I2ROhR%EneaTDB%vklrb`)is<2M5_nE{Ji8mTKpXL}jFf;_ByD(^?laB1Z1d;~} z@Bq}J3y5M-LvB(JBh(xtL6p!+MoCaeoqNk;4r0wpD+;g856ZC&qD8!%GS%D=7?)E5 zpaWqKqEA6{Gz}c{=r$QCV6~o-40;Ojw`uLgAUS_ zES^&{8W1tK!u-s!m*{Aq`JAR51FLao5si=tTyu^Etz5u08Ne6xd?J7I&U7<7c?$-? ziTkPAsYxL^cn2PWe^!*!2d1iEo|Y%)dP2$suo}hugDxMK2YvHq0s0E>5V@43JLVV6 zsc@Rx|SaU6~A_D+PjDbNc1tZZ4gqK2~eAumJR*@X;bXHA(QR04OBjKi_Y(Z!3 zc#g6K>E_BQbm_PwSoXBzcQ-%k* zTlk$~2A3v$>?8m#M4{kxk$0|iQx5LSyuNWBIT&eDC z9+jMmIzW=>>h`+U32T%>mNR8X(cWE4lxp(FKKyMD7!>ShG6QEn7)!3>6EZ(P__|@@ z&(8@(?ijOClUHD(f-yIOiG>bVMs*Q>VR0(%iqB`rR7zK-p

aF(193m@&eQ6i9IC;%ZXhQ7*)(5fs&vAh9jBS z?)Emv7=}MkCX;QG`$)ky)(RWXtb6Koh^1!koz$P^ha>vEKqQ5t02$LlLLkiW6*_9` z!+`v(JEg8iO+17r9EvOgKLDS+c{3&d1po!+@%1%z zs0aSF?1*2Q#q#dZP&HrX{a`Sm@;SJ|gx*t|xkYA#79L>_PS{KJ(#p&-QMBnujHK9f zz)*geQ}N?0t~`W;Q-MZ*|8PV2oCWs(vG?}fZQM$paQ^nE=vDR{OIevta&vQcmF3K6 z_vep^d+&Ky5psztV>zNXk5cGHR`C;9A8RRQS6TfaA{CW$^LF-0~CK%r2m`T?ji zbrbI%4Kp`dJfIydXNjtHGxWv}<3MvQWGf`wwH&-A;Xj|oT;b4>;3H(aG%Zr+MQfYD zjl3%#Y(dsSe|8VU=f^Ud{z;OC0x`@7Eo6i zD2BpAu|Ge+5Bqzjv4iIm(j|BAFkOG4?q6Bi1Gzd2{!vt)#XhJ~p9xtia{3}Iz=6R!VYxGI+@@%ld_vP|{4*?NF^UX)bo8R)NONL!3*__JYsy3vBUL~uNcco0$(vb^r8yroB zp{30JfwfQ>r^!&u`FY<;Q8a~HHCQm54O!#3T{D744&gs*d9$7709S3jddOq{fb~RD zV~@(~v5r7y9HMR}r#T0`Y%o+Q@eLZY^lKJPpN?x}2MRzLFn^EsIaJUA_{Y$UY?WAo z+K0hP5q|?e9Ij`-q+nB{=2nViWe%m!6#(6#_1kcrkJpvv2&Q}>X>aP z#{O3e&>{;Mqn;~ftdcWW0j*XWSmwgs_rOL5OV@P6zBSrM(9|7oofr5E5TgaRr}Nzd zL*nhnErg^q&0>*vdP!BD!$Lh|7Oy#F@L}FyJTx-|;j_O-n(o&BZG=wP=oTgh#>|}t zv+LvrY^orSP_vT39Gs8tfaW|%yB6J z0fq+SFW`zHg1|9q-Sq$s>fuk}jmf=t1KP+_aKG>>&&?AUp}NlGy*#YK z`5eWs40-N^m4%7bSt?6LGxG#WP9mAfQi>lcjrt_-Vw$(GHJy_lC(kd&E~0+^oH2R< z1O8r|jZ2qqfu+)}5^pR&SIQ1?;_(+rB(aj1$5p~qNO;Z;_bF1a4vjf+Vp+y&Y$t6p zEcMUwPMe+ov#iT$5f8Vh*fuIGp@)3mi*{2E8MsCVTeZ`$&~tM+nx)&Y!6I)mF+h$c z&mQ6;Y4v+h{t1+Sas?BNSsQFuc8nkte23dq5+SULgMaf!V-OXx zAC!&!9UTOQY5PxHh!7W)D~JdI@Yp7B+Rm8dB7j+-OzOw7NIxbe5Y80*$L7N051-Vc zh~F5qbg-QHi~AA%-<;HspXQx%AAn|%PET4K_06w^e(U_N~ zVI~yJv5AJU#Ex8{hGFfjpkY|E;x_uEyk}+)ojzHQK2hYgran>2u2i4MB2-_WSOoCF z^@+y3JbiM75ne~32=Q7=qgcbnR>D>6ab>G(7izVawz>?@1qR(lsWy5XOC`aQ`S@Bo zlX6b;M|v9peXKH?&Eb3R>q&sYHNAcQl6JWyW`ST5sDq0-kDu(Z@X815RC!u|S`b8G zya+G3sU@yJ(54wG7HA`@$`=6Bz`B-os@$;Tj zUM&`oW3i&>X2`hQaXH?&xqViu!mEgqDN<%R2a&H_qiY(YrcT#OuT-n6(otWpTcxrc z;AI!srU011&BCp^Wfn$tv|s^;Yj4}-1~sm{gO?xmxaMY_)E$p^r+i~is@>z&iy&hR zKC5qj)?tgup8WDom#t^J&oV8VZ2j5Dtb7~Ll$&Ndg1PeBeseHiv|H^HTG?H+XJ{6v zyMLG$@4u4jGYZ$+RWy}d=?-J+QJXri<`!ecj++elv$)%70jJNp+junPyul`+w54{cw4f2*;02E=et?`re;0mrEYMVtgpS7*+P9ekZ_IL znyocgKAkmecXpt^ipBN8A;kjrmTXtF)L+FJtX98^QBQvvI~wimuUefqnc#HTS~ogc z>#%$}YuEtkK!+8J>x1jC0`?YSXOlGd*=U?5KdX(N6(m`!jGq-{VXKLtWu5Y}PL*S5 zwid`I(3(ML)p=v`sEC4t(bfZ_S!YNSAk9u_&&mN6nN;&fhjP@7Hu8-Q(AGOLE$ z?0JiIlI4I~zRca$c_wfhBU0p3_Ky)pQx0)Oo_$mIM>Sd^H2MO_w}~AmnpTh3-7YD<0b=~ zHd?D!DNA-UZ&IPK1}{>QsixkeDV7heldQ}v+y<3jt-t*#UnQ!$?WvY+wB0FdrwZGg z%EhPF+neQmH+f(y>9#Z1vz@6(dXsHTmB7lkFJ&odwry#V(DvJvHsNixO{uZ9XnV4; z0rfISN{tA+rjm-)+lH)aIpuCYN;TKqc5GxX<#aTC)#;+{wi#QPOGfckZ!5Mkl&r$o zP6x@;qQ&-MH4}-)@Mx@eSX`2|I&M4?P*wF)As$deMO3lxCJ&tNw${i%EtHXs!WyCk zwNgoWV)@{{o0XX*JAI866Wb_Qt776idsP*av7^^e4OQ%^*<+`M*1Ch&LJip{tYOEl zl^V(u%Li9OR%Yg@p*ZmusVx=FYN?ZSD;=^koYEWJzl^SqC*2jZuM zWtE|<2vL@8bUDY2%s9_+hm$4_OT`D@#4~>$-$Y4#h?2bs%uHM3`!P+v@l7yUV%ok- zmQ;Hl!K?RmlwK9ynml$IZ#^1Mn>97HonCsSnobp@`fAQ9h!3vg3>N0;H)zfBHfX5e z-c#W_`e$_6;9%_umi-9z=&)je6sDHDHELc-@viPcg-6*_J*z$u_LDIiUz z>nb3<_-Yl9B1#PukWCaHUI7_AEIh)WzE}VJzUX=F!~0UfMkn`E#Zlqdep(mPJ?zYW zQ|qTfug%^Y#oU?w^_eW~=yPwS_`(d?+cE|Trf=^N78>X5$7%Aync%}k+} zK~mKYQnWWOQ}1AYB?Bn;RKBRQ=8^pR){d=n>3dGebaxoPsimWqUG*{i<~EKgeeIM> zIs;mqzOUk2aW9Nvu1%30R(h@24hMr{XoV5+MCOCY9sQ+{wXC3 zCyN26?9B#{Q`-Ofpp#s*8SIoPlPbVdR$ph(Q(5m#E?5dW_-Re>lO*Vk04TZq>LI91 zL>hunhH!QOLz!~h4v11%S_nloG@Q_1u52|a`aLaG6OgKAFy%v1X}xtpsRq`Oy_4yi zPW^NUOf|NR^wKK_r&?G=HaTnwP-XL>4MbJh9J*da%Xxi6=p_}aYXgZ=jm#g`(sILx zRU(JTf}Z~~7$+q4(}*1quWS1hb=d6qpC#Q*OE{I&p~b@_q=~J=ORn6?VG_~Iz)>Wy zy=|ikXDhQtaIeUqp?B(Ff13SCUvi40J6nZB zpn;Xb%B|WyAsJ|7n#jV|PGK-nZ()#dR+a3R)mIV>E3c#{I@=^G)fj3#VQO5L=16Iu z&AvNec&)otO%#e!bPYRH4b_S%d=C!+E1WBdhF4$3u$WtGQZYOhK>U5c#gQc~aU@ zv%^lWtTozQ6TPAoT|<1khI+*mz6aMUD(6aq+11x8EQr>c^a_t(SE^Txz;(5?NNKms z?l~>8)?jr_w1`r44dLk;Y7tZT9$bs4oXgW9{$#>lX?Owtcru}0ukivrG+F4ADmUPv zg{W3ui~Z-1w-n>3zJjUPRkO=Z&8$bwSY)}Twy{xIsnRiIs=n&U6UzrzKvrhv$Bes$ z$=ga5y(bdu)<&%1brce7r>>K(fX7X=QuSV&y?2UfU7^x!!d*LHnw7|k!={~kvrju)@HnXQ*@w5iRyARyriyW4857Fby-@#gLM z^CPtc-jjd=)9BKlrgtiS@j#)BSs=7%HoZ>?#LM|STHsZSul{t&nl2D)q;zq?C|z9C z-A=EDFYQT_>^f4R=*mnr*yWWwreVyj_f2ZNwYwE!vS+U#`0~ zue837>QoBW+p1TUWurZNrS|@-%4&=@8UANJo70z_ZtU&^fjXBO93{{QtolrWA{~v+ z7TCnHolaDzW{a~1IxkBO9kkGcY%{c$D(vhOLUm=R9!Jo0+y>f@mAP(m-+9_=JqOWB zE!t_U;bcTh<(My?5AJ2>u(agJL<DDcz(o z>X!ZNY`3{~0EUW8F`1KF-0hvLXYa(E5lyyFEL2v$gJK9xvrUvd(QUtvk}K7%wo+`Y zF4|2o-mkl%qIaW?zSGOr+g33&T%(;8y$vKGs)PQ{cOgNiw3z$||`O-4z0 z8$`=w_$HcJMpok3Q2MM5*`e7594JS?L)zxv$ma3$gI5+S3xqqfp@_ZEG=Vm^YK|M9o6%p)_4L9kLKxdxzr0UnJQL zq~@K`2(7&%iy&U!23_<-r?mF2Xj$Z&_e3MKeoxm(4c)@oHE2E5!kOknYQ1Wvl-A!B zEo)_qu4t4VX7$ff-nCr%GeQrt?sqUC3YiC+BUwP^_Om3T^ z7Kzlu%$F_(MkDkvqr!p;w;T^f&Vz(R8iwNn_P7ixt^UhM%4$CQ3L1;G)WA5o3 z*{gL9(=6WL2@ zNs@apw#Ib`H*2z4qp+jqlu^sBV7|yA&}gz)WT^Q}>Gsy8&b`9hmRZ&H=Mi3@%6OVP zll0g4wZS?UDWzt*iKQ{5=G4+luV8Yi1KwzQSw*X}31*kbhO^CJXyJSl(Fm$cxAfh# z(XYfe*<>qxslims2)dc3j#!h4mKAO@&)5~UG~HV|z)zLot~Sxig{t{9t00SQCYi*{ zBFj*`R(poQnl9R#JHPl}Zb~(rQt|*bFbdP6E16D`05q9Qru=j^l|);c8-y9>9zA+A z8iA~gM!-YHrpMBK*O$Q1V+1Wv-<~i0S&a8H9v?nBc=XL0AL)wgldnHKncwrVdrD*X zRQh@J^@pc;pE?`|F?^qGg*{C~>*J@RQ8){e(P%Kg&+7Odo}YjEiT;I0|M$ng{`CDf zKm7FbPv8Ia^I!k+UrNRq9`ePuk7~?eZKXceD}l~ zM|d&#$Xg~?PyQ!<^XOaeB%0qZ!t0yF`|FYNK3_6~jl3ir_xbm%>)CcJo@+=QUZLZ~D7Z5+%= zU*U~rcHaP$Z*oJ`a3TXB@gJN-beZ@RyJZY*#&`$Pd!C@bS)z5&XZZzM7QDUVGw<|l&-?e|v(vLfpz-VJ z`QP7uIQM=%e*gaX&H3r`Gw9XQ$_Ko!y#QDR)dauI z7ubGiWQc4GCdjk1AW#}0*3WnzjKiyN4E>s2Fa7JlyT-*6T@DYH{@XB)X|;h>3#d%P z+c4ovtD?E+p7CeOlg!rn>l=U4^*8NWaD&hO{JBlh!v zE~@iiCFPlFO#T|KPL|hD$J$oP4Zv9`y`p=g>|8i_w=F`YfhbcyI$k+b2bEN7| z522;t+Tm4G7zp@^8w7d5gg`wB>ilE~7e7A+zj^!xdL+JjBwEL5`AZP3bo~skXAumX z_R2gQjqz)_4dP2tFOyrwrP#w?M%h<|CB<2m!k56|gmvGK=|dP4Q5lrTLsA2>Vcz^ub7c8jTLX*kl2pY*y1g%+$g0zn}1^s75McFY}+vDDlN%#8Eh@ zQja8JM`eO1u}TtHm7YJn^Y7ykUg!MhU4q&H)+4DQmr*pumb?IFXiY(V<}W8XwVDsS+@K|Z7fXj)Hf!2{BB;LN#k^?h_p?3}h@zt4s z8=zId!$081eSW6!s8E0p26^%#)h_AsL7w;>9ARUO7GjxbAwX!EJZ5@M60nQ#69-}A z0TPK#GIGI?K3(0jjMMWhP$ke2VHiV;Ou^>}$A)X1DM|E^BEj8l#I5De-%=dfM~KoNUC5(_KaZ4}p`BFy#lRqUjy5rf^%5J8w&LxQ?>>NGF>gi|UYi zrm7C=BW<04)y&=<6si#mk7ls2v9Hn?^*oj!t`wIrfUpLdLq3}@;)6UDd3li9w zI5EsBBDn==zzWTAWxGx=j)&w1VQ78Y?qN+!m@fpA1%7c8unZGRw$gK0YeN^QQj;FlIk(4(*hVq6-Pu}>r$y*gMc?)ADZ)23? zZHILKQU0eNd;A8$|8<1LAIye*NAwk%%`s2JuEmAKr$z z!`l^cc*|l9Z&8%tZHh0vWs!xqET-_*MHAk-IKmqrL3nR(?*zZcdt&^okLSm6G{&Q< zlk6U)<<`Ss;NAIjtyUb;k10DjOX!!#Uffzd>iG(|0ee={mf3uzKN34+xaxWSA_0pc0)C*pEfMt0D$f%5Sz);1-GlETnW@(mIU0CmR7rSX)M zx9I}qCqwpfX|O;!rm&{>HuJ0Jkn z&y|y7wK{)7B^&fVFGOY$7jh%IcF7Cn6k07_e4vus#0%v}TP`wk`ig9wd@4z>#ZU>oog-| zFYD?qOM@FT(n6~$?<_@Ep}|^njOnnpOzZ6wEjZ}eK#y%Ln~dY5HGLN~ zQ5(#x*P{5x+wEYBd91beVkhyW-6E$Fs=v6|%6Gn~H5MRP%$iD%Oh%$nl{Zq6Rlp;S zIl@4at(#Jo^Slifr>$d)c0RZkOU|&Y6!df(_@SRQuEmh|RCvocqMcl>#gKPccFXu- zo`J51H1gtG#ufcYbptEz1k3&-y4(_mXveebF@y?l7elnO-n9){!Hss-tVE^0DQgt& z+>UJ~E?~qqk`+bdIDxAC5bv)ywltEj5Zv zr-4o}i+8V88j23;m1c6I2w+O0vTjLBbT2dPOn+@@c}c}u35p<5Uq;lDor?#tq^@94 zn;P@urTwV6odxvrD%P3$9cL>{{l52BkIMHJ8o)$b#0mKlL<3}Ki#TDqN>Pg;$CC+h zW6NAz`<;xM01=YdM&{UVc+_5G&#C-7UcA*}tCOm~=-MfCzWAycr?=D0dc~!|y1j+0v0j&Hu#j&dYjQ5$)Yi}MGZH66p_PiZP^+({ zbBT1Ws15$r)zx}a8#7NQRFz+Px$b2wljibN;OPtc9Kc~s=Yd7U7>7yk9L~^6TWWEeULu%&+Im z`P7~O)<~g>Nyu-4DYUh5X4Jf_thRKqIZr`G&~6g1Qs$uS?!KJ&{w$uJ6i|62amxJB zrD!cr(Mp8}nB!c$Z(Dc|ZHX~$$yb%M^!qkaSvJ<|_wP=;OMmK63&8{O@2&PDN@h)?7R6Qy!99NJPrb?v^3?S`V)Erl=YB` zkv5p#BTuEk5WfsfM2Zc<>7qy|_TR52K3XsRak9ineyE)=*Z8NMxBM%e5%6Y*EfnwbW)MnjPQxvso~e3Nfpj zOu-ZOW5&8qgTdg?lYjf1Ll?F2Z32x4nV3i6EUA&f7ITEA8Dr8?X&XL$<}1sm%liZq z4bne(4Tl=^R7a*6n{+EF470|%w^`#XV6xmpV1(__CwkeLOPIhb<%MoghW z1C)5oqA@1#;xv6RdzZ~4_CAr#T7@rPhhKx)A=p=GGU72=IR@d>wI(xA3?CVSR3S{p zoHh=MS8Q{FJPW`l#Wc1P(mOmUt#|(F%oBx7sfM0qsd%9~Xbvvmub3NlsE%RqQn~ZV zL=J;EW0k3qGF0Z` zlRI>&o{45x;q?+$Z`*v~Z#Pi#FaV%Y>?6wr!OmirjXo0zmyKSN=BnA~(~|FTlST0Y zWW!5JzW$m-A0(fv8`_CELZ(ZTBK0z~meB%)%fOWnMjLCNKf8y)^J7G8%-V&3m8XBF zHqbPNX(mr0tqmyN${WmpykKeWDIa*&5IKq^t@dO8{4ni}JS{!U)8BgeT&M*z zA^)MhEunNw&?H|`fp@b#@0d+Y;YKQn?@gpZVV}UT2l!!s&$Mz7!%x@Ry~A|jg=&9g zWe?=)EEq*meHO!@N`-Qba?WyLD9g*IrmDX6PDz8SJ|HUd)KCJ`P!}66>(bDZgRfK8 z$ppWlWQPgpoXp5WtrKdNpj8z4C(DcZ5~+?qrkPi}UoH{&@GRrTn~#h)zxCL;M8l+P z-BWaAUDPh%j=N(UosMnWwr$%^I!VX2Z9D0T)3I%{VpYtO@Bc5(xi~j3}z zYdeBFESHJG>iqpvYdq_M73Qz?+2VWhJH!&2R2Uz1-7q(JhF*9i4u>F!aR^!@1$8^0 zNv7u`)s}S4Xw)4^5RXv<3Aj^@XWw$)xrtkQ0nBPMJ>Da=F7EWdEcrRP~^ufcC@y1!I8S2)%R;DhjSBc>Q;{b`et92CQ8RW`hAv9ivNljK0~{>$of$ETkxT zW;NnP<{!g9)IkA3uN{_5qpi+}WUr)W>26^u3Z8-5W^9cMl$p3ns_4;$YH%3e?7P6b z<^=vKr^KOKLzkYYR&V8%TY*K~iEMBNi}^af?Y>slmt3l#8XUB(ge%?H` zSpZL~jBn;Pp~rKeNBu|Tdx5nc&gz8pI?mdJC*Pr|0t!&8!^w$s=3^@}*uUfHMzgJ@ zo`*(+Fwc^j(XM@83xL-~Qa~Uv0=s<&&&h^KzKC$I7RwvNbdZj28JH?_==$t{A2#^C z+xIk%GW~7v0#R|y<3xN2qa7nDe4$bxgoFHX3&9g7w=o4v|Inz-cwIpa&Wiy_COtQ; zQHId+Sz{2Iqe)=)MNXG+g>1xf_a%uZrNlVVKE>2!bXwQZ=xp{M4Rh!Xx`FF0YDzn4 zkfy}>jW#d0hk^vc90meL9VacVO~5*MqFvaB)|Sf6o7SAd&F@1<84eckK27d}hi^GS zoTlmo3f86BIw6;t-3PR6U(ReR+6d2zRph}@f~3YDX-pvSR-x7qv!Nt?HQB^oYWD^; z0$F`9W;^hXt)}+pK$4Z9cI*y@`N6Mgp`wxP*#y1xtWQw})JaM}P`J8aTuzhpI!+QJ zbWnOE5u4C8xA)3gFv zM*ZKc>>QH5LPI9nT(jUiIXotEm!jxHvAdOVh!Zn{?<3!3+6Tw_?#ZQ^4mheR<@1Gf zv(TxM(!wv~!5vEtb0QsGzAJb@;Hc{m+$+st+`L)2i}K1FxE3=o8&y}(6$jBQVpLQw zETgxlx6GsIPT*BSXXqg%h%i2eda051(TzFt^{t`0tb?Mjf;}vJk{{K01GGD+2+M@I zm5C!)mKJ_}(K~8XE&J0m)To6;4GOO$$7}HHG!|}2b%`>|37>G+?3zVb8(pZDe{263 zI-lVjW6|0jm&TB(uJS#z>9wNhl}uYo>Hl+hX(P@m25Fkbmwj$u4lhj7VqH6}en@SG zteVaVZ&GQC;D&Ru0dulI(p+w`AXTs8DE_dt`>0-WGuQ?(#tSLs4IrF*RO$UE^Rz^c zPDGRH(zeora9CNYUY@@@wN-Q4YEIIDq&QYhyot;A%8%~{V_jj}w80#`#t<#C6u6t? zGk=6VP{#A-`J6i&3g*00{XeWX6!0I`dnSFbJK==2M*APECphzs1lJ5>o}t+!2^LAo z=&qhqgI^lh2zJ}B!@Jj!@jq5CX}X}(T(f1v$;z>bujq8FJ@PGl*mpf}scLC6)4sf- z>pxqvUFo>6yrZsU3nROF*g~af=GerMacV=FRM(O~e&4t6N4c$J-BT+C{H!8`+tFPP_HaaXK6 ziX&!yahzdY@WzjFfth2XVnPH@-G$TSozkBtaWdmPfQu}00lZ| z${AuVZ(XHpzG*cD)|aFj``}}g*=yiM-Y+D#11xVl9{7#z#14Bq@9n5smz17em+BW+ z0!yh=XJNuVU{`b+180;~nDAZoG9#~O7Uorl2t|0ZD%Il#_nQ~F+X%I7s{UhniN}IE z7~{vmHdX(zJY6(_o8dp>aZm3dmP$m2-l@u5QW2{CfOE2}pL$vfoz)bFnrSs)w-L4G ziW+XA;brC7!5vHB9$G+QwBGSAniroY=b0I(54E>W_&}X_qu#6WMf36*zG&V~T8Y46 z`?PX7<~Q?s_ZY;#I=ISch*cW_|Fs048_tU*Vp8*@JLvrMl!;0srl`NH;6t}$Ejj8< zlLeSN={dt>*P1qRLmM|^NdTJg>e^o_Ld-HQ>o^W`F3I2FS)(Rpq~L$Tzg-{o$Fyi~LxVj9keuEU$rA zTO%CWze`~(Z`@WHL9F^v5SF=dZ|vC^f#VEnbd@ZRJvB%h^4O6~hhXY>EKU#-#uYY% z8Zoh}U%B5rv8iFmg;261sL2l^Mh$!EpG8~D3ty~IRui|%(HtgGL?K;zX=P|NjxT9K zF&+EgQ-@zws;LPL*=vi0s5JQOIl)@wbXd@#$9_RR_i=5iY+kJ|2w-Anp8GEXEg)e{ zVzxT9k*mLvNy~r5?&j+ zRck#w*0mfj2zVp+M~hjwJ=nxlAAdW}YAD7bXcX1uul`n34sxt%w{&E{f9hBF7G{4 z<UXe}uJ^Ra&OZ?8($ZTU9LpvnB0>RpkBsR~524kh48!Um0S}IfJ)P{$OcZPu*5< ziC`iHD(Q-b$}6>jmhAtUJamVWU97nIPMg`z7vI_n@0dNB#jeb6iyGbTKYSf8Y@C@C z-V?#C%l)>ER@G<>tPR;VWiCcly2>;r_CTltAHrPwjnLN{vWlC0S+;3lM>}{hwhz-- zU}C7EU1P#bzhas>sapacjRC)J;Z_&W$;lH2v>YRT#P^?_84^!2rti=HhLIS+jdqD^Js}KvXR$>xONX-VU}A3=RSGnfK$g|23Je!fmvoDM{;R_2gt~^z+>pQq!vh@T4z)rB#(aG z!Y)(kfOSPCY!^nH3fq|yTjt%88k_gcVkNGaKW;g0)*D}EC6lM7=LDZ$-3N}xEGQCY zqhvWN+g?FUG^FUlN=rG)+s(HL@$i3&boLso^8W1LCkD(62LHILOt-Qd{C})n5#1xRd0S&vErM z?5emg{IYmT_ebtgRL&O*lGG1$^5q&g(SMN!zs;6@ho|ZCh7av;byLLFFa92eayVtR zW{4LQ@p$^K^Czrn|2yk*1(OyHyl!Tsq6r0S*|ndoUARj~OXbp$7TZVU@Uw|ch<_v3 zJn~z@_iBg_sgiQ0Z^h%g{jX-2@~MG>a%u!FvKqCgoXDygiz$LaH~?tFcol&zWr0w9 z4#+=CrT(l`*6^_R3h$bnTJZ2@4(z`}=RP!`!VbV=b_!(eRKda^GTqR~?^g~btKi0|BGs=>tq%C43mVk>ck zo@bP_?ewn88wX7;GCZ>jPf!J|ZLf|?G!TEa)VtdLTSk=}BNxJ>tZ0mI=?YH;y$nst zP^(YYqFk{vS!sgCVsO;M@c;d2f1NhWjxSdraSv~=MNZfE9&Xr*F4-`hc z|NCNi&PL#~6P8K?wOw6>W9Bp}VqXkT@;`=0u`uN9CS143EM3kPGl5cBRZ6BjgYdQ9 za~0;57jv}?nEA_5&#MVgTgN8_kC{Nw`nOgAO} zU%aXW)6L2_*4#6ruG!`O=pXN{)A5ZN z`2w!WjiXTW0&p)ncQ1i0W%%5e%3|ZsfqnEbZS+VnYnxLHypWViERpzAnvDNCxY}0- z_rGh@NpGl0p7QzCfZ5frts`+?KXkGNgvDML{ZzfG^vs6UR+*vC!d^z)G$U)=`=(zi z$`-MgLX(D68+-d#`>#m$6P&0I*NRp^)l>FZ&;DSQ9nP6qrY%8}J6wG0Kf*@s3aH~0 z=}s@7k2guWz&7aoUe@-zvJ-@01KycmCYXsdnQ~Vu;5W|vahRSrJ5>UDjiqq#I8=JN zjM7+GZX7jL*E+lpsP-2*)tsMvtm=``( z49lC}G_(zBNmG_>?82+88)m2eDtmpV7_(hQ0;hGiz8Xy*;^WDp*1TcAK1uy)j*l28 z?#0f!X+zF~3eY5qz%M6_Oy`x3m2f@0nvt$!?X0f$VL>iHF3T=oPBUY1&&mImTLG_G z`L{c+4QIfNGQ!dLLGbGc7cCuE`iw9}Bf+9uxiCs#Pa}1;qp4B9ZQt0$*QzG;jF)p( z8s|TJM=2&_md=obR15zfz8fkGVK!YKJW~vPn-Oy}v&`;ZVO-S6XxVeBbjYy~)UM#? ziDAozwW@fzHM{LoGeDGqYm+YaB_K(yD|)aWeT^RYp;X>#WK6YWIz5o+SnRq!P_F%u z*p#!i)(1)LEX)fC*{~ndc4v`Yb!aRwDrmgrLl7~~w6i%FwRz2n(JioV0T`LM&3=U5 z_;1o7cHtdn$}uR}6!p)T#XNA|kuPj`mM>X+{ooc%Za7;OcOQa@7ZBWk%HmdS{h28# zp5+&fwQN<<7;?30z%$xCE3$<%#vRm!FzYwD&F*qn+^a7w-R~BTWYb)9%wuIq(yFg$ z$e41tl4Gr^t-EvAR89HWjF;r1036Y;@v_2nU?h7SNFMm3#>;AOq&}d~Qm|dc`hzB7 zdPf$WGtM>_uE;JciqehkC?iCH>;_v$76TKr_Cj@beYZ4nDj`#4kn#(i79#i+RTyLC z-OFJlDTpmOM|pwUG?^tfL-VGn1OETY2~%qxpb=hfrna0Xam;POJDDT(VuRqwQjuYA zYz1Gz)$(PB({)dOb7bnP&z{-_t&%nF+OlA4b8Zi?tE8Nyc4x7_q&$&l*@iH%1(vG> z*_T$3ESVOXg{)7oKx-AFIL?9jSHgR=M5xoNPL^pwY1y)jlA2>`h3>VivA{36&Tefy z4}LnURPH7x!juOprDN)ix+X&AkD4+cmNiw7uB~nSoZw93@aX>2B-MI|Oc6zrb4^@V*te$&%RirkH*6 zN73IV-HO}(d`fyu9QfyRe|j+6c6~;J455gJ)(Rsw_UMWD!j9a7?@bge7ES#=-1oS} z-(5c(u*UNQMY$m%qe*`$1;=2*OMwxzhFB20)8@oTu_*f^PgvC4Fh|P199Q1-8|g=I zQaC+Yo;+D}!Q|f_iZ0;u4>s()EYb`jK0j{{502}KhG0vlch@m}NS~v-gXgR!phAA1 z>OnvJQdv5y!{6Vv`ddC9+3a+VF*z?DgtW{b_u#3dy5ady9#O~&B0G_8DI3pG-^yhT z5%mA0jf)zkS`yr8`3I^CI$S+X@bImJKHi_s@6M4e-@Ls)9@~hfx(wpBdj$Ml{9oQC zd|tP{@X68Y$@9rN$MrJY)zf5v=O^%PvPp#Do4OENp92W0l?WH-7ar5ej&FOS)+K1bYUQv$V4;w+1?NBFKI2zg+K{MQ~&>wBo(egrUafGvj0o@1B;|J#P z))8O^W5%|aZx;mp)3e~1xuaTwEi+^O0!Xo)*WQ?5SkF-Oe3UzW1|LiX z1;gLLTHtVoy3%6kcrs>hD;*CK`<1FkyO!_dC~3IZc!;<2;Wp_B

7MU(0B3+zBT5MqC(7SO-VMOsL|l>M$Bc3KFhn5 z6B$O^H_mr0Uz!2mJ&F%cSaJqsLeC>XQ$6)HF1&O7CUeS>AeP1F@a44ONJhGdj0k82a1iCzyZgG%;hp4aQb*B=D6gkZ-^Ddz_{kGtsGhG8 zKHGW+{`%cjvUoc=5%tkppQA@=KBlP4sY9Fa?N`j(JKCg$1D5u-& z2D1bVGYCjB?l4296Jf*-X)^QLWQsmjTiEx*k3S@C!v2VX2@LOOkx5bCBvb&vS7_Ke zFKjL1TO-4`wiid3a6Xm;vy7ja3<;MU8m{xc6Dz$vi%W*F8|GTfA!rw5t~q2&+l^VxnIry{$NSRDFJCC)%og&Bh9=fbjG0DEi~7^p{wxwQlZ+o47>I@B&uo(ZE7_({lgk|sqln^1*2dUv#0Zq%Iopj1dbjU0!A4> zZt>^)_aBR7vx(wv0tT{(stN=Il8o-+UP_yDy8^PqpS`@^Y-au6L9gCl;i!I$i2v&P zMA7+f{egKOD?Ig2vj;`Ei@eP1IDMp4)|7aQ+!rQf<$>oWMsTY%si9yHVu);HUT#-^ z)7HoM>*Zzk7IcoZ)}Hgv_eVv1=)JsZ&LPgc8N8k^&cR+s8W9~MzywU#gP~B>^Z7vy z^?iJXmY7k1I($`~6^PW5RW1nw2cJnU8xfygLHGN{M>OnQ!4T#VOPrBCDdKlWXPi@_W8A8VTX`6 zF%tAaBg(e&gZT!+eV&P4$M+~|Zb6zHBjmv~2N7m!y?Zb@>pag?H-*uhkbT}}z0Am- zH-(v7ZHqM7p!qg^eGcm@`ydUC)tN|R0{yR&P>T(Pk3+WGU7WOx+%EH+nhc~V-mJw{ z3wq49$G%mmP|LjMGPdhJ9CDokzoV?K9Hgo4?3I%D10x|5qU?kT@(Y&7J4}Agaa$_r z*U|RQRDMo4IiKcfTUzT2kw)iBhW)LgTdx>j$svpb`b&aO>9v=7+vv2mF09@Sb$-&b z>s0qSkEyR4AjTPX@x8-NYx|#K32+AbCkEyGG|B&|rbCiM&i}^Bc^T{N zG_TF_vJ!-JNcSmn5tyLYN0h0xB{X$wsv4%&bBFR0sBug8|2N*JDJ@!9>01Jl9HnyP z&FCCxE6KGKaZcXy{uE8y5*QraLxw=~`;aXNTS;5AJW@{lOj=9#mM+>$-Jzr|Mp*i05WBBdaUJJaj~;CblpLgvc?$VyFO*g! z^F+s1vi7d)MqM91M)7niP&kfwB!t+Pnk0BNcQo}o(Poqe<5T|cU!2A~kFiPW_wz&f z!)?;lS@;p|)@PTWkICEG=0Y;^559!xTgl7jU|s8nxP}xf?$DNcYlhDZh{*NYCs#pH zS;Vgx%iqYWb85l7NO>~BbQ++O2fZ}MX;(tn^51sa?Sy${WOBlVb0(vIt!>Jp=;U$u z*Q#>P_ryxg<2Y~_KWILP+Rlg6=S`7^OV?yk2@$M5aT%_E(+->A0B(s(dVR2`%B?g- zPqpPlbjFx-1Tj3??H~3S;yDn^=d&?z7_+ZDklKNEqPNa$VJ#2Z6a1IbV$yuh2+z4m zyP-bWg_ojQ6YZD-6>O9C_+$%RHzO{tm382ApEG#pTaPI)cC!!mxEL&G^h-pB% zk*@3_w^SZ1G80?&Z?aTfd2O+)b0`L{d?wTqrYb=Aao;Z7;)-ndaW9n_;A9ThBFSQn z>!s`DdQ3WBi6k1@No_niUWdLdU$b_@^4NOlncOmQmkjNfneud-LAbpK@x( zZM7!iwtRD{Oz1Us?$zK{)I}SUw5#OB71oYhZWF0Ff|;=U2vwj1sBUlSt#d=~17uq+ znr1?~OI^y?MqOU^H*vh%uD2HJrb4*x2VeT+Kk-YNQ`?ufb2|K!tx5lm*Py4P8o#g6 z=;3qknf6!+3$Z%7p?1P2B3^xwf);e&5{fJukXXZXi=WDrpvYqsQDuaePq*FgKN=k~ zzm-=H?Vx$O=ns7HE}787s+LXp%!;TkP88S<{Hh!nRHFb6;UCuSNiyF(7;#!{hycd0 z;0P;>T(%Qv<2;KL6S3zMz+z3tQfUpIQRoW9(*DpZVqi(a%+R-OM$zo<8v2Fxb_3n) z*MG=I_8yTg-`#(%tT#yLCfpR{xpAKz=q(2QmiDo+r`4GMzokcKs6%ZMVlmGqA!`=R0@nRqP${iXS;KXCW$uOEl zG}}*4ufFZUS5#~5r$}W7KTd*7BLvQNDho;pSJHx#@{?6~_pQx6PW?TQxYG1Dvw1(Y zyfAv=g`v9bJWjZDMg4*ji>J*5@_x)|lPSfN5IXs@a>hHXK1LRm6O7B(;Z8UV%JmT8l>s2*`7%iQrwZwyoBiRv_VBU&?#kV;nrtMO|596?ZyF)$Jk^0 zj5Aq~|DIi28ZTZQCDrfUu-i0{8NnPt3rimKB8@QX&^L?_@8&gKqIyuGms1P5E!_xr zqru&}+tkZ1>6Ij8X4RKm-=%3{+zh;io``GQs33p6r^~H1m*(H3FO6EAM#y6+@iL`} z(d|1Q_3IcyKMg;_V~ne=aG4}F%#zTP!^zRcLJRRQ?Y9WyQ*i9_M3;rU$idy)4o$=R z2?_zk$?4N{d|eiZU#K?$S>uDp|J9iV(&E(nARBtLO>$lPP7u-=N+N0}l^7qA+A}$z z{&b}Cq}JL$y-`iS>e=1F9w~jCu^lOEWM4h{Qct+oA`bBQve_BJ%u|FJj$0MoTe?`t zIK@7u=;K}lg}tY~QjebAlVoWYf;tOAOm*a;d?+|P#FOFIaLL8P@GoB9!qeI?utFd2 z?Awz5$v52lD)O|9vJhK%E-}M!?-=)#2tZ3vSCGG1JXxnT=84po9NX}%>5fk0WwL$u z$KpM2+h71DNpscl&-mzV616DVP+dApuxl*U^fy2YIZSrN#5;TGH0rLD@Xbt#ZizSH z^`*VG-rPD6l;6t*FLiE&uPXZI#E#lpaGX|ub+r$<9t{hk#Cxf?rLE@u_bUI@*dJEQ zj~9{U?ko_khf8`lziS-CZQmz54)Lk8AxQ%G^FlwWZOQV};s!f%WFznsYkJXbBFKR4B?f2g{TdCQjyn z4?>WZ29C-0jYc0nY*!gD+6@kW$bor5&rErY3brQL z+`v)cH#MH>j4+=o?(LyAe>)G-cu)1owJvPkXqxy{75~aRws}Ck3Jzc(YHW4h{!#Zr z_h|XBi0RF^uR(mH-bnBlM(5`lS-Y{G^4<6I?R=x-ZrC6Q$5G@>exCvZzrOGFX>Huo7n&Cl%G}c*Le~rd3FVBy|;7{Af9^n?Ek$3NT$+M8^Lf*^+^y6ZlV#A>=DsAcG?zy(LxhI_T z4(8UEibi_Jex0X^W_7r?3PMA{y^d>Yb1?iVv_4oUc`jD|QAmm_p%R}~Rb>daU2y&O z{`R&xPXsN%i&{NqzVlt2LROpvamn8!T^f%6M9^F0sv$beKw|cu^%`izi!IR>x2U`? z#u%s`^1;e~yEWDDTj1UGBCePSnqn0=El4m4(4{V_a>SJ^R+P~mA23NTb}p%iB^$J^ z3lq0wMa10uwf$Yx+%=1`Mj+7Xnn6e|KpA!)^c-LHKK@D?j>Pu@bdk6F1Vp16*e*o> zlSswDP{mB()LqR2(Al&xLoXnww$zpjuJ`$683MRMo>f>~5TU(<85XC;;C*LWgFCrg9sk5IX&<{FOrqz=5@sG#2A$VqSwHgRtkBlbK!*7GAzxv4V~%WISV679>QHSi zdj&-M&38sla_7TdAuekJuIM&Kmzgw223b6an2z>6|_0l)WtJ`m+Lh$JR z!b?{5pURlU)}}Vy%!cslK7k}FaB!s;4dCIOo9~{Y&d6E`u^z9zp=mxKxxAd1x^IO3 zmSTM+a9PIJF(M}gihY_9tZUqDgSnyD;pkGYbU+j-7pb}7Ddj76z01ZOmCIR@%$pxM zLI@#eFv*!_TK`AmOi$c1Xx}TooL{s$cU+s(?{Tvs(Ix|o*P<%hsEvuQX&eKuH$MB= zgnOqS$_P^DVx$FXrnH5`VC*z&(F$)i zZ#dq;>=6PnJD-#@&^7xWWr>xXV$g-%U4QenctL;1OfY6mLveyIG8;db(*wEqa<+)P zA7|&H%;$X^FvCm1J{4(=!mlM%v6FUe7-Npu`TxVN^9R4 z(gt*a;UU?QH-~j%o5Ez?#TiU@J&|k6%MtIro50j(?16r}H;Wc2C@%u4D4R$Ci$mR{ z#!q~Wc;Z%secs&HhE_TozlNj5&u4KvJtXzPF+#!q6^JgAfukk*pxhL69TTpWr6sDj z@*r<}U!@gC_Dw*qhT?qx)l|$Xwn_tZ$m`ndi8EKQuM5mE%om@p3&cWE`N~(hWO&oT zUKe8Akv@)>3l?FJ9D;~JkNFON!7MM>-(-ek5xg@FCa;T}E^-xw((%pj8-pK=Zd`Yf zd?2gXDeP@c;Z~6hHyeq6=lvB!FiPxfO%8z&s>oi;J;*xC`|d3|~zD@7eFi3Tb_yFZ6$IaN(B@ z)zkNv^ru-xMc)(R*wx4@LC>4X)i)nDgQw-TkA%mg8jstDebD17c)B_dtdUzxfr_>Z zv}?9EYHZSba5eUg&#~Ucd+z8t(TtuxmChbo&Py5J!_k%n!#A|Va#PlQGS0bInBawb zM)*474~AttZ0S4~gu{Y6K+ru;vwxODEaIWSTwCL=_yrTPKQrTuWAdVW)AFJJ4>jrT zyLf*r_xJxMw$9k3G-1yEnli}r^tC(r{%G8fBcuFNL-?;am8^Ayt+6@J!y~?S;_fJ% zq2U#3;qG$eXTCil{?d@k*W&ii`%+s)*L0xlk=k zmrZD0VF8#6`(sx1;a-S9)`t z8P7~y9PfO}@Gxn%dhZSqqs!Hv_V5`r1`S~p0hf2$A zS}nR0$?sF-)OSDkvj7~-Fp0bf-iyE*S8tUxe#XM)aP^j#IR^8_SElx-Rlw+ZXUC5| zSW-sF=CTv*9g-}*(gZ`gf7ON`>}_=ya%rrWiXZ(SFB=N>jzV3q0eF{w??zXGX4bil z%Ydvl{mU{4X4PSdN|?7eTe|(bA5R4-j5#{^Sfn!%aTA zpyCLMh`Syojg|Df`Hmiog^3(<@I- z_-wB~M$oO0V)tPwS^mRA#`odj6JK?=83FMTdn4JNHpztV+Vcl71f}B9nCSvYbB3vp z1XmFazo-s|wG)QXZ)Ct6KBCuB44FeP5BG~H&*yCdDHVmik+}rD3lKW@e(hc)kuo0h zy(boMG_z&R`x5`!^8esNMu}k`jHu{aOfMS*}qoO2wN(b91^smJUdoRCR5TQgyaPu8B&CTtc9nD>3s zU2oxw~Nh3|Qc5;z&Q?ZNd&S}^q7QRp3J}tdU;7<;OCjX4m zRo(7)$Zrk!H~yV><7IS*O+^xjqRfcE+tiY`a;!;fBN`jOxZL-PT$d!B&S8J|*|-9> zc?>C@*fOz(Fqz&h9H89RGc|bcf?~6yHj@eOzv#}n6NWNuh7)GFPrc%Yu7BW15W1mlfJJo$>e5lPX`aLgbvRko~hVQn{1{P^z&YmyKX8Z z4t9eN5jZz+F~Zo!1^(>`E`D#|FbwXjdu5?45P6z5uD`ywANgc6*vY}Y4Vc8j?$787 zK$A6M3Ww29+4#(fIUrUVid|rLOe`Llqcy!mwx}2!n1i`Qhu7X1{aq458!Qsr1IoGh z8X=qkfHl*L_c@e{;Rp+c!c+@chM>q_mGoGvg|iq{VtjiD!v+Y!_qRdL-%y*Pn>!AzjDW7S)Yh$e>JO00LOyI#!OFPQC+QxR$2@ z{^w4$c`onSXUj|XENNAlvD?n2Ufi?t6{9ZLXh_&a9XZC#cn007Z z`=5O4=g{Unfg!Pm&>po*80W?mGqrTtJjWYCK*YvjK=2fS>!qQ@rD0S~uLX7kzu-R# z+Dqr=<1LnE)wzZ!P9_`2?!rZl=IFs%o|ug5;<{KU2lXAXqqtt{4JjGFsXAAGGQRbF zjgOm!Mrd^J)FmS(k;x#5XrvZ+74V*NNzMiM{=)w$UN zuX>L_Wg{^5n%)`~uC7cyfeOO5b)YV?TNwFBc!OPb1*@ZNp0H81xF~5Q& z8}E2S5D5KMp};8wS9?Pa`}|hRMG*9~CEMi|im5Bl16an%&W1qM>o8~cSuRmqd&lE5 z`h$B@+OTB%Brov9uB7ZS%<(=_m*-(jI)__bOvXb#<6|nxB{v&%u(Hp~1svs4sKryD z*Q+>vb_9NalMnN>e)qT$$O~8<=OY|6uL@n4G!s zkqde`UiGb0m^}%ZBJyz=_))X)L$%8K1b)r+59mjZ!m+RL183gM^Pee-^C1dW%v$g6 z-7wPZ(9glHKCfoYzyM3t*@n2k3nx4Rv!@ie`}Jqtg`}L8r4SP8I}Aroer)_jN?9Ph zoNdYJ($|<vUJ%d%#q27v)T%Geo|STjXOc&_4JvdD ztlA*VoUh7X1vAK9*7a+XDBC;SrWRM_HNpl*bz5ZS=}}9$T5^{6Ix&GQoOOdsS2_HFmv#oQ`|0)KV-TlJ58b3I~FsN{tm#QA_ zT)o0403LHn40CZ$&3gTmC^J$NEuHQ_ilm%()0c14pNfUyKR}#<1t-#8S)bgBhVwnf z&&+YOR6px$hPSoM*qX9)vX64n$zI>vNQH6Mv6lE|D(!2A@{R5w=XI{;b?@J+l>P*4 z|LdWP51S4feP?W8$p^0%w zQwah6ZomJnyTd&Rr|q=UZd_Y8gy$T1mMzg-La5~KI~lFhX8l>-Z|FLx-S;dtrQqzJ z2ujM%yA$+Rt}3@<2r~6`;eLgUiNbu;YnP-p1LC+H;#BxK;@5(&r^QMdD1D019tiA)z*Se4xW^HdZPXm<_JD z(7&;6zpbAzD{M5t2pYuy(1@oW%V}5Vb^_|T9qFA^Zz94}^~KI(0RN;hm+4GXht29a zFyq|+y&!Ar5}k%{U{D*4BHdQ2At2d39z%W)(v{k-8JXR)!!BXz0o0`wG3m0CrXh?1 zBEMQ`;dp2>m%gdO<6^aqy4vuSS$y_yCe$~Q_Vc;Jq!Dh5IvNWF<5Ty)Ued5qTTS3t zNDQhmH*8mVvu0&mIistsH^iio^t_^RyzR~jXmL*%r8c}@G5`!<=2?Wak%rBsV0Anb z2m)vpI+)MABtxnB=yg(%iy6GyBFd3^@TZ64g{IYu_tP3yVR8TH&G6(JV%MiDD^=r? z*vF9m%B)1}RM-oAJd@)zJM#|BiM|@1|JnK|X-(0*2X}3H8V7;Qf2(IC7uhdEitWY7 z0SL_5j*qMBn@TUx{Ab+Ln;TNiGEgLPb*pdOEEI|@@RQ5Tq}QqeJrFGs7hOLcV+#^f z3*Fqs`^m7VaVg4q9Q!QEi~4EsaLFLu@3u@47oQ3Mp}ek`o*(&@lZNFE%{=xq7>#Zq zvUgCx)aJ(X#$G>4)Afl&7S7Go26C zIwT#(Dh%$_UdGenvVBDdsdo>B{{f5vY7BtWJOTbL?_R*><+T?%zD??^uD!z#+pE(m zK?0(HjQpZza0UUg^S3wp_qXI4o#T@-KN`^eY81`QgWHGu?o}CU&hWNIoPfmLK+=0| zto_luPPPJleltZDnfcRGW;Xx6TLky|eu}$)pr~(?ENT|$k3UV<$IX2KJoooB^i7Q_ z6J9ia+NYHak&f@_2^i@ikb`pWL(1fJD+DI@&F&+vVh6g+z(lUJ34m$GUZPp76j>Rq zUzde_MkDTm<3w)BYMR2_!T6@PWh!oV)lxx~`R>)jvu&z;DyM^%wiAOK%~lIm+Vo3p z+~FFHi-n8N-f~K0nI|nnW^S(1T$<<;v*cyaZ#rk%gU-cw<0=mOs9i#G6J*A0_l*_) zm5Dt?|E?|&Rv@p(!+XZ#!#)%FtIRm=Abmz4!qNHOZ}tUEo0IYC;nHYPX%;IiR{bd| zSu}Di^m8@>9X~Wab#L$|%xF1_+rb27)J1^qC&OX;c1*wjV3(G*ng6~5@~mpvq+Xbvri zNNTe~{RzMZkX5$AzAr9t{ybcvAO4YAAHHjqp+}7J12;CZ+0*^JRx&wfey(8t*Nxk& zE>?vL8KSKF0-VvU{a2{lAb}?fsuFPiZlP=xL*Qm)`Er3Lg2+JS0J{i%bG;pX`6VbK z3=W%B2+oBy0uY>n zT0_B-bpKJwDLnW3?i|*PQ4p$e$FJk0aE=j^(;Z~BEjv_HZ3*hqq#>ldPEYE ze7vSNw)+G-^?AYu=nvp?%8nFcCMoR>2|GX)$llH1ZRK5&Z+}i3VTL_w(50=%3KhjO zTiI&|_|MIU3{@_^$Sd2C7+d1OP)iVSGK_gCO+`8DFT{E(g~BNfrp&?JkLNYkpt5CC zhkg}BnyGLq@N_27n0AxDE#kgvKx;2>pXVVSJ=MKFZQvMSSDfoD!Y+k2oq^0q(j0;{ z9qind-`y2>8mm zJ^akiv-j#K(-S$|uYZx2mqh)EJ2lBA7UVyyULEU)AJXdL#_j5cK4qUbT;y6eaI;%5 z0hnBDfiN|>gMA1~wk8BM>n=68cE>Lqsl5n8F;fyArnpAKxwJW1@%=Y`q-mZvUE8k} z56i$jOPd5xd;*n<@+z1fRWF?wsl|ATtZ@poo?QC=1VV5TjXVqT>_Jo@3SnqSQq3~N zjcDRndx{e!I^up{J%%vWDh+QX2yJ^w5_n5Od$dikwFLX_hvyy|7dIUZ)Ua|&( z!=|c-u?zPDPShweH@=J|PT=>UDn8IQTAq&zTYiF2Zg_N;NL@d1kPy$EFd1PXN@+~+ zq=*b07W&#triK@}m6Y8`*a_|MD|qF0vZ;WwToz+oDm;6#8T_IcVPlkw3}s{O%BpVF zj&c~Q4SV!_)FF-@wdnjlE^`wGL94kQkmCIXPe#k{v?0KCprO^KiAq)PXy(6Ht;CbR zDpzAer?s2ZIs{WSrx7}8Lf9;k8@5WZ2Go$Sv4#(QBH$*Fo?1MTBB^p7Z2qY7*R)Z_ z8!JMMa;!icuIUjk@hO%yldT;tU&6x@F37!4-f@a)SHi?8`<`^qJ1- z&ryQv<6mX~FO3~i9C(9>EYpQO{1SdHX*1!BSysK0Ih24-vZ=&{B8+w!E%*LZ#3ZJ} z?C}F#av(ETnpK)Exrk)f}jTpi3Xku1{3(}Z+m`lmhk@V_HPY!=dSJ`5A z6)lYBi*Y7gwU0xUp{)9@`)Z|2tVSGu-DzSLO5JH-3j7B&z&JoNX|#6cM-v&eEieW{ z))$z{)iwbzo1$AMZmYIjtvb)cKsm`MN^Q$sxLKh@QUmhi7M*rBws@IE@2;POMRcoy zIyFNlru1k-`s_@u%^>xVy9qm##DdZi#(54kxO=-iQa*N0%r%Zt8(_7c1;-{__2WR^ z*~|N#xdgY~3u={(c}19K85T+OaBjLdTuDC5h%vJ305%&J8`D;YGMA!<`phU2in@!f z`G#v>s4U4;?F~%jINv;Hz(lzECU>Hh{b_1~udhRhe?qozeU6W5hUJu$vwWgUVs=uq zh5DkrTU)k7gVF91qUv#a2m0sE#-DewJ%3d3Tv%K=N zIg@7%Xlj(cI9;9nUWXzZK4B+FyG%7RczbNk&VdWhC-_9bC(hwvE`FYaCrcSMGY<)x zWflqw9o$n-cInj0DFXbIc96@`5wJXZTi!$B%7m>>LN0o}>(S)!jXH?G90PFv*U#xs zWw@Dm>#2I8Uo%H9g)-V!?F^f85^k$YLUq!Lm-Lj1b8aFi*?mN%vCb@ofZXRM_gU_! zU1>OgIZ@f|QY3?oQ^4BJKY8@+;;zK@z4}NY-1 zs$DY#V%tYSrW?)dXhg4I+w6$X7U***?+y&$`W$~YnEG5J{-gRlb~hTyuMrK0I^(tA=7JZ5|(UlqP_<6)6ChUC!0mC$li&oC(*6Uc7ygm2WEIP9%0inh5wzIHN+@jj<3R-WEZyx1{=Bl{?59=ymsT9 zxr6<(MJst(IEaOmdhTYYyW6gOq%i8?YGV+@ommCyRbDn@1q_dM>%=^YAz+s@bv4YJ zEuz}EwW>Nu#)~~vT_AolBuxdb*0&` z2^MhHxQ58A<&rpyT6HzOj>kSa&3<%3Co;s`m~IzPyEDjkV^hn*L1@B|cvj;8gmK+b z100s*`R^D4@9Je1eggEYS+8?bYJ&@ zv-`#SXE}`ScwoE93Kn?Er7;cg{#vl-y4+`1Ew3%IEPc)OZfWf?B&Ixhe(hQI+z$7? z_AFXR4C3t7BYjPcf6wq7mZUdAIDm(B@#-TDU&erQnYCnJ)9$S^o#s zKq|k+9_OYxH_f?eE!{M2ovP=fNy)Xl_tYff&R^@+Uz1q7>t0)m@&lVz;Jlff?s`|w zsK@QdIY*A3O>pGoExAH}E_Yw9$iI`Ruhh+xD{ATOnHt0Se9q@{J|BCW&*ywT=ks;r z^J$A#J=c#Vxa;2QV|1Ov*R8|HxVr1U9=Ef*_wp3>cCtt3(pWp+Zqt1`*7a&$U7;Jt z-dd>x$Es-Qx+!YFd2P;Xb6y*JoY&^OHs`f<z~^Pm=bcxq1X5=T#^yHbZwt*WKtXHyx@ z|8xGI^Z(f6{6FXaIsdO4|Ib*ss{4VkXib7+oJ;%BXbw(|hH^8i)O?y&nujPQKH ziH==AE1SDNtf^Mxygujk(euz=Uxnx?$lP&&s}e}!Yz9IfEy_=8W~EL~Suja{-+T*xCg&SFBR^@856$gGF*rf1w}ZPbNl| z1@iFFG{>>@FTqe#sD6@{yW`2knh{7-ZFx-moDJ-^+>~a60+Su>qpJ}74et`n%-j3< zJ$y5JoOp3G2LmiY6%b6kU=}T}!32z;Kft3~C_%>W%oqoCIvRro z8I1lJUDg_w6DoXyW&aUf?!cI+9bV~xEE9Ayn+^#py;Fmdc6l|!vIr0hYdBA+@Gi|0 zrNb*7kf!s5wQ#5AiPq&+4vWooZ!kX3OkaLy2FlX+RgM^o$54NWcahCCEMI)hYNY)<_+v%C@9~kvO?h40e znS|5uzldF!j-7?gSKCg0Q8W?J99j0}8`Z!+o-F#?Zfse1eiLY(yAgs=_N47V1>!D?(KE3?D z^zx>T#H#)IYdTGup28fB@5j@6emykueMaB}%a@OgUSd;+NAJhV#;5_{0?jKzTa@IX z^xmcp!U{naWPJ;S1sYcYUXe>EuW#yrtR7sUqwwvJ6=-KgSVg%Mq8HiJFGKF4d zZem<(fbhlA&6%t}P8N5n z;(*ypZurRAI<>kXWa$cPj~PqlS#6ZWyBj_(FEdW9WF%ylv;KfcPFTfZQA=$2;K-d> z-4GdGX#H{0y|IdeWhu7dBWCnyb;HIlh1VV{9t*wN2&FG?__&-&%v#B4sJ?3bQBgd% zii4w<+3+z^yR*8XGTqnu!(}*e6^G1LZo`Mo?9xhxZtml~{$`ue@38DH?L?~`UdebY zf?IIKT3vj8Pb7Bk?z64iD;lDBdE0c(yr;suH7-hzS283q*a=C)5jn%MyEGtbhgUKl zO1|bggTW%z?#i)qskf^fhQ|BTdAUBfe@s@rO|7O$s6QqUrdShdadAHpIqeakN)qb@IrKrc<)purJ$?vsm2oDl06Ri>-I5(he8q78g z3rPYX(a(!y+dPVGjR>|)qSw;QP`e}ga-_x?Qv%mwwh~dQWz5<#URDlQO95P^^1NLx z3hlb1(B_DfCqOn2gWHvk)G9*4g4mWtge}PXp{MyULblqJMTMBHigqjs*UEn$eYu0B zG|r28ihSuHN~^&sHEip5->I$90uydR0Mx-`c{`8y%LAP1VMW&-8B~*kT?-AWFIzhs z?vn@8wCmV?Yv9fDh@OKs~glV>9`M~wVn*1X( zCs$-kYFgA;lg^rS)}*s0>sgaFmHTj}rJ>Rq7?(Wcb&A{;nwKov^IPTJP7F+)a5pBV z21jd^Y^Ifoq>9W)Hl9)*qIQO4B^K7RB{dq(n(W+~lnXsn{-~lX!I@BDZYU?Iol=rE?_F{RRHZMDqGbcCGoWv(5Rnab6nv#WO*m#DHLIdESB(_{NYmNm{ zTY)vF6JCimr&Y3@)*KtpRatX(7S^-oG#bvD+c;~E$yjIh+=^^9L$hs!E)XK^_I zPw)L|%_>8k6q;4Ihg;32dKn}uFsKx&E3u~J8aC6E$~${nc35vkwv~mUwa@E0tLmY5 zTyurWJhE3jSpC>#UAxt$Do$szIg`zqY|dmW*>lZPx(|DXPgY}15AkI^D?P>cR(-Xz zV|)_bl^Bw09a~{a>RqaMmM^2ytz~KDaQ)+aZ}sLm>+*rE%N#kgoaieVyZ#xQe@NEm zD$n;x3f38$&e(LurZYC{8Jl(;{J=;26s^|4_WTmgCfRLo(D#Pjxrai;7Y#ZUIE~^! zw^5auF<`F%Qy+~+WF!vR9C@snmFK7uFzy!U{ewr}xTjx_bjkn8*B_qD@1HVr?QgJ1paFW-3IuY&zl;;@%tZt@|c46UcEYb^ez1Q3d8_3-NakYV0EJ9;dt(k;UE6X zq4yCMB=ib?9DMKX;|qKIr@ez;fWm#W^ltroZx$uql2#as1Oat0eeQ*@6h*f@`a))K zb0PyE@gJN-beZ_@wh!;m?{Vpp-t+u~8jKGv3`b9&-re1SH-n8GM2qXEQ}$x~^wsIf z^EYSDpFo4D$cNb!l${6~0baqq$L)zrXyw$u^I(ZosIHt`e~2 z0-!Ph6}|{Bmx;nG(K_g}`~tAc2X%aW=AEAHdH;TVc6xRQG=4oj|NGky=iaZ!@82K4 zIX``V=DmIIoxFYX?DYKf?Hl;(g?IesKfM2Q`sUf87XYgQTz|nXhW0}vLu4bmSZHnq zN&}c56?pMH7>8Hk82UB4UV`=OU8BD`!`K>g47fpRKZfQ_fXXzy4HNEy7@dM@9+9sy zj;2#^2Iwtl0xSaF+XcKFOwh1?#J`GS@d@}v<&yh3R?EM|cMsDbC5PT?7zASS>t%x9 z=zj}u?=Zy(4!!IX@lSm47;1Cq z=}_C~HU0Z6xbl}%m~059eSXCC@NvS`6ZPo`>z*(C>s$ZGd-E2Q(8uTRtJlm>C|-lv zjUq|Rc4`a9C$H4VkMC#W!m@0Zr{P;T1?3JHRDPt7iBw_31bAw8B)VK)iIS5g?`v7D zdcoj!o|Ly$FLf0L)5+-8kH6F|itajCjJNaBl9Hz3{%mfEOhLtiOZ2{ZImwku-Kay4 z4g(o_dpZ*`^X~hdG77);aBW!VXR1{_;SfH*K;%?Va&dUlOSgM9#5vh*I>$l97f`D z8BWpQMPr7qYhU3{q7X0VOqfYg#om4}xE^?E_YTMqMF1M+$#jX<9=mr%tpFPk#v1Gl zBE?AzL_g@?QA%pG2(HoeLtQDEMf(StkYp$=+AE)I^6>d{9@$TOIGlTkgXKyb(%9oQs=N=V@Jw=kwTRsWJzja(+H1$|5(Uptgo2d$FmarPmUjIy)1 zKN#pp*ev)h*$9@jo3dxBs))u5l~IP4Xp|;(`_GLdzmUbW41!NfAep+ zaD-!~y3$!f+tIw!BQ%Xi!E7>*LZ}vvAMwY5BIGC04BQdWXYh(AUO^$a1)DYfLJ}li zz}x$75QCb$jD8!ig$)SA18~guNPEK1`qxR6Rs7um8(2nx-qC+UL=&AyP~P{0g1IO6 z+1ppt!od;8t<^4%S=R=|lLm28@hZ$=;*(6tK6Sz?0yN}CSto(~LdJAuG(qG*uPqQw zzMY3tZ5wH^xBsv2{x@oyfBE$P2A}`O0se{Q|KZ2v(#ao7@Qtz#{^9TZVf(v z^X%Q*(>LdYCn^XISMy*fUBP6kWh^9^K!*3jFNqrlp_DayQt z`5_m~*HVMg=xR9|k4F23H7ppVH{_AT$b!yj&Hequn^SO3&z_H-y?uRr`sR;4m4Nse z%jsQX`j=F=rhaLQNpsUj;p{3RQ^mtiN3_Hodf(x0F7EI0eO*-}F9H}LGCPFT$n1tt zKtQlS3-eOg1~ST`Zl6K5g(eEV;O%3(_(2NZ1y3LiVD@}PyXQ-A&#B49vHeHh@njM* z{fb{KZ=oe*NzA!LL6$K1f5~ErDfCnlj0p{h6zgeYfo0uGDIn9hiy(17{Vao2Lmhq@ zNC43wf8g##;C#F`7GP&Cck zho*5s#8VSu+>3+~_gf7O&1!U#S}v(qh6y1CV@0BCZ3PY@5X^01-X3;ph-VwwHqXxL z*d>blgANmJTJWT90g5OC)w^0q9`-x`Bn5tZ z`n&k}$5Wm?@agaD!yix6)_%N&Z{@cC@pLS5B0v2-ZA5k^hgT#{rX8ku?ofQd?K-Sw z$o>J7RU$u>|2WKgIZQtt3d_VkI&(Z4GSbHg{zqIUCZ{kDIxPyj>0AkNJL4{?OE9A% zFHBwz>3_>=gH{U%0(JPP{E zzE=i?{11s&?3HY6@b|PA^y7aA8y9vreMeZ{zu_7$nsXVod_AF zW>X<6zy8UP<)DV?kTqmw6C$f(D1ELrDU1=TJuM_oZ`j0;#)+mz){|9C4qMjnTC>DP zpwZ;85n9PC$tucndO!W$R(-3vVIw%SeOYNr6pT~dxnX5=k0yzAeDEb(!&fmUSaQg+ zNkDHkl5{HBg=jN~?CJ0HZ#`k9B18IrCHa$iQdi(ue;+`?IDZJ)#E+{G7FmP0G%sq3 zkxXFS=ERDOh6;jc;dfnmR2bJI#aC_}bS%4zEbaSfjCtQ%3a~-1kz5;8)^00HEjYmj zzzasBRy75TiiXBFmF7v_*w&pa=4foxjIoR*zGw7m71N8gwAP%eIaOHERm_hz(p^D1 z71q=hN#5)J$YIBFqvpyil^^x>MslQ*=t7>y@d)c!|4>Q3b7?ceAd3?+p0AMTO(2=)%?|C z_9jTCRyGq$?T4ZEcQp{Upy#zD3_7iMvXyk{Y(QbqDp;W;Tt(AKz@azxx!Jh0vPHwq z-hg3dAF|P9e-GI|b;eR|d)*=A?QJ!3qDMGl?DGl-Dq39oGoc`;%knqP22G|=G<5QN zFo5!(*)YoA4&^`U45``6x&y29snzhRy~aV7zggi>=Ud8k2e^?1oNoMd`F%Qao8Tqs8OSBSWdIA`G`hp1a}i$d$=bI6199%+<=eL} zUp*f|gGL|Do{Q^TC(qxXpT0OfIX-`W0S)~cE}|KZviH?rgmm#7YQuBUd&y!M?9pY1 zl(fBVZ)lbtL>bg(qoJ`wKBIksFBCJvWN(Yn-Sek+{(ZccR%NhPxwIh$ zA)nqX_!=zsOx8o=QqmcUR>M$ddR$-~$cJt&l-rj`~^uuY4`OGjz+!a{+ z6VFd5ghPDv^r^V*8_oxl;OkSoL;dupAAb0$@bsy6*WQS1r^$e#WDbtJlVzMlx1K1@ zFC!{7WVH;ux3eib26&+g6Dpkx+jQfH9z*ceF{%Z08xIp2^hu(_Ec9FYg8lAS7V=Jn zQ26xeGmnGt>GD1aU?}OI&!0aZaXlZ~Rb_r}6#)@f%d&=HtR}5p_UrTm>pl7-x{o%y z=Ya*i8-G3zX6o_D^bZlhVSpd@_evKZ+l2{!Ybd){B+jFz_a*k!ONnB!fj<1o>R0Zw zXoAO;SfOwZEpZ@JiIlF)Ea`+{Dp45MDjq=3K_l$%m1-iqYI5aIF))ilQDIvlP37_j zl7nH5_7oQAO~fS(Bza#fW1jD%$oIW-rbu9v$TZ>%G8B zMi*4`h1p!S|7nA%Z-<#y73$jBbgMj9?1jSBtOFNR@x>wN6=(_T0&Bv>o^;vhTkl19 zy#!T?mz5K{;i6vxHMJ5qt%^o+IOMj7cHu-9dy9!-hIO;Hpp=e6CYbUYWP=+&POl)D zh4w8$Q?1n#ts*)(OlKiQ_1lLE!%ZeBYKNP8rm|4pG8m-Xh*Q{NnbyNpfKih6bKXFi zm&|3k{|6;aiwD*_Vp7B6vfgDR($czTB9}R|w6gF319MUNAH%?x?{qSt0U6ZqStYkUQR5UHtr48ny zZA?I1<)bU_leR2;Rxjw(HXe#NVj5U%)}>9!Q~00l7dSdwj0fPc1dIKS7iE*`EW}7v z!HC_l#d%<*YZVr^$Unp)pH|OwU+#*0Xm;_?Hr}P-1}v+daDU}5S$*`y)zrVX>COUE zggZRB+S7FCY;ExN$(!Mq3#FPclm*@;6vs+SbMV+B$ zQv8$jjxgTjCy<)s0}S?&uFLvh4D%45+ElX)XT_;oG#BvE20&(p_{rlxm69@+2u|$p z(VaZ`HSmj>{*z!1Um;WD2t#{j{Gnjn2vWvo-hy{g9EZ46ut+n+!3+` z846@#2tqxrf|(p-@v7>W$c5JKiKOZ!9rU4j2YXYVn4v@HC9$ldi52o!3tieZLC6ybwP0>#m2GSi_=D@p6bYO9i2|D<}@p`Q_$3? zWq@l`Ve9 zolJQZ>&k!~F)*~W^hhx-jFvt^eIn{!II97D5g#+A>0Kjc1hL9Y?3dKA>I&fwqbllEOrn6z z7OJbbCTYC0T3gx}QUx*zk&QkQy7=9&#^|(!w7YFlXej4du+tHk_u&M*8pDp!@~&W%NdBsb$@DnZ6~|*!+o0co zv4z4osXrBy;xUK5QuFJt$HhcZJUC&g`{`$%B`4Nd#&`+yX20Z(XrZ>xoT=tYLL?2J zp1#cjyUNP)z!>@BR^`P!QeX#DD5}E-l>;2vUByCzwqa6wZ87PMo?2%>Ya_gVw`i)+vTK9NOZeTatXL)-jCXDGh8AlA6T<|9UI# z@9I&;@v#_Y^4gS*o3vGxH-OBdGWWuuOtcV3wq^3*9)Wq_k11{*kBS@*kVtGfp(7Ox z=@ZZOCnd+z;_v;!;@HkCZCV5>Y?w}ryKp+iR-si-4U7?)@!7&%*eI6sMcq*y*o9eQ zY$nWBS*|3?7LZwu=Ee{{LfiawcCdigY1qD4gpudxlxM-66!F`rfI@4hq+rdv1}y;# zO2}CVz7b~K1;vx5Jc==5VjLuhx}xR)u5qcbj86)@#)?61<3N4{MBY%W6Ieh~5^qMz z!MMjaQ49t(;&Hd=l0lpAtpIO&+)f+1I;Zc1ey|Lf{ZyVgVa4+U%@glJJ(YKn9r5Bv z4vBft`4scCiLp4!C?6DKheFj=gM5#Rir{(=B+QpRTu|Y~eLjog5iyTkTikSJ?L0txan**ML z#QW?+@j=vsbQ4#+ZxGbWFM{jk)L&#ISe$Z(Jn!Q_PhyyxV-dA9S1Oc-Xs2n#mIe)I zfSHAV5t}g9-4{WVxN=~T>mLWg#4bO4VZ-VSf_QQ`J7dnY$c63Ts(tR5y@-UwQ9MI~ z6LjhxIi{pbuuc+Has_M7&R*H*3a!etp-GUle^B|{3O~ib1C$%|U_Ktg4`ofU4B=md zYSJvnw%SRLZk^h>0}3L}*0aQ-6fL~s&4?51O5%SBNPfq-nxox7hnp?!w@CGPxmW;$ zruW(|h>!z~L6W^^p4=|63Uk)^)TFio=i4xZPp$$Gq3z`%7++ty5MU}9$nz;mz;{0(XKESzS+L5 zEHfcANvKo_xhoX0nC?B<$|%Q*tVFG6zN=TCck(-rf*&XQWn>Pmr6mYaM=RhBBU84{ zY1fO>1*x0lGT~!r_?L}PSIITJKNL)B^Hu7C!lN$upCZ4wD(wV zOr;Gc+qS1=lnR)pSF3IE;#hg#ddoS&jbQD8cDXy`2N~%0)XbC2O8MaPsc=jJD?G!| z&QPB2rEuO0TxhdOu&rN$`w=^WQYMLe{PjH{fzlLJDQQ@086IvqZH@8i^{pIqm6>(~ z9S*v5x{RTh>Jj}jvVIpFRZ3XmDcJ)ZNH4!#zz~2i03SW^s5KPD5DcnOLB@Ue1;=D*8Bt9%-9LS(c>K{Ta&YSZbZk z4OK?Qq@@nWx2hNF+Z|gIrQ_t~0m8Vm)+sD)D^NmWT&-k*$vf>K3(2pz@Ut$kfk=$T z+4dHUXHN_>-TjqXKMBF?0_#aX29mP?4dOAFZWedSXu7pc)%qj1mDQKi#l5Wc#_tD~ zB{HjwuWfexGBHIeqoHX!jqu5iRwy87i_1OO~WKyksVPRSMel@{J#pj<=D62_%?{h2*Riw&SBp{tO$v zK@PQjrCA4Rt21^WG5M_HK16!)Z9O>t*wd-RFM}Ux-tW@9F zkYBpzPjjzA`*Ww_fu_vE%xXyC&MeK0KuI~Khj~{RqDdVt(G%*xnB0^Gcqs3)7rjX9 z!LZV*VbVbjGc;9*WiFEHv{%D^voz9B1tVCtX)+J1D~tbJMv0#WDG4X`Ht28Vwgw&E zq4e2&kwJ2#cm8>oU|gplj)%AnZFv`%<}W89A`SM2$!}ioU*ygVKCU@kG zEi5^+*ef7$#wfgJuNQ7$X&ZdFzdTFIQkb%~U|w${v$meTo9}pO8-U?$5G_-MbTy6q zMC9N8T$KpsvBYrfN8TCs6WIDmx=@boCQWr<*e~mrbgCMZKKqUmle2p$v?cqk(6zz4yXa?FFr+hO9g(*ZoAet}?ko@x` z^6sL=7u~RZg2nLWzbG}17HB0s4QEe4mtChP!qFb*Vyf*2>FqE`vc0=|G~qC#Ddn~j ziYVqsqzJ6xDZluJphh;m_7BVfmfd0UFugaP7OR2KM~v0L#)^OY1ipTP5Z+VdWt=?K zX7o*RJ5>l9xza6Z(Lt(JQJ^TjK8#l|Qf9x!O8C}eDbZ4lI!CvG*lS7J%`C77Cd8}w z$zlw}rrmyQuH51sqdHRu*)4abZH9a7UuMGW*-t{^lpQ6}mtcmki_f`5tlfLqbWJ(h?*&Xb&hW$odI zMvWrxnU^ z`?Z*{K3D{gvE$w%jK5%;$Wpu)=2tkIBb*y6<3pwR#Y!(_5o=z2K!=saT!?0BtP#52 zp5Xusu@DveHu{}+n?+(XN7D6MF8wW+O*;2sidVKg5DOySE4~D1l+yO&Nj5r{5}SxG zU-5D;#YkNm@OOv2kUXHjE>PxSNZ!9Y;i0$qfeo1VF<&+45-eBQ=gVI^Jkh8q+>)nC!L*SSdl^N!6j#V-gADXe~8HJ);WJk;eIk`LZW9o9G zpc3M-(zbAYNaw9gxyzAVps$D#0km+T0Hih1Q!&5DL9Hqyn1;pJZmp zc7i83CK7ale>&h~rKkYY9_@euwum*x2C5%65!oEmH%*tjsNg7^Y&!;lcb^zL-il8u z2*JimTmt51k2}@kkcm|z6RM)wWN^Zw?pmK~Nfp#^Fa6jtsFA9M4AoG_q#W2_kj37w zen@hP(;=e@lM5r$OoJpC3Ayi8cwM=7TXC`x^rGl;mTjFC%R^m4REytizTpj zATur~+zAb#-Xq%yD_ufUIx)YYr@n3ii}t>b&;%LEZ>Q$d>(zm_EcQh^(Dnn-Xbjpm zhGKc!Z~gd-RGPE_eL0$6{y2Dnf4+vlb`YUu0~7P>#3BicJ22*8*;T-@sw&xJSk|J@ z%yqjn=v3vKgHCm)Jb!tq2%RzlDsn0lt$Ks1a~zS4{8r$I(psD{NWc<DP+2p#Y|<^J|)dD`wT|y-6AA>f*bxCG$UfVvIY;Vv8aVZAwoY3QgSEJmtF** zTEULa3ymu3JY=C{u<=X2bfIuzrbX&52davDbA>^Z!&tNh8<7S<#Q=_J$_dNl6oE*o z<%DOz3N5-RU^1z;TK8EcuJl6|9kA?A-Jz8x<6jA*!vwrwC( z#>3bFrVcRe957Yq_$C9U7EQC}d$tx_Rb{WkRdt^@e|czgBvq#B?)N%qN^j?GLQ^Re zPHDgi1%Hm8F1%y5?1y8XAzVx*f?F^v4(32w1Wzb$SLFF$qi}+YNJx#HELm1VO9m=< z6pDl#Q=XjTcc(Fe&(H<5JiOpHT8}8FZ)Br`b%!)Q3Y4)>O?=`A?k&%-1{)o2#Cb2$ zBoKH5I|qK@%RRgtdB5jFH0a3wyT35@9EiOK+`zU%b?nJ0_)A{1{@6wM&fUN6J6>m5 z%q!t_Hp{Iac->Ci!d7h5?ZngEMQr)UZ9>pATc%I&*;SB?Z$=@8>Pw=8@IAE@2T7OzF+Z@KqFx)6ME%*&S;2H;Q zWL1G(B{qjK!Dw2ZCmO{N%ju+@QVIy9hs7fy*HY&){`y#O9`PeEQ(i3=;MmUW`r~b! zZcWE}$E9Hr#k2qnW*KGV&3q3wh1A_F z*g-&xJKPS^>M^8cT}>*1TJ}}FAFx)NV`v)&ZfPdWcEVe1XpEC$4&qvAtU*ft0fQyH zw$UO$k!zFU@#K9t6 zWdPkWWTaRpwm#rvRae73>(^^b7}^MJ*|kVbl@`k`;hmfcS8{0R@z$LhGG)3-&H#hk zrM%>{QQ&F3>fAvy+t^p$RnAR%`V6~=v5KzJ&_qZ;>_OsMZjiVPKv}S~ zwpk+1CiA`U$JtHmTBsx`Qdqrz3vZXV-ZYq9CpXBZpa0^GZ~TQn#*{pVWVevJVJ=ST zTZ8~S{p3ISug{;pfAYURKY2>w$ZwZ0onbr{3B%R=nLz_;orduZRG;8Yd8~{|;V7W@ z!peC!_w$>&!T)XJ)eli}fa`9?TC1aDFG`T$3dnDY^xBNB9S46!K37vq*uHalUVDxd z7u%sVQoi;aFYYk=tHl z#-kf{wrRkERl2i`tIBQQ4lz2kesy^cwhXN=Rz|%^f8YT2%Bc|62(af==#Ef2M9(35 zE_;H@p0G_Qs5=7NcVM%4{jZToq36KnP8@{IHGH=d>vLyeC zAI!+v3^Y9$*)1aQJxl4Gq~un5Ab69}J?SRAjc>V8_-rq;3;QkzpTqq+#r+DD#3loO zC8}!E1M%4htg9=~y$i)xzUXuvjL%kM2PbRASsR8Sfue}*7~43S;&~+wk7Yx=vBzy4 zD%gV{eHCnwtn#X1`fAJ+d|aSD7pO1i*-cohWPPg~s;|h}=?Ad2Yr*=gM%s4bTkb5| zR)p)zH4wHZV4rPLHV@fnVVFDURvNU=!Zl0SK5@eX_glr`H%m!}f;kkdlMsGZ&9KQB zSfPIEMHoLT%ez9cRvgH$RP}cp%Fj|?>yv0wicI6pVpW^<$el=Y*i(8$vuI%#kL9IQ z_|tUWCYY0%u07;%7H~I3v9S`cu|?gY<*}dN0ANpa(-A_fWwA3)UMsY zthl6hALOt)_EqOFmW^sG;u>b}T06sG2UuY4$c4f&$y+)`Xc>S~LEtW~ z5YWqLa&H^;Jhs`I+FvGC4%Ij@Icb!Drp*#COM-gXa8A4W!88XK@8$*OdP?P@8jjrr zxArPR*Bq+0l`lcBb+p<>!VX}U0M<4_DL)-%oyJMV#wxO%p0jO< zmON?O&(5>n3eUQD@)kvRdl+|{A8g~5f|!53ZFQ;mwIKBIcBPkz~oieooBzg%fgE8*<{~7PXo5T9IPp-;hy%z+AaetL*@K``z7GqC9wO;zfx5l zT>6!%rI&pzP2Pk%va+OBxf?6>ebskj<)-zIS(Wd=-pclYbl0^RBit2N2buNtimRj> zE)=skyUL1He03jZvGoby;vyN3xgKM*1HXldZFc8W#x*P_@KRXP{OMU6Sq`fs3{_RP3+rgQ~ zmx0Wn2H?~##1G5CD=Vh8l}b2N%Ar!7q_f?c6Ngs)(~I=AHBSmY{Mo%CRo)yTqV%-# zxw>4l)>szWr>V88&a4M6IG4kIEN7fdkt;p(WRxgA17*A}or!V>pj@1%jY4It3rE!q zuDw0kv=b4XbVFr3kr)@oN&ayi=mLv`(*?lrfhe`Z7`nJBDSG6`UnCMVGw4f-CG`UT zd<}nXABIsOoYI8uP9|)#7Uoz2bHE`P4#`+yU?fw^Y%-XUr|Zl$t;3*3CJWuQM%_0o zS%kWcYot|`b3R~|*ZY`Ir0w7Q>wVJVZ3b7)Tf;4EqTf6s18rKyu%tk*xgMtea8nt+ zwO|=|isNn(lBdkAW*Jz(!y0r!N+jT;R@+m|3X`0w4xt^Kp4?OP_b8enSfjQm+I%`u zorlCb>cNt)btrP)G52Bf!YnCWy26Oul!=ge1ki|q$31M!CJ1(OKn|5<^3w2vhNhO2 z&kaku=%xTuq}poXc@kIpA&?H%b9XG=9m~EzjOyJ=Nm)4DvCp_;o>f*cu3V0--4FC} zrI#UPBcT#)xxi2^zG--;#ogIX$W!j&K*K+c-y9g~u0^gjmt_aIFv|<#&YpFjyV9Yw z4yBa|ca*boYf#!e&C{D4l@83UkehNXV6IVB>s*xXw3~y)whtC_sVKQ9xm1*!h#$Hm zihYL)^Va+tDJXjj74F1AMT=>>oxq(tt0@1tP4HZgQ%-{FTqIfCi-wTg8B$4I@$SxP z?j|lr+>E`Hy<|=M-pAJikN-p`Ef>)k3|LrX)56ez$fwnX^c8C56kv*H{v1?eg09j` z-u+EWkMGA*Fot8WxF*Xfs7-ztWgfw+_YM$rfM9DtP}eq_3ZoAR;?*T2XsxHx8PA7;2m5!N)4_zh0TUV}tDmORr&+y}o@(jUCG^|`a7%Hy z9mv&VkjuKXR6@AyR!l$Ot!_`kZ5ZsO*=^eidC3Emb4<-aU|Ru!73rM*Wrjr?`K@cfw#>iU)75PynDRK&vl;kBzwM~O0r%xENqsUc$)L@a~53}oyV z4#7xu3SW2PjhD$2yo8inKfgLh8aM3@ZcLBq78c#HP#RFN!D&OYf}+6=lXI9{YfR42 zb(;*z*)?weP&tF?4wlpX_`=1rO;kFKaK*564ta9OQ(cLz2R-R>xiai&Q&A4PMyLdH z4wzlvG;| zw<7<|{05J>ar#nBrwV$plolSPrt*WnoUb@b5=cMZ{Pth9I z#z$A_Iv3r!=-s&Jy1dr&&^4)a4!Y)`TeU$Y|J=SHY^r;%tsBleXOHvF&8}~ncWzgp zeR9sP!Wmhpt^M;CoRGWM(veI5+FyK8J$gURcGwSDh#*|P(idc*Cug0XXygkRnik-t zUj|r+9BuC{__TDW41CthX=W<;R|&j11`itZ>B4F;p#{$Q<<2i}>6csd%_h6%d0MZ3 z-noVG&Oz55o{~kZ%lj=xRqk$!`nbC-4!&pyUsz^yJp`j@j&=-UxEn6+hD&$QQr~V0J+4W6>%W@a&J|SjIEkj>`#^|5XWkbA-844#zy z1F#HMQ($Hlm@I8-PEJ43h?3HyaI*8D9K#J*7-(V}&)dh+3yrh21rOdhyv*TcZSgWg z+iWsgX4QFisEld1;U4=p7an7s%M{dbPyTE5sG2c64pY;;@S=sT&7l{SZpA|{Oq{CW zXhiyP%*)hC?8i#<11C#Gvr6(q!Oc?M5Y=>?>Lxx++tf1_fy$^R8m#-sRH${9U}nKZ zBL+Z?{osLvQ+ESStpT43WpLq%Pg;sS=^}P&g!z1Kpjm8Ntv_Wu5U)Syt{wwugtS%h z*+xl4Ffqd@*d$;$U-~h-kB+}GE6r9sUXHQxSIa5CMGl3stK#0T>Ctp^dtG|?F?VtT zqy|GF5THNhx6UxS56jhZ&+<7XiPmmCvRGoM5ZJW+6Ww3m&fOCxOwzsy`@-#*Y~7BD(15+#AR*(W z{RRngGM$b)cT|=&e>5CeFxq?d}`ea;i7_tqsyD$wrX-Nf7dy#Do#Q$ zYyu{JY{zcK(R2!p<**Bn>iO|?TFqla*ueK9qa;K7-B28q6G1*~Z(ys%M;X5n-#2kBJ z267RJ6*=}UMxzi`(9!4urtJ)T`4CMIUW1hjxhws?-XWkc1fE%8n_&*`ST#dC;#HMN zZGfliAZdMG>1B}EcbeT{B@Q{+4z8(a6YwyG0ReS4@L_0qpBn9}B6rL=MO0gktoVC#~Nh|bj+*wZ^;}L$xaw3MJ6RD zDc@@s*-m5&*5@;hU!4zmt6XkThaYwqlTlK2n+zi6DBSjO85PYq+*AKvUu;HcnA{b~ zoal@>t8JIZ-t?L}IP%7cZGMc#OhhY1X-s)oewCE3mtw?fM{3Mk);m^JkJgwO4Nc=U zDz)~56AnAyjZ3z5F4d-r;lj&4r)oI^`2BQFkZrD*CdDtB1o=%M3Lln}!CPZqjx_!tVI#&Rld(HDaGG zH;YgL?E!LjkGl;(z6+;Ky9AN73Q18@v*-g$gvk-*oG&s@c_AchA$g@Ey7+XjoHOysB{r&B0qu+? zmxNmtoCr&PPJC&~+XF46k%@8T@H{hIRuH*7H@ci^U3U{!v_n*W6Gc@~_pyz-(%|w? z0h_Kr*S!)&o5@^bWzEML6k3d%xH9|9N7towqSW^t#klTQL1~1bg~a&C!P;h3<* zSddLDF1IiUM~)8uBF&op*PJyk@=y>qgTm5XX5R!zctHT?7Yrg%at%M9sV@BnF*(jm z)ZO^S++;n8TZEa*g}anYm?*1;EJ+n3)2dlbW?(!o?qS^M5nmT9y6QcjtYURJSTlnmOeaL|-0O>keWWwJ6G2rGLa(Vl**Y(U^0A(2Vzy z0)9MstW!oMG4#nZ&NQ2RI&R0B56roHM)j%^ zM2ij&19Lp^>L+o~`3=CCJJ1~xq^eMy6UT_dJ+s5W6DovO&y~6S#`?6D4#QYU!{B+2 zB1@f#)g1w@QFs?hNl7PI^#$h1IH3(y_f53VTMTNWImXyK@Wv%q=4=0j|GRBa`JK%= zaBqbjoc)gAghCwSIZdkBX-o1c6ASc&3-UA>G15NiU$e+z^O01i zMXj~NG6wpa7AKa4aE-7F`Is}s&%qc;=)NvBZ<}V(g?7Hz&h0Al&R1ZYAGTi7IB>5c2`L;1N~@?CvRST!ISp zzAu4jtRt-}1g3U!&d+*S81m$=fYww&=}>{bpVS2YvJ@NCx3mw6V#OQ1K@{80X3b-HS0*lF7gaC+cGa+0~X*D6Z(4Q~B; zSO$Na!SJ@fR`heRLTqgkh#!v%WQ8fFu>_6%S*6a|dq7b!rJC9*zrCYIhed)421Yn; zTgN1@x&g-&OmDFoq;Q5r>t{yWB(d>edh}{Td0fFC!)(<95)rzNJMh%BCu@ll<|H)D z^FvdKuf77rA-$J5h5ts*>`Mrl0>T!=Pj(9C%6539mSf4V=cCKlQW?T%4uWP~_7ai@=LnD5k|a78r-3I$=rbWna>hz;cB^>QOm@XwtiZ0%brfs-iACtt6-&E3tZh_)i3=ZDQ9wG(V5MTo+d8DOR8FG?R)8ZH z>))5Xh8jk+l@hcCDYz z4O_=msI+O0oloFsw#iJ!Lq;swBQ3f48M2D==$K@eF|f!u%JmLG#Jk!9tl>N`Qwh;h z)i6z-EVyCy`Ee3h%$}BpA=*+fpb^4$dejDgU!M&?Gf9|dqZkogvBxiPH&{B|%@Rg% z$`yvgk=Lh$%vHbx?XU{%Cg@e)N=QxnXRt@1)%Mh8c=J=7`!m2tInlA3&T{3$M_ihB zvqA!-ZLuO+>FsXd)^sQo)Vnj>eyE&ttbf11DCki8x)gEap01EvbhQgq(?SnIP0Gnz zU0fAAAi=m-DAc{11Hb)!#ghYR?eAq)s7+~)&2v_6JHfjvj6M$OeZdQr(!{PN68NBT z?!PCMZ>8h-fv)>`tvLHxS3}hi$Z_n&4d#Cl6Io(P9p*o5a4^=6=dz zm4h8Q3QQ)XCy&5^0&ayHL4IRLV3husJ!@%FU8wF)4%Vk5r@1$q=eFl7(G$kYa{-rg zn=J}rvkH2uIJMj&S=yeA^crx$^SM+KZG-xQFYOo8F{UTd$lJ=yV+ChjJU#fcio656 zg6LNhM6w-Y)+6}E4YVx&cspLYpsn7E+VZeCRqoSvQH_wKGkW*SqI|IxPMl-`POj=~ZWIhuO;?TchRl2alU!0AIC95bNu9*;M z;uHZ*@ThbtVD$1Wx3e7h!#qKgp-D9P&7A1i$ zcKSLbEjvbjFKtx%mZ>r}>^P{7pm~_bn!gFwa(%@~T0@j!$|F zu5DZFhqZk51G3H_&7`0BvN1}a3zXqN+D_6OedS|9dwS#%mdI1LXe&=zxXZn~Xlc#OoCoQW4H5LlzS&eA zpvfcSxs%y85400)I_vns18ae|KN*M4G=h-#$*XJLw5xaB?1{_pvgS8fC!|@c>t@h& z=c-|+i@W#ux{5Yn^6I9SSIprXa)%okh{p3#-U~?Hf9g~w%zx{Yc*fFy>eNPyVp?RO zSl(X_II8x&(B(DQ7>L@BAez;GwTc<~e`-|*uN!C$I_eVndMX>lr%{43X ztQ1M+MQRkzp~WI>Vei9~U!GwqNtqs2oL~*YB)N0@`wjj5^zRK*3;~wOEvP5Lw0D*O zH)OyBkpJ$AH0~US^n<2*)O?dMG7m~zMXGn9I>6GJS-*xr)Q15FN-lySIpE6_jflm= zAvYZ-3z8Pz{P_?!j_kdEqVSUF(8V6rPbB1{-!2>JIJ{sU%5ztXq#3-mgxuh}t;+LY zM0>26-PKA-+WV+rOev+31>j|AmYC(9bG67A*b@xXTBTWxSS84|C;eL@1kRw=rr;23 zfBVxzm3!U-@wMoo1mJzi0Is5kekEA%GW9zTKiZM1ySl{&ZPa;0^p^IK_nm&rr^Hgo2v@hz>^Gwl}nl40hr%V;-iy=az`{|Hv+xX4so|2A zX(+tqQj9XtzC<&9vT!qByS$pw8_9YeA)s{CO3Fa|4euqPD#TButa4IAKx6dem<<2cCQf3eS@vCTafcQ>lme zOCd4|vWzU4C1fz++K0S-<|~5p&^z<6aYy4pYy8EDL(vobK_d77e7$#5?p8SZ#9MHu z0TU;}bhd;z8r39`Bcidqb}7s%gO}XC{*Ygi7h=G8@0Ec03M;ob>k1_QA#?lia+K{F ziD)S$$*}vAYwl@OrLM{uDGS+9p3E+U`+znG;rR9^}T0*_^i20i?~wJMrt1v)~W zo>!)q8MzTKSvp}WZp6~5BDM-eT*wcZgn5&*{?~MnNG11+%H-$W*m-cG?F{@^6iPm5 ze}5}bt|LI%AcC%h1T1IAzsxqS8}VMGV4!oVuv%c+WBQ%a=1@`_vZ>3e-G2=Gg$hEe zhaVP--rk7R><d9P0`DM;rWO3sWGE|B9liOeaji}Kn z?EcD`G>Sh{F}-1o0kib1#KbxDRmCBlg?l_dBItOEMgIlyYnd3qKRZN2bzT^O)SSf} zWqq7Otx7KE>$aCoITyO&-R(G>{s{A@ji6TBZDVhxDm*4w0JprvU<@;hZ=9hCbhutY zoPt5FK!B?NkKf~geVlm1kC$R=g_E^pJW~-`iy~uMo#`Qk*K(CiTRWY=kBr%IhHvyP z2ek7Bs1JG9l*n4cjK`^lE_NpTT3kC7K$8*Aw4qLhh=Z zpu)Ud@jd$B6e6~N?0}hy z8*=CLG*Z04Vbj=Oqc+p8$t(w%JBx&Rj5l)0enJ`uM**Eyvc=h>g<4n~6n;msRav+f z(|y(a4Wmz$RZ|{V!KisjT+!kJaursnF=O>f7EuY>SgW!`CjqE?=XC~nXdap8%Ng^P zPNSi0lo}3lYa>4JF|d9O|G76a1xsW>QE2ZZA(1K0*r)q5(z=dpBPq_r;ETD4ep+Vo z)$FuQp_wve?68W59{kyfxv{Nh-eSxlF3oq4p1Yk$t;(odPdlZvS~ITONc!r-8>}!= z%vN&)Wg1@3^t~LGcn~0Xzh;PS&O2TD8CM1$exkX2Jy)^#`a71H4%KPL^66KJ_PXnaYq&v{&uA*S#o!E-KRgrS@0}r_C*BU%TM*D&R@JgY_}BV& z4=X<~lk3g|!+}$o7N9p*D^gDOW{*GZjAE)CBBE!)W*Ux$1M=hV9(kdx%3m)>JO4RR z^vG8}!2+nmkbTj(Jb|9BF7PE}Jl;smRmHNak+<`zrQ}n`**w7@DAh!yCYm*t;$3Dq zu+rDj?CSlszMKQ^Jzkk%-yRq(5oasVlXfVH;1x`L3eP{JAhc*&$XNTwtjZY_I?#S; zhLO~7Z#(yyo<6OoUmy4D=j$Z%Z_iJkw~m52zI}v!0Rf*UpHIJm7V15~XtSB7rN^Z< z$GtkNo%`&+cYo&2vn?YGkQcYv>vb^K{N)gX?ZlEX+`s3u3z6&Xdlrt)*R4OJ#^X>{v51C-APbR#t0|xpz zqlzzSeFwEGI>?ZRv^m{1Nff<>Xl7~rJMW8VD%|bgBX@`QF=@ zp>J8N4`YW`u)Wa_R%(R&BB!~(jJJa<9k?Bz_prO}^R!7jX?T6){|cCno{iP zam~5wkRm~dtA~6H3-E(?_{eT!J`@lLFl_QcIS#61@l|6dU;o`l>T!~G5TdP?_QN}^ zCsA1mKlR~2J$M9ekzPcP8zltK`n3G|@Zh;T%S*`;WuB!&KS_{U{#u-M` z(w(ME1uHE*haRiKS6{2jfLR_&xeDD|BITvSLz#VVK%z4@Jxy#*S;YM4o>0Bg5DpU+*IW2bX8^{DMtF{Q$`R;_;deZ?u? zfq7-sI?l)PqjjGe8!*RxwJINXC+O^N+OR11n0UDJicLmOb7wB>uf|_^Nlp=_fba~n z>ZmyV_}5CIF}iWevY8o%wKm+uwT&2C8+B2)oCpd8`foT}Q}Ir2$m18z zQhlwQ%h9tJ%-%kPG8jAfzQW3^X{KtcX-@Z)B&By}4EX``+STtBF(oT4)F-KG8`uoB zUzykmIt&~#IvbmTKF;1H*Uu+0B?%=X@+ZcO=6^(6Ni@p}WN2h%ZB=HNrUpI($W${^ z72Dovc=Jw9(P;Yw^GxRD-rU4=EhBb3^JDj_ZhJpmB7QDMs@mBivy`(#QHy>IE^``; zlFqAkzLM>uPWD3D!=u}K9m4MjY%a>iubG1BgQ`zs?Q3oY{zlz$wQ+H_`FJ7(b5Ya{JxStsDZ#KC!y-=ZSr1)=BH~xH(A(or z2~!G_ks-}5EGm}?i|cQaxM*$b7uy)lfi;5|m@L-v|zy;zOp`9vMt!|{vLtA1r zb)c3)ILx%|#1AwBfpRD-0@Isr5OCl_dvfZMWB#OVzuG_~pZW+DByaZ%BvJki;L}1` zI*Yqu-FFcBmG?yipe}x#YI8K~^$`e$iWSJ=$Eu&3cziuAV^UD;ujmU5_Xma~!~{?H zKVy;DPux|>`Vup>$1_Tjx3pcyq9(fkmDK3LWX}6b)1V*C-g8u7uF4>!yIz1xlTF6k z8V=F7-%t}1=ao9Hlrzwk@D~^c;_=pULv31!VAHfPzZT@wlEwV?v0gTopsX2G@q6!O&#yx{#`0zut!LFgxMMJ` zeE*S#XS^5TIvE@2%b*zWz8~=uE}h8Uags~upYMm3Q45duDA3;O$H8~S1+C=vKQBA8 zT3klAA{dlvJXo#gP+%MpeWF_N&V5*&i1=)#BgtZAo+wiq1m_94YwDjs*N6!&UK0RK=Z4vXv6FgHOpnn-8CmD(-Vi6E%qbzN9)gLUiOUB64SEc4 zJ1vFXmSnqJw_S;)jJg``!sj#&0F@>!4q0m=`}8bdzGUpppujBE(!Kz;)@0M&bXt0e zu3HgG>AmzJx9xc$`8RP^tQG#x0qK|ZJUQBl(&V(gsFX@SCMNZkkb(X`vz9zCeN?xn z*V>9dG}ygd6*CA^bI~Ed!XlLJ8}zQAg}EutL3bL?1cP3mHH_Zf%phKm!@j9D)5}WI zzBD-}VMca?nlcuX9BNVOIMK_IAju~GB>$7ar{G`ARyxd-#>ee4kRYJnFflYIiQ>NE z`V~gOm!ZAUoIuJ-H0hcE=4L7ow#g02a(Bogcy6ojSRzrfS(bGCtscH^cumf$rcqbg z&6SbQY=s3ca8cy#+|CH4P{mM_yu@6#;C3dMHzb$>@g`Lcgf$SyPpl}8~qiEHFy6*QKZNx{TMK}nI zS)xAfnYQstdvwNOCF@axPq3a(8mm%0Tc_@I(2VLt_|*B<4MhR0iXC2)SieQJOh&(q zdSGKjd{Rgz#7s%Fjq45Z)FLDBn!(ChmG7usV?*gi>X3NfTQE0EXFHeZbV2aQmHAna zVO#D?d539+UkwRGYH6LA0-rZ=IY}ksZke^RXewzZ6P$5N*72twwZ{slw1k$)~*W|UHmyNJWkfDCp#uxn9V(~?R{UNJ*Ns~jo49A_OuNp+CP4$DeBbdX| zvd+#eOv8L*o_u^=@rurpz~vYYv(5-<70N0`I9`Qvrm(S8EBua0gu|NCM)$gz%G?BB zvdy=mgg+lm+D>~3qcBXd8`e2^TZ%dqB~ND%l0Y6B42s^qO^RLdgTowps!29p1d9Dc zD*WdUpOlOUZdtzzAw6*#Hq&nH!^5A^RDU@B;4k?JoR{Va!~3;PBlC`^dA92Tv3PB= z(Lh?2F+-~7B$cE=Rv)Rc8(H_aM47wM!J(&|?)0TQ zmwl!iU18j%wLo^(7;Y*C_*jAx3`p6>Nu;vxktpy%b%)f@5Q+SpnRb?L|6Uo3x=FVfY-oWMM_BWl(V<7U5>5s}xx@BD5AZc;TMliK*2J(>)AqBT- zIM{Ef?7~;t$*`8IoAV>=$=l{%Q&ZokZ7u?COv8s{R5Pr^>E>Dzm`%@2-})L8bpGrl zV4aEkn>Wf+DGV}5e*}g`hk64f9_KmaM!yH?8tpwtSVd!#)R9}DGyMMWDGMA& zezOSk3g`YbZ%ijZJx(Z(OQ5!{bmRk+*b?xcBInlnrn8 zi_pwO-7t1ps=}k1JXI8*^PC>?zV(WFzBS370nj}BFfftQDM^Nn#N)8`DN3$UjN4;a zCqYFNKv1xBI*kb$^OM=!+}G|!orMeb-eQhgugNJxTvtd~{UpquT8dB!O{;g2B1h*3 zRij4cbwz!=mz*=EW!7cTM{(;`Nth?Gs|mG?a7zeU`!QQb??j%-n5$D4vrAVE)SS>2 zS_y!E#A0n?p9v`y!9Az&;~|-=A@w{M-N(Ni;8vSyx>t%2hiw&bO|GojH+XL_jUe%UL zg}gMxGn1g~nndI64$nxh1z&hNhXK4UF7;}PV^87?_b{?pr7s-y0+JUmv3rbB%M-I$ zNe9j9FQbf&I?^>pLCTwn_?)crmS+_fx>M5CXO!;oqn{#`xcgp3UwJ2!J)wg-3ItF-DYCMze7@GBuWH|Wn0 z`MxL;$Ae`tlJ{;Ay+M;97}qc=_Ns=e*Gfb3qu3f#xypHCe<5PNS3Pg7%Qb@3rWtiY z{Bk&hf``N}HeUHK=Y>wA>Q)Jde<{+L7Gt{RCo14(P1#kDuUM@bjYxl#w*CGFq#9$8 zzDf9bZ?ZT?sOij{u>23th=*WdI{eZ#p*A>=dQ+S&8mJiwQq^gGh+-6-#kTq}tE7|a z4JcuFK7rRLh@xgF$`5X4U8(#wsu7{aTCfIJtfJG6r~n&kn$VWE$t5o6BgPcdv_>k2 z(S$8IogC=MAcbRaHH45F>F!h}65=g}K>6z-h$A$|NkeRyQ&{GP;r%!ogq>yW#JeCy z47d{(wE0Y`bE9?u?u2o<&eXTE=@48nM++I&BH67_p!7i|7nL)06b|M=lQ141g{u8m>bHA!~pgiHY>Y^S=yjc&Y}-c;X?qj;W|2X z30WUsO0)ydO;!6h-5(z=kaYwhslDzn^_-*tP=6Q*FH~asdEhSz_ASVxxPG0{*)`!N z0MN*Zy-MLdHo}78-Eu}VkpZT5(llZ(jb{b2N-Ep6l~vmlcEi{Z@KG7)SAxt}iq%2& z^u_Jpc^8*CfgH#GPLpdJdTIn>kC566lc(hMcl@zWVjm(sF9DZVyAhu{P3ZaGn7zI< zVPou8!F0I00N$#_YrwHNs$iNbF%|%vvMbSOO^7@bMv}FI3#h7WRH%ft=D&hPMP+)L zxoE>6PKmseMs@E#vJkuF|J^pcx{RTGA#}3cj)H8YD%)f7o_ROLx)=5|?70ohH*cte zfZ34a_q6r%>(4b=aiDNIWvsm=RV!QP{u(;31qM2@!LitxpfcRxk-9S_OjZytj#$ss zh+Rf$jfRiO*@6=Ejx-B2v^!?TVKBB68IG+hu{G)WWXowcPgxqB?)n%i<{Q=Dz5JHd zQ4w^481MI+{zdTiOx_uW!FQMUFNw>kUvIJbPqR_0U~H-}v6daKxy5K0^2T`OgSd)8 zS_L(OVqg8)>bY2+iUiVspvLY04K+4#{|9Q!SojarcoX+usPUu~T%3S<1BJTMb}cqS zyk>F-5Yq^oK1!mcm?M$9e~fJ%KR-E`3Jhzs{s%RxJ#n{LgR4(AL-{ib6zRYol79=Q zib2;^vH13F|EU6;x5T5C?!YvYBsK9Ho99}Jh9{dTGz#lYKW|L+7l4iL71yAaG-j%`i%En`Q!E3Cg~6ksSRo9*nS+ z6DYUCA@ZSWdum6ChQD69}_&qmEvlT`8h3(N?X>q|pAtFv{>jgCt6qT{%{n z0qU5JY4kQ}%hYGSc@rW(uOA~+VXE5G?Gs_`I^Z?cU}nN?rg^R8RLmsT<9>HtC6Pta z!r^NwwvewA$#O^*9l@vlW$d64&AH|!S1rWyOl@8j_K4?BS|0prx9m+a;Z##4Qqu;L?&SC-hyh{5(w^db|zfmn`TSh&|nFk;VeO z6k=zM5L*#Eg6z};VazxMsDuL-swW(5xQczWE)ED{NBbZ zhr@k;)vcyUwxZZHJvP)<)>P;ZigR-SJ>QlNYj~H;qI`43kf1)MGAHQvV z4)RN14p#ov_3G+=E*-ey=@9n+`owble#rF6QmW5G?i!6DQvydIRsp#OZFJY{C9{V7$b8vxCroE5{=oej-R{BGiye8 z?f&B_A#NoeH{U-yb$Hq#JZeGM%IX_u95$VcwTpjqxJO*`rvGU>t#@lU)*(Z4A{sac zB!TH73_q|VS!5Q3DLHebCc$h*uhVYk9S!n=^>&41bm4Z@A|u@zlJgRZG&X&~VxlhR zcI%0f!g;QM|AM!~EPXQ7Y*$#&%oX#t^s zz-$2gEO}B;aiQZs>YiXOM5pT?Z9DLaXho&34}$kR%OAlIiiUhQIcyj~U1>QdLAoyb zwK8(o3(a3$Pw7tZGOuBtUKTpyO&l&4#QNi!cn63$X3_#W%}x6nBqIo}s9Tz#_mQhM z7_{Llp~R|L!tR_&Q1qpSb1c81G$p0hxhM^jHd%oy;y7@*q&d#oQ@EYX9@?844Vx4h zZ;Fs@SlB-9MPlxBi29W5qcG?-K}ey$syiiX=KN|(am&aWTINAWvsyvIi!aBhtR#e# zYj)|QGqcktL7Tz~iwmLDp}o4<%SjjJ}ai=BB$fG&@qFK9D7jVAz8e- zrKC+6sQSk_rh5T7$A}^I?f=a=_7IH9od7w<$N$AS4kNIR9AAfs|M@>SMQw0@C&+NLD+4vkD*^J|=`y;x8%$y$% zb)BStC~e4rIq$-<+>T%z7Q@#=hMp{*uS6XX`HPFeEOq`^@Cx8U;8xCkP=Ld@mN^d zJ~=a-x|hR)%?M&0Vonj-kypSBvo^#4!oPO*H%#9yp+|Bu_&8*Q@GN07*o66?xXXgR z_VU1sfltb3>`j(T8Lrh11omKu4iGiI(OHaUkf} zXg-JX%*xg&VK?P}a6ur}){N^{0#Q>Eu3=)HsvhN%sX1?O{36!5mB|m`+3KNLSDFs; z{?%1EdnoSKzAzXZ)IQW~`@`#ecD^$KHXurV7*s#C9M2oKAnz# z$d<$*#c6?wKqHGEFDA9~EM2cs?`cXt)OefwxVNa%TtX!FE&WSO-SY+*lDE>GYE;Bq z-yJPvdTVOLc&c|h$ zIIgQ)P949W7hvbr0+u&XiVB(<(RS_cD@br@6jS4689 zhGe~|*Kp^ZPHb`Qx`XS7{k+fTrwqp0p41W^9(dSQz|dX-15^xVnMkXGmE-8_fq^UA z_DG91&JY+v_TnK3=-k|lA<7{Hso>mRO**;+QT^NwG($fqlgH_D+*eBmjo%i#+3M99 zDk77cq9sm*3o@@J&tRgt!=;B?m}8c7i4LBBR|?kQ5;g=uvK#p)&>G}zEGo(vDO|%+ zrdj)ddF&$oNSihBprxjZE}y(1G-mD zA#LvNB34G|v3NDZRKKaEbJ`bOwPkt)0yh0$Gw zg_8cC;-tb&VZFsL226Kzt9Pp}1H{jRn(}84R)d^BjNvGmIq(?|oDx%^3t3lYM@7lJ zap(2Ec!2BnhlTCSYGmIsubK%FHV#-dlL0m^~W7ICpt)z}L@a!M7XwC~npBu{Z2k~vt5GUtmJ5}IXhsndOd5(s=Z zb*7Wj^@HFK%k*g3qd02ZEjfH%^&n#3Alb=QG~lUI+82=~+`I~w6+GLPw;8TUVk&lM zQq>}dI6q?SPcj`b$Ucs>&XFRWYL8gU?Wj@~Qw#|w#lI2Aws=YD!j?@E;9IR#-e-gB zv@AHUiV*P-*g(UuPr)7nCTrNgDuzM`2BG z0Pwn8eE^=W?b%Zn7mb+?WJ2e&+Ajpr(@n58W-QlOm>sTV3=E@p8l<5&{l|<4fjx6N zaFgzdW&G1GbvV{rv|QC*;0 zF`0@(`GP7rUEXik`6Ad(EjDi^9tQqiBEox_AR7%M!j??zl^e-+Ak_*8%|rTs*S ziHlRPXKgJe{%Rc`_X*=~pyH}}z7eI**z!%ae5v{DUF%I4mhYVShD-E4HN(G-?kBmu zPU|`Cm z6hSiwWQIvks)y{+&+CR);UI4@;a?_Rpyxde<1r;ud6Chz`TG|nEW2(HY%vlorLuSG z6td@=ge-+yK#GSDyq)&<#q|q{{0!hXvZ~4X@c_Jc-Rl)gOA;?Z6p>qcuj;W zyyIZYd_bV$tR=>cDI7ByLaI==MuX3Ef5^nbsG+UxAk~k(TSj#|)=o?k>2#KO4oXON zfIv?VxhNH#OmWns#pr~S68|^SR8TC*u{;>m!w=DiJp{QQ^YGUK9eKv|dI`22`ozU-)HMLoReMc@>4Y&m{$!5`-MtsO^_+i$61w{5AR3PN&Dq0$ zFG1XMu!PA^I1eop@op&h`@LurxmIA|h{(~Zuj4>isj0^vsi6WJ+fbj(-V6)ZRmK92 zMiwkX901CRS%```P#n~r4>h3-{sS6HtNr#aP(`xRuIBO~D?vHEi}a`#hI=hk@G?-I zzNv@MMTI?#7fNwUoWxVPoL7p@F}Etz<``G_rgMHM#HDom)QQ^%pRsMbUGK(ZN6;#c z#^DS_3HOVw(+*~uMfCup;*+e?E^u<}n>;uMvM3h47 zyVC)&BEf`;Mr@NiED}1m(JZLzHi&CD@VINu0*`wJ{*w0)|BE9dV9Y0@qGmtubM<1M z*E9y-OY>qDt2V+O@K_#7M|ffkrh!&p#6vjN?UcKfR4pb5(xGN^Nq&HS#bAk=s3=+M zfI8dk%zubco|-i{_!ejveqjk~(V@qF0HL;xWWhzQ34CNoIye$G)wI11lGARKI|+Vf zxe5Gau`=7l{8U^|8^4_ExSRpOCArT1-m0uJpgJ7{Z-JPxpYA^$46#=?ebR&xpKfaR zx#BWe_aa(w^{4mM)+cb64}+NhlNF=`T_vP|!6+{9IgZ9&n{&e(eQf`DISULcuWmqu z{8m2u@ty{Bej|fAvi{`jKb}|~d9nk?<6jv#%xMajJVtAjOnvfjT z6bqD#`Aj?FC(a@sbhly#6G^YIA1-U%q=Y%<9&8-BPMjlG{xmv!+P)l4u>lU}FNx5R z`%)X09C3P1Koia=Ahq~ajc=;7G$P0rh5BLW+(kH(Xiez$zypSD0?uDa3^+3FVtWttCEG%y*~ZxaH^a*mvsg%1nJ^%*7^!ZaKd4av>=M$3ee zb=)3+yz&owWF19Bsr-jMau}Q&@5_gmpBOp(!ye7P_YM)MMZy_IEnO@3F8L!i`JO1; z@EF-(^rzIqauTLD(v7BnC!NVM53P=z#x2m3P7{ox&n=FX;m=k=(X$8}JyPjf zl~8852-)jF6RJ1Yx_RsGXeiFc{+5t*9I-|W_X>20yxyDV%2Fs;!Jpp0*B0!Jv(+!W zU9#4Pwv@iULZ5A%#qDJux%2aobX8ip8Lw;+7L&P;f?*UWlkT6vh=LT`IuQb22Y=O| zF|VYegoh|Xksm;Uu46QV3tdj8iHX8#N?yar{s8n`u=$wl+R+ASYJ^yT&-vSP1()EM z=)xLxB&%-+YMGU=1exsL)qx}5@zOPq+<_XCy9E8fAbDk!AUo5k$Btz*BAx4nYC@ht zH3&<^8L9f)yTd@t1~IG6l5Y%v*47v0&Cp0yziz1h$3FhLFi$wL3+M{bKp1Hx=uvH; z+cQQ02a9r=45I61XPHs>;9Z_9&>$$#xX9V{nx0e>v=xvtuP*%Vt?_#cuA zKsx5;FM@7eBD)H$J6%|vPF2rq(5V|RrN%9yYf+_t?4w8~kbOij{}20!UJ?vVTR`nC zlTm1tQb_+eqP!*q+2iv!ty(>?FI-s9%-JQ$g&HKWUxL%gPXNWcI4GfQ(!9*w%4~Ik ziDJ9$KEW&w*MSIBbs>F-|M~V=d?00XavQk@7n;pc`Q||>&p=K0I$hv+G=i`%L>&l{Dt0yr=(<~Ib2TDUQFbDcuMuls@`6ev&|7t{#JlzhCYv1SUi z81C}l|0t2wpDQ(;>)2E5TmdFJvv*h-xB51>N!LVt>GSk09YaQL2iMn9AxNhA6e84k zi#rdQLv_Q{HdECCL{NCjJA|1BTZCqG)VY;hlLJHH479*0-6TCr#)3jFnt=IcC9qr6 z)CKk$H^j)Nv*Is=)=f-W?qFyyu-2O$Xi24+t*P~?yp$b}3F@p|z z)&csFgR~@YY#yl)G}8ud#&85qEosbQjS_2KTa&dpoC0bEd=mQl*tdT5gIgS>k4|9{ z@<>GWN*cczEeeLZ7R&Uf2TerDtAP1JGGz+0IRj%O3~tWwu6f&`ZC6za&*NdGVNF3} zhtn^JaV(nW4)ip5&R!!iojQ+-#MLO6P1G!6;C_~IZ0FpW!2te9$YgJ8gg>SlH zPnCwhqfgcU(yk`VjiOb#wLiqMpkjC!?bwVAPa@^myasL-<(-5Qy}=hySL*L13M&}l z9jP&ukq$pEe@JxXTt-c9i$&8qI%ztWG0}EDD*Hhv*vV=hk2~L(ErSnAWQ{bZ<|p!E zu0)(ULns*xz0GXmKYL3FVV}%?0EP4V!a5j>< zWE0SXwc|rJIV+METpNP6(2RT1T211Vl9gyCoo*aOU*vx#%q zlJ;zNm5V(h4=$;;w)en0Ew4y9j7u?C`<;L?;t4e>gsC95JxELz99HwOtUTM#+7})%FIJ2{|AB8!Z>p($aB@~;e?46 zb5EtR*MiK>lTHW{=Wu~hX`_Sax7d(G(AvHVTCOH^F83c58eOyK025FBG720zEcUq3 zBfi58>dUmD9!01!2?axIuDRw#LW>g3E2aXdA|59U36MpUHmH(e85-UV0T%D{qiGD~ zf_ga3>hO-~N;YM8@k_%v31(CHV`{|Mw^3NIDsn^&TZMAEpZAElm-=~_G z9uDYAQ+lLEPkRe35VsrR?2lW_vcHoC!2ud~ZjDmEFOd1nx0@qW!9HbI8C_t%5&*f9 zhp_a^8z5JLyA^A+7YpLnEh`bmu|+5=?M0<#4a2aPax`1`w+Duqg7K}<&dd%i5!gb$ zC~u~J4-!>=jN>j%NS{_XpH9U}lBCNavl{L{jD)VY2E7p#sx392T!b;jrm^ETCa#Z* zc7TJBudMlnq5FgGD?vH}LiXBCs$Mjh2p{$YroNa4A7;xEXs^&m8`O`P{SGR;*9ueH zy^*ex_}~6xY+;Ral&Ga2OTOC#ZijdZ{Ew?{}HtHUV3 S-refb1~^_Fb>!Qy`TqcFJ<`Ph diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py index 605cecd1f29e..558c8aab67c5 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py index 605cecd1f29e..558c8aab67c5 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py index 67020f06701d..e462eeb99f04 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VmwareEngineTransport from .transports.grpc_asyncio import VmwareEngineGrpcAsyncIOTransport +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 VmwareEngineAsyncClient: """VMwareEngine manages VMware's private clusters in the Cloud.""" @@ -320,6 +330,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vmwareengine_v1.VmwareEngineAsyncClient`.", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "credentialsType": None, + }, + ) + async def list_private_clouds( self, request: Optional[Union[vmwareengine.ListPrivateCloudsRequest, dict]] = None, @@ -327,7 +359,7 @@ async def list_private_clouds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateCloudsAsyncPager: r"""Lists ``PrivateCloud`` resources in a given project and location. @@ -376,8 +408,10 @@ async def sample_list_private_clouds(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsAsyncPager: @@ -452,7 +486,7 @@ async def get_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Retrieves a ``PrivateCloud`` resource by its resource name. @@ -500,8 +534,10 @@ async def sample_get_private_cloud(): 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, 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: google.cloud.vmwareengine_v1.types.PrivateCloud: @@ -565,7 +601,7 @@ async def create_private_cloud( private_cloud_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new ``PrivateCloud`` resource in a given project and location. Private clouds of type ``STANDARD`` and @@ -654,8 +690,10 @@ async def sample_create_private_cloud(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -732,7 +770,7 @@ async def update_private_cloud( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a ``PrivateCloud`` resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -801,8 +839,10 @@ async def sample_update_private_cloud(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -878,7 +918,7 @@ async def delete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Schedules a ``PrivateCloud`` resource for deletion. @@ -947,8 +987,10 @@ async def sample_delete_private_cloud(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1020,7 +1062,7 @@ async def undelete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restores a private cloud that was previously scheduled for deletion by ``DeletePrivateCloud``. A ``PrivateCloud`` resource @@ -1076,8 +1118,10 @@ async def sample_undelete_private_cloud(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1149,7 +1193,7 @@ async def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersAsyncPager: r"""Lists ``Cluster`` resources in a given private cloud. @@ -1198,8 +1242,10 @@ async def sample_list_clusters(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersAsyncPager: @@ -1274,7 +1320,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Cluster: r"""Retrieves a ``Cluster`` resource by its resource name. @@ -1322,8 +1368,10 @@ async def sample_get_cluster(): 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, 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: google.cloud.vmwareengine_v1.types.Cluster: @@ -1384,7 +1432,7 @@ async def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new cluster in a given private cloud. Creating a new cluster provides additional nodes for use in the parent private @@ -1466,8 +1514,10 @@ async def sample_create_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1544,7 +1594,7 @@ async def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a ``Cluster`` resource. Only fields specified in ``updateMask`` are applied. @@ -1608,8 +1658,10 @@ async def sample_update_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1685,7 +1737,7 @@ async def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``Cluster`` resource. To avoid unintended data loss, migrate or gracefully shut down any workloads running on the @@ -1740,8 +1792,10 @@ async def sample_delete_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1820,7 +1874,7 @@ async def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes in a given cluster. @@ -1869,8 +1923,10 @@ async def sample_list_nodes(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesAsyncPager: @@ -1945,7 +2001,7 @@ async def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Gets details of a single node. @@ -1990,8 +2046,10 @@ async def sample_get_node(): 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, 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: google.cloud.vmwareengine_v1.types.Node: @@ -2050,7 +2108,7 @@ async def list_external_addresses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExternalAddressesAsyncPager: r"""Lists external IP addresses assigned to VMware workload VMs in a given private cloud. @@ -2100,8 +2158,10 @@ async def sample_list_external_addresses(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesAsyncPager: @@ -2178,7 +2238,7 @@ async def fetch_network_policy_external_addresses( network_policy: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchNetworkPolicyExternalAddressesAsyncPager: r"""Lists external IP addresses assigned to VMware workload VMs within the scope of the given network @@ -2229,8 +2289,10 @@ async def sample_fetch_network_policy_external_addresses(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesAsyncPager: @@ -2309,7 +2371,7 @@ async def get_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Gets details of a single external IP address. @@ -2357,8 +2419,10 @@ async def sample_get_external_address(): 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, 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: google.cloud.vmwareengine_v1.types.ExternalAddress: @@ -2424,7 +2488,7 @@ async def create_external_address( external_address_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new ``ExternalAddress`` resource in a given private cloud. The network policy that corresponds to the private cloud @@ -2506,8 +2570,10 @@ async def sample_create_external_address(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2585,7 +2651,7 @@ async def update_external_address( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single external IP address. Only fields specified in ``update_mask`` are applied. @@ -2650,8 +2716,10 @@ async def sample_update_external_address(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2728,7 +2796,7 @@ async def delete_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single external IP address. When you delete an external IP address, connectivity between the @@ -2783,8 +2851,10 @@ async def sample_delete_external_address(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2863,7 +2933,7 @@ async def list_subnets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubnetsAsyncPager: r"""Lists subnets in a given private cloud. @@ -2912,8 +2982,10 @@ async def sample_list_subnets(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsAsyncPager: @@ -2988,7 +3060,7 @@ async def get_subnet( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Gets details of a single subnet. @@ -3036,8 +3108,10 @@ async def sample_get_subnet(): 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, 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: google.cloud.vmwareengine_v1.types.Subnet: @@ -3100,7 +3174,7 @@ async def update_subnet( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single subnet. Only fields specified in ``update_mask`` are applied. @@ -3161,8 +3235,10 @@ async def sample_update_subnet(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3240,7 +3316,7 @@ async def list_external_access_rules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExternalAccessRulesAsyncPager: r"""Lists ``ExternalAccessRule`` resources in the specified network policy. @@ -3290,8 +3366,10 @@ async def sample_list_external_access_rules(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesAsyncPager: @@ -3368,7 +3446,7 @@ async def get_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Gets details of a single external access rule. @@ -3416,8 +3494,10 @@ async def sample_get_external_access_rule(): 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, 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: google.cloud.vmwareengine_v1.types.ExternalAccessRule: @@ -3484,7 +3564,7 @@ async def create_external_access_rule( external_access_rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new external access rule in a given network policy. @@ -3565,8 +3645,10 @@ async def sample_create_external_access_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3648,7 +3730,7 @@ async def update_external_access_rule( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single external access rule. Only fields specified in ``update_mask`` are applied. @@ -3708,8 +3790,10 @@ async def sample_update_external_access_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3786,7 +3870,7 @@ async def delete_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single external access rule. @@ -3838,8 +3922,10 @@ async def sample_delete_external_access_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3918,7 +4004,7 @@ async def list_logging_servers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLoggingServersAsyncPager: r"""Lists logging servers configured for a given private cloud. @@ -3968,8 +4054,10 @@ async def sample_list_logging_servers(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersAsyncPager: @@ -4044,7 +4132,7 @@ async def get_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Gets details of a logging server. @@ -4092,8 +4180,10 @@ async def sample_get_logging_server(): 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, 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: google.cloud.vmwareengine_v1.types.LoggingServer: @@ -4156,7 +4246,7 @@ async def create_logging_server( logging_server_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new logging server for a given private cloud. @@ -4243,8 +4333,10 @@ async def sample_create_logging_server(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4321,7 +4413,7 @@ async def update_logging_server( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single logging server. Only fields specified in ``update_mask`` are applied. @@ -4386,8 +4478,10 @@ async def sample_update_logging_server(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4463,7 +4557,7 @@ async def delete_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single logging server. @@ -4515,8 +4609,10 @@ async def sample_delete_logging_server(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4595,7 +4691,7 @@ async def list_node_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodeTypesAsyncPager: r"""Lists node types @@ -4643,8 +4739,10 @@ async def sample_list_node_types(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesAsyncPager: @@ -4719,7 +4817,7 @@ async def get_node_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NodeType: r"""Gets details of a single ``NodeType``. @@ -4767,8 +4865,10 @@ async def sample_get_node_type(): 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, 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: google.cloud.vmwareengine_v1.types.NodeType: @@ -4827,7 +4927,7 @@ async def show_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for NSX appliance. @@ -4875,8 +4975,10 @@ async def sample_show_nsx_credentials(): 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, 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: google.cloud.vmwareengine_v1.types.Credentials: @@ -4939,7 +5041,7 @@ async def show_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for Vcenter appliance. @@ -4987,8 +5089,10 @@ async def sample_show_vcenter_credentials(): 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, 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: google.cloud.vmwareengine_v1.types.Credentials: @@ -5049,7 +5153,7 @@ async def reset_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Resets credentials of the NSX appliance. @@ -5101,8 +5205,10 @@ async def sample_reset_nsx_credentials(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5178,7 +5284,7 @@ async def reset_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Resets credentials of the Vcenter appliance. @@ -5230,8 +5336,10 @@ async def sample_reset_vcenter_credentials(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5305,7 +5413,7 @@ async def get_dns_forwarding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Gets details of the ``DnsForwarding`` config. @@ -5353,8 +5461,10 @@ async def sample_get_dns_forwarding(): 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, 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: google.cloud.vmwareengine_v1.types.DnsForwarding: @@ -5419,7 +5529,7 @@ async def update_dns_forwarding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of the ``DnsForwarding`` config, like associated domains. Only fields specified in ``update_mask`` are @@ -5485,8 +5595,10 @@ async def sample_update_dns_forwarding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5563,7 +5675,7 @@ async def get_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Retrieves a ``NetworkPeering`` resource by its resource name. The resource contains details of the network peering, such as @@ -5615,8 +5727,10 @@ async def sample_get_network_peering(): 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, 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: google.cloud.vmwareengine_v1.types.NetworkPeering: @@ -5675,7 +5789,7 @@ async def list_network_peerings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworkPeeringsAsyncPager: r"""Lists ``NetworkPeering`` resources in a given project. NetworkPeering is a global resource and location can only be @@ -5725,8 +5839,10 @@ async def sample_list_network_peerings(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsAsyncPager: @@ -5803,7 +5919,7 @@ async def create_network_peering( network_peering_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new network peering between the peer network and VMware Engine network provided in a ``NetworkPeering`` resource. @@ -5892,8 +6008,10 @@ async def sample_create_network_peering(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -5969,7 +6087,7 @@ async def delete_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``NetworkPeering`` resource. When a network peering is deleted for a VMware Engine network, the peer network becomes @@ -6024,8 +6142,10 @@ async def sample_delete_network_peering(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6105,7 +6225,7 @@ async def update_network_peering( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a ``NetworkPeering`` resource. Only the ``description`` field can be updated. Only fields specified in ``updateMask`` @@ -6173,8 +6293,10 @@ async def sample_update_network_peering(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6250,7 +6372,7 @@ async def list_peering_routes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPeeringRoutesAsyncPager: r"""Lists the network peering routes exchanged over a peering connection. NetworkPeering is a global resource @@ -6301,8 +6423,10 @@ async def sample_list_peering_routes(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesAsyncPager: @@ -6381,7 +6505,7 @@ async def create_hcx_activation_key( hcx_activation_key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new HCX activation key in a given private cloud. @@ -6463,8 +6587,10 @@ async def sample_create_hcx_activation_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -6547,7 +6673,7 @@ async def list_hcx_activation_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHcxActivationKeysAsyncPager: r"""Lists ``HcxActivationKey`` resources in a given private cloud. @@ -6596,8 +6722,10 @@ async def sample_list_hcx_activation_keys(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysAsyncPager: @@ -6672,7 +6800,7 @@ async def get_hcx_activation_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Retrieves a ``HcxActivationKey`` resource by its resource name. @@ -6720,8 +6848,10 @@ async def sample_get_hcx_activation_key(): 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, 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: google.cloud.vmwareengine_v1.types.HcxActivationKey: @@ -6788,7 +6918,7 @@ async def get_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Retrieves a ``NetworkPolicy`` resource by its resource name. @@ -6836,8 +6966,10 @@ async def sample_get_network_policy(): 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, 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: google.cloud.vmwareengine_v1.types.NetworkPolicy: @@ -6907,7 +7039,7 @@ async def list_network_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworkPoliciesAsyncPager: r"""Lists ``NetworkPolicy`` resources in a specified project and location. @@ -6956,8 +7088,10 @@ async def sample_list_network_policies(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesAsyncPager: @@ -7034,7 +7168,7 @@ async def create_network_policy( network_policy_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new network policy in a given VMware Engine network of a project and location (region). A new @@ -7120,8 +7254,10 @@ async def sample_create_network_policy(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -7203,7 +7339,7 @@ async def update_network_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a ``NetworkPolicy`` resource. Only the following fields can be updated: ``internet_access``, ``external_ip``, @@ -7276,8 +7412,10 @@ async def sample_update_network_policy(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -7358,7 +7496,7 @@ async def delete_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``NetworkPolicy`` resource. A network policy cannot be deleted when ``NetworkService.state`` is set to ``RECONCILING`` @@ -7412,8 +7550,10 @@ async def sample_delete_network_policy(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -7494,7 +7634,7 @@ async def list_management_dns_zone_bindings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagementDnsZoneBindingsAsyncPager: r"""Lists Consumer VPCs bound to Management DNS Zone of a given private cloud. @@ -7544,8 +7684,10 @@ async def sample_list_management_dns_zone_bindings(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsAsyncPager: @@ -7622,7 +7764,7 @@ async def get_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Retrieves a 'ManagementDnsZoneBinding' resource by its resource name. @@ -7671,8 +7813,10 @@ async def sample_get_management_dns_zone_binding(): 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, 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: google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding: @@ -7746,7 +7890,7 @@ async def create_management_dns_zone_binding( management_dns_zone_binding_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new ``ManagementDnsZoneBinding`` resource in a private cloud. This RPC creates the DNS binding and the resource that @@ -7837,8 +7981,10 @@ async def sample_create_management_dns_zone_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -7925,7 +8071,7 @@ async def update_management_dns_zone_binding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``ManagementDnsZoneBinding`` resource. Only fields specified in ``update_mask`` are applied. @@ -7989,8 +8135,10 @@ async def sample_update_management_dns_zone_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8077,7 +8225,7 @@ async def delete_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``ManagementDnsZoneBinding`` resource. When a management DNS zone binding is deleted, the corresponding @@ -8132,8 +8280,10 @@ async def sample_delete_management_dns_zone_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8214,7 +8364,7 @@ async def repair_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Retries to create a ``ManagementDnsZoneBinding`` resource that is in failed state. @@ -8267,8 +8417,10 @@ async def sample_repair_management_dns_zone_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8350,7 +8502,7 @@ async def create_vmware_engine_network( vmware_engine_network_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new VMware Engine network that can be used by a private cloud. @@ -8440,8 +8592,10 @@ async def sample_create_vmware_engine_network(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8523,7 +8677,7 @@ async def update_vmware_engine_network( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a VMware Engine network resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -8589,8 +8743,10 @@ async def sample_update_vmware_engine_network(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8667,7 +8823,7 @@ async def delete_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``VmwareEngineNetwork`` resource. You can only delete a VMware Engine network after all resources that refer to it are @@ -8722,8 +8878,10 @@ async def sample_delete_vmware_engine_network(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -8804,7 +8962,7 @@ async def get_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Retrieves a ``VmwareEngineNetwork`` resource by its resource name. The resource contains details of the VMware Engine @@ -8856,8 +9014,10 @@ async def sample_get_vmware_engine_network(): 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, 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: google.cloud.vmwareengine_v1.types.VmwareEngineNetwork: @@ -8921,7 +9081,7 @@ async def list_vmware_engine_networks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVmwareEngineNetworksAsyncPager: r"""Lists ``VmwareEngineNetwork`` resources in a given project and location. @@ -8970,8 +9130,10 @@ async def sample_list_vmware_engine_networks(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksAsyncPager: @@ -9050,7 +9212,7 @@ async def create_private_connection( private_connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new private connection that can be used for accessing private Clouds. @@ -9136,8 +9298,10 @@ async def sample_create_private_connection(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -9212,7 +9376,7 @@ async def get_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Retrieves a ``PrivateConnection`` resource by its resource name. The resource contains details of the private connection, such as @@ -9262,8 +9426,10 @@ async def sample_get_private_connection(): 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, 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: google.cloud.vmwareengine_v1.types.PrivateConnection: @@ -9327,7 +9493,7 @@ async def list_private_connections( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateConnectionsAsyncPager: r"""Lists ``PrivateConnection`` resources in a given project and location. @@ -9376,8 +9542,10 @@ async def sample_list_private_connections(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsAsyncPager: @@ -9455,7 +9623,7 @@ async def update_private_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Modifies a ``PrivateConnection`` resource. Only ``description`` and ``routing_mode`` fields can be updated. Only fields @@ -9522,8 +9690,10 @@ async def sample_update_private_connection(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -9600,7 +9770,7 @@ async def delete_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``PrivateConnection`` resource. When a private connection is deleted for a VMware Engine network, the connected @@ -9654,8 +9824,10 @@ async def sample_delete_private_connection(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -9736,7 +9908,7 @@ async def list_private_connection_peering_routes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateConnectionPeeringRoutesAsyncPager: r"""Lists the private connection routes exchanged over a peering connection. @@ -9786,8 +9958,10 @@ async def sample_list_private_connection_peering_routes(): 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, 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesAsyncPager: @@ -9867,7 +10041,7 @@ async def grant_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Grants the bind permission to the customer provided principal(user / service account) to bind their DNS zone @@ -9939,8 +10113,10 @@ async def sample_grant_dns_bind_permission(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -10014,7 +10190,7 @@ async def get_dns_bind_permission( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Gets all the principals having bind permission on the intranet VPC associated with the consumer project @@ -10067,8 +10243,10 @@ async def sample_get_dns_bind_permission(): 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, 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: google.cloud.vmwareengine_v1.types.DnsBindPermission: @@ -10135,7 +10313,7 @@ async def revoke_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Revokes the bind permission from the customer provided principal(user / service account) on the @@ -10207,8 +10385,10 @@ async def sample_revoke_dns_bind_permission(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -10281,7 +10461,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -10292,8 +10472,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -10334,7 +10516,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -10345,8 +10527,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -10387,7 +10571,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -10403,8 +10587,10 @@ async def delete_operation( 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, 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: None """ @@ -10441,7 +10627,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -10454,8 +10640,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -10560,7 +10748,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -10574,8 +10762,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -10680,7 +10870,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -10695,8 +10885,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -10740,7 +10932,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -10751,8 +10943,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -10793,7 +10987,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -10804,8 +10998,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py index 18f39a920829..dc91f0f6f43d 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -951,6 +961,10 @@ def __init__( # 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( @@ -1013,6 +1027,29 @@ def __init__( 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.vmwareengine_v1.VmwareEngineClient`.", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "credentialsType": None, + }, + ) + def list_private_clouds( self, request: Optional[Union[vmwareengine.ListPrivateCloudsRequest, dict]] = None, @@ -1020,7 +1057,7 @@ def list_private_clouds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateCloudsPager: r"""Lists ``PrivateCloud`` resources in a given project and location. @@ -1069,8 +1106,10 @@ def sample_list_private_clouds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsPager: @@ -1142,7 +1181,7 @@ def get_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Retrieves a ``PrivateCloud`` resource by its resource name. @@ -1190,8 +1229,10 @@ def sample_get_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.PrivateCloud: @@ -1252,7 +1293,7 @@ def create_private_cloud( private_cloud_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new ``PrivateCloud`` resource in a given project and location. Private clouds of type ``STANDARD`` and @@ -1341,8 +1382,10 @@ def sample_create_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1416,7 +1459,7 @@ def update_private_cloud( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a ``PrivateCloud`` resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -1485,8 +1528,10 @@ def sample_update_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1559,7 +1604,7 @@ def delete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Schedules a ``PrivateCloud`` resource for deletion. @@ -1628,8 +1673,10 @@ def sample_delete_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1698,7 +1745,7 @@ def undelete_private_cloud( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restores a private cloud that was previously scheduled for deletion by ``DeletePrivateCloud``. A ``PrivateCloud`` resource @@ -1754,8 +1801,10 @@ def sample_undelete_private_cloud(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1824,7 +1873,7 @@ def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersPager: r"""Lists ``Cluster`` resources in a given private cloud. @@ -1873,8 +1922,10 @@ def sample_list_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersPager: @@ -1946,7 +1997,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Cluster: r"""Retrieves a ``Cluster`` resource by its resource name. @@ -1994,8 +2045,10 @@ def sample_get_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.Cluster: @@ -2053,7 +2106,7 @@ def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new cluster in a given private cloud. Creating a new cluster provides additional nodes for use in the parent private @@ -2135,8 +2188,10 @@ def sample_create_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2210,7 +2265,7 @@ def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a ``Cluster`` resource. Only fields specified in ``updateMask`` are applied. @@ -2274,8 +2329,10 @@ def sample_update_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2348,7 +2405,7 @@ def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``Cluster`` resource. To avoid unintended data loss, migrate or gracefully shut down any workloads running on the @@ -2403,8 +2460,10 @@ def sample_delete_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2480,7 +2539,7 @@ def list_nodes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes in a given cluster. @@ -2529,8 +2588,10 @@ def sample_list_nodes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesPager: @@ -2602,7 +2663,7 @@ def get_node( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Gets details of a single node. @@ -2647,8 +2708,10 @@ def sample_get_node(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.Node: @@ -2706,7 +2769,7 @@ def list_external_addresses( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExternalAddressesPager: r"""Lists external IP addresses assigned to VMware workload VMs in a given private cloud. @@ -2756,8 +2819,10 @@ def sample_list_external_addresses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesPager: @@ -2831,7 +2896,7 @@ def fetch_network_policy_external_addresses( network_policy: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchNetworkPolicyExternalAddressesPager: r"""Lists external IP addresses assigned to VMware workload VMs within the scope of the given network @@ -2882,8 +2947,10 @@ def sample_fetch_network_policy_external_addresses(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesPager: @@ -2961,7 +3028,7 @@ def get_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Gets details of a single external IP address. @@ -3009,8 +3076,10 @@ def sample_get_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.ExternalAddress: @@ -3073,7 +3142,7 @@ def create_external_address( external_address_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new ``ExternalAddress`` resource in a given private cloud. The network policy that corresponds to the private cloud @@ -3155,8 +3224,10 @@ def sample_create_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3231,7 +3302,7 @@ def update_external_address( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single external IP address. Only fields specified in ``update_mask`` are applied. @@ -3296,8 +3367,10 @@ def sample_update_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3371,7 +3444,7 @@ def delete_external_address( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single external IP address. When you delete an external IP address, connectivity between the @@ -3426,8 +3499,10 @@ def sample_delete_external_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3503,7 +3578,7 @@ def list_subnets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubnetsPager: r"""Lists subnets in a given private cloud. @@ -3552,8 +3627,10 @@ def sample_list_subnets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsPager: @@ -3625,7 +3702,7 @@ def get_subnet( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Gets details of a single subnet. @@ -3673,8 +3750,10 @@ def sample_get_subnet(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.Subnet: @@ -3734,7 +3813,7 @@ def update_subnet( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single subnet. Only fields specified in ``update_mask`` are applied. @@ -3795,8 +3874,10 @@ def sample_update_subnet(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3871,7 +3952,7 @@ def list_external_access_rules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExternalAccessRulesPager: r"""Lists ``ExternalAccessRule`` resources in the specified network policy. @@ -3921,8 +4002,10 @@ def sample_list_external_access_rules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesPager: @@ -3998,7 +4081,7 @@ def get_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Gets details of a single external access rule. @@ -4046,8 +4129,10 @@ def sample_get_external_access_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.ExternalAccessRule: @@ -4111,7 +4196,7 @@ def create_external_access_rule( external_access_rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new external access rule in a given network policy. @@ -4192,8 +4277,10 @@ def sample_create_external_access_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4274,7 +4361,7 @@ def update_external_access_rule( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single external access rule. Only fields specified in ``update_mask`` are applied. @@ -4334,8 +4421,10 @@ def sample_update_external_access_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4411,7 +4500,7 @@ def delete_external_access_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single external access rule. @@ -4463,8 +4552,10 @@ def sample_delete_external_access_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4542,7 +4633,7 @@ def list_logging_servers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLoggingServersPager: r"""Lists logging servers configured for a given private cloud. @@ -4592,8 +4683,10 @@ def sample_list_logging_servers(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersPager: @@ -4665,7 +4758,7 @@ def get_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Gets details of a logging server. @@ -4713,8 +4806,10 @@ def sample_get_logging_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.LoggingServer: @@ -4774,7 +4869,7 @@ def create_logging_server( logging_server_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a new logging server for a given private cloud. @@ -4861,8 +4956,10 @@ def sample_create_logging_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4936,7 +5033,7 @@ def update_logging_server( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single logging server. Only fields specified in ``update_mask`` are applied. @@ -5001,8 +5098,10 @@ def sample_update_logging_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5075,7 +5174,7 @@ def delete_logging_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single logging server. @@ -5127,8 +5226,10 @@ def sample_delete_logging_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5204,7 +5305,7 @@ def list_node_types( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNodeTypesPager: r"""Lists node types @@ -5252,8 +5353,10 @@ def sample_list_node_types(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesPager: @@ -5325,7 +5428,7 @@ def get_node_type( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NodeType: r"""Gets details of a single ``NodeType``. @@ -5373,8 +5476,10 @@ def sample_get_node_type(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.NodeType: @@ -5430,7 +5535,7 @@ def show_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for NSX appliance. @@ -5478,8 +5583,10 @@ def sample_show_nsx_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.Credentials: @@ -5539,7 +5646,7 @@ def show_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Gets details of credentials for Vcenter appliance. @@ -5587,8 +5694,10 @@ def sample_show_vcenter_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.Credentials: @@ -5646,7 +5755,7 @@ def reset_nsx_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Resets credentials of the NSX appliance. @@ -5698,8 +5807,10 @@ def sample_reset_nsx_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5772,7 +5883,7 @@ def reset_vcenter_credentials( private_cloud: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Resets credentials of the Vcenter appliance. @@ -5824,8 +5935,10 @@ def sample_reset_vcenter_credentials(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -5898,7 +6011,7 @@ def get_dns_forwarding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Gets details of the ``DnsForwarding`` config. @@ -5946,8 +6059,10 @@ def sample_get_dns_forwarding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.DnsForwarding: @@ -6009,7 +6124,7 @@ def update_dns_forwarding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of the ``DnsForwarding`` config, like associated domains. Only fields specified in ``update_mask`` are @@ -6075,8 +6190,10 @@ def sample_update_dns_forwarding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6150,7 +6267,7 @@ def get_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Retrieves a ``NetworkPeering`` resource by its resource name. The resource contains details of the network peering, such as @@ -6202,8 +6319,10 @@ def sample_get_network_peering(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.NetworkPeering: @@ -6259,7 +6378,7 @@ def list_network_peerings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworkPeeringsPager: r"""Lists ``NetworkPeering`` resources in a given project. NetworkPeering is a global resource and location can only be @@ -6309,8 +6428,10 @@ def sample_list_network_peerings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsPager: @@ -6384,7 +6505,7 @@ def create_network_peering( network_peering_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new network peering between the peer network and VMware Engine network provided in a ``NetworkPeering`` resource. @@ -6473,8 +6594,10 @@ def sample_create_network_peering(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6547,7 +6670,7 @@ def delete_network_peering( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``NetworkPeering`` resource. When a network peering is deleted for a VMware Engine network, the peer network becomes @@ -6602,8 +6725,10 @@ def sample_delete_network_peering(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6680,7 +6805,7 @@ def update_network_peering( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a ``NetworkPeering`` resource. Only the ``description`` field can be updated. Only fields specified in ``updateMask`` @@ -6748,8 +6873,10 @@ def sample_update_network_peering(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -6822,7 +6949,7 @@ def list_peering_routes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPeeringRoutesPager: r"""Lists the network peering routes exchanged over a peering connection. NetworkPeering is a global resource @@ -6873,8 +7000,10 @@ def sample_list_peering_routes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesPager: @@ -6950,7 +7079,7 @@ def create_hcx_activation_key( hcx_activation_key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new HCX activation key in a given private cloud. @@ -7032,8 +7161,10 @@ def sample_create_hcx_activation_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -7115,7 +7246,7 @@ def list_hcx_activation_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHcxActivationKeysPager: r"""Lists ``HcxActivationKey`` resources in a given private cloud. @@ -7164,8 +7295,10 @@ def sample_list_hcx_activation_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysPager: @@ -7237,7 +7370,7 @@ def get_hcx_activation_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Retrieves a ``HcxActivationKey`` resource by its resource name. @@ -7285,8 +7418,10 @@ def sample_get_hcx_activation_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.HcxActivationKey: @@ -7350,7 +7485,7 @@ def get_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Retrieves a ``NetworkPolicy`` resource by its resource name. @@ -7398,8 +7533,10 @@ def sample_get_network_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.NetworkPolicy: @@ -7466,7 +7603,7 @@ def list_network_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworkPoliciesPager: r"""Lists ``NetworkPolicy`` resources in a specified project and location. @@ -7515,8 +7652,10 @@ def sample_list_network_policies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesPager: @@ -7590,7 +7729,7 @@ def create_network_policy( network_policy_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new network policy in a given VMware Engine network of a project and location (region). A new @@ -7676,8 +7815,10 @@ def sample_create_network_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -7756,7 +7897,7 @@ def update_network_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a ``NetworkPolicy`` resource. Only the following fields can be updated: ``internet_access``, ``external_ip``, @@ -7829,8 +7970,10 @@ def sample_update_network_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -7908,7 +8051,7 @@ def delete_network_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``NetworkPolicy`` resource. A network policy cannot be deleted when ``NetworkService.state`` is set to ``RECONCILING`` @@ -7962,8 +8105,10 @@ def sample_delete_network_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -8041,7 +8186,7 @@ def list_management_dns_zone_bindings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagementDnsZoneBindingsPager: r"""Lists Consumer VPCs bound to Management DNS Zone of a given private cloud. @@ -8091,8 +8236,10 @@ def sample_list_management_dns_zone_bindings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsPager: @@ -8168,7 +8315,7 @@ def get_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Retrieves a 'ManagementDnsZoneBinding' resource by its resource name. @@ -8217,8 +8364,10 @@ def sample_get_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding: @@ -8291,7 +8440,7 @@ def create_management_dns_zone_binding( management_dns_zone_binding_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new ``ManagementDnsZoneBinding`` resource in a private cloud. This RPC creates the DNS binding and the resource that @@ -8382,8 +8531,10 @@ def sample_create_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -8469,7 +8620,7 @@ def update_management_dns_zone_binding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a ``ManagementDnsZoneBinding`` resource. Only fields specified in ``update_mask`` are applied. @@ -8533,8 +8684,10 @@ def sample_update_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -8620,7 +8773,7 @@ def delete_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``ManagementDnsZoneBinding`` resource. When a management DNS zone binding is deleted, the corresponding @@ -8675,8 +8828,10 @@ def sample_delete_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -8756,7 +8911,7 @@ def repair_management_dns_zone_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Retries to create a ``ManagementDnsZoneBinding`` resource that is in failed state. @@ -8809,8 +8964,10 @@ def sample_repair_management_dns_zone_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -8891,7 +9048,7 @@ def create_vmware_engine_network( vmware_engine_network_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new VMware Engine network that can be used by a private cloud. @@ -8981,8 +9138,10 @@ def sample_create_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -9063,7 +9222,7 @@ def update_vmware_engine_network( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a VMware Engine network resource. Only the following fields can be updated: ``description``. Only fields specified in @@ -9129,8 +9288,10 @@ def sample_update_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -9206,7 +9367,7 @@ def delete_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``VmwareEngineNetwork`` resource. You can only delete a VMware Engine network after all resources that refer to it are @@ -9261,8 +9422,10 @@ def sample_delete_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -9342,7 +9505,7 @@ def get_vmware_engine_network( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Retrieves a ``VmwareEngineNetwork`` resource by its resource name. The resource contains details of the VMware Engine @@ -9394,8 +9557,10 @@ def sample_get_vmware_engine_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.VmwareEngineNetwork: @@ -9458,7 +9623,7 @@ def list_vmware_engine_networks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVmwareEngineNetworksPager: r"""Lists ``VmwareEngineNetwork`` resources in a given project and location. @@ -9507,8 +9672,10 @@ def sample_list_vmware_engine_networks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksPager: @@ -9586,7 +9753,7 @@ def create_private_connection( private_connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new private connection that can be used for accessing private Clouds. @@ -9672,8 +9839,10 @@ def sample_create_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -9747,7 +9916,7 @@ def get_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Retrieves a ``PrivateConnection`` resource by its resource name. The resource contains details of the private connection, such as @@ -9797,8 +9966,10 @@ def sample_get_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.PrivateConnection: @@ -9859,7 +10030,7 @@ def list_private_connections( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateConnectionsPager: r"""Lists ``PrivateConnection`` resources in a given project and location. @@ -9908,8 +10079,10 @@ def sample_list_private_connections(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsPager: @@ -9984,7 +10157,7 @@ def update_private_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Modifies a ``PrivateConnection`` resource. Only ``description`` and ``routing_mode`` fields can be updated. Only fields @@ -10051,8 +10224,10 @@ def sample_update_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -10128,7 +10303,7 @@ def delete_private_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``PrivateConnection`` resource. When a private connection is deleted for a VMware Engine network, the connected @@ -10182,8 +10357,10 @@ def sample_delete_private_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -10263,7 +10440,7 @@ def list_private_connection_peering_routes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPrivateConnectionPeeringRoutesPager: r"""Lists the private connection routes exchanged over a peering connection. @@ -10313,8 +10490,10 @@ def sample_list_private_connection_peering_routes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesPager: @@ -10393,7 +10572,7 @@ def grant_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Grants the bind permission to the customer provided principal(user / service account) to bind their DNS zone @@ -10465,8 +10644,10 @@ def sample_grant_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -10539,7 +10720,7 @@ def get_dns_bind_permission( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Gets all the principals having bind permission on the intranet VPC associated with the consumer project @@ -10592,8 +10773,10 @@ def sample_get_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vmwareengine_v1.types.DnsBindPermission: @@ -10657,7 +10840,7 @@ def revoke_dns_bind_permission( principal: Optional[vmwareengine_resources.Principal] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Revokes the bind permission from the customer provided principal(user / service account) on the @@ -10729,8 +10912,10 @@ def sample_revoke_dns_bind_permission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -10815,7 +11000,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -10826,8 +11011,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -10868,7 +11055,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -10879,8 +11066,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -10921,7 +11110,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -10937,8 +11126,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -10975,7 +11166,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -10988,8 +11179,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -11094,7 +11287,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -11108,8 +11301,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -11214,7 +11409,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -11229,8 +11424,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -11272,7 +11469,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -11283,8 +11480,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -11325,7 +11524,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -11336,8 +11535,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py index 7bcc0c727840..5fe90219b943 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListPrivateCloudsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListPrivateCloudsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListClustersRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListClustersRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListNodesRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListNodesRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListExternalAddressesRequest(request) @@ -597,7 +611,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -611,8 +625,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListExternalAddressesRequest(request) @@ -675,7 +691,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -689,8 +705,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.FetchNetworkPolicyExternalAddressesRequest(request) @@ -753,7 +771,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -767,8 +785,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.FetchNetworkPolicyExternalAddressesRequest(request) @@ -833,7 +853,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -847,8 +867,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListSubnetsRequest(request) @@ -907,7 +929,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -921,8 +943,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListSubnetsRequest(request) @@ -985,7 +1009,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -999,8 +1023,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListExternalAccessRulesRequest(request) @@ -1059,7 +1085,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1073,8 +1099,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListExternalAccessRulesRequest(request) @@ -1139,7 +1167,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1153,8 +1181,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListLoggingServersRequest(request) @@ -1213,7 +1243,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1227,8 +1257,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListLoggingServersRequest(request) @@ -1291,7 +1323,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1305,8 +1337,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListNodeTypesRequest(request) @@ -1365,7 +1399,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1379,8 +1413,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListNodeTypesRequest(request) @@ -1443,7 +1479,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1457,8 +1493,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListNetworkPeeringsRequest(request) @@ -1517,7 +1555,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1531,8 +1569,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListNetworkPeeringsRequest(request) @@ -1595,7 +1635,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1609,8 +1649,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListPeeringRoutesRequest(request) @@ -1669,7 +1711,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1683,8 +1725,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListPeeringRoutesRequest(request) @@ -1747,7 +1791,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1761,8 +1805,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListHcxActivationKeysRequest(request) @@ -1821,7 +1867,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1835,8 +1881,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListHcxActivationKeysRequest(request) @@ -1899,7 +1947,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1913,8 +1961,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListNetworkPoliciesRequest(request) @@ -1973,7 +2023,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1987,8 +2037,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListNetworkPoliciesRequest(request) @@ -2051,7 +2103,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2065,8 +2117,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListManagementDnsZoneBindingsRequest(request) @@ -2127,7 +2181,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2141,8 +2195,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListManagementDnsZoneBindingsRequest(request) @@ -2209,7 +2265,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2223,8 +2279,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListVmwareEngineNetworksRequest(request) @@ -2283,7 +2341,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2297,8 +2355,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListVmwareEngineNetworksRequest(request) @@ -2363,7 +2423,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2377,8 +2437,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionsRequest(request) @@ -2437,7 +2499,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2451,8 +2513,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionsRequest(request) @@ -2515,7 +2579,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2529,8 +2593,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionPeeringRoutesRequest(request) @@ -2593,7 +2659,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2607,8 +2673,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vmwareengine.ListPrivateConnectionPeeringRoutesRequest(request) diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py index 52c9a5af483c..b171967dd693 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vmwareengine_v1.types import vmwareengine, vmwareengine_resources from .base import DEFAULT_CLIENT_INFO, VmwareEngineTransport +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.vmwareengine.v1.VmwareEngine", + "rpcName": 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.vmwareengine.v1.VmwareEngine", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmwareEngineGrpcTransport(VmwareEngineTransport): """gRPC backend transport for VmwareEngine. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def list_private_clouds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_clouds" not in self._stubs: - self._stubs["list_private_clouds"] = self.grpc_channel.unary_unary( + self._stubs["list_private_clouds"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateClouds", request_serializer=vmwareengine.ListPrivateCloudsRequest.serialize, response_deserializer=vmwareengine.ListPrivateCloudsResponse.deserialize, @@ -303,7 +391,7 @@ def get_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_cloud" not in self._stubs: - self._stubs["get_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["get_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateCloud", request_serializer=vmwareengine.GetPrivateCloudRequest.serialize, response_deserializer=vmwareengine_resources.PrivateCloud.deserialize, @@ -335,7 +423,7 @@ def create_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_cloud" not in self._stubs: - self._stubs["create_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["create_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateCloud", request_serializer=vmwareengine.CreatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +456,7 @@ def update_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_cloud" not in self._stubs: - self._stubs["update_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["update_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateCloud", request_serializer=vmwareengine.UpdatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -411,7 +499,7 @@ def delete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_cloud" not in self._stubs: - self._stubs["delete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateCloud", request_serializer=vmwareengine.DeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +529,7 @@ def undelete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_private_cloud" not in self._stubs: - self._stubs["undelete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["undelete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UndeletePrivateCloud", request_serializer=vmwareengine.UndeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,7 +557,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListClusters", request_serializer=vmwareengine.ListClustersRequest.serialize, response_deserializer=vmwareengine.ListClustersResponse.deserialize, @@ -495,7 +583,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetCluster", request_serializer=vmwareengine.GetClusterRequest.serialize, response_deserializer=vmwareengine_resources.Cluster.deserialize, @@ -524,7 +612,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateCluster", request_serializer=vmwareengine.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +644,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateCluster", request_serializer=vmwareengine.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -585,7 +673,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteCluster", request_serializer=vmwareengine.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -611,7 +699,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodes", request_serializer=vmwareengine.ListNodesRequest.serialize, response_deserializer=vmwareengine.ListNodesResponse.deserialize, @@ -637,7 +725,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNode", request_serializer=vmwareengine.GetNodeRequest.serialize, response_deserializer=vmwareengine_resources.Node.deserialize, @@ -667,7 +755,7 @@ def list_external_addresses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_addresses" not in self._stubs: - self._stubs["list_external_addresses"] = self.grpc_channel.unary_unary( + self._stubs["list_external_addresses"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAddresses", request_serializer=vmwareengine.ListExternalAddressesRequest.serialize, response_deserializer=vmwareengine.ListExternalAddressesResponse.deserialize, @@ -701,7 +789,7 @@ def fetch_network_policy_external_addresses( if "fetch_network_policy_external_addresses" not in self._stubs: self._stubs[ "fetch_network_policy_external_addresses" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/FetchNetworkPolicyExternalAddresses", request_serializer=vmwareengine.FetchNetworkPolicyExternalAddressesRequest.serialize, response_deserializer=vmwareengine.FetchNetworkPolicyExternalAddressesResponse.deserialize, @@ -729,7 +817,7 @@ def get_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_address" not in self._stubs: - self._stubs["get_external_address"] = self.grpc_channel.unary_unary( + self._stubs["get_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAddress", request_serializer=vmwareengine.GetExternalAddressRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAddress.deserialize, @@ -760,7 +848,7 @@ def create_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_address" not in self._stubs: - self._stubs["create_external_address"] = self.grpc_channel.unary_unary( + self._stubs["create_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAddress", request_serializer=vmwareengine.CreateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -794,7 +882,7 @@ def update_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_address" not in self._stubs: - self._stubs["update_external_address"] = self.grpc_channel.unary_unary( + self._stubs["update_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAddress", request_serializer=vmwareengine.UpdateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -825,7 +913,7 @@ def delete_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_address" not in self._stubs: - self._stubs["delete_external_address"] = self.grpc_channel.unary_unary( + self._stubs["delete_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAddress", request_serializer=vmwareengine.DeleteExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -851,7 +939,7 @@ def list_subnets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subnets" not in self._stubs: - self._stubs["list_subnets"] = self.grpc_channel.unary_unary( + self._stubs["list_subnets"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListSubnets", request_serializer=vmwareengine.ListSubnetsRequest.serialize, response_deserializer=vmwareengine.ListSubnetsResponse.deserialize, @@ -877,7 +965,7 @@ def get_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subnet" not in self._stubs: - self._stubs["get_subnet"] = self.grpc_channel.unary_unary( + self._stubs["get_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetSubnet", request_serializer=vmwareengine.GetSubnetRequest.serialize, response_deserializer=vmwareengine_resources.Subnet.deserialize, @@ -908,7 +996,7 @@ def update_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subnet" not in self._stubs: - self._stubs["update_subnet"] = self.grpc_channel.unary_unary( + self._stubs["update_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateSubnet", request_serializer=vmwareengine.UpdateSubnetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1026,9 @@ def list_external_access_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_access_rules" not in self._stubs: - self._stubs["list_external_access_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_external_access_rules" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAccessRules", request_serializer=vmwareengine.ListExternalAccessRulesRequest.serialize, response_deserializer=vmwareengine.ListExternalAccessRulesResponse.deserialize, @@ -967,7 +1057,7 @@ def get_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_access_rule" not in self._stubs: - self._stubs["get_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_external_access_rule"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAccessRule", request_serializer=vmwareengine.GetExternalAccessRuleRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAccessRule.deserialize, @@ -996,7 +1086,9 @@ def create_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_access_rule" not in self._stubs: - self._stubs["create_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAccessRule", request_serializer=vmwareengine.CreateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1025,7 +1117,9 @@ def update_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_access_rule" not in self._stubs: - self._stubs["update_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAccessRule", request_serializer=vmwareengine.UpdateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1053,7 +1147,9 @@ def delete_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_access_rule" not in self._stubs: - self._stubs["delete_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAccessRule", request_serializer=vmwareengine.DeleteExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1083,7 +1179,7 @@ def list_logging_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_logging_servers" not in self._stubs: - self._stubs["list_logging_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_logging_servers"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListLoggingServers", request_serializer=vmwareengine.ListLoggingServersRequest.serialize, response_deserializer=vmwareengine.ListLoggingServersResponse.deserialize, @@ -1111,7 +1207,7 @@ def get_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_server" not in self._stubs: - self._stubs["get_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetLoggingServer", request_serializer=vmwareengine.GetLoggingServerRequest.serialize, response_deserializer=vmwareengine_resources.LoggingServer.deserialize, @@ -1138,7 +1234,7 @@ def create_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_logging_server" not in self._stubs: - self._stubs["create_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["create_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateLoggingServer", request_serializer=vmwareengine.CreateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1165,7 +1261,7 @@ def update_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_server" not in self._stubs: - self._stubs["update_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateLoggingServer", request_serializer=vmwareengine.UpdateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1191,7 +1287,7 @@ def delete_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_logging_server" not in self._stubs: - self._stubs["delete_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteLoggingServer", request_serializer=vmwareengine.DeleteLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1219,7 +1315,7 @@ def list_node_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_node_types" not in self._stubs: - self._stubs["list_node_types"] = self.grpc_channel.unary_unary( + self._stubs["list_node_types"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodeTypes", request_serializer=vmwareengine.ListNodeTypesRequest.serialize, response_deserializer=vmwareengine.ListNodeTypesResponse.deserialize, @@ -1245,7 +1341,7 @@ def get_node_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node_type" not in self._stubs: - self._stubs["get_node_type"] = self.grpc_channel.unary_unary( + self._stubs["get_node_type"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNodeType", request_serializer=vmwareengine.GetNodeTypeRequest.serialize, response_deserializer=vmwareengine_resources.NodeType.deserialize, @@ -1273,7 +1369,7 @@ def show_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_nsx_credentials" not in self._stubs: - self._stubs["show_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowNsxCredentials", request_serializer=vmwareengine.ShowNsxCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1301,7 +1397,7 @@ def show_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_vcenter_credentials" not in self._stubs: - self._stubs["show_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowVcenterCredentials", request_serializer=vmwareengine.ShowVcenterCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1327,7 +1423,7 @@ def reset_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_nsx_credentials" not in self._stubs: - self._stubs["reset_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetNsxCredentials", request_serializer=vmwareengine.ResetNsxCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1355,7 +1451,7 @@ def reset_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_vcenter_credentials" not in self._stubs: - self._stubs["reset_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetVcenterCredentials", request_serializer=vmwareengine.ResetVcenterCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1383,7 +1479,7 @@ def get_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_forwarding" not in self._stubs: - self._stubs["get_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsForwarding", request_serializer=vmwareengine.GetDnsForwardingRequest.serialize, response_deserializer=vmwareengine_resources.DnsForwarding.deserialize, @@ -1411,7 +1507,7 @@ def update_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_forwarding" not in self._stubs: - self._stubs["update_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateDnsForwarding", request_serializer=vmwareengine.UpdateDnsForwardingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1443,7 +1539,7 @@ def get_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_peering" not in self._stubs: - self._stubs["get_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["get_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPeering", request_serializer=vmwareengine.GetNetworkPeeringRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPeering.deserialize, @@ -1474,7 +1570,7 @@ def list_network_peerings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_peerings" not in self._stubs: - self._stubs["list_network_peerings"] = self.grpc_channel.unary_unary( + self._stubs["list_network_peerings"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPeerings", request_serializer=vmwareengine.ListNetworkPeeringsRequest.serialize, response_deserializer=vmwareengine.ListNetworkPeeringsResponse.deserialize, @@ -1503,7 +1599,7 @@ def create_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_peering" not in self._stubs: - self._stubs["create_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["create_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPeering", request_serializer=vmwareengine.CreateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1532,7 +1628,7 @@ def delete_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_peering" not in self._stubs: - self._stubs["delete_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPeering", request_serializer=vmwareengine.DeleteNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1561,7 +1657,7 @@ def update_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_peering" not in self._stubs: - self._stubs["update_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["update_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPeering", request_serializer=vmwareengine.UpdateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1591,7 +1687,7 @@ def list_peering_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_peering_routes" not in self._stubs: - self._stubs["list_peering_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_peering_routes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPeeringRoutes", request_serializer=vmwareengine.ListPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPeeringRoutesResponse.deserialize, @@ -1620,7 +1716,7 @@ def create_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hcx_activation_key" not in self._stubs: - self._stubs["create_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["create_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateHcxActivationKey", request_serializer=vmwareengine.CreateHcxActivationKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1649,7 +1745,7 @@ def list_hcx_activation_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hcx_activation_keys" not in self._stubs: - self._stubs["list_hcx_activation_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_hcx_activation_keys"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListHcxActivationKeys", request_serializer=vmwareengine.ListHcxActivationKeysRequest.serialize, response_deserializer=vmwareengine.ListHcxActivationKeysResponse.deserialize, @@ -1678,7 +1774,7 @@ def get_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hcx_activation_key" not in self._stubs: - self._stubs["get_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["get_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetHcxActivationKey", request_serializer=vmwareengine.GetHcxActivationKeyRequest.serialize, response_deserializer=vmwareengine_resources.HcxActivationKey.deserialize, @@ -1706,7 +1802,7 @@ def get_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_policy" not in self._stubs: - self._stubs["get_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPolicy", request_serializer=vmwareengine.GetNetworkPolicyRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPolicy.deserialize, @@ -1736,7 +1832,7 @@ def list_network_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_policies" not in self._stubs: - self._stubs["list_network_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_network_policies"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPolicies", request_serializer=vmwareengine.ListNetworkPoliciesRequest.serialize, response_deserializer=vmwareengine.ListNetworkPoliciesResponse.deserialize, @@ -1765,7 +1861,7 @@ def create_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_policy" not in self._stubs: - self._stubs["create_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPolicy", request_serializer=vmwareengine.CreateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1803,7 +1899,7 @@ def update_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_policy" not in self._stubs: - self._stubs["update_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPolicy", request_serializer=vmwareengine.UpdateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1831,7 +1927,7 @@ def delete_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_policy" not in self._stubs: - self._stubs["delete_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPolicy", request_serializer=vmwareengine.DeleteNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1864,7 +1960,7 @@ def list_management_dns_zone_bindings( if "list_management_dns_zone_bindings" not in self._stubs: self._stubs[ "list_management_dns_zone_bindings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListManagementDnsZoneBindings", request_serializer=vmwareengine.ListManagementDnsZoneBindingsRequest.serialize, response_deserializer=vmwareengine.ListManagementDnsZoneBindingsResponse.deserialize, @@ -1897,7 +1993,7 @@ def get_management_dns_zone_binding( if "get_management_dns_zone_binding" not in self._stubs: self._stubs[ "get_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetManagementDnsZoneBinding", request_serializer=vmwareengine.GetManagementDnsZoneBindingRequest.serialize, response_deserializer=vmwareengine_resources.ManagementDnsZoneBinding.deserialize, @@ -1935,7 +2031,7 @@ def create_management_dns_zone_binding( if "create_management_dns_zone_binding" not in self._stubs: self._stubs[ "create_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateManagementDnsZoneBinding", request_serializer=vmwareengine.CreateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1967,7 +2063,7 @@ def update_management_dns_zone_binding( if "update_management_dns_zone_binding" not in self._stubs: self._stubs[ "update_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateManagementDnsZoneBinding", request_serializer=vmwareengine.UpdateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2001,7 +2097,7 @@ def delete_management_dns_zone_binding( if "delete_management_dns_zone_binding" not in self._stubs: self._stubs[ "delete_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteManagementDnsZoneBinding", request_serializer=vmwareengine.DeleteManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2033,7 +2129,7 @@ def repair_management_dns_zone_binding( if "repair_management_dns_zone_binding" not in self._stubs: self._stubs[ "repair_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RepairManagementDnsZoneBinding", request_serializer=vmwareengine.RepairManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2062,7 +2158,9 @@ def create_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vmware_engine_network" not in self._stubs: - self._stubs["create_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateVmwareEngineNetwork", request_serializer=vmwareengine.CreateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2092,7 +2190,9 @@ def update_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vmware_engine_network" not in self._stubs: - self._stubs["update_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateVmwareEngineNetwork", request_serializer=vmwareengine.UpdateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2123,7 +2223,9 @@ def delete_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vmware_engine_network" not in self._stubs: - self._stubs["delete_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteVmwareEngineNetwork", request_serializer=vmwareengine.DeleteVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2156,7 +2258,7 @@ def get_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vmware_engine_network" not in self._stubs: - self._stubs["get_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs["get_vmware_engine_network"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetVmwareEngineNetwork", request_serializer=vmwareengine.GetVmwareEngineNetworkRequest.serialize, response_deserializer=vmwareengine_resources.VmwareEngineNetwork.deserialize, @@ -2186,7 +2288,9 @@ def list_vmware_engine_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vmware_engine_networks" not in self._stubs: - self._stubs["list_vmware_engine_networks"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vmware_engine_networks" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListVmwareEngineNetworks", request_serializer=vmwareengine.ListVmwareEngineNetworksRequest.serialize, response_deserializer=vmwareengine.ListVmwareEngineNetworksResponse.deserialize, @@ -2215,7 +2319,7 @@ def create_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_connection" not in self._stubs: - self._stubs["create_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateConnection", request_serializer=vmwareengine.CreatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2246,7 +2350,7 @@ def get_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_connection" not in self._stubs: - self._stubs["get_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateConnection", request_serializer=vmwareengine.GetPrivateConnectionRequest.serialize, response_deserializer=vmwareengine_resources.PrivateConnection.deserialize, @@ -2276,7 +2380,7 @@ def list_private_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_connections" not in self._stubs: - self._stubs["list_private_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_private_connections"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnections", request_serializer=vmwareengine.ListPrivateConnectionsRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionsResponse.deserialize, @@ -2306,7 +2410,7 @@ def update_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_connection" not in self._stubs: - self._stubs["update_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateConnection", request_serializer=vmwareengine.UpdatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2336,7 +2440,7 @@ def delete_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_connection" not in self._stubs: - self._stubs["delete_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateConnection", request_serializer=vmwareengine.DeletePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2369,7 +2473,7 @@ def list_private_connection_peering_routes( if "list_private_connection_peering_routes" not in self._stubs: self._stubs[ "list_private_connection_peering_routes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnectionPeeringRoutes", request_serializer=vmwareengine.ListPrivateConnectionPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionPeeringRoutesResponse.deserialize, @@ -2401,7 +2505,7 @@ def grant_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "grant_dns_bind_permission" not in self._stubs: - self._stubs["grant_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["grant_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GrantDnsBindPermission", request_serializer=vmwareengine.GrantDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2433,7 +2537,7 @@ def get_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_bind_permission" not in self._stubs: - self._stubs["get_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsBindPermission", request_serializer=vmwareengine.GetDnsBindPermissionRequest.serialize, response_deserializer=vmwareengine_resources.DnsBindPermission.deserialize, @@ -2465,7 +2569,9 @@ def revoke_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_dns_bind_permission" not in self._stubs: - self._stubs["revoke_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs[ + "revoke_dns_bind_permission" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RevokeDnsBindPermission", request_serializer=vmwareengine.RevokeDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2473,7 +2579,7 @@ def revoke_dns_bind_permission( return self._stubs["revoke_dns_bind_permission"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -2485,7 +2591,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -2502,7 +2608,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -2521,7 +2627,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -2540,7 +2646,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -2557,7 +2663,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -2582,7 +2688,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -2608,7 +2714,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -2637,7 +2743,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py index 96d05cf76b09..d5facf597d8c 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vmwareengine_v1.types import vmwareengine, vmwareengine_resources from .base import DEFAULT_CLIENT_INFO, VmwareEngineTransport from .grpc import VmwareEngineGrpcTransport +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.vmwareengine.v1.VmwareEngine", + "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.vmwareengine.v1.VmwareEngine", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VmwareEngineGrpcAsyncIOTransport(VmwareEngineTransport): """gRPC AsyncIO backend transport for VmwareEngine. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def list_private_clouds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_clouds" not in self._stubs: - self._stubs["list_private_clouds"] = self.grpc_channel.unary_unary( + self._stubs["list_private_clouds"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateClouds", request_serializer=vmwareengine.ListPrivateCloudsRequest.serialize, response_deserializer=vmwareengine.ListPrivateCloudsResponse.deserialize, @@ -315,7 +400,7 @@ def get_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_cloud" not in self._stubs: - self._stubs["get_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["get_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateCloud", request_serializer=vmwareengine.GetPrivateCloudRequest.serialize, response_deserializer=vmwareengine_resources.PrivateCloud.deserialize, @@ -349,7 +434,7 @@ def create_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_cloud" not in self._stubs: - self._stubs["create_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["create_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateCloud", request_serializer=vmwareengine.CreatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -384,7 +469,7 @@ def update_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_cloud" not in self._stubs: - self._stubs["update_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["update_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateCloud", request_serializer=vmwareengine.UpdatePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def delete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_cloud" not in self._stubs: - self._stubs["delete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateCloud", request_serializer=vmwareengine.DeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +546,7 @@ def undelete_private_cloud( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_private_cloud" not in self._stubs: - self._stubs["undelete_private_cloud"] = self.grpc_channel.unary_unary( + self._stubs["undelete_private_cloud"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UndeletePrivateCloud", request_serializer=vmwareengine.UndeletePrivateCloudRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +574,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListClusters", request_serializer=vmwareengine.ListClustersRequest.serialize, response_deserializer=vmwareengine.ListClustersResponse.deserialize, @@ -517,7 +602,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetCluster", request_serializer=vmwareengine.GetClusterRequest.serialize, response_deserializer=vmwareengine_resources.Cluster.deserialize, @@ -548,7 +633,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateCluster", request_serializer=vmwareengine.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +667,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateCluster", request_serializer=vmwareengine.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -613,7 +698,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteCluster", request_serializer=vmwareengine.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -641,7 +726,7 @@ def list_nodes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nodes" not in self._stubs: - self._stubs["list_nodes"] = self.grpc_channel.unary_unary( + self._stubs["list_nodes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodes", request_serializer=vmwareengine.ListNodesRequest.serialize, response_deserializer=vmwareengine.ListNodesResponse.deserialize, @@ -669,7 +754,7 @@ def get_node( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node" not in self._stubs: - self._stubs["get_node"] = self.grpc_channel.unary_unary( + self._stubs["get_node"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNode", request_serializer=vmwareengine.GetNodeRequest.serialize, response_deserializer=vmwareengine_resources.Node.deserialize, @@ -699,7 +784,7 @@ def list_external_addresses( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_addresses" not in self._stubs: - self._stubs["list_external_addresses"] = self.grpc_channel.unary_unary( + self._stubs["list_external_addresses"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAddresses", request_serializer=vmwareengine.ListExternalAddressesRequest.serialize, response_deserializer=vmwareengine.ListExternalAddressesResponse.deserialize, @@ -733,7 +818,7 @@ def fetch_network_policy_external_addresses( if "fetch_network_policy_external_addresses" not in self._stubs: self._stubs[ "fetch_network_policy_external_addresses" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/FetchNetworkPolicyExternalAddresses", request_serializer=vmwareengine.FetchNetworkPolicyExternalAddressesRequest.serialize, response_deserializer=vmwareengine.FetchNetworkPolicyExternalAddressesResponse.deserialize, @@ -762,7 +847,7 @@ def get_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_address" not in self._stubs: - self._stubs["get_external_address"] = self.grpc_channel.unary_unary( + self._stubs["get_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAddress", request_serializer=vmwareengine.GetExternalAddressRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAddress.deserialize, @@ -793,7 +878,7 @@ def create_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_address" not in self._stubs: - self._stubs["create_external_address"] = self.grpc_channel.unary_unary( + self._stubs["create_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAddress", request_serializer=vmwareengine.CreateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -827,7 +912,7 @@ def update_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_address" not in self._stubs: - self._stubs["update_external_address"] = self.grpc_channel.unary_unary( + self._stubs["update_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAddress", request_serializer=vmwareengine.UpdateExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -858,7 +943,7 @@ def delete_external_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_address" not in self._stubs: - self._stubs["delete_external_address"] = self.grpc_channel.unary_unary( + self._stubs["delete_external_address"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAddress", request_serializer=vmwareengine.DeleteExternalAddressRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -886,7 +971,7 @@ def list_subnets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subnets" not in self._stubs: - self._stubs["list_subnets"] = self.grpc_channel.unary_unary( + self._stubs["list_subnets"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListSubnets", request_serializer=vmwareengine.ListSubnetsRequest.serialize, response_deserializer=vmwareengine.ListSubnetsResponse.deserialize, @@ -914,7 +999,7 @@ def get_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subnet" not in self._stubs: - self._stubs["get_subnet"] = self.grpc_channel.unary_unary( + self._stubs["get_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetSubnet", request_serializer=vmwareengine.GetSubnetRequest.serialize, response_deserializer=vmwareengine_resources.Subnet.deserialize, @@ -947,7 +1032,7 @@ def update_subnet( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subnet" not in self._stubs: - self._stubs["update_subnet"] = self.grpc_channel.unary_unary( + self._stubs["update_subnet"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateSubnet", request_serializer=vmwareengine.UpdateSubnetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -977,7 +1062,9 @@ def list_external_access_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_external_access_rules" not in self._stubs: - self._stubs["list_external_access_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_external_access_rules" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListExternalAccessRules", request_serializer=vmwareengine.ListExternalAccessRulesRequest.serialize, response_deserializer=vmwareengine.ListExternalAccessRulesResponse.deserialize, @@ -1006,7 +1093,7 @@ def get_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_external_access_rule" not in self._stubs: - self._stubs["get_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_external_access_rule"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetExternalAccessRule", request_serializer=vmwareengine.GetExternalAccessRuleRequest.serialize, response_deserializer=vmwareengine_resources.ExternalAccessRule.deserialize, @@ -1036,7 +1123,9 @@ def create_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_access_rule" not in self._stubs: - self._stubs["create_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateExternalAccessRule", request_serializer=vmwareengine.CreateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1066,7 +1155,9 @@ def update_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_access_rule" not in self._stubs: - self._stubs["update_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateExternalAccessRule", request_serializer=vmwareengine.UpdateExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1095,7 +1186,9 @@ def delete_external_access_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_external_access_rule" not in self._stubs: - self._stubs["delete_external_access_rule"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_external_access_rule" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteExternalAccessRule", request_serializer=vmwareengine.DeleteExternalAccessRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1125,7 +1218,7 @@ def list_logging_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_logging_servers" not in self._stubs: - self._stubs["list_logging_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_logging_servers"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListLoggingServers", request_serializer=vmwareengine.ListLoggingServersRequest.serialize, response_deserializer=vmwareengine.ListLoggingServersResponse.deserialize, @@ -1154,7 +1247,7 @@ def get_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_server" not in self._stubs: - self._stubs["get_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetLoggingServer", request_serializer=vmwareengine.GetLoggingServerRequest.serialize, response_deserializer=vmwareengine_resources.LoggingServer.deserialize, @@ -1183,7 +1276,7 @@ def create_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_logging_server" not in self._stubs: - self._stubs["create_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["create_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateLoggingServer", request_serializer=vmwareengine.CreateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1212,7 +1305,7 @@ def update_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_server" not in self._stubs: - self._stubs["update_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateLoggingServer", request_serializer=vmwareengine.UpdateLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1240,7 +1333,7 @@ def delete_logging_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_logging_server" not in self._stubs: - self._stubs["delete_logging_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_logging_server"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteLoggingServer", request_serializer=vmwareengine.DeleteLoggingServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1269,7 +1362,7 @@ def list_node_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_node_types" not in self._stubs: - self._stubs["list_node_types"] = self.grpc_channel.unary_unary( + self._stubs["list_node_types"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNodeTypes", request_serializer=vmwareengine.ListNodeTypesRequest.serialize, response_deserializer=vmwareengine.ListNodeTypesResponse.deserialize, @@ -1297,7 +1390,7 @@ def get_node_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_node_type" not in self._stubs: - self._stubs["get_node_type"] = self.grpc_channel.unary_unary( + self._stubs["get_node_type"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNodeType", request_serializer=vmwareengine.GetNodeTypeRequest.serialize, response_deserializer=vmwareengine_resources.NodeType.deserialize, @@ -1326,7 +1419,7 @@ def show_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_nsx_credentials" not in self._stubs: - self._stubs["show_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowNsxCredentials", request_serializer=vmwareengine.ShowNsxCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1355,7 +1448,7 @@ def show_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "show_vcenter_credentials" not in self._stubs: - self._stubs["show_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["show_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ShowVcenterCredentials", request_serializer=vmwareengine.ShowVcenterCredentialsRequest.serialize, response_deserializer=vmwareengine_resources.Credentials.deserialize, @@ -1383,7 +1476,7 @@ def reset_nsx_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_nsx_credentials" not in self._stubs: - self._stubs["reset_nsx_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_nsx_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetNsxCredentials", request_serializer=vmwareengine.ResetNsxCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1412,7 +1505,7 @@ def reset_vcenter_credentials( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_vcenter_credentials" not in self._stubs: - self._stubs["reset_vcenter_credentials"] = self.grpc_channel.unary_unary( + self._stubs["reset_vcenter_credentials"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ResetVcenterCredentials", request_serializer=vmwareengine.ResetVcenterCredentialsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1441,7 +1534,7 @@ def get_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_forwarding" not in self._stubs: - self._stubs["get_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsForwarding", request_serializer=vmwareengine.GetDnsForwardingRequest.serialize, response_deserializer=vmwareengine_resources.DnsForwarding.deserialize, @@ -1471,7 +1564,7 @@ def update_dns_forwarding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_forwarding" not in self._stubs: - self._stubs["update_dns_forwarding"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_forwarding"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateDnsForwarding", request_serializer=vmwareengine.UpdateDnsForwardingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1504,7 +1597,7 @@ def get_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_peering" not in self._stubs: - self._stubs["get_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["get_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPeering", request_serializer=vmwareengine.GetNetworkPeeringRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPeering.deserialize, @@ -1535,7 +1628,7 @@ def list_network_peerings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_peerings" not in self._stubs: - self._stubs["list_network_peerings"] = self.grpc_channel.unary_unary( + self._stubs["list_network_peerings"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPeerings", request_serializer=vmwareengine.ListNetworkPeeringsRequest.serialize, response_deserializer=vmwareengine.ListNetworkPeeringsResponse.deserialize, @@ -1566,7 +1659,7 @@ def create_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_peering" not in self._stubs: - self._stubs["create_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["create_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPeering", request_serializer=vmwareengine.CreateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1597,7 +1690,7 @@ def delete_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_peering" not in self._stubs: - self._stubs["delete_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPeering", request_serializer=vmwareengine.DeleteNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1628,7 +1721,7 @@ def update_network_peering( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_peering" not in self._stubs: - self._stubs["update_network_peering"] = self.grpc_channel.unary_unary( + self._stubs["update_network_peering"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPeering", request_serializer=vmwareengine.UpdateNetworkPeeringRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1659,7 +1752,7 @@ def list_peering_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_peering_routes" not in self._stubs: - self._stubs["list_peering_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_peering_routes"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPeeringRoutes", request_serializer=vmwareengine.ListPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPeeringRoutesResponse.deserialize, @@ -1689,7 +1782,7 @@ def create_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hcx_activation_key" not in self._stubs: - self._stubs["create_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["create_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateHcxActivationKey", request_serializer=vmwareengine.CreateHcxActivationKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1718,7 +1811,7 @@ def list_hcx_activation_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hcx_activation_keys" not in self._stubs: - self._stubs["list_hcx_activation_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_hcx_activation_keys"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListHcxActivationKeys", request_serializer=vmwareengine.ListHcxActivationKeysRequest.serialize, response_deserializer=vmwareengine.ListHcxActivationKeysResponse.deserialize, @@ -1747,7 +1840,7 @@ def get_hcx_activation_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hcx_activation_key" not in self._stubs: - self._stubs["get_hcx_activation_key"] = self.grpc_channel.unary_unary( + self._stubs["get_hcx_activation_key"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetHcxActivationKey", request_serializer=vmwareengine.GetHcxActivationKeyRequest.serialize, response_deserializer=vmwareengine_resources.HcxActivationKey.deserialize, @@ -1776,7 +1869,7 @@ def get_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network_policy" not in self._stubs: - self._stubs["get_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetNetworkPolicy", request_serializer=vmwareengine.GetNetworkPolicyRequest.serialize, response_deserializer=vmwareengine_resources.NetworkPolicy.deserialize, @@ -1806,7 +1899,7 @@ def list_network_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_policies" not in self._stubs: - self._stubs["list_network_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_network_policies"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListNetworkPolicies", request_serializer=vmwareengine.ListNetworkPoliciesRequest.serialize, response_deserializer=vmwareengine.ListNetworkPoliciesResponse.deserialize, @@ -1837,7 +1930,7 @@ def create_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_network_policy" not in self._stubs: - self._stubs["create_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateNetworkPolicy", request_serializer=vmwareengine.CreateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1877,7 +1970,7 @@ def update_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network_policy" not in self._stubs: - self._stubs["update_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateNetworkPolicy", request_serializer=vmwareengine.UpdateNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1907,7 +2000,7 @@ def delete_network_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_network_policy" not in self._stubs: - self._stubs["delete_network_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_network_policy"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteNetworkPolicy", request_serializer=vmwareengine.DeleteNetworkPolicyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1940,7 +2033,7 @@ def list_management_dns_zone_bindings( if "list_management_dns_zone_bindings" not in self._stubs: self._stubs[ "list_management_dns_zone_bindings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListManagementDnsZoneBindings", request_serializer=vmwareengine.ListManagementDnsZoneBindingsRequest.serialize, response_deserializer=vmwareengine.ListManagementDnsZoneBindingsResponse.deserialize, @@ -1973,7 +2066,7 @@ def get_management_dns_zone_binding( if "get_management_dns_zone_binding" not in self._stubs: self._stubs[ "get_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetManagementDnsZoneBinding", request_serializer=vmwareengine.GetManagementDnsZoneBindingRequest.serialize, response_deserializer=vmwareengine_resources.ManagementDnsZoneBinding.deserialize, @@ -2012,7 +2105,7 @@ def create_management_dns_zone_binding( if "create_management_dns_zone_binding" not in self._stubs: self._stubs[ "create_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateManagementDnsZoneBinding", request_serializer=vmwareengine.CreateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2045,7 +2138,7 @@ def update_management_dns_zone_binding( if "update_management_dns_zone_binding" not in self._stubs: self._stubs[ "update_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateManagementDnsZoneBinding", request_serializer=vmwareengine.UpdateManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2080,7 +2173,7 @@ def delete_management_dns_zone_binding( if "delete_management_dns_zone_binding" not in self._stubs: self._stubs[ "delete_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteManagementDnsZoneBinding", request_serializer=vmwareengine.DeleteManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2113,7 +2206,7 @@ def repair_management_dns_zone_binding( if "repair_management_dns_zone_binding" not in self._stubs: self._stubs[ "repair_management_dns_zone_binding" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RepairManagementDnsZoneBinding", request_serializer=vmwareengine.RepairManagementDnsZoneBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2143,7 +2236,9 @@ def create_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vmware_engine_network" not in self._stubs: - self._stubs["create_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreateVmwareEngineNetwork", request_serializer=vmwareengine.CreateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2174,7 +2269,9 @@ def update_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vmware_engine_network" not in self._stubs: - self._stubs["update_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdateVmwareEngineNetwork", request_serializer=vmwareengine.UpdateVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2206,7 +2303,9 @@ def delete_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_vmware_engine_network" not in self._stubs: - self._stubs["delete_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_vmware_engine_network" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeleteVmwareEngineNetwork", request_serializer=vmwareengine.DeleteVmwareEngineNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2239,7 +2338,7 @@ def get_vmware_engine_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vmware_engine_network" not in self._stubs: - self._stubs["get_vmware_engine_network"] = self.grpc_channel.unary_unary( + self._stubs["get_vmware_engine_network"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetVmwareEngineNetwork", request_serializer=vmwareengine.GetVmwareEngineNetworkRequest.serialize, response_deserializer=vmwareengine_resources.VmwareEngineNetwork.deserialize, @@ -2269,7 +2368,9 @@ def list_vmware_engine_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vmware_engine_networks" not in self._stubs: - self._stubs["list_vmware_engine_networks"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vmware_engine_networks" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListVmwareEngineNetworks", request_serializer=vmwareengine.ListVmwareEngineNetworksRequest.serialize, response_deserializer=vmwareengine.ListVmwareEngineNetworksResponse.deserialize, @@ -2299,7 +2400,7 @@ def create_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_private_connection" not in self._stubs: - self._stubs["create_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/CreatePrivateConnection", request_serializer=vmwareengine.CreatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2330,7 +2431,7 @@ def get_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_private_connection" not in self._stubs: - self._stubs["get_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetPrivateConnection", request_serializer=vmwareengine.GetPrivateConnectionRequest.serialize, response_deserializer=vmwareengine_resources.PrivateConnection.deserialize, @@ -2360,7 +2461,7 @@ def list_private_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_private_connections" not in self._stubs: - self._stubs["list_private_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_private_connections"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnections", request_serializer=vmwareengine.ListPrivateConnectionsRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionsResponse.deserialize, @@ -2391,7 +2492,7 @@ def update_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_private_connection" not in self._stubs: - self._stubs["update_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/UpdatePrivateConnection", request_serializer=vmwareengine.UpdatePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2422,7 +2523,7 @@ def delete_private_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_private_connection" not in self._stubs: - self._stubs["delete_private_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_private_connection"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/DeletePrivateConnection", request_serializer=vmwareengine.DeletePrivateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2455,7 +2556,7 @@ def list_private_connection_peering_routes( if "list_private_connection_peering_routes" not in self._stubs: self._stubs[ "list_private_connection_peering_routes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/ListPrivateConnectionPeeringRoutes", request_serializer=vmwareengine.ListPrivateConnectionPeeringRoutesRequest.serialize, response_deserializer=vmwareengine.ListPrivateConnectionPeeringRoutesResponse.deserialize, @@ -2488,7 +2589,7 @@ def grant_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "grant_dns_bind_permission" not in self._stubs: - self._stubs["grant_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["grant_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GrantDnsBindPermission", request_serializer=vmwareengine.GrantDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -2520,7 +2621,7 @@ def get_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_bind_permission" not in self._stubs: - self._stubs["get_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_bind_permission"] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/GetDnsBindPermission", request_serializer=vmwareengine.GetDnsBindPermissionRequest.serialize, response_deserializer=vmwareengine_resources.DnsBindPermission.deserialize, @@ -2553,7 +2654,9 @@ def revoke_dns_bind_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_dns_bind_permission" not in self._stubs: - self._stubs["revoke_dns_bind_permission"] = self.grpc_channel.unary_unary( + self._stubs[ + "revoke_dns_bind_permission" + ] = self._logged_channel.unary_unary( "/google.cloud.vmwareengine.v1.VmwareEngine/RevokeDnsBindPermission", request_serializer=vmwareengine.RevokeDnsBindPermissionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -3287,7 +3390,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -3303,7 +3406,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -3320,7 +3423,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -3339,7 +3442,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -3358,7 +3461,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -3375,7 +3478,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -3400,7 +3503,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -3426,7 +3529,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -3455,7 +3558,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py index 838825d6ae40..92229beb1391 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/services/vmware_engine/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -665,8 +673,10 @@ def post_update_vmware_engine_network(self, response): def pre_create_cluster( self, request: vmwareengine.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -688,8 +698,11 @@ def post_create_cluster( def pre_create_external_access_rule( self, request: vmwareengine.CreateExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_external_access_rule Override in a subclass to manipulate the request or metadata @@ -711,8 +724,11 @@ def post_create_external_access_rule( def pre_create_external_address( self, request: vmwareengine.CreateExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_external_address Override in a subclass to manipulate the request or metadata @@ -734,8 +750,11 @@ def post_create_external_address( def pre_create_hcx_activation_key( self, request: vmwareengine.CreateHcxActivationKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateHcxActivationKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateHcxActivationKeyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_hcx_activation_key Override in a subclass to manipulate the request or metadata @@ -757,8 +776,10 @@ def post_create_hcx_activation_key( def pre_create_logging_server( self, request: vmwareengine.CreateLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_logging_server Override in a subclass to manipulate the request or metadata @@ -780,9 +801,10 @@ def post_create_logging_server( def pre_create_management_dns_zone_binding( self, request: vmwareengine.CreateManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.CreateManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.CreateManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_management_dns_zone_binding @@ -805,8 +827,11 @@ def post_create_management_dns_zone_binding( def pre_create_network_peering( self, request: vmwareengine.CreateNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_network_peering Override in a subclass to manipulate the request or metadata @@ -828,8 +853,10 @@ def post_create_network_peering( def pre_create_network_policy( self, request: vmwareengine.CreateNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreateNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreateNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_network_policy Override in a subclass to manipulate the request or metadata @@ -851,8 +878,10 @@ def post_create_network_policy( def pre_create_private_cloud( self, request: vmwareengine.CreatePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreatePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreatePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_private_cloud Override in a subclass to manipulate the request or metadata @@ -874,8 +903,11 @@ def post_create_private_cloud( def pre_create_private_connection( self, request: vmwareengine.CreatePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.CreatePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.CreatePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_private_connection Override in a subclass to manipulate the request or metadata @@ -897,9 +929,10 @@ def post_create_private_connection( def pre_create_vmware_engine_network( self, request: vmwareengine.CreateVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.CreateVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.CreateVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_vmware_engine_network @@ -922,8 +955,10 @@ def post_create_vmware_engine_network( def pre_delete_cluster( self, request: vmwareengine.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -945,8 +980,11 @@ def post_delete_cluster( def pre_delete_external_access_rule( self, request: vmwareengine.DeleteExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_external_access_rule Override in a subclass to manipulate the request or metadata @@ -968,8 +1006,11 @@ def post_delete_external_access_rule( def pre_delete_external_address( self, request: vmwareengine.DeleteExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_external_address Override in a subclass to manipulate the request or metadata @@ -991,8 +1032,10 @@ def post_delete_external_address( def pre_delete_logging_server( self, request: vmwareengine.DeleteLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_logging_server Override in a subclass to manipulate the request or metadata @@ -1014,9 +1057,10 @@ def post_delete_logging_server( def pre_delete_management_dns_zone_binding( self, request: vmwareengine.DeleteManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.DeleteManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.DeleteManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_management_dns_zone_binding @@ -1039,8 +1083,11 @@ def post_delete_management_dns_zone_binding( def pre_delete_network_peering( self, request: vmwareengine.DeleteNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_network_peering Override in a subclass to manipulate the request or metadata @@ -1062,8 +1109,10 @@ def post_delete_network_peering( def pre_delete_network_policy( self, request: vmwareengine.DeleteNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeleteNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeleteNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_network_policy Override in a subclass to manipulate the request or metadata @@ -1085,8 +1134,10 @@ def post_delete_network_policy( def pre_delete_private_cloud( self, request: vmwareengine.DeletePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeletePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeletePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_private_cloud Override in a subclass to manipulate the request or metadata @@ -1108,8 +1159,11 @@ def post_delete_private_cloud( def pre_delete_private_connection( self, request: vmwareengine.DeletePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.DeletePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.DeletePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_private_connection Override in a subclass to manipulate the request or metadata @@ -1131,9 +1185,10 @@ def post_delete_private_connection( def pre_delete_vmware_engine_network( self, request: vmwareengine.DeleteVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.DeleteVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.DeleteVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_vmware_engine_network @@ -1156,10 +1211,10 @@ def post_delete_vmware_engine_network( def pre_fetch_network_policy_external_addresses( self, request: vmwareengine.FetchNetworkPolicyExternalAddressesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ vmwareengine.FetchNetworkPolicyExternalAddressesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for fetch_network_policy_external_addresses @@ -1182,8 +1237,8 @@ def post_fetch_network_policy_external_addresses( def pre_get_cluster( self, request: vmwareengine.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -1205,8 +1260,11 @@ def post_get_cluster( def pre_get_dns_bind_permission( self, request: vmwareengine.GetDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -1228,8 +1286,10 @@ def post_get_dns_bind_permission( def pre_get_dns_forwarding( self, request: vmwareengine.GetDnsForwardingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetDnsForwardingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetDnsForwardingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_dns_forwarding Override in a subclass to manipulate the request or metadata @@ -1251,8 +1311,11 @@ def post_get_dns_forwarding( def pre_get_external_access_rule( self, request: vmwareengine.GetExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_external_access_rule Override in a subclass to manipulate the request or metadata @@ -1274,8 +1337,10 @@ def post_get_external_access_rule( def pre_get_external_address( self, request: vmwareengine.GetExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetExternalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_external_address Override in a subclass to manipulate the request or metadata @@ -1297,8 +1362,10 @@ def post_get_external_address( def pre_get_hcx_activation_key( self, request: vmwareengine.GetHcxActivationKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetHcxActivationKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetHcxActivationKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_hcx_activation_key Override in a subclass to manipulate the request or metadata @@ -1320,8 +1387,10 @@ def post_get_hcx_activation_key( def pre_get_logging_server( self, request: vmwareengine.GetLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_logging_server Override in a subclass to manipulate the request or metadata @@ -1343,9 +1412,10 @@ def post_get_logging_server( def pre_get_management_dns_zone_binding( self, request: vmwareengine.GetManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.GetManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.GetManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_management_dns_zone_binding @@ -1368,8 +1438,10 @@ def post_get_management_dns_zone_binding( def pre_get_network_peering( self, request: vmwareengine.GetNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNetworkPeeringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_network_peering Override in a subclass to manipulate the request or metadata @@ -1391,8 +1463,10 @@ def post_get_network_peering( def pre_get_network_policy( self, request: vmwareengine.GetNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_network_policy Override in a subclass to manipulate the request or metadata @@ -1412,8 +1486,10 @@ def post_get_network_policy( return response def pre_get_node( - self, request: vmwareengine.GetNodeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[vmwareengine.GetNodeRequest, Sequence[Tuple[str, str]]]: + self, + request: vmwareengine.GetNodeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetNodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_node Override in a subclass to manipulate the request or metadata @@ -1435,8 +1511,10 @@ def post_get_node( def pre_get_node_type( self, request: vmwareengine.GetNodeTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetNodeTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetNodeTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_node_type Override in a subclass to manipulate the request or metadata @@ -1458,8 +1536,10 @@ def post_get_node_type( def pre_get_private_cloud( self, request: vmwareengine.GetPrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetPrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetPrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_private_cloud Override in a subclass to manipulate the request or metadata @@ -1481,8 +1561,11 @@ def post_get_private_cloud( def pre_get_private_connection( self, request: vmwareengine.GetPrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetPrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetPrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_private_connection Override in a subclass to manipulate the request or metadata @@ -1504,8 +1587,8 @@ def post_get_private_connection( def pre_get_subnet( self, request: vmwareengine.GetSubnetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetSubnetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.GetSubnetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_subnet Override in a subclass to manipulate the request or metadata @@ -1527,8 +1610,11 @@ def post_get_subnet( def pre_get_vmware_engine_network( self, request: vmwareengine.GetVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GetVmwareEngineNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GetVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_vmware_engine_network Override in a subclass to manipulate the request or metadata @@ -1550,8 +1636,11 @@ def post_get_vmware_engine_network( def pre_grant_dns_bind_permission( self, request: vmwareengine.GrantDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.GrantDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.GrantDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for grant_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -1573,8 +1662,10 @@ def post_grant_dns_bind_permission( def pre_list_clusters( self, request: vmwareengine.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -1596,8 +1687,11 @@ def post_list_clusters( def pre_list_external_access_rules( self, request: vmwareengine.ListExternalAccessRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListExternalAccessRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListExternalAccessRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_external_access_rules Override in a subclass to manipulate the request or metadata @@ -1619,8 +1713,11 @@ def post_list_external_access_rules( def pre_list_external_addresses( self, request: vmwareengine.ListExternalAddressesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListExternalAddressesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListExternalAddressesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_external_addresses Override in a subclass to manipulate the request or metadata @@ -1642,8 +1739,11 @@ def post_list_external_addresses( def pre_list_hcx_activation_keys( self, request: vmwareengine.ListHcxActivationKeysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListHcxActivationKeysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListHcxActivationKeysRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_hcx_activation_keys Override in a subclass to manipulate the request or metadata @@ -1665,8 +1765,10 @@ def post_list_hcx_activation_keys( def pre_list_logging_servers( self, request: vmwareengine.ListLoggingServersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListLoggingServersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListLoggingServersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_logging_servers Override in a subclass to manipulate the request or metadata @@ -1688,9 +1790,10 @@ def post_list_logging_servers( def pre_list_management_dns_zone_bindings( self, request: vmwareengine.ListManagementDnsZoneBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.ListManagementDnsZoneBindingsRequest, Sequence[Tuple[str, str]] + vmwareengine.ListManagementDnsZoneBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_management_dns_zone_bindings @@ -1713,8 +1816,10 @@ def post_list_management_dns_zone_bindings( def pre_list_network_peerings( self, request: vmwareengine.ListNetworkPeeringsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNetworkPeeringsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNetworkPeeringsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_network_peerings Override in a subclass to manipulate the request or metadata @@ -1736,8 +1841,10 @@ def post_list_network_peerings( def pre_list_network_policies( self, request: vmwareengine.ListNetworkPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNetworkPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNetworkPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_network_policies Override in a subclass to manipulate the request or metadata @@ -1759,8 +1866,8 @@ def post_list_network_policies( def pre_list_nodes( self, request: vmwareengine.ListNodesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNodesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vmwareengine.ListNodesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_nodes Override in a subclass to manipulate the request or metadata @@ -1782,8 +1889,10 @@ def post_list_nodes( def pre_list_node_types( self, request: vmwareengine.ListNodeTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListNodeTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListNodeTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_node_types Override in a subclass to manipulate the request or metadata @@ -1805,8 +1914,10 @@ def post_list_node_types( def pre_list_peering_routes( self, request: vmwareengine.ListPeeringRoutesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPeeringRoutesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPeeringRoutesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_peering_routes Override in a subclass to manipulate the request or metadata @@ -1828,8 +1939,10 @@ def post_list_peering_routes( def pre_list_private_clouds( self, request: vmwareengine.ListPrivateCloudsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPrivateCloudsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPrivateCloudsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_private_clouds Override in a subclass to manipulate the request or metadata @@ -1851,10 +1964,10 @@ def post_list_private_clouds( def pre_list_private_connection_peering_routes( self, request: vmwareengine.ListPrivateConnectionPeeringRoutesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ vmwareengine.ListPrivateConnectionPeeringRoutesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_private_connection_peering_routes @@ -1877,8 +1990,11 @@ def post_list_private_connection_peering_routes( def pre_list_private_connections( self, request: vmwareengine.ListPrivateConnectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListPrivateConnectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListPrivateConnectionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_private_connections Override in a subclass to manipulate the request or metadata @@ -1900,8 +2016,10 @@ def post_list_private_connections( def pre_list_subnets( self, request: vmwareengine.ListSubnetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListSubnetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListSubnetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_subnets Override in a subclass to manipulate the request or metadata @@ -1923,8 +2041,11 @@ def post_list_subnets( def pre_list_vmware_engine_networks( self, request: vmwareengine.ListVmwareEngineNetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ListVmwareEngineNetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ListVmwareEngineNetworksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_vmware_engine_networks Override in a subclass to manipulate the request or metadata @@ -1946,9 +2067,10 @@ def post_list_vmware_engine_networks( def pre_repair_management_dns_zone_binding( self, request: vmwareengine.RepairManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.RepairManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.RepairManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for repair_management_dns_zone_binding @@ -1971,8 +2093,10 @@ def post_repair_management_dns_zone_binding( def pre_reset_nsx_credentials( self, request: vmwareengine.ResetNsxCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ResetNsxCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ResetNsxCredentialsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for reset_nsx_credentials Override in a subclass to manipulate the request or metadata @@ -1994,8 +2118,11 @@ def post_reset_nsx_credentials( def pre_reset_vcenter_credentials( self, request: vmwareengine.ResetVcenterCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ResetVcenterCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ResetVcenterCredentialsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for reset_vcenter_credentials Override in a subclass to manipulate the request or metadata @@ -2017,8 +2144,11 @@ def post_reset_vcenter_credentials( def pre_revoke_dns_bind_permission( self, request: vmwareengine.RevokeDnsBindPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.RevokeDnsBindPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.RevokeDnsBindPermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for revoke_dns_bind_permission Override in a subclass to manipulate the request or metadata @@ -2040,8 +2170,10 @@ def post_revoke_dns_bind_permission( def pre_show_nsx_credentials( self, request: vmwareengine.ShowNsxCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ShowNsxCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ShowNsxCredentialsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for show_nsx_credentials Override in a subclass to manipulate the request or metadata @@ -2063,8 +2195,11 @@ def post_show_nsx_credentials( def pre_show_vcenter_credentials( self, request: vmwareengine.ShowVcenterCredentialsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.ShowVcenterCredentialsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.ShowVcenterCredentialsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for show_vcenter_credentials Override in a subclass to manipulate the request or metadata @@ -2086,8 +2221,11 @@ def post_show_vcenter_credentials( def pre_undelete_private_cloud( self, request: vmwareengine.UndeletePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UndeletePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UndeletePrivateCloudRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for undelete_private_cloud Override in a subclass to manipulate the request or metadata @@ -2109,8 +2247,10 @@ def post_undelete_private_cloud( def pre_update_cluster( self, request: vmwareengine.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -2132,8 +2272,10 @@ def post_update_cluster( def pre_update_dns_forwarding( self, request: vmwareengine.UpdateDnsForwardingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateDnsForwardingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateDnsForwardingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_dns_forwarding Override in a subclass to manipulate the request or metadata @@ -2155,8 +2297,11 @@ def post_update_dns_forwarding( def pre_update_external_access_rule( self, request: vmwareengine.UpdateExternalAccessRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateExternalAccessRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateExternalAccessRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_external_access_rule Override in a subclass to manipulate the request or metadata @@ -2178,8 +2323,11 @@ def post_update_external_access_rule( def pre_update_external_address( self, request: vmwareengine.UpdateExternalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateExternalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateExternalAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_external_address Override in a subclass to manipulate the request or metadata @@ -2201,8 +2349,10 @@ def post_update_external_address( def pre_update_logging_server( self, request: vmwareengine.UpdateLoggingServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateLoggingServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateLoggingServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_logging_server Override in a subclass to manipulate the request or metadata @@ -2224,9 +2374,10 @@ def post_update_logging_server( def pre_update_management_dns_zone_binding( self, request: vmwareengine.UpdateManagementDnsZoneBindingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.UpdateManagementDnsZoneBindingRequest, Sequence[Tuple[str, str]] + vmwareengine.UpdateManagementDnsZoneBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_management_dns_zone_binding @@ -2249,8 +2400,11 @@ def post_update_management_dns_zone_binding( def pre_update_network_peering( self, request: vmwareengine.UpdateNetworkPeeringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateNetworkPeeringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateNetworkPeeringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_network_peering Override in a subclass to manipulate the request or metadata @@ -2272,8 +2426,10 @@ def post_update_network_peering( def pre_update_network_policy( self, request: vmwareengine.UpdateNetworkPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateNetworkPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateNetworkPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_network_policy Override in a subclass to manipulate the request or metadata @@ -2295,8 +2451,10 @@ def post_update_network_policy( def pre_update_private_cloud( self, request: vmwareengine.UpdatePrivateCloudRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdatePrivateCloudRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdatePrivateCloudRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_private_cloud Override in a subclass to manipulate the request or metadata @@ -2318,8 +2476,11 @@ def post_update_private_cloud( def pre_update_private_connection( self, request: vmwareengine.UpdatePrivateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdatePrivateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdatePrivateConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_private_connection Override in a subclass to manipulate the request or metadata @@ -2341,8 +2502,10 @@ def post_update_private_connection( def pre_update_subnet( self, request: vmwareengine.UpdateSubnetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vmwareengine.UpdateSubnetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vmwareengine.UpdateSubnetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_subnet Override in a subclass to manipulate the request or metadata @@ -2364,9 +2527,10 @@ def post_update_subnet( def pre_update_vmware_engine_network( self, request: vmwareengine.UpdateVmwareEngineNetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vmwareengine.UpdateVmwareEngineNetworkRequest, Sequence[Tuple[str, str]] + vmwareengine.UpdateVmwareEngineNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_vmware_engine_network @@ -2389,8 +2553,10 @@ def post_update_vmware_engine_network( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -2412,8 +2578,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -2435,8 +2603,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -2456,8 +2626,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -2477,8 +2649,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -2500,8 +2675,10 @@ def post_test_iam_permissions( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2521,8 +2698,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2544,8 +2723,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2733,7 +2914,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -2744,8 +2925,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2758,6 +2941,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -2772,6 +2956,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateCluster._get_response( self._host, @@ -2791,7 +3002,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.vmwareengine_v1.VmwareEngineClient.create_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExternalAccessRule( @@ -2830,7 +3063,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create external access rule method over HTTP. @@ -2842,8 +3075,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2856,6 +3091,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_access_rule( request, metadata ) @@ -2872,6 +3108,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateExternalAccessRule._get_response( @@ -2893,7 +3156,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_external_access_rule(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.vmwareengine_v1.VmwareEngineClient.create_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExternalAddress( @@ -2931,7 +3216,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create external address method over HTTP. @@ -2942,8 +3227,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2956,6 +3243,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_address( request, metadata ) @@ -2972,6 +3260,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateExternalAddress._get_response( self._host, @@ -2991,7 +3306,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_external_address(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.vmwareengine_v1.VmwareEngineClient.create_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateHcxActivationKey( @@ -3029,7 +3366,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create hcx activation key method over HTTP. @@ -3040,8 +3377,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3054,6 +3393,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateHcxActivationKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_hcx_activation_key( request, metadata ) @@ -3070,6 +3410,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateHcxActivationKey", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateHcxActivationKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateHcxActivationKey._get_response( self._host, @@ -3089,7 +3456,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_hcx_activation_key(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.vmwareengine_v1.VmwareEngineClient.create_hcx_activation_key", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateHcxActivationKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateLoggingServer( @@ -3127,7 +3516,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create logging server method over HTTP. @@ -3138,8 +3527,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3152,6 +3543,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_create_logging_server( request, metadata ) @@ -3168,6 +3560,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateLoggingServer._get_response( self._host, @@ -3187,7 +3606,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_logging_server(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.vmwareengine_v1.VmwareEngineClient.create_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateManagementDnsZoneBinding( @@ -3226,7 +3667,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create management dns zone binding method over HTTP. @@ -3238,8 +3679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3252,6 +3695,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -3271,6 +3715,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateManagementDnsZoneBinding._get_response( @@ -3292,7 +3763,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_management_dns_zone_binding(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.vmwareengine_v1.VmwareEngineClient.create_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNetworkPeering( @@ -3330,7 +3823,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create network peering method over HTTP. @@ -3341,8 +3834,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3355,6 +3850,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_create_network_peering( request, metadata ) @@ -3371,6 +3867,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateNetworkPeering._get_response( self._host, @@ -3390,7 +3913,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_network_peering(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.vmwareengine_v1.VmwareEngineClient.create_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNetworkPolicy( @@ -3428,7 +3973,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create network policy method over HTTP. @@ -3439,8 +3984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3453,6 +4000,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_create_network_policy( request, metadata ) @@ -3469,6 +4017,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreateNetworkPolicy._get_response( self._host, @@ -3488,7 +4063,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_network_policy(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.vmwareengine_v1.VmwareEngineClient.create_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePrivateCloud( @@ -3526,7 +4123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create private cloud method over HTTP. @@ -3537,8 +4134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3551,6 +4150,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreatePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_create_private_cloud( request, metadata ) @@ -3567,6 +4167,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreatePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreatePrivateCloud._get_response( self._host, @@ -3586,7 +4213,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_private_cloud(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.vmwareengine_v1.VmwareEngineClient.create_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePrivateConnection( @@ -3625,7 +4274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create private connection method over HTTP. @@ -3636,8 +4285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3650,6 +4301,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreatePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_create_private_connection( request, metadata ) @@ -3666,6 +4318,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreatePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._CreatePrivateConnection._get_response( self._host, @@ -3685,7 +4364,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_private_connection(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.vmwareengine_v1.VmwareEngineClient.create_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreatePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateVmwareEngineNetwork( @@ -3724,7 +4425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create vmware engine network method over HTTP. @@ -3736,8 +4437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3750,6 +4453,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseCreateVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_create_vmware_engine_network( request, metadata ) @@ -3766,6 +4470,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.CreateVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._CreateVmwareEngineNetwork._get_response( @@ -3787,7 +4518,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_vmware_engine_network(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.vmwareengine_v1.VmwareEngineClient.create_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "CreateVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -3824,7 +4577,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -3835,8 +4588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3849,6 +4604,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -3859,6 +4615,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteCluster._get_response( self._host, @@ -3877,7 +4660,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.vmwareengine_v1.VmwareEngineClient.delete_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteExternalAccessRule( @@ -3915,7 +4720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete external access rule method over HTTP. @@ -3927,8 +4732,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3941,6 +4748,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_external_access_rule( request, metadata ) @@ -3953,6 +4761,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteExternalAccessRule._get_response( @@ -3973,7 +4808,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_external_access_rule(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.vmwareengine_v1.VmwareEngineClient.delete_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteExternalAddress( @@ -4010,7 +4867,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete external address method over HTTP. @@ -4021,8 +4878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4035,6 +4894,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_delete_external_address( request, metadata ) @@ -4047,6 +4907,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteExternalAddress._get_response( self._host, @@ -4065,7 +4952,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_external_address(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.vmwareengine_v1.VmwareEngineClient.delete_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteLoggingServer( @@ -4102,7 +5011,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete logging server method over HTTP. @@ -4113,8 +5022,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4127,6 +5038,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_delete_logging_server( request, metadata ) @@ -4139,6 +5051,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteLoggingServer._get_response( self._host, @@ -4157,7 +5096,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_logging_server(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.vmwareengine_v1.VmwareEngineClient.delete_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteManagementDnsZoneBinding( @@ -4195,7 +5156,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete management dns zone binding method over HTTP. @@ -4207,8 +5168,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4221,6 +5184,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -4236,6 +5200,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteManagementDnsZoneBinding._get_response( @@ -4256,7 +5247,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_management_dns_zone_binding(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.vmwareengine_v1.VmwareEngineClient.delete_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNetworkPeering( @@ -4293,7 +5306,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete network peering method over HTTP. @@ -4304,8 +5317,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4318,6 +5333,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_delete_network_peering( request, metadata ) @@ -4330,6 +5346,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteNetworkPeering._get_response( self._host, @@ -4348,7 +5391,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_network_peering(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.vmwareengine_v1.VmwareEngineClient.delete_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNetworkPolicy( @@ -4385,7 +5450,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete network policy method over HTTP. @@ -4396,8 +5461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4410,6 +5477,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_delete_network_policy( request, metadata ) @@ -4422,6 +5490,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteNetworkPolicy._get_response( self._host, @@ -4440,7 +5535,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_network_policy(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.vmwareengine_v1.VmwareEngineClient.delete_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePrivateCloud( @@ -4477,7 +5594,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete private cloud method over HTTP. @@ -4488,8 +5605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4502,6 +5621,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeletePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_delete_private_cloud( request, metadata ) @@ -4514,6 +5634,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeletePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeletePrivateCloud._get_response( self._host, @@ -4532,7 +5679,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_private_cloud(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.vmwareengine_v1.VmwareEngineClient.delete_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePrivateConnection( @@ -4570,7 +5739,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete private connection method over HTTP. @@ -4581,8 +5750,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4595,6 +5766,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeletePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_private_connection( request, metadata ) @@ -4607,6 +5779,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeletePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeletePrivateConnection._get_response( self._host, @@ -4625,7 +5824,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_private_connection(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.vmwareengine_v1.VmwareEngineClient.delete_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeletePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteVmwareEngineNetwork( @@ -4663,7 +5884,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete vmware engine network method over HTTP. @@ -4675,8 +5896,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4689,6 +5912,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_delete_vmware_engine_network( request, metadata ) @@ -4701,6 +5925,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._DeleteVmwareEngineNetwork._get_response( @@ -4721,7 +5972,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_vmware_engine_network(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.vmwareengine_v1.VmwareEngineClient.delete_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchNetworkPolicyExternalAddresses( @@ -4759,7 +6032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.FetchNetworkPolicyExternalAddressesResponse: r"""Call the fetch network policy external addresses method over HTTP. @@ -4771,8 +6044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.FetchNetworkPolicyExternalAddressesResponse: @@ -4784,6 +6059,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseFetchNetworkPolicyExternalAddresses._get_http_options() ) + ( request, metadata, @@ -4799,6 +6075,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.FetchNetworkPolicyExternalAddresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "FetchNetworkPolicyExternalAddresses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._FetchNetworkPolicyExternalAddresses._get_response( self._host, @@ -4819,7 +6122,31 @@ def __call__( pb_resp = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_network_policy_external_addresses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.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.vmwareengine_v1.VmwareEngineClient.fetch_network_policy_external_addresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "FetchNetworkPolicyExternalAddresses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -4856,7 +6183,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Cluster: r"""Call the get cluster method over HTTP. @@ -4867,8 +6194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.Cluster: @@ -4878,6 +6207,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetCluster._get_transcoded_request( @@ -4892,6 +6222,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetCluster._get_response( self._host, @@ -4912,7 +6269,29 @@ def __call__( pb_resp = vmwareengine_resources.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Cluster.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.vmwareengine_v1.VmwareEngineClient.get_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDnsBindPermission( @@ -4949,7 +6328,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsBindPermission: r"""Call the get dns bind permission method over HTTP. @@ -4960,8 +6339,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.DnsBindPermission: @@ -4976,6 +6357,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_get_dns_bind_permission( request, metadata ) @@ -4988,6 +6370,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetDnsBindPermission._get_response( self._host, @@ -5008,7 +6417,31 @@ def __call__( pb_resp = vmwareengine_resources.DnsBindPermission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_bind_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.DnsBindPermission.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.vmwareengine_v1.VmwareEngineClient.get_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDnsForwarding( @@ -5045,7 +6478,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.DnsForwarding: r"""Call the get dns forwarding method over HTTP. @@ -5056,8 +6489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.DnsForwarding: @@ -5072,6 +6507,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetDnsForwarding._get_http_options() ) + request, metadata = self._interceptor.pre_get_dns_forwarding( request, metadata ) @@ -5084,6 +6520,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetDnsForwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsForwarding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetDnsForwarding._get_response( self._host, @@ -5104,7 +6567,31 @@ def __call__( pb_resp = vmwareengine_resources.DnsForwarding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_forwarding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.DnsForwarding.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.vmwareengine_v1.VmwareEngineClient.get_dns_forwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetDnsForwarding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExternalAccessRule( @@ -5141,7 +6628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAccessRule: r"""Call the get external access rule method over HTTP. @@ -5152,8 +6639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.ExternalAccessRule: @@ -5165,6 +6654,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_external_access_rule( request, metadata ) @@ -5177,6 +6667,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetExternalAccessRule._get_response( self._host, @@ -5197,7 +6714,31 @@ def __call__( pb_resp = vmwareengine_resources.ExternalAccessRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_external_access_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.ExternalAccessRule.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.vmwareengine_v1.VmwareEngineClient.get_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExternalAddress( @@ -5234,7 +6775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ExternalAddress: r"""Call the get external address method over HTTP. @@ -5245,8 +6786,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.ExternalAddress: @@ -5259,6 +6802,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_get_external_address( request, metadata ) @@ -5271,6 +6815,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetExternalAddress._get_response( self._host, @@ -5291,7 +6862,31 @@ def __call__( pb_resp = vmwareengine_resources.ExternalAddress.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_external_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.ExternalAddress.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.vmwareengine_v1.VmwareEngineClient.get_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHcxActivationKey( @@ -5328,7 +6923,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.HcxActivationKey: r"""Call the get hcx activation key method over HTTP. @@ -5339,8 +6934,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.HcxActivationKey: @@ -5357,6 +6954,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetHcxActivationKey._get_http_options() ) + request, metadata = self._interceptor.pre_get_hcx_activation_key( request, metadata ) @@ -5369,6 +6967,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetHcxActivationKey", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetHcxActivationKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetHcxActivationKey._get_response( self._host, @@ -5389,7 +7014,31 @@ def __call__( pb_resp = vmwareengine_resources.HcxActivationKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_hcx_activation_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.HcxActivationKey.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.vmwareengine_v1.VmwareEngineClient.get_hcx_activation_key", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetHcxActivationKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetLoggingServer( @@ -5426,7 +7075,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.LoggingServer: r"""Call the get logging server method over HTTP. @@ -5437,8 +7086,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.LoggingServer: @@ -5450,6 +7101,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_get_logging_server( request, metadata ) @@ -5462,6 +7114,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetLoggingServer._get_response( self._host, @@ -5482,7 +7161,31 @@ def __call__( pb_resp = vmwareengine_resources.LoggingServer.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_logging_server(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.LoggingServer.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.vmwareengine_v1.VmwareEngineClient.get_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetManagementDnsZoneBinding( @@ -5520,7 +7223,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.ManagementDnsZoneBinding: r"""Call the get management dns zone binding method over HTTP. @@ -5532,8 +7235,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.ManagementDnsZoneBinding: @@ -5552,6 +7257,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetManagementDnsZoneBinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_management_dns_zone_binding( request, metadata ) @@ -5564,6 +7270,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._GetManagementDnsZoneBinding._get_response( @@ -5586,7 +7319,33 @@ def __call__( pb_resp = vmwareengine_resources.ManagementDnsZoneBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_management_dns_zone_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.ManagementDnsZoneBinding.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.vmwareengine_v1.VmwareEngineClient.get_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNetworkPeering( @@ -5623,7 +7382,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPeering: r"""Call the get network peering method over HTTP. @@ -5634,8 +7393,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.NetworkPeering: @@ -5645,6 +7406,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_get_network_peering( request, metadata ) @@ -5657,6 +7419,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNetworkPeering._get_response( self._host, @@ -5677,7 +7466,31 @@ def __call__( pb_resp = vmwareengine_resources.NetworkPeering.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_network_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.NetworkPeering.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.vmwareengine_v1.VmwareEngineClient.get_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNetworkPolicy( @@ -5714,7 +7527,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NetworkPolicy: r"""Call the get network policy method over HTTP. @@ -5725,8 +7538,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.NetworkPolicy: @@ -5747,6 +7562,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_network_policy( request, metadata ) @@ -5759,6 +7575,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNetworkPolicy._get_response( self._host, @@ -5779,7 +7622,31 @@ def __call__( pb_resp = vmwareengine_resources.NetworkPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_network_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.NetworkPolicy.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.vmwareengine_v1.VmwareEngineClient.get_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNode(_BaseVmwareEngineRestTransport._BaseGetNode, VmwareEngineRestStub): @@ -5814,7 +7681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Node: r"""Call the get node method over HTTP. @@ -5825,8 +7692,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.Node: @@ -5836,6 +7705,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNode._get_http_options() ) + request, metadata = self._interceptor.pre_get_node(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetNode._get_transcoded_request( @@ -5850,6 +7720,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetNode", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNode._get_response( self._host, @@ -5870,7 +7767,29 @@ def __call__( pb_resp = vmwareengine_resources.Node.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Node.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.vmwareengine_v1.VmwareEngineClient.get_node", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNodeType( @@ -5907,7 +7826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.NodeType: r"""Call the get node type method over HTTP. @@ -5918,8 +7837,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.NodeType: @@ -5929,6 +7850,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetNodeType._get_http_options() ) + request, metadata = self._interceptor.pre_get_node_type(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetNodeType._get_transcoded_request( @@ -5943,6 +7865,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetNodeType", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNodeType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetNodeType._get_response( self._host, @@ -5963,7 +7912,29 @@ def __call__( pb_resp = vmwareengine_resources.NodeType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_node_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.NodeType.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.vmwareengine_v1.VmwareEngineClient.get_node_type", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetNodeType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPrivateCloud( @@ -6000,7 +7971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateCloud: r"""Call the get private cloud method over HTTP. @@ -6011,8 +7982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.PrivateCloud: @@ -6025,6 +7998,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetPrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_get_private_cloud( request, metadata ) @@ -6037,6 +8011,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetPrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetPrivateCloud._get_response( self._host, @@ -6057,7 +8058,31 @@ def __call__( pb_resp = vmwareengine_resources.PrivateCloud.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_private_cloud(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.PrivateCloud.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.vmwareengine_v1.VmwareEngineClient.get_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPrivateConnection( @@ -6094,7 +8119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.PrivateConnection: r"""Call the get private connection method over HTTP. @@ -6105,8 +8130,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.PrivateConnection: @@ -6119,6 +8146,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetPrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_get_private_connection( request, metadata ) @@ -6131,6 +8159,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetPrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetPrivateConnection._get_response( self._host, @@ -6151,7 +8206,31 @@ def __call__( pb_resp = vmwareengine_resources.PrivateConnection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_private_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.PrivateConnection.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.vmwareengine_v1.VmwareEngineClient.get_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetPrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSubnet( @@ -6188,7 +8267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Subnet: r"""Call the get subnet method over HTTP. @@ -6199,8 +8278,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.Subnet: @@ -6213,6 +8294,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetSubnet._get_http_options() ) + request, metadata = self._interceptor.pre_get_subnet(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetSubnet._get_transcoded_request( @@ -6227,6 +8309,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetSubnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetSubnet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetSubnet._get_response( self._host, @@ -6247,7 +8356,29 @@ def __call__( pb_resp = vmwareengine_resources.Subnet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_subnet(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Subnet.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.vmwareengine_v1.VmwareEngineClient.get_subnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetSubnet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVmwareEngineNetwork( @@ -6284,7 +8415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.VmwareEngineNetwork: r"""Call the get vmware engine network method over HTTP. @@ -6295,8 +8426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.VmwareEngineNetwork: @@ -6309,6 +8442,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_get_vmware_engine_network( request, metadata ) @@ -6321,6 +8455,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GetVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetVmwareEngineNetwork._get_response( self._host, @@ -6341,7 +8502,31 @@ def __call__( pb_resp = vmwareengine_resources.VmwareEngineNetwork.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_vmware_engine_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine_resources.VmwareEngineNetwork.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.vmwareengine_v1.VmwareEngineClient.get_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GrantDnsBindPermission( @@ -6379,7 +8564,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the grant dns bind permission method over HTTP. @@ -6390,8 +8575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6404,6 +8591,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGrantDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_grant_dns_bind_permission( request, metadata ) @@ -6420,6 +8608,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.GrantDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GrantDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GrantDnsBindPermission._get_response( self._host, @@ -6439,7 +8654,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_grant_dns_bind_permission(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.vmwareengine_v1.VmwareEngineClient.grant_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GrantDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -6476,7 +8713,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -6487,8 +8724,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListClustersResponse: @@ -6500,6 +8739,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -6512,6 +8752,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.ListClusters", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListClusters._get_response( self._host, @@ -6532,7 +8799,31 @@ def __call__( pb_resp = vmwareengine.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListClustersResponse.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.vmwareengine_v1.VmwareEngineClient.list_clusters", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExternalAccessRules( @@ -6570,7 +8861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListExternalAccessRulesResponse: r"""Call the list external access rules method over HTTP. @@ -6582,8 +8873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListExternalAccessRulesResponse: @@ -6595,6 +8888,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListExternalAccessRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_external_access_rules( request, metadata ) @@ -6607,6 +8901,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListExternalAccessRules", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAccessRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListExternalAccessRules._get_response( self._host, @@ -6627,7 +8948,31 @@ def __call__( pb_resp = vmwareengine.ListExternalAccessRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_external_access_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListExternalAccessRulesResponse.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.vmwareengine_v1.VmwareEngineClient.list_external_access_rules", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAccessRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExternalAddresses( @@ -6664,7 +9009,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListExternalAddressesResponse: r"""Call the list external addresses method over HTTP. @@ -6675,8 +9020,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListExternalAddressesResponse: @@ -6688,6 +9035,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListExternalAddresses._get_http_options() ) + request, metadata = self._interceptor.pre_list_external_addresses( request, metadata ) @@ -6700,6 +9048,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListExternalAddresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAddresses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListExternalAddresses._get_response( self._host, @@ -6720,7 +9095,31 @@ def __call__( pb_resp = vmwareengine.ListExternalAddressesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_external_addresses(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListExternalAddressesResponse.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.vmwareengine_v1.VmwareEngineClient.list_external_addresses", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListExternalAddresses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListHcxActivationKeys( @@ -6757,7 +9156,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListHcxActivationKeysResponse: r"""Call the list hcx activation keys method over HTTP. @@ -6768,8 +9167,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListHcxActivationKeysResponse: @@ -6781,6 +9182,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListHcxActivationKeys._get_http_options() ) + request, metadata = self._interceptor.pre_list_hcx_activation_keys( request, metadata ) @@ -6793,6 +9195,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListHcxActivationKeys", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListHcxActivationKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListHcxActivationKeys._get_response( self._host, @@ -6813,7 +9242,31 @@ def __call__( pb_resp = vmwareengine.ListHcxActivationKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_hcx_activation_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListHcxActivationKeysResponse.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.vmwareengine_v1.VmwareEngineClient.list_hcx_activation_keys", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListHcxActivationKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListLoggingServers( @@ -6850,7 +9303,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListLoggingServersResponse: r"""Call the list logging servers method over HTTP. @@ -6861,8 +9314,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListLoggingServersResponse: @@ -6874,6 +9329,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListLoggingServers._get_http_options() ) + request, metadata = self._interceptor.pre_list_logging_servers( request, metadata ) @@ -6886,6 +9342,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListLoggingServers", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLoggingServers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListLoggingServers._get_response( self._host, @@ -6906,7 +9389,31 @@ def __call__( pb_resp = vmwareengine.ListLoggingServersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_logging_servers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListLoggingServersResponse.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.vmwareengine_v1.VmwareEngineClient.list_logging_servers", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLoggingServers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListManagementDnsZoneBindings( @@ -6944,7 +9451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListManagementDnsZoneBindingsResponse: r"""Call the list management dns zone bindings method over HTTP. @@ -6956,8 +9463,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListManagementDnsZoneBindingsResponse: @@ -6969,6 +9478,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListManagementDnsZoneBindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_management_dns_zone_bindings( request, metadata ) @@ -6981,6 +9491,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListManagementDnsZoneBindings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListManagementDnsZoneBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._ListManagementDnsZoneBindings._get_response( @@ -7003,7 +9540,33 @@ def __call__( pb_resp = vmwareengine.ListManagementDnsZoneBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_management_dns_zone_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListManagementDnsZoneBindingsResponse.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.vmwareengine_v1.VmwareEngineClient.list_management_dns_zone_bindings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListManagementDnsZoneBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkPeerings( @@ -7040,7 +9603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNetworkPeeringsResponse: r"""Call the list network peerings method over HTTP. @@ -7051,8 +9614,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListNetworkPeeringsResponse: @@ -7064,6 +9629,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNetworkPeerings._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_peerings( request, metadata ) @@ -7076,6 +9642,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListNetworkPeerings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPeerings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNetworkPeerings._get_response( self._host, @@ -7096,7 +9689,31 @@ def __call__( pb_resp = vmwareengine.ListNetworkPeeringsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_peerings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNetworkPeeringsResponse.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.vmwareengine_v1.VmwareEngineClient.list_network_peerings", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPeerings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkPolicies( @@ -7133,7 +9750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNetworkPoliciesResponse: r"""Call the list network policies method over HTTP. @@ -7144,8 +9761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListNetworkPoliciesResponse: @@ -7157,6 +9776,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNetworkPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_policies( request, metadata ) @@ -7169,6 +9789,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListNetworkPolicies", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNetworkPolicies._get_response( self._host, @@ -7189,7 +9836,31 @@ def __call__( pb_resp = vmwareengine.ListNetworkPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNetworkPoliciesResponse.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.vmwareengine_v1.VmwareEngineClient.list_network_policies", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNetworkPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodes( @@ -7226,7 +9897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNodesResponse: r"""Call the list nodes method over HTTP. @@ -7237,8 +9908,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListNodesResponse: @@ -7250,6 +9923,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNodes._get_http_options() ) + request, metadata = self._interceptor.pre_list_nodes(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseListNodes._get_transcoded_request( @@ -7264,6 +9938,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.ListNodes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNodes._get_response( self._host, @@ -7284,7 +9985,29 @@ def __call__( pb_resp = vmwareengine.ListNodesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNodesResponse.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.vmwareengine_v1.VmwareEngineClient.list_nodes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodeTypes( @@ -7321,7 +10044,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListNodeTypesResponse: r"""Call the list node types method over HTTP. @@ -7332,8 +10055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListNodeTypesResponse: @@ -7345,6 +10070,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListNodeTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_node_types(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListNodeTypes._get_transcoded_request( http_options, request @@ -7355,6 +10081,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListNodeTypes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodeTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListNodeTypes._get_response( self._host, @@ -7375,7 +10128,31 @@ def __call__( pb_resp = vmwareengine.ListNodeTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_node_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListNodeTypesResponse.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.vmwareengine_v1.VmwareEngineClient.list_node_types", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListNodeTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPeeringRoutes( @@ -7412,7 +10189,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPeeringRoutesResponse: r"""Call the list peering routes method over HTTP. @@ -7423,8 +10200,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListPeeringRoutesResponse: @@ -7436,6 +10215,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPeeringRoutes._get_http_options() ) + request, metadata = self._interceptor.pre_list_peering_routes( request, metadata ) @@ -7448,6 +10228,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListPeeringRoutes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPeeringRoutes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPeeringRoutes._get_response( self._host, @@ -7468,7 +10275,31 @@ def __call__( pb_resp = vmwareengine.ListPeeringRoutesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_peering_routes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListPeeringRoutesResponse.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.vmwareengine_v1.VmwareEngineClient.list_peering_routes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPeeringRoutes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateClouds( @@ -7505,7 +10336,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateCloudsResponse: r"""Call the list private clouds method over HTTP. @@ -7516,8 +10347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListPrivateCloudsResponse: @@ -7529,6 +10362,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateClouds._get_http_options() ) + request, metadata = self._interceptor.pre_list_private_clouds( request, metadata ) @@ -7541,6 +10375,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListPrivateClouds", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateClouds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateClouds._get_response( self._host, @@ -7561,7 +10422,31 @@ def __call__( pb_resp = vmwareengine.ListPrivateCloudsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_clouds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListPrivateCloudsResponse.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.vmwareengine_v1.VmwareEngineClient.list_private_clouds", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateClouds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateConnectionPeeringRoutes( @@ -7599,7 +10484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateConnectionPeeringRoutesResponse: r"""Call the list private connection peering routes method over HTTP. @@ -7611,8 +10496,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListPrivateConnectionPeeringRoutesResponse: @@ -7624,6 +10511,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateConnectionPeeringRoutes._get_http_options() ) + ( request, metadata, @@ -7639,6 +10527,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListPrivateConnectionPeeringRoutes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnectionPeeringRoutes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateConnectionPeeringRoutes._get_response( self._host, @@ -7659,7 +10574,33 @@ def __call__( pb_resp = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_connection_peering_routes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListPrivateConnectionPeeringRoutesResponse.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.vmwareengine_v1.VmwareEngineClient.list_private_connection_peering_routes", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnectionPeeringRoutes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPrivateConnections( @@ -7696,7 +10637,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListPrivateConnectionsResponse: r"""Call the list private connections method over HTTP. @@ -7707,8 +10648,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListPrivateConnectionsResponse: @@ -7720,6 +10663,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListPrivateConnections._get_http_options() ) + request, metadata = self._interceptor.pre_list_private_connections( request, metadata ) @@ -7732,6 +10676,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListPrivateConnections", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListPrivateConnections._get_response( self._host, @@ -7752,7 +10723,31 @@ def __call__( pb_resp = vmwareengine.ListPrivateConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_private_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListPrivateConnectionsResponse.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.vmwareengine_v1.VmwareEngineClient.list_private_connections", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListPrivateConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSubnets( @@ -7789,7 +10784,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListSubnetsResponse: r"""Call the list subnets method over HTTP. @@ -7800,8 +10795,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListSubnetsResponse: @@ -7813,6 +10810,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListSubnets._get_http_options() ) + request, metadata = self._interceptor.pre_list_subnets(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseListSubnets._get_transcoded_request( @@ -7827,6 +10825,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.ListSubnets", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListSubnets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListSubnets._get_response( self._host, @@ -7847,7 +10872,31 @@ def __call__( pb_resp = vmwareengine.ListSubnetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_subnets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine.ListSubnetsResponse.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.vmwareengine_v1.VmwareEngineClient.list_subnets", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListSubnets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVmwareEngineNetworks( @@ -7885,7 +10934,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine.ListVmwareEngineNetworksResponse: r"""Call the list vmware engine networks method over HTTP. @@ -7897,8 +10946,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine.ListVmwareEngineNetworksResponse: @@ -7910,6 +10961,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListVmwareEngineNetworks._get_http_options() ) + request, metadata = self._interceptor.pre_list_vmware_engine_networks( request, metadata ) @@ -7922,6 +10974,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListVmwareEngineNetworks", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListVmwareEngineNetworks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._ListVmwareEngineNetworks._get_response( @@ -7944,7 +11023,31 @@ def __call__( pb_resp = vmwareengine.ListVmwareEngineNetworksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_vmware_engine_networks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vmwareengine.ListVmwareEngineNetworksResponse.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.vmwareengine_v1.VmwareEngineClient.list_vmware_engine_networks", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListVmwareEngineNetworks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RepairManagementDnsZoneBinding( @@ -7983,7 +11086,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the repair management dns zone binding method over HTTP. @@ -7995,8 +11098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8009,6 +11114,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseRepairManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -8028,6 +11134,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.RepairManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RepairManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._RepairManagementDnsZoneBinding._get_response( @@ -8049,7 +11182,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_repair_management_dns_zone_binding(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.vmwareengine_v1.VmwareEngineClient.repair_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RepairManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResetNsxCredentials( @@ -8087,7 +11242,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the reset nsx credentials method over HTTP. @@ -8098,8 +11253,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8112,6 +11269,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseResetNsxCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_reset_nsx_credentials( request, metadata ) @@ -8128,6 +11286,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ResetNsxCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetNsxCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ResetNsxCredentials._get_response( self._host, @@ -8147,7 +11332,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset_nsx_credentials(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.vmwareengine_v1.VmwareEngineClient.reset_nsx_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetNsxCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResetVcenterCredentials( @@ -8186,7 +11393,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the reset vcenter credentials method over HTTP. @@ -8197,8 +11404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8211,6 +11420,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseResetVcenterCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_reset_vcenter_credentials( request, metadata ) @@ -8227,6 +11437,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ResetVcenterCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetVcenterCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ResetVcenterCredentials._get_response( self._host, @@ -8246,7 +11483,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset_vcenter_credentials(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.vmwareengine_v1.VmwareEngineClient.reset_vcenter_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ResetVcenterCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RevokeDnsBindPermission( @@ -8285,7 +11544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the revoke dns bind permission method over HTTP. @@ -8297,8 +11556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8311,6 +11572,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseRevokeDnsBindPermission._get_http_options() ) + request, metadata = self._interceptor.pre_revoke_dns_bind_permission( request, metadata ) @@ -8327,6 +11589,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.RevokeDnsBindPermission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RevokeDnsBindPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._RevokeDnsBindPermission._get_response( self._host, @@ -8346,7 +11635,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_revoke_dns_bind_permission(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.vmwareengine_v1.VmwareEngineClient.revoke_dns_bind_permission", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "RevokeDnsBindPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ShowNsxCredentials( @@ -8383,7 +11694,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Call the show nsx credentials method over HTTP. @@ -8394,8 +11705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.Credentials: @@ -8405,6 +11718,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseShowNsxCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_show_nsx_credentials( request, metadata ) @@ -8417,6 +11731,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ShowNsxCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowNsxCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ShowNsxCredentials._get_response( self._host, @@ -8437,7 +11778,31 @@ def __call__( pb_resp = vmwareengine_resources.Credentials.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_show_nsx_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Credentials.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.vmwareengine_v1.VmwareEngineClient.show_nsx_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowNsxCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ShowVcenterCredentials( @@ -8474,7 +11839,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vmwareengine_resources.Credentials: r"""Call the show vcenter credentials method over HTTP. @@ -8485,8 +11850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vmwareengine_resources.Credentials: @@ -8496,6 +11863,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseShowVcenterCredentials._get_http_options() ) + request, metadata = self._interceptor.pre_show_vcenter_credentials( request, metadata ) @@ -8508,6 +11876,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ShowVcenterCredentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowVcenterCredentials", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ShowVcenterCredentials._get_response( self._host, @@ -8528,7 +11923,31 @@ def __call__( pb_resp = vmwareengine_resources.Credentials.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_show_vcenter_credentials(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vmwareengine_resources.Credentials.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.vmwareengine_v1.VmwareEngineClient.show_vcenter_credentials", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ShowVcenterCredentials", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeletePrivateCloud( @@ -8566,7 +11985,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete private cloud method over HTTP. @@ -8577,8 +11996,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8591,6 +12012,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUndeletePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_private_cloud( request, metadata ) @@ -8607,6 +12029,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UndeletePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UndeletePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UndeletePrivateCloud._get_response( self._host, @@ -8626,7 +12075,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_private_cloud(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.vmwareengine_v1.VmwareEngineClient.undelete_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UndeletePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -8664,7 +12135,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -8675,8 +12146,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8689,6 +12162,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -8703,6 +12177,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateCluster._get_response( self._host, @@ -8722,7 +12223,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.vmwareengine_v1.VmwareEngineClient.update_cluster", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDnsForwarding( @@ -8760,7 +12283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update dns forwarding method over HTTP. @@ -8771,8 +12294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8785,6 +12310,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateDnsForwarding._get_http_options() ) + request, metadata = self._interceptor.pre_update_dns_forwarding( request, metadata ) @@ -8801,6 +12327,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateDnsForwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateDnsForwarding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateDnsForwarding._get_response( self._host, @@ -8820,7 +12373,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dns_forwarding(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.vmwareengine_v1.VmwareEngineClient.update_dns_forwarding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateDnsForwarding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalAccessRule( @@ -8859,7 +12434,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update external access rule method over HTTP. @@ -8871,8 +12446,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8885,6 +12462,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateExternalAccessRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_access_rule( request, metadata ) @@ -8901,6 +12479,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateExternalAccessRule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAccessRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateExternalAccessRule._get_response( @@ -8922,7 +12527,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_external_access_rule(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.vmwareengine_v1.VmwareEngineClient.update_external_access_rule", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAccessRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalAddress( @@ -8960,7 +12587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update external address method over HTTP. @@ -8971,8 +12598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -8985,6 +12614,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateExternalAddress._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_address( request, metadata ) @@ -9001,6 +12631,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateExternalAddress", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateExternalAddress._get_response( self._host, @@ -9020,7 +12677,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_external_address(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.vmwareengine_v1.VmwareEngineClient.update_external_address", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateExternalAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateLoggingServer( @@ -9058,7 +12737,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update logging server method over HTTP. @@ -9069,8 +12748,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9083,6 +12764,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateLoggingServer._get_http_options() ) + request, metadata = self._interceptor.pre_update_logging_server( request, metadata ) @@ -9099,6 +12781,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateLoggingServer", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateLoggingServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateLoggingServer._get_response( self._host, @@ -9118,7 +12827,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_logging_server(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.vmwareengine_v1.VmwareEngineClient.update_logging_server", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateLoggingServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateManagementDnsZoneBinding( @@ -9157,7 +12888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update management dns zone binding method over HTTP. @@ -9169,8 +12900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9183,6 +12916,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateManagementDnsZoneBinding._get_http_options() ) + ( request, metadata, @@ -9202,6 +12936,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateManagementDnsZoneBinding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateManagementDnsZoneBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateManagementDnsZoneBinding._get_response( @@ -9223,7 +12984,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_management_dns_zone_binding(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.vmwareengine_v1.VmwareEngineClient.update_management_dns_zone_binding", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateManagementDnsZoneBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetworkPeering( @@ -9261,7 +13044,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update network peering method over HTTP. @@ -9272,8 +13055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9286,6 +13071,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateNetworkPeering._get_http_options() ) + request, metadata = self._interceptor.pre_update_network_peering( request, metadata ) @@ -9302,6 +13088,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateNetworkPeering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateNetworkPeering._get_response( self._host, @@ -9321,7 +13134,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_network_peering(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.vmwareengine_v1.VmwareEngineClient.update_network_peering", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetworkPolicy( @@ -9359,7 +13194,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update network policy method over HTTP. @@ -9370,8 +13205,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9384,6 +13221,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateNetworkPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_update_network_policy( request, metadata ) @@ -9400,6 +13238,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateNetworkPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateNetworkPolicy._get_response( self._host, @@ -9419,7 +13284,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_network_policy(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.vmwareengine_v1.VmwareEngineClient.update_network_policy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateNetworkPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePrivateCloud( @@ -9457,7 +13344,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update private cloud method over HTTP. @@ -9468,8 +13355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9482,6 +13371,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdatePrivateCloud._get_http_options() ) + request, metadata = self._interceptor.pre_update_private_cloud( request, metadata ) @@ -9498,6 +13388,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdatePrivateCloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateCloud", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdatePrivateCloud._get_response( self._host, @@ -9517,7 +13434,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_private_cloud(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.vmwareengine_v1.VmwareEngineClient.update_private_cloud", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateCloud", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePrivateConnection( @@ -9556,7 +13495,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update private connection method over HTTP. @@ -9567,8 +13506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9581,6 +13522,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdatePrivateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_update_private_connection( request, metadata ) @@ -9597,6 +13539,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdatePrivateConnection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdatePrivateConnection._get_response( self._host, @@ -9616,7 +13585,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_private_connection(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.vmwareengine_v1.VmwareEngineClient.update_private_connection", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdatePrivateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSubnet( @@ -9654,7 +13645,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update subnet method over HTTP. @@ -9665,8 +13656,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9679,6 +13672,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateSubnet._get_http_options() ) + request, metadata = self._interceptor.pre_update_subnet(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseUpdateSubnet._get_transcoded_request( http_options, request @@ -9697,6 +13691,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.UpdateSubnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateSubnet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._UpdateSubnet._get_response( self._host, @@ -9716,7 +13737,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_subnet(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.vmwareengine_v1.VmwareEngineClient.update_subnet", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateSubnet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVmwareEngineNetwork( @@ -9755,7 +13798,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update vmware engine network method over HTTP. @@ -9767,8 +13810,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -9781,6 +13826,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseUpdateVmwareEngineNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_update_vmware_engine_network( request, metadata ) @@ -9797,6 +13843,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.UpdateVmwareEngineNetwork", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateVmwareEngineNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( VmwareEngineRestTransport._UpdateVmwareEngineNetwork._get_response( @@ -9818,7 +13891,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_vmware_engine_network(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.vmwareengine_v1.VmwareEngineClient.update_vmware_engine_network", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "UpdateVmwareEngineNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -10566,7 +14661,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -10576,8 +14671,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -10586,6 +14683,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVmwareEngineRestTransport._BaseGetLocation._get_transcoded_request( @@ -10600,6 +14698,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetLocation._get_response( self._host, @@ -10619,6 +14744,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.vmwareengine_v1.VmwareEngineAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10659,7 +14805,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -10669,8 +14815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -10679,6 +14827,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -10689,6 +14838,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListLocations._get_response( self._host, @@ -10708,6 +14884,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.vmwareengine_v1.VmwareEngineAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10748,7 +14945,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -10758,8 +14955,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -10768,6 +14967,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -10780,6 +14980,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetIamPolicy._get_response( self._host, @@ -10799,6 +15026,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.vmwareengine_v1.VmwareEngineAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10840,7 +15088,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -10850,8 +15098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -10860,6 +15110,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -10878,6 +15129,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._SetIamPolicy._get_response( self._host, @@ -10898,6 +15176,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.vmwareengine_v1.VmwareEngineAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -10939,7 +15238,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -10949,8 +15248,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -10959,6 +15260,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -10975,6 +15277,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._TestIamPermissions._get_response( self._host, @@ -10995,6 +15324,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.vmwareengine_v1.VmwareEngineAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -11035,7 +15385,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -11045,13 +15395,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseVmwareEngineRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -11064,6 +15417,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._DeleteOperation._get_response( self._host, @@ -11119,7 +15499,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -11129,8 +15509,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -11139,6 +15521,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -11151,6 +15534,33 @@ def __call__( ) ) + 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.vmwareengine_v1.VmwareEngineClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._GetOperation._get_response( self._host, @@ -11170,6 +15580,27 @@ def __call__( 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.vmwareengine_v1.VmwareEngineAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -11210,7 +15641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -11220,8 +15651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -11230,6 +15663,7 @@ def __call__( http_options = ( _BaseVmwareEngineRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVmwareEngineRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -11240,6 +15674,33 @@ def __call__( 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.vmwareengine_v1.VmwareEngineClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VmwareEngineRestTransport._ListOperations._get_response( self._host, @@ -11259,6 +15720,27 @@ def __call__( 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.vmwareengine_v1.VmwareEngineAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vmwareengine.v1.VmwareEngine", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json index 988355f12a51..6d234586a410 100644 --- a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json +++ b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vmwareengine", - "version": "1.6.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -674,7 +674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -851,7 +851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1028,7 +1028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1205,7 +1205,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1382,7 +1382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1471,7 +1471,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1559,7 +1559,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1648,7 +1648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1736,7 +1736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1825,7 +1825,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1913,7 +1913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1994,7 +1994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2074,7 +2074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2155,7 +2155,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2235,7 +2235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2316,7 +2316,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2396,7 +2396,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2477,7 +2477,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2557,7 +2557,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2638,7 +2638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2718,7 +2718,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2799,7 +2799,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2879,7 +2879,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2960,7 +2960,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3040,7 +3040,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3121,7 +3121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3201,7 +3201,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3282,7 +3282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3362,7 +3362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3443,7 +3443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3523,7 +3523,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3604,7 +3604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesAsyncPager", @@ -3684,7 +3684,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.FetchNetworkPolicyExternalAddressesPager", @@ -3765,7 +3765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Cluster", @@ -3845,7 +3845,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Cluster", @@ -3926,7 +3926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsBindPermission", @@ -4006,7 +4006,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsBindPermission", @@ -4087,7 +4087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsForwarding", @@ -4167,7 +4167,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.DnsForwarding", @@ -4248,7 +4248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAccessRule", @@ -4328,7 +4328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAccessRule", @@ -4409,7 +4409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAddress", @@ -4489,7 +4489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ExternalAddress", @@ -4570,7 +4570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.HcxActivationKey", @@ -4650,7 +4650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.HcxActivationKey", @@ -4731,7 +4731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.LoggingServer", @@ -4811,7 +4811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.LoggingServer", @@ -4892,7 +4892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding", @@ -4972,7 +4972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.ManagementDnsZoneBinding", @@ -5053,7 +5053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPeering", @@ -5133,7 +5133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPeering", @@ -5214,7 +5214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPolicy", @@ -5294,7 +5294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NetworkPolicy", @@ -5375,7 +5375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NodeType", @@ -5455,7 +5455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.NodeType", @@ -5536,7 +5536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Node", @@ -5616,7 +5616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Node", @@ -5697,7 +5697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateCloud", @@ -5777,7 +5777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateCloud", @@ -5858,7 +5858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateConnection", @@ -5938,7 +5938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.PrivateConnection", @@ -6019,7 +6019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Subnet", @@ -6099,7 +6099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Subnet", @@ -6180,7 +6180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.VmwareEngineNetwork", @@ -6260,7 +6260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.VmwareEngineNetwork", @@ -6345,7 +6345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6429,7 +6429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6510,7 +6510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersAsyncPager", @@ -6590,7 +6590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListClustersPager", @@ -6671,7 +6671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesAsyncPager", @@ -6751,7 +6751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAccessRulesPager", @@ -6832,7 +6832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesAsyncPager", @@ -6912,7 +6912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListExternalAddressesPager", @@ -6993,7 +6993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysAsyncPager", @@ -7073,7 +7073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListHcxActivationKeysPager", @@ -7154,7 +7154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersAsyncPager", @@ -7234,7 +7234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListLoggingServersPager", @@ -7315,7 +7315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsAsyncPager", @@ -7395,7 +7395,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListManagementDnsZoneBindingsPager", @@ -7476,7 +7476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsAsyncPager", @@ -7556,7 +7556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPeeringsPager", @@ -7637,7 +7637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesAsyncPager", @@ -7717,7 +7717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNetworkPoliciesPager", @@ -7798,7 +7798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesAsyncPager", @@ -7878,7 +7878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodeTypesPager", @@ -7959,7 +7959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesAsyncPager", @@ -8039,7 +8039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListNodesPager", @@ -8120,7 +8120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesAsyncPager", @@ -8200,7 +8200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPeeringRoutesPager", @@ -8281,7 +8281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsAsyncPager", @@ -8361,7 +8361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateCloudsPager", @@ -8442,7 +8442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesAsyncPager", @@ -8522,7 +8522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionPeeringRoutesPager", @@ -8603,7 +8603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsAsyncPager", @@ -8683,7 +8683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListPrivateConnectionsPager", @@ -8764,7 +8764,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsAsyncPager", @@ -8844,7 +8844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListSubnetsPager", @@ -8925,7 +8925,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksAsyncPager", @@ -9005,7 +9005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.services.vmware_engine.pagers.ListVmwareEngineNetworksPager", @@ -9086,7 +9086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9166,7 +9166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9247,7 +9247,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9327,7 +9327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9408,7 +9408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9488,7 +9488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9573,7 +9573,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9657,7 +9657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9738,7 +9738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9818,7 +9818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9899,7 +9899,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -9979,7 +9979,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vmwareengine_v1.types.Credentials", @@ -10060,7 +10060,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10140,7 +10140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10225,7 +10225,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10309,7 +10309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10394,7 +10394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10478,7 +10478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10563,7 +10563,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10647,7 +10647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10732,7 +10732,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10816,7 +10816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10901,7 +10901,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10985,7 +10985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11070,7 +11070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11154,7 +11154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11239,7 +11239,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11323,7 +11323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11408,7 +11408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11492,7 +11492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11577,7 +11577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11661,7 +11661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11746,7 +11746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11830,7 +11830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11915,7 +11915,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11999,7 +11999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -12084,7 +12084,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -12168,7 +12168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py index c803626d8bd6..8ed7826f3a23 100644 --- a/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py +++ b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py @@ -30931,6 +30931,7 @@ def test_list_private_clouds_rest_required_fields( response_value._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_private_clouds(request) @@ -30986,6 +30987,7 @@ def test_list_private_clouds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_clouds(**mock_args) @@ -31182,6 +31184,7 @@ def test_get_private_cloud_rest_required_fields( response_value._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_private_cloud(request) @@ -31229,6 +31232,7 @@ def test_get_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_cloud(**mock_args) @@ -31381,6 +31385,7 @@ def test_create_private_cloud_rest_required_fields( response_value._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_private_cloud(request) @@ -31447,6 +31452,7 @@ def test_create_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_cloud(**mock_args) @@ -31588,6 +31594,7 @@ def test_update_private_cloud_rest_required_fields( response_value._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_private_cloud(request) @@ -31649,6 +31656,7 @@ def test_update_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_cloud(**mock_args) @@ -31794,6 +31802,7 @@ def test_delete_private_cloud_rest_required_fields( response_value._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_private_cloud(request) @@ -31848,6 +31857,7 @@ def test_delete_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_cloud(**mock_args) @@ -31986,6 +31996,7 @@ def test_undelete_private_cloud_rest_required_fields( response_value._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.undelete_private_cloud(request) @@ -32031,6 +32042,7 @@ def test_undelete_private_cloud_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_private_cloud(**mock_args) @@ -32171,6 +32183,7 @@ def test_list_clusters_rest_required_fields( response_value._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_clusters(request) @@ -32228,6 +32241,7 @@ def test_list_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clusters(**mock_args) @@ -32420,6 +32434,7 @@ def test_get_cluster_rest_required_fields(request_type=vmwareengine.GetClusterRe response_value._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_cluster(request) @@ -32467,6 +32482,7 @@ def test_get_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -32615,6 +32631,7 @@ def test_create_cluster_rest_required_fields( response_value._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_cluster(request) @@ -32683,6 +32700,7 @@ def test_create_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -32821,6 +32839,7 @@ def test_update_cluster_rest_required_fields( response_value._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_cluster(request) @@ -32883,6 +32902,7 @@ def test_update_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -33018,6 +33038,7 @@ def test_delete_cluster_rest_required_fields( response_value._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_cluster(request) @@ -33063,6 +33084,7 @@ def test_delete_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -33199,6 +33221,7 @@ def test_list_nodes_rest_required_fields(request_type=vmwareengine.ListNodesRequ response_value._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_nodes(request) @@ -33254,6 +33277,7 @@ def test_list_nodes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_nodes(**mock_args) @@ -33446,6 +33470,7 @@ def test_get_node_rest_required_fields(request_type=vmwareengine.GetNodeRequest) response_value._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_node(request) @@ -33493,6 +33518,7 @@ def test_get_node_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node(**mock_args) @@ -33638,6 +33664,7 @@ def test_list_external_addresses_rest_required_fields( response_value._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_external_addresses(request) @@ -33695,6 +33722,7 @@ def test_list_external_addresses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_addresses(**mock_args) @@ -33911,6 +33939,7 @@ def test_fetch_network_policy_external_addresses_rest_required_fields( response_value._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.fetch_network_policy_external_addresses(request) @@ -33970,6 +33999,7 @@ def test_fetch_network_policy_external_addresses_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.fetch_network_policy_external_addresses(**mock_args) @@ -34177,6 +34207,7 @@ def test_get_external_address_rest_required_fields( response_value._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_external_address(request) @@ -34224,6 +34255,7 @@ def test_get_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_address(**mock_args) @@ -34376,6 +34408,7 @@ def test_create_external_address_rest_required_fields( response_value._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_external_address(request) @@ -34443,6 +34476,7 @@ def test_create_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_address(**mock_args) @@ -34585,6 +34619,7 @@ def test_update_external_address_rest_required_fields( response_value._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_external_address(request) @@ -34646,6 +34681,7 @@ def test_update_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_address(**mock_args) @@ -34786,6 +34822,7 @@ def test_delete_external_address_rest_required_fields( response_value._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_external_address(request) @@ -34831,6 +34868,7 @@ def test_delete_external_address_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_address(**mock_args) @@ -34969,6 +35007,7 @@ def test_list_subnets_rest_required_fields( response_value._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_subnets(request) @@ -35024,6 +35063,7 @@ def test_list_subnets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_subnets(**mock_args) @@ -35216,6 +35256,7 @@ def test_get_subnet_rest_required_fields(request_type=vmwareengine.GetSubnetRequ response_value._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_subnet(request) @@ -35263,6 +35304,7 @@ def test_get_subnet_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_subnet(**mock_args) @@ -35393,6 +35435,7 @@ def test_update_subnet_rest_required_fields( response_value._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_subnet(request) @@ -35449,6 +35492,7 @@ def test_update_subnet_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_subnet(**mock_args) @@ -35595,6 +35639,7 @@ def test_list_external_access_rules_rest_required_fields( response_value._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_external_access_rules(request) @@ -35652,6 +35697,7 @@ def test_list_external_access_rules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_access_rules(**mock_args) @@ -35855,6 +35901,7 @@ def test_get_external_access_rule_rest_required_fields( response_value._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_external_access_rule(request) @@ -35902,6 +35949,7 @@ def test_get_external_access_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_access_rule(**mock_args) @@ -36057,6 +36105,7 @@ def test_create_external_access_rule_rest_required_fields( response_value._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_external_access_rule(request) @@ -36126,6 +36175,7 @@ def test_create_external_access_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_access_rule(**mock_args) @@ -36270,6 +36320,7 @@ def test_update_external_access_rule_rest_required_fields( response_value._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_external_access_rule(request) @@ -36333,6 +36384,7 @@ def test_update_external_access_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_access_rule(**mock_args) @@ -36475,6 +36527,7 @@ def test_delete_external_access_rule_rest_required_fields( response_value._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_external_access_rule(request) @@ -36520,6 +36573,7 @@ def test_delete_external_access_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_access_rule(**mock_args) @@ -36664,6 +36718,7 @@ def test_list_logging_servers_rest_required_fields( response_value._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_logging_servers(request) @@ -36721,6 +36776,7 @@ def test_list_logging_servers_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_servers(**mock_args) @@ -36921,6 +36977,7 @@ def test_get_logging_server_rest_required_fields( response_value._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_logging_server(request) @@ -36968,6 +37025,7 @@ def test_get_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_server(**mock_args) @@ -37120,6 +37178,7 @@ def test_create_logging_server_rest_required_fields( response_value._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_logging_server(request) @@ -37187,6 +37246,7 @@ def test_create_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_server(**mock_args) @@ -37329,6 +37389,7 @@ def test_update_logging_server_rest_required_fields( response_value._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_logging_server(request) @@ -37390,6 +37451,7 @@ def test_update_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_server(**mock_args) @@ -37530,6 +37592,7 @@ def test_delete_logging_server_rest_required_fields( response_value._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_logging_server(request) @@ -37575,6 +37638,7 @@ def test_delete_logging_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_server(**mock_args) @@ -37714,6 +37778,7 @@ def test_list_node_types_rest_required_fields( response_value._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_node_types(request) @@ -37768,6 +37833,7 @@ def test_list_node_types_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node_types(**mock_args) @@ -37961,6 +38027,7 @@ def test_get_node_type_rest_required_fields( response_value._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_node_type(request) @@ -38008,6 +38075,7 @@ def test_get_node_type_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_node_type(**mock_args) @@ -38142,6 +38210,7 @@ def test_show_nsx_credentials_rest_required_fields( response_value._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.show_nsx_credentials(request) @@ -38189,6 +38258,7 @@ def test_show_nsx_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.show_nsx_credentials(**mock_args) @@ -38327,6 +38397,7 @@ def test_show_vcenter_credentials_rest_required_fields( response_value._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.show_vcenter_credentials(request) @@ -38374,6 +38445,7 @@ def test_show_vcenter_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.show_vcenter_credentials(**mock_args) @@ -38512,6 +38584,7 @@ def test_reset_nsx_credentials_rest_required_fields( response_value._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.reset_nsx_credentials(request) @@ -38557,6 +38630,7 @@ def test_reset_nsx_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reset_nsx_credentials(**mock_args) @@ -38695,6 +38769,7 @@ def test_reset_vcenter_credentials_rest_required_fields( response_value._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.reset_vcenter_credentials(request) @@ -38740,6 +38815,7 @@ def test_reset_vcenter_credentials_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reset_vcenter_credentials(**mock_args) @@ -38875,6 +38951,7 @@ def test_get_dns_forwarding_rest_required_fields( response_value._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_dns_forwarding(request) @@ -38922,6 +38999,7 @@ def test_get_dns_forwarding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dns_forwarding(**mock_args) @@ -39062,6 +39140,7 @@ def test_update_dns_forwarding_rest_required_fields( response_value._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_dns_forwarding(request) @@ -39123,6 +39202,7 @@ def test_update_dns_forwarding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dns_forwarding(**mock_args) @@ -39259,6 +39339,7 @@ def test_get_network_peering_rest_required_fields( response_value._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_network_peering(request) @@ -39306,6 +39387,7 @@ def test_get_network_peering_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_peering(**mock_args) @@ -39451,6 +39533,7 @@ def test_list_network_peerings_rest_required_fields( response_value._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_network_peerings(request) @@ -39506,6 +39589,7 @@ def test_list_network_peerings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_peerings(**mock_args) @@ -39723,6 +39807,7 @@ def test_create_network_peering_rest_required_fields( response_value._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_network_peering(request) @@ -39788,6 +39873,7 @@ def test_create_network_peering_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_peering(**mock_args) @@ -39929,6 +40015,7 @@ def test_delete_network_peering_rest_required_fields( response_value._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_network_peering(request) @@ -39974,6 +40061,7 @@ def test_delete_network_peering_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_peering(**mock_args) @@ -40114,6 +40202,7 @@ def test_update_network_peering_rest_required_fields( response_value._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_network_peering(request) @@ -40175,6 +40264,7 @@ def test_update_network_peering_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_peering(**mock_args) @@ -40319,6 +40409,7 @@ def test_list_peering_routes_rest_required_fields( response_value._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_peering_routes(request) @@ -40375,6 +40466,7 @@ def test_list_peering_routes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_peering_routes(**mock_args) @@ -40594,6 +40686,7 @@ def test_create_hcx_activation_key_rest_required_fields( response_value._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_hcx_activation_key(request) @@ -40663,6 +40756,7 @@ def test_create_hcx_activation_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hcx_activation_key(**mock_args) @@ -40810,6 +40904,7 @@ def test_list_hcx_activation_keys_rest_required_fields( response_value._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_hcx_activation_keys(request) @@ -40865,6 +40960,7 @@ def test_list_hcx_activation_keys_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hcx_activation_keys(**mock_args) @@ -41068,6 +41164,7 @@ def test_get_hcx_activation_key_rest_required_fields( response_value._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_hcx_activation_key(request) @@ -41115,6 +41212,7 @@ def test_get_hcx_activation_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hcx_activation_key(**mock_args) @@ -41250,6 +41348,7 @@ def test_get_network_policy_rest_required_fields( response_value._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_network_policy(request) @@ -41297,6 +41396,7 @@ def test_get_network_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_policy(**mock_args) @@ -41442,6 +41542,7 @@ def test_list_network_policies_rest_required_fields( response_value._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_network_policies(request) @@ -41497,6 +41598,7 @@ def test_list_network_policies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_policies(**mock_args) @@ -41712,6 +41814,7 @@ def test_create_network_policy_rest_required_fields( response_value._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_network_policy(request) @@ -41777,6 +41880,7 @@ def test_create_network_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_policy(**mock_args) @@ -41919,6 +42023,7 @@ def test_update_network_policy_rest_required_fields( response_value._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_network_policy(request) @@ -41980,6 +42085,7 @@ def test_update_network_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_policy(**mock_args) @@ -42120,6 +42226,7 @@ def test_delete_network_policy_rest_required_fields( response_value._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_network_policy(request) @@ -42165,6 +42272,7 @@ def test_delete_network_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_network_policy(**mock_args) @@ -42312,6 +42420,7 @@ def test_list_management_dns_zone_bindings_rest_required_fields( response_value._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_management_dns_zone_bindings(request) @@ -42373,6 +42482,7 @@ def test_list_management_dns_zone_bindings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_management_dns_zone_bindings(**mock_args) @@ -42584,6 +42694,7 @@ def test_get_management_dns_zone_binding_rest_required_fields( response_value._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_management_dns_zone_binding(request) @@ -42633,6 +42744,7 @@ def test_get_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_management_dns_zone_binding(**mock_args) @@ -42793,6 +42905,7 @@ def test_create_management_dns_zone_binding_rest_required_fields( response_value._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_management_dns_zone_binding(request) @@ -42864,6 +42977,7 @@ def test_create_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_management_dns_zone_binding(**mock_args) @@ -43010,6 +43124,7 @@ def test_update_management_dns_zone_binding_rest_required_fields( response_value._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_management_dns_zone_binding(request) @@ -43075,6 +43190,7 @@ def test_update_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_management_dns_zone_binding(**mock_args) @@ -43219,6 +43335,7 @@ def test_delete_management_dns_zone_binding_rest_required_fields( response_value._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_management_dns_zone_binding(request) @@ -43266,6 +43383,7 @@ def test_delete_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_management_dns_zone_binding(**mock_args) @@ -43406,6 +43524,7 @@ def test_repair_management_dns_zone_binding_rest_required_fields( response_value._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.repair_management_dns_zone_binding(request) @@ -43453,6 +43572,7 @@ def test_repair_management_dns_zone_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.repair_management_dns_zone_binding(**mock_args) @@ -43612,6 +43732,7 @@ def test_create_vmware_engine_network_rest_required_fields( response_value._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_vmware_engine_network(request) @@ -43679,6 +43800,7 @@ def test_create_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vmware_engine_network(**mock_args) @@ -43823,6 +43945,7 @@ def test_update_vmware_engine_network_rest_required_fields( response_value._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_vmware_engine_network(request) @@ -43886,6 +44009,7 @@ def test_update_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vmware_engine_network(**mock_args) @@ -44033,6 +44157,7 @@ def test_delete_vmware_engine_network_rest_required_fields( response_value._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_vmware_engine_network(request) @@ -44086,6 +44211,7 @@ def test_delete_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vmware_engine_network(**mock_args) @@ -44222,6 +44348,7 @@ def test_get_vmware_engine_network_rest_required_fields( response_value._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_vmware_engine_network(request) @@ -44269,6 +44396,7 @@ def test_get_vmware_engine_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vmware_engine_network(**mock_args) @@ -44416,6 +44544,7 @@ def test_list_vmware_engine_networks_rest_required_fields( response_value._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_vmware_engine_networks(request) @@ -44471,6 +44600,7 @@ def test_list_vmware_engine_networks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vmware_engine_networks(**mock_args) @@ -44691,6 +44821,7 @@ def test_create_private_connection_rest_required_fields( response_value._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_private_connection(request) @@ -44758,6 +44889,7 @@ def test_create_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connection(**mock_args) @@ -44898,6 +45030,7 @@ def test_get_private_connection_rest_required_fields( response_value._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_private_connection(request) @@ -44945,6 +45078,7 @@ def test_get_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connection(**mock_args) @@ -45090,6 +45224,7 @@ def test_list_private_connections_rest_required_fields( response_value._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_private_connections(request) @@ -45145,6 +45280,7 @@ def test_list_private_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connections(**mock_args) @@ -45350,6 +45486,7 @@ def test_update_private_connection_rest_required_fields( response_value._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_private_connection(request) @@ -45413,6 +45550,7 @@ def test_update_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connection(**mock_args) @@ -45555,6 +45693,7 @@ def test_delete_private_connection_rest_required_fields( response_value._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_private_connection(request) @@ -45600,6 +45739,7 @@ def test_delete_private_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connection(**mock_args) @@ -45749,6 +45889,7 @@ def test_list_private_connection_peering_routes_rest_required_fields( response_value._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_private_connection_peering_routes(request) @@ -45808,6 +45949,7 @@ def test_list_private_connection_peering_routes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_private_connection_peering_routes(**mock_args) @@ -46016,6 +46158,7 @@ def test_grant_dns_bind_permission_rest_required_fields( response_value._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.grant_dns_bind_permission(request) @@ -46070,6 +46213,7 @@ def test_grant_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.grant_dns_bind_permission(**mock_args) @@ -46207,6 +46351,7 @@ def test_get_dns_bind_permission_rest_required_fields( response_value._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_dns_bind_permission(request) @@ -46254,6 +46399,7 @@ def test_get_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_dns_bind_permission(**mock_args) @@ -46392,6 +46538,7 @@ def test_revoke_dns_bind_permission_rest_required_fields( response_value._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.revoke_dns_bind_permission(request) @@ -46446,6 +46593,7 @@ def test_revoke_dns_bind_permission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.revoke_dns_bind_permission(**mock_args) @@ -50448,6 +50596,7 @@ def test_list_private_clouds_rest_bad_request( 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_private_clouds(request) @@ -50484,6 +50633,7 @@ def test_list_private_clouds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_clouds(request) # Establish that the response is the type that we expect. @@ -50525,6 +50675,7 @@ def test_list_private_clouds_rest_interceptors(null_interceptor): 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 = vmwareengine.ListPrivateCloudsResponse.to_json( vmwareengine.ListPrivateCloudsResponse() ) @@ -50571,6 +50722,7 @@ def test_get_private_cloud_rest_bad_request( 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_private_cloud(request) @@ -50610,6 +50762,7 @@ def test_get_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_cloud(request) # Establish that the response is the type that we expect. @@ -50654,6 +50807,7 @@ def test_get_private_cloud_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.PrivateCloud.to_json( vmwareengine_resources.PrivateCloud() ) @@ -50700,6 +50854,7 @@ def test_create_private_cloud_rest_bad_request( 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_private_cloud(request) @@ -50841,6 +50996,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_cloud(request) # Establish that the response is the type that we expect. @@ -50882,6 +51038,7 @@ def test_create_private_cloud_rest_interceptors(null_interceptor): 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 @@ -50930,6 +51087,7 @@ def test_update_private_cloud_rest_bad_request( 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_private_cloud(request) @@ -51075,6 +51233,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_cloud(request) # Establish that the response is the type that we expect. @@ -51116,6 +51275,7 @@ def test_update_private_cloud_rest_interceptors(null_interceptor): 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 @@ -51160,6 +51320,7 @@ def test_delete_private_cloud_rest_bad_request( 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_private_cloud(request) @@ -51190,6 +51351,7 @@ def test_delete_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_cloud(request) # Establish that the response is the type that we expect. @@ -51231,6 +51393,7 @@ def test_delete_private_cloud_rest_interceptors(null_interceptor): 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 @@ -51275,6 +51438,7 @@ def test_undelete_private_cloud_rest_bad_request( 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.undelete_private_cloud(request) @@ -51305,6 +51469,7 @@ def test_undelete_private_cloud_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_private_cloud(request) # Establish that the response is the type that we expect. @@ -51346,6 +51511,7 @@ def test_undelete_private_cloud_rest_interceptors(null_interceptor): 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 @@ -51390,6 +51556,7 @@ def test_list_clusters_rest_bad_request(request_type=vmwareengine.ListClustersRe 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_clusters(request) @@ -51428,6 +51595,7 @@ def test_list_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clusters(request) # Establish that the response is the type that we expect. @@ -51469,6 +51637,7 @@ def test_list_clusters_rest_interceptors(null_interceptor): 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 = vmwareengine.ListClustersResponse.to_json( vmwareengine.ListClustersResponse() ) @@ -51515,6 +51684,7 @@ def test_get_cluster_rest_bad_request(request_type=vmwareengine.GetClusterReques 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_cluster(request) @@ -51555,6 +51725,7 @@ def test_get_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -51596,6 +51767,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.Cluster.to_json( vmwareengine_resources.Cluster() ) @@ -51644,6 +51816,7 @@ def test_create_cluster_rest_bad_request( 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_cluster(request) @@ -51762,6 +51935,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -51803,6 +51977,7 @@ def test_create_cluster_rest_interceptors(null_interceptor): 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 @@ -51851,6 +52026,7 @@ def test_update_cluster_rest_bad_request( 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_cluster(request) @@ -51971,6 +52147,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -52012,6 +52189,7 @@ def test_update_cluster_rest_interceptors(null_interceptor): 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 @@ -52058,6 +52236,7 @@ def test_delete_cluster_rest_bad_request( 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_cluster(request) @@ -52090,6 +52269,7 @@ def test_delete_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -52131,6 +52311,7 @@ def test_delete_cluster_rest_interceptors(null_interceptor): 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 @@ -52175,6 +52356,7 @@ def test_list_nodes_rest_bad_request(request_type=vmwareengine.ListNodesRequest) 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_nodes(request) @@ -52212,6 +52394,7 @@ def test_list_nodes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_nodes(request) # Establish that the response is the type that we expect. @@ -52250,6 +52433,7 @@ def test_list_nodes_rest_interceptors(null_interceptor): 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 = vmwareengine.ListNodesResponse.to_json( vmwareengine.ListNodesResponse() ) @@ -52296,6 +52480,7 @@ def test_get_node_rest_bad_request(request_type=vmwareengine.GetNodeRequest): 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_node(request) @@ -52339,6 +52524,7 @@ def test_get_node_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_node(request) # Establish that the response is the type that we expect. @@ -52383,6 +52569,7 @@ def test_get_node_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.Node.to_json( vmwareengine_resources.Node() ) @@ -52431,6 +52618,7 @@ def test_list_external_addresses_rest_bad_request( 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_external_addresses(request) @@ -52469,6 +52657,7 @@ def test_list_external_addresses_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_addresses(request) # Establish that the response is the type that we expect. @@ -52510,6 +52699,7 @@ def test_list_external_addresses_rest_interceptors(null_interceptor): 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 = vmwareengine.ListExternalAddressesResponse.to_json( vmwareengine.ListExternalAddressesResponse() ) @@ -52558,6 +52748,7 @@ def test_fetch_network_policy_external_addresses_rest_bad_request( 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.fetch_network_policy_external_addresses(request) @@ -52597,6 +52788,7 @@ def test_fetch_network_policy_external_addresses_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.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.fetch_network_policy_external_addresses(request) # Establish that the response is the type that we expect. @@ -52639,6 +52831,7 @@ def test_fetch_network_policy_external_addresses_rest_interceptors(null_intercep 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 = vmwareengine.FetchNetworkPolicyExternalAddressesResponse.to_json( vmwareengine.FetchNetworkPolicyExternalAddressesResponse() ) @@ -52687,6 +52880,7 @@ def test_get_external_address_rest_bad_request( 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_external_address(request) @@ -52729,6 +52923,7 @@ def test_get_external_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_address(request) # Establish that the response is the type that we expect. @@ -52774,6 +52969,7 @@ def test_get_external_address_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.ExternalAddress.to_json( vmwareengine_resources.ExternalAddress() ) @@ -52822,6 +53018,7 @@ def test_create_external_address_rest_bad_request( 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_external_address(request) @@ -52933,6 +53130,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_address(request) # Establish that the response is the type that we expect. @@ -52974,6 +53172,7 @@ def test_create_external_address_rest_interceptors(null_interceptor): 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 @@ -53022,6 +53221,7 @@ def test_update_external_address_rest_bad_request( 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_external_address(request) @@ -53135,6 +53335,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_address(request) # Establish that the response is the type that we expect. @@ -53176,6 +53377,7 @@ def test_update_external_address_rest_interceptors(null_interceptor): 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 @@ -53222,6 +53424,7 @@ def test_delete_external_address_rest_bad_request( 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_external_address(request) @@ -53254,6 +53457,7 @@ def test_delete_external_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_address(request) # Establish that the response is the type that we expect. @@ -53295,6 +53499,7 @@ def test_delete_external_address_rest_interceptors(null_interceptor): 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 @@ -53339,6 +53544,7 @@ def test_list_subnets_rest_bad_request(request_type=vmwareengine.ListSubnetsRequ 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_subnets(request) @@ -53377,6 +53583,7 @@ def test_list_subnets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_subnets(request) # Establish that the response is the type that we expect. @@ -53418,6 +53625,7 @@ def test_list_subnets_rest_interceptors(null_interceptor): 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 = vmwareengine.ListSubnetsResponse.to_json( vmwareengine.ListSubnetsResponse() ) @@ -53464,6 +53672,7 @@ def test_get_subnet_rest_bad_request(request_type=vmwareengine.GetSubnetRequest) 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_subnet(request) @@ -53506,6 +53715,7 @@ def test_get_subnet_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_subnet(request) # Establish that the response is the type that we expect. @@ -53549,6 +53759,7 @@ def test_get_subnet_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.Subnet.to_json( vmwareengine_resources.Subnet() ) @@ -53597,6 +53808,7 @@ def test_update_subnet_rest_bad_request(request_type=vmwareengine.UpdateSubnetRe 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_subnet(request) @@ -53706,6 +53918,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_subnet(request) # Establish that the response is the type that we expect. @@ -53747,6 +53960,7 @@ def test_update_subnet_rest_interceptors(null_interceptor): 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 @@ -53793,6 +54007,7 @@ def test_list_external_access_rules_rest_bad_request( 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_external_access_rules(request) @@ -53831,6 +54046,7 @@ def test_list_external_access_rules_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_access_rules(request) # Establish that the response is the type that we expect. @@ -53872,6 +54088,7 @@ def test_list_external_access_rules_rest_interceptors(null_interceptor): 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 = vmwareengine.ListExternalAccessRulesResponse.to_json( vmwareengine.ListExternalAccessRulesResponse() ) @@ -53920,6 +54137,7 @@ def test_get_external_access_rule_rest_bad_request( 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_external_access_rule(request) @@ -53965,6 +54183,7 @@ def test_get_external_access_rule_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54013,6 +54232,7 @@ def test_get_external_access_rule_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.ExternalAccessRule.to_json( vmwareengine_resources.ExternalAccessRule() ) @@ -54061,6 +54281,7 @@ def test_create_external_access_rule_rest_bad_request( 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_external_access_rule(request) @@ -54185,6 +54406,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54226,6 +54448,7 @@ def test_create_external_access_rule_rest_interceptors(null_interceptor): 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 @@ -54274,6 +54497,7 @@ def test_update_external_access_rule_rest_bad_request( 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_external_access_rule(request) @@ -54400,6 +54624,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54441,6 +54666,7 @@ def test_update_external_access_rule_rest_interceptors(null_interceptor): 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 @@ -54487,6 +54713,7 @@ def test_delete_external_access_rule_rest_bad_request( 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_external_access_rule(request) @@ -54519,6 +54746,7 @@ def test_delete_external_access_rule_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_access_rule(request) # Establish that the response is the type that we expect. @@ -54560,6 +54788,7 @@ def test_delete_external_access_rule_rest_interceptors(null_interceptor): 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 @@ -54606,6 +54835,7 @@ def test_list_logging_servers_rest_bad_request( 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_logging_servers(request) @@ -54644,6 +54874,7 @@ def test_list_logging_servers_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_servers(request) # Establish that the response is the type that we expect. @@ -54685,6 +54916,7 @@ def test_list_logging_servers_rest_interceptors(null_interceptor): 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 = vmwareengine.ListLoggingServersResponse.to_json( vmwareengine.ListLoggingServersResponse() ) @@ -54733,6 +54965,7 @@ def test_get_logging_server_rest_bad_request( 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_logging_server(request) @@ -54775,6 +55008,7 @@ def test_get_logging_server_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_server(request) # Establish that the response is the type that we expect. @@ -54820,6 +55054,7 @@ def test_get_logging_server_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.LoggingServer.to_json( vmwareengine_resources.LoggingServer() ) @@ -54868,6 +55103,7 @@ def test_create_logging_server_rest_bad_request( 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_logging_server(request) @@ -54977,6 +55213,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_server(request) # Establish that the response is the type that we expect. @@ -55018,6 +55255,7 @@ def test_create_logging_server_rest_interceptors(null_interceptor): 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 @@ -55066,6 +55304,7 @@ def test_update_logging_server_rest_bad_request( 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_logging_server(request) @@ -55177,6 +55416,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_server(request) # Establish that the response is the type that we expect. @@ -55218,6 +55458,7 @@ def test_update_logging_server_rest_interceptors(null_interceptor): 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 @@ -55264,6 +55505,7 @@ def test_delete_logging_server_rest_bad_request( 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_logging_server(request) @@ -55296,6 +55538,7 @@ def test_delete_logging_server_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_server(request) # Establish that the response is the type that we expect. @@ -55337,6 +55580,7 @@ def test_delete_logging_server_rest_interceptors(null_interceptor): 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 @@ -55381,6 +55625,7 @@ def test_list_node_types_rest_bad_request( 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_node_types(request) @@ -55417,6 +55662,7 @@ def test_list_node_types_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_node_types(request) # Establish that the response is the type that we expect. @@ -55458,6 +55704,7 @@ def test_list_node_types_rest_interceptors(null_interceptor): 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 = vmwareengine.ListNodeTypesResponse.to_json( vmwareengine.ListNodeTypesResponse() ) @@ -55502,6 +55749,7 @@ def test_get_node_type_rest_bad_request(request_type=vmwareengine.GetNodeTypeReq 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_node_type(request) @@ -55549,6 +55797,7 @@ def test_get_node_type_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_node_type(request) # Establish that the response is the type that we expect. @@ -55601,6 +55850,7 @@ def test_get_node_type_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.NodeType.to_json( vmwareengine_resources.NodeType() ) @@ -55649,6 +55899,7 @@ def test_show_nsx_credentials_rest_bad_request( 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.show_nsx_credentials(request) @@ -55687,6 +55938,7 @@ def test_show_nsx_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.show_nsx_credentials(request) # Establish that the response is the type that we expect. @@ -55728,6 +55980,7 @@ def test_show_nsx_credentials_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.Credentials.to_json( vmwareengine_resources.Credentials() ) @@ -55776,6 +56029,7 @@ def test_show_vcenter_credentials_rest_bad_request( 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.show_vcenter_credentials(request) @@ -55814,6 +56068,7 @@ def test_show_vcenter_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.show_vcenter_credentials(request) # Establish that the response is the type that we expect. @@ -55855,6 +56110,7 @@ def test_show_vcenter_credentials_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.Credentials.to_json( vmwareengine_resources.Credentials() ) @@ -55903,6 +56159,7 @@ def test_reset_nsx_credentials_rest_bad_request( 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.reset_nsx_credentials(request) @@ -55935,6 +56192,7 @@ def test_reset_nsx_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reset_nsx_credentials(request) # Establish that the response is the type that we expect. @@ -55976,6 +56234,7 @@ def test_reset_nsx_credentials_rest_interceptors(null_interceptor): 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 @@ -56022,6 +56281,7 @@ def test_reset_vcenter_credentials_rest_bad_request( 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.reset_vcenter_credentials(request) @@ -56054,6 +56314,7 @@ def test_reset_vcenter_credentials_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reset_vcenter_credentials(request) # Establish that the response is the type that we expect. @@ -56095,6 +56356,7 @@ def test_reset_vcenter_credentials_rest_interceptors(null_interceptor): 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 @@ -56141,6 +56403,7 @@ def test_get_dns_forwarding_rest_bad_request( 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_dns_forwarding(request) @@ -56178,6 +56441,7 @@ def test_get_dns_forwarding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_dns_forwarding(request) # Establish that the response is the type that we expect. @@ -56218,6 +56482,7 @@ def test_get_dns_forwarding_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.DnsForwarding.to_json( vmwareengine_resources.DnsForwarding() ) @@ -56268,6 +56533,7 @@ def test_update_dns_forwarding_rest_bad_request( 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_dns_forwarding(request) @@ -56380,6 +56646,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_dns_forwarding(request) # Establish that the response is the type that we expect. @@ -56421,6 +56688,7 @@ def test_update_dns_forwarding_rest_interceptors(null_interceptor): 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 @@ -56467,6 +56735,7 @@ def test_get_network_peering_rest_bad_request( 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_network_peering(request) @@ -56517,6 +56786,7 @@ def test_get_network_peering_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_peering(request) # Establish that the response is the type that we expect. @@ -56573,6 +56843,7 @@ def test_get_network_peering_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.NetworkPeering.to_json( vmwareengine_resources.NetworkPeering() ) @@ -56619,6 +56890,7 @@ def test_list_network_peerings_rest_bad_request( 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_network_peerings(request) @@ -56655,6 +56927,7 @@ def test_list_network_peerings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_peerings(request) # Establish that the response is the type that we expect. @@ -56696,6 +56969,7 @@ def test_list_network_peerings_rest_interceptors(null_interceptor): 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 = vmwareengine.ListNetworkPeeringsResponse.to_json( vmwareengine.ListNetworkPeeringsResponse() ) @@ -56742,6 +57016,7 @@ def test_create_network_peering_rest_bad_request( 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_network_peering(request) @@ -56857,6 +57132,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_peering(request) # Establish that the response is the type that we expect. @@ -56898,6 +57174,7 @@ def test_create_network_peering_rest_interceptors(null_interceptor): 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 @@ -56944,6 +57221,7 @@ def test_delete_network_peering_rest_bad_request( 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_network_peering(request) @@ -56976,6 +57254,7 @@ def test_delete_network_peering_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_peering(request) # Establish that the response is the type that we expect. @@ -57017,6 +57296,7 @@ def test_delete_network_peering_rest_interceptors(null_interceptor): 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 @@ -57065,6 +57345,7 @@ def test_update_network_peering_rest_bad_request( 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_network_peering(request) @@ -57184,6 +57465,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_peering(request) # Establish that the response is the type that we expect. @@ -57225,6 +57507,7 @@ def test_update_network_peering_rest_interceptors(null_interceptor): 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 @@ -57271,6 +57554,7 @@ def test_list_peering_routes_rest_bad_request( 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_peering_routes(request) @@ -57308,6 +57592,7 @@ def test_list_peering_routes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_peering_routes(request) # Establish that the response is the type that we expect. @@ -57348,6 +57633,7 @@ def test_list_peering_routes_rest_interceptors(null_interceptor): 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 = vmwareengine.ListPeeringRoutesResponse.to_json( vmwareengine.ListPeeringRoutesResponse() ) @@ -57396,6 +57682,7 @@ def test_create_hcx_activation_key_rest_bad_request( 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_hcx_activation_key(request) @@ -57504,6 +57791,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_hcx_activation_key(request) # Establish that the response is the type that we expect. @@ -57545,6 +57833,7 @@ def test_create_hcx_activation_key_rest_interceptors(null_interceptor): 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 @@ -57591,6 +57880,7 @@ def test_list_hcx_activation_keys_rest_bad_request( 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_hcx_activation_keys(request) @@ -57629,6 +57919,7 @@ def test_list_hcx_activation_keys_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hcx_activation_keys(request) # Establish that the response is the type that we expect. @@ -57670,6 +57961,7 @@ def test_list_hcx_activation_keys_rest_interceptors(null_interceptor): 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 = vmwareengine.ListHcxActivationKeysResponse.to_json( vmwareengine.ListHcxActivationKeysResponse() ) @@ -57718,6 +58010,7 @@ def test_get_hcx_activation_key_rest_bad_request( 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_hcx_activation_key(request) @@ -57758,6 +58051,7 @@ def test_get_hcx_activation_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hcx_activation_key(request) # Establish that the response is the type that we expect. @@ -57801,6 +58095,7 @@ def test_get_hcx_activation_key_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.HcxActivationKey.to_json( vmwareengine_resources.HcxActivationKey() ) @@ -57849,6 +58144,7 @@ def test_get_network_policy_rest_bad_request( 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_network_policy(request) @@ -57891,6 +58187,7 @@ def test_get_network_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_policy(request) # Establish that the response is the type that we expect. @@ -57939,6 +58236,7 @@ def test_get_network_policy_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.NetworkPolicy.to_json( vmwareengine_resources.NetworkPolicy() ) @@ -57985,6 +58283,7 @@ def test_list_network_policies_rest_bad_request( 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_network_policies(request) @@ -58021,6 +58320,7 @@ def test_list_network_policies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_policies(request) # Establish that the response is the type that we expect. @@ -58062,6 +58362,7 @@ def test_list_network_policies_rest_interceptors(null_interceptor): 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 = vmwareengine.ListNetworkPoliciesResponse.to_json( vmwareengine.ListNetworkPoliciesResponse() ) @@ -58108,6 +58409,7 @@ def test_create_network_policy_rest_bad_request( 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_network_policy(request) @@ -58217,6 +58519,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_policy(request) # Establish that the response is the type that we expect. @@ -58258,6 +58561,7 @@ def test_create_network_policy_rest_interceptors(null_interceptor): 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 @@ -58306,6 +58610,7 @@ def test_update_network_policy_rest_bad_request( 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_network_policy(request) @@ -58419,6 +58724,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_policy(request) # Establish that the response is the type that we expect. @@ -58460,6 +58766,7 @@ def test_update_network_policy_rest_interceptors(null_interceptor): 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 @@ -58506,6 +58813,7 @@ def test_delete_network_policy_rest_bad_request( 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_network_policy(request) @@ -58538,6 +58846,7 @@ def test_delete_network_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_network_policy(request) # Establish that the response is the type that we expect. @@ -58579,6 +58888,7 @@ def test_delete_network_policy_rest_interceptors(null_interceptor): 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 @@ -58625,6 +58935,7 @@ def test_list_management_dns_zone_bindings_rest_bad_request( 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_management_dns_zone_bindings(request) @@ -58665,6 +58976,7 @@ def test_list_management_dns_zone_bindings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_management_dns_zone_bindings(request) # Establish that the response is the type that we expect. @@ -58706,6 +59018,7 @@ def test_list_management_dns_zone_bindings_rest_interceptors(null_interceptor): 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 = vmwareengine.ListManagementDnsZoneBindingsResponse.to_json( vmwareengine.ListManagementDnsZoneBindingsResponse() ) @@ -58754,6 +59067,7 @@ def test_get_management_dns_zone_binding_rest_bad_request( 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_management_dns_zone_binding(request) @@ -58795,6 +59109,7 @@ def test_get_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -58840,6 +59155,7 @@ def test_get_management_dns_zone_binding_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.ManagementDnsZoneBinding.to_json( vmwareengine_resources.ManagementDnsZoneBinding() ) @@ -58888,6 +59204,7 @@ def test_create_management_dns_zone_binding_rest_bad_request( 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_management_dns_zone_binding(request) @@ -59003,6 +59320,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59045,6 +59363,7 @@ def test_create_management_dns_zone_binding_rest_interceptors(null_interceptor): 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 @@ -59093,6 +59412,7 @@ def test_update_management_dns_zone_binding_rest_bad_request( 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_management_dns_zone_binding(request) @@ -59210,6 +59530,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59252,6 +59573,7 @@ def test_update_management_dns_zone_binding_rest_interceptors(null_interceptor): 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 @@ -59298,6 +59620,7 @@ def test_delete_management_dns_zone_binding_rest_bad_request( 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_management_dns_zone_binding(request) @@ -59330,6 +59653,7 @@ def test_delete_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59372,6 +59696,7 @@ def test_delete_management_dns_zone_binding_rest_interceptors(null_interceptor): 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 @@ -59418,6 +59743,7 @@ def test_repair_management_dns_zone_binding_rest_bad_request( 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.repair_management_dns_zone_binding(request) @@ -59450,6 +59776,7 @@ def test_repair_management_dns_zone_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.repair_management_dns_zone_binding(request) # Establish that the response is the type that we expect. @@ -59492,6 +59819,7 @@ def test_repair_management_dns_zone_binding_rest_interceptors(null_interceptor): 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 @@ -59536,6 +59864,7 @@ def test_create_vmware_engine_network_rest_bad_request( 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_vmware_engine_network(request) @@ -59648,6 +59977,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -59689,6 +60019,7 @@ def test_create_vmware_engine_network_rest_interceptors(null_interceptor): 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 @@ -59737,6 +60068,7 @@ def test_update_vmware_engine_network_rest_bad_request( 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_vmware_engine_network(request) @@ -59853,6 +60185,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -59894,6 +60227,7 @@ def test_update_vmware_engine_network_rest_interceptors(null_interceptor): 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 @@ -59940,6 +60274,7 @@ def test_delete_vmware_engine_network_rest_bad_request( 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_vmware_engine_network(request) @@ -59972,6 +60307,7 @@ def test_delete_vmware_engine_network_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -60013,6 +60349,7 @@ def test_delete_vmware_engine_network_rest_interceptors(null_interceptor): 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 @@ -60059,6 +60396,7 @@ def test_get_vmware_engine_network_rest_bad_request( 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_vmware_engine_network(request) @@ -60101,6 +60439,7 @@ def test_get_vmware_engine_network_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vmware_engine_network(request) # Establish that the response is the type that we expect. @@ -60146,6 +60485,7 @@ def test_get_vmware_engine_network_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.VmwareEngineNetwork.to_json( vmwareengine_resources.VmwareEngineNetwork() ) @@ -60192,6 +60532,7 @@ def test_list_vmware_engine_networks_rest_bad_request( 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_vmware_engine_networks(request) @@ -60228,6 +60569,7 @@ def test_list_vmware_engine_networks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vmware_engine_networks(request) # Establish that the response is the type that we expect. @@ -60269,6 +60611,7 @@ def test_list_vmware_engine_networks_rest_interceptors(null_interceptor): 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 = vmwareengine.ListVmwareEngineNetworksResponse.to_json( vmwareengine.ListVmwareEngineNetworksResponse() ) @@ -60315,6 +60658,7 @@ def test_create_private_connection_rest_bad_request( 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_private_connection(request) @@ -60429,6 +60773,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connection(request) # Establish that the response is the type that we expect. @@ -60470,6 +60815,7 @@ def test_create_private_connection_rest_interceptors(null_interceptor): 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 @@ -60516,6 +60862,7 @@ def test_get_private_connection_rest_bad_request( 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_private_connection(request) @@ -60563,6 +60910,7 @@ def test_get_private_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connection(request) # Establish that the response is the type that we expect. @@ -60625,6 +60973,7 @@ def test_get_private_connection_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.PrivateConnection.to_json( vmwareengine_resources.PrivateConnection() ) @@ -60671,6 +61020,7 @@ def test_list_private_connections_rest_bad_request( 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_private_connections(request) @@ -60707,6 +61057,7 @@ def test_list_private_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connections(request) # Establish that the response is the type that we expect. @@ -60748,6 +61099,7 @@ def test_list_private_connections_rest_interceptors(null_interceptor): 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 = vmwareengine.ListPrivateConnectionsResponse.to_json( vmwareengine.ListPrivateConnectionsResponse() ) @@ -60798,6 +61150,7 @@ def test_update_private_connection_rest_bad_request( 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_private_connection(request) @@ -60916,6 +61269,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connection(request) # Establish that the response is the type that we expect. @@ -60957,6 +61311,7 @@ def test_update_private_connection_rest_interceptors(null_interceptor): 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 @@ -61003,6 +61358,7 @@ def test_delete_private_connection_rest_bad_request( 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_private_connection(request) @@ -61035,6 +61391,7 @@ def test_delete_private_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connection(request) # Establish that the response is the type that we expect. @@ -61076,6 +61433,7 @@ def test_delete_private_connection_rest_interceptors(null_interceptor): 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 @@ -61122,6 +61480,7 @@ def test_list_private_connection_peering_routes_rest_bad_request( 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_private_connection_peering_routes(request) @@ -61161,6 +61520,7 @@ def test_list_private_connection_peering_routes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_private_connection_peering_routes(request) # Establish that the response is the type that we expect. @@ -61203,6 +61563,7 @@ def test_list_private_connection_peering_routes_rest_interceptors(null_intercept 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 = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.to_json( vmwareengine.ListPrivateConnectionPeeringRoutesResponse() ) @@ -61249,6 +61610,7 @@ def test_grant_dns_bind_permission_rest_bad_request( 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.grant_dns_bind_permission(request) @@ -61279,6 +61641,7 @@ def test_grant_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.grant_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61320,6 +61683,7 @@ def test_grant_dns_bind_permission_rest_interceptors(null_interceptor): 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 @@ -61364,6 +61728,7 @@ def test_get_dns_bind_permission_rest_bad_request( 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_dns_bind_permission(request) @@ -61399,6 +61764,7 @@ def test_get_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61439,6 +61805,7 @@ def test_get_dns_bind_permission_rest_interceptors(null_interceptor): 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 = vmwareengine_resources.DnsBindPermission.to_json( vmwareengine_resources.DnsBindPermission() ) @@ -61485,6 +61852,7 @@ def test_revoke_dns_bind_permission_rest_bad_request( 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.revoke_dns_bind_permission(request) @@ -61515,6 +61883,7 @@ def test_revoke_dns_bind_permission_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.revoke_dns_bind_permission(request) # Establish that the response is the type that we expect. @@ -61556,6 +61925,7 @@ def test_revoke_dns_bind_permission_rest_interceptors(null_interceptor): 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 @@ -61600,6 +61970,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -61630,6 +62001,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -61658,6 +62030,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -61688,6 +62061,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -61719,6 +62093,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -61751,6 +62126,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -61782,6 +62158,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -61814,6 +62191,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -61845,6 +62223,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -61877,6 +62256,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -61907,6 +62287,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -61937,6 +62318,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -61967,6 +62349,7 @@ def test_get_operation_rest_bad_request( 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) @@ -61997,6 +62380,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -62027,6 +62411,7 @@ def test_list_operations_rest_bad_request( 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) @@ -62057,6 +62442,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py index 505f41457a49..87301fecf313 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport from .transports.grpc_asyncio import VpcAccessServiceGrpcAsyncIOTransport +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 VpcAccessServiceAsyncClient: """Serverless VPC Access API allows users to create and manage @@ -265,6 +275,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.vpcaccess_v1.VpcAccessServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "credentialsType": None, + }, + ) + async def create_connector( self, request: Optional[Union[vpc_access.CreateConnectorRequest, dict]] = None, @@ -274,7 +306,7 @@ async def create_connector( connector: Optional[vpc_access.Connector] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Serverless VPC Access connector, returns an operation. @@ -337,8 +369,10 @@ async def sample_create_connector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -414,7 +448,7 @@ async def get_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.Connector: r"""Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -459,8 +493,10 @@ async def sample_get_connector(): 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, 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: google.cloud.vpcaccess_v1.types.Connector: @@ -521,7 +557,7 @@ async def list_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConnectorsAsyncPager: r"""Lists Serverless VPC Access connectors. @@ -566,8 +602,10 @@ async def sample_list_connectors(): 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, 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: google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsAsyncPager: @@ -642,7 +680,7 @@ async def delete_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -691,8 +729,10 @@ async def sample_delete_connector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -770,7 +810,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -781,8 +821,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -823,7 +865,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -834,8 +876,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -876,7 +920,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -887,8 +931,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py index d286c651fa58..8a80f3ef1064 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -589,6 +599,10 @@ def __init__( # 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( @@ -655,6 +669,29 @@ def __init__( 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.vpcaccess_v1.VpcAccessServiceClient`.", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "credentialsType": None, + }, + ) + def create_connector( self, request: Optional[Union[vpc_access.CreateConnectorRequest, dict]] = None, @@ -664,7 +701,7 @@ def create_connector( connector: Optional[vpc_access.Connector] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Serverless VPC Access connector, returns an operation. @@ -727,8 +764,10 @@ def sample_create_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -801,7 +840,7 @@ def get_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.Connector: r"""Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -846,8 +885,10 @@ def sample_get_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vpcaccess_v1.types.Connector: @@ -905,7 +946,7 @@ def list_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConnectorsPager: r"""Lists Serverless VPC Access connectors. @@ -950,8 +991,10 @@ def sample_list_connectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsPager: @@ -1023,7 +1066,7 @@ def delete_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist. @@ -1072,8 +1115,10 @@ def sample_delete_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1161,7 +1206,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1172,8 +1217,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1214,7 +1261,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1225,8 +1272,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1267,7 +1316,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1278,8 +1327,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py index 1965d08054e1..75ce612acee8 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vpc_access.ListConnectorsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vpc_access.ListConnectorsRequest(request) diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py index 018777049b61..c2271f45eafa 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.vpcaccess_v1.types import vpc_access from .base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport +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.vpcaccess.v1.VpcAccessService", + "rpcName": 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.vpcaccess.v1.VpcAccessService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VpcAccessServiceGrpcTransport(VpcAccessServiceTransport): """gRPC backend transport for VpcAccessService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def create_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connector" not in self._stubs: - self._stubs["create_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/CreateConnector", request_serializer=vpc_access.CreateConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -300,7 +388,7 @@ def get_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connector" not in self._stubs: - self._stubs["get_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/GetConnector", request_serializer=vpc_access.GetConnectorRequest.serialize, response_deserializer=vpc_access.Connector.deserialize, @@ -328,7 +416,7 @@ def list_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connectors" not in self._stubs: - self._stubs["list_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_connectors"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/ListConnectors", request_serializer=vpc_access.ListConnectorsRequest.serialize, response_deserializer=vpc_access.ListConnectorsResponse.deserialize, @@ -355,7 +443,7 @@ def delete_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connector" not in self._stubs: - self._stubs["delete_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/DeleteConnector", request_serializer=vpc_access.DeleteConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -363,7 +451,7 @@ def delete_connector( return self._stubs["delete_connector"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -375,7 +463,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -394,7 +482,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -413,7 +501,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py index 43029bf41113..5bb36f89d9a1 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.vpcaccess_v1.types import vpc_access from .base import DEFAULT_CLIENT_INFO, VpcAccessServiceTransport from .grpc import VpcAccessServiceGrpcTransport +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.vpcaccess.v1.VpcAccessService", + "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.vpcaccess.v1.VpcAccessService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VpcAccessServiceGrpcAsyncIOTransport(VpcAccessServiceTransport): """gRPC AsyncIO backend transport for VpcAccessService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def create_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connector" not in self._stubs: - self._stubs["create_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/CreateConnector", request_serializer=vpc_access.CreateConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +397,7 @@ def get_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connector" not in self._stubs: - self._stubs["get_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/GetConnector", request_serializer=vpc_access.GetConnectorRequest.serialize, response_deserializer=vpc_access.Connector.deserialize, @@ -340,7 +425,7 @@ def list_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connectors" not in self._stubs: - self._stubs["list_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_connectors"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/ListConnectors", request_serializer=vpc_access.ListConnectorsRequest.serialize, response_deserializer=vpc_access.ListConnectorsResponse.deserialize, @@ -369,7 +454,7 @@ def delete_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connector" not in self._stubs: - self._stubs["delete_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_connector"] = self._logged_channel.unary_unary( "/google.cloud.vpcaccess.v1.VpcAccessService/DeleteConnector", request_serializer=vpc_access.DeleteConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -438,7 +523,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -457,7 +542,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -476,7 +561,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py index 3bd78bd610a7..a1c7d5539ab1 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/services/vpc_access_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -103,8 +111,10 @@ def post_list_connectors(self, response): def pre_create_connector( self, request: vpc_access.CreateConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.CreateConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.CreateConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_connector Override in a subclass to manipulate the request or metadata @@ -126,8 +136,10 @@ def post_create_connector( def pre_delete_connector( self, request: vpc_access.DeleteConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.DeleteConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.DeleteConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_connector Override in a subclass to manipulate the request or metadata @@ -149,8 +161,8 @@ def post_delete_connector( def pre_get_connector( self, request: vpc_access.GetConnectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.GetConnectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vpc_access.GetConnectorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_connector Override in a subclass to manipulate the request or metadata @@ -172,8 +184,10 @@ def post_get_connector( def pre_list_connectors( self, request: vpc_access.ListConnectorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpc_access.ListConnectorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpc_access.ListConnectorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_connectors Override in a subclass to manipulate the request or metadata @@ -195,8 +209,10 @@ def post_list_connectors( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -218,8 +234,10 @@ def post_list_locations( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -241,8 +259,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -427,7 +447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create connector method over HTTP. @@ -438,8 +458,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -452,6 +474,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseCreateConnector._get_http_options() ) + request, metadata = self._interceptor.pre_create_connector( request, metadata ) @@ -468,6 +491,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.CreateConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "CreateConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._CreateConnector._get_response( self._host, @@ -487,7 +537,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_connector(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.vpcaccess_v1.VpcAccessServiceClient.create_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "CreateConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConnector( @@ -525,7 +597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete connector method over HTTP. @@ -536,8 +608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -550,6 +624,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseDeleteConnector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_connector( request, metadata ) @@ -562,6 +637,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.DeleteConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "DeleteConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._DeleteConnector._get_response( self._host, @@ -580,7 +682,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_connector(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.vpcaccess_v1.VpcAccessServiceClient.delete_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "DeleteConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnector( @@ -617,7 +741,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.Connector: r"""Call the get connector method over HTTP. @@ -628,8 +752,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vpc_access.Connector: @@ -641,6 +767,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseGetConnector._get_http_options() ) + request, metadata = self._interceptor.pre_get_connector(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseGetConnector._get_transcoded_request( http_options, request @@ -651,6 +778,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.GetConnector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._GetConnector._get_response( self._host, @@ -671,7 +825,29 @@ def __call__( pb_resp = vpc_access.Connector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vpc_access.Connector.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.vpcaccess_v1.VpcAccessServiceClient.get_connector", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConnectors( @@ -708,7 +884,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpc_access.ListConnectorsResponse: r"""Call the list connectors method over HTTP. @@ -719,8 +895,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vpc_access.ListConnectorsResponse: @@ -732,6 +910,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListConnectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_connectors(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListConnectors._get_transcoded_request( http_options, request @@ -742,6 +921,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.ListConnectors", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListConnectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListConnectors._get_response( self._host, @@ -762,7 +968,31 @@ def __call__( pb_resp = vpc_access.ListConnectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_connectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vpc_access.ListConnectorsResponse.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.vpcaccess_v1.VpcAccessServiceClient.list_connectors", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListConnectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -837,7 +1067,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -847,8 +1077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -857,6 +1089,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -867,6 +1100,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListLocations._get_response( self._host, @@ -886,6 +1146,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.vpcaccess_v1.VpcAccessServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -926,7 +1207,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -936,8 +1217,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -946,6 +1229,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -956,6 +1240,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._GetOperation._get_response( self._host, @@ -975,6 +1286,27 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1015,7 +1347,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1025,8 +1357,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1035,6 +1369,7 @@ def __call__( http_options = ( _BaseVpcAccessServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseVpcAccessServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1045,6 +1380,33 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpcAccessServiceRestTransport._ListOperations._get_response( self._host, @@ -1064,6 +1426,27 @@ def __call__( 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.vpcaccess_v1.VpcAccessServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.vpcaccess.v1.VpcAccessService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json index d00c14f226a2..97bc0f76d20d 100644 --- a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json +++ b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vpc-access", - "version": "1.11.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.types.Connector", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.types.Connector", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.vpcaccess_v1.services.vpc_access_service.pagers.ListConnectorsPager", diff --git a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py index 5684d551915d..870232fe7dd8 100644 --- a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py +++ b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py @@ -2775,6 +2775,7 @@ def test_create_connector_rest_required_fields( response_value._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_connector(request) @@ -2835,6 +2836,7 @@ def test_create_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_connector(**mock_args) @@ -2967,6 +2969,7 @@ def test_get_connector_rest_required_fields( response_value._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_connector(request) @@ -3014,6 +3017,7 @@ def test_get_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_connector(**mock_args) @@ -3151,6 +3155,7 @@ def test_list_connectors_rest_required_fields( response_value._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_connectors(request) @@ -3204,6 +3209,7 @@ def test_list_connectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_connectors(**mock_args) @@ -3398,6 +3404,7 @@ def test_delete_connector_rest_required_fields( response_value._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_connector(request) @@ -3443,6 +3450,7 @@ def test_delete_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_connector(**mock_args) @@ -3816,6 +3824,7 @@ def test_create_connector_rest_bad_request( 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_connector(request) @@ -3929,6 +3938,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_connector(request) # Establish that the response is the type that we expect. @@ -3970,6 +3980,7 @@ def test_create_connector_rest_interceptors(null_interceptor): 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 @@ -4012,6 +4023,7 @@ def test_get_connector_rest_bad_request(request_type=vpc_access.GetConnectorRequ 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_connector(request) @@ -4056,6 +4068,7 @@ def test_get_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_connector(request) # Establish that the response is the type that we expect. @@ -4103,6 +4116,7 @@ def test_get_connector_rest_interceptors(null_interceptor): 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 = vpc_access.Connector.to_json(vpc_access.Connector()) req.return_value.content = return_value @@ -4147,6 +4161,7 @@ def test_list_connectors_rest_bad_request( 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_connectors(request) @@ -4182,6 +4197,7 @@ def test_list_connectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_connectors(request) # Establish that the response is the type that we expect. @@ -4222,6 +4238,7 @@ def test_list_connectors_rest_interceptors(null_interceptor): 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 = vpc_access.ListConnectorsResponse.to_json( vpc_access.ListConnectorsResponse() ) @@ -4268,6 +4285,7 @@ def test_delete_connector_rest_bad_request( 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_connector(request) @@ -4298,6 +4316,7 @@ def test_delete_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_connector(request) # Establish that the response is the type that we expect. @@ -4339,6 +4358,7 @@ def test_delete_connector_rest_interceptors(null_interceptor): 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 @@ -4383,6 +4403,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -4413,6 +4434,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -4443,6 +4465,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4473,6 +4496,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4503,6 +4527,7 @@ def test_list_operations_rest_bad_request( 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) @@ -4533,6 +4558,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py index 82c58142ff1c..a849cbdbc036 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebRiskServiceTransport from .transports.grpc_asyncio import WebRiskServiceGrpcAsyncIOTransport +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 WebRiskServiceAsyncClient: """Web Risk API defines an interface to detect malicious URLs on @@ -258,6 +268,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.webrisk_v1.WebRiskServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "credentialsType": None, + }, + ) + async def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -267,7 +299,7 @@ async def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep @@ -341,8 +373,10 @@ async def sample_compute_threat_list_diff(): 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, 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: google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse: @@ -400,7 +434,7 @@ async def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched @@ -458,8 +492,10 @@ async def sample_search_uris(): 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, 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: google.cloud.webrisk_v1.types.SearchUrisResponse: @@ -515,7 +551,7 @@ async def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -577,8 +613,10 @@ async def sample_search_hashes(): 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, 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: google.cloud.webrisk_v1.types.SearchHashesResponse: @@ -634,7 +672,7 @@ async def create_submission( submission: Optional[webrisk.Submission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.Submission: r"""Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of @@ -699,8 +737,10 @@ async def sample_create_submission(): 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, 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: google.cloud.webrisk_v1.types.Submission: @@ -762,7 +802,7 @@ async def submit_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the @@ -818,8 +858,10 @@ async def sample_submit_uri(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -876,7 +918,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -887,8 +929,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -929,7 +973,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -940,8 +984,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -982,7 +1028,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -998,8 +1044,10 @@ async def delete_operation( 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, 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: None """ @@ -1036,7 +1084,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1051,8 +1099,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py index 890971100cc0..0314d235bfe5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -562,6 +572,10 @@ def __init__( # 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( @@ -627,6 +641,29 @@ def __init__( 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.webrisk_v1.WebRiskServiceClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "credentialsType": None, + }, + ) + def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -636,7 +673,7 @@ def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep @@ -710,8 +747,10 @@ def sample_compute_threat_list_diff(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse: @@ -766,7 +805,7 @@ def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched @@ -824,8 +863,10 @@ def sample_search_uris(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1.types.SearchUrisResponse: @@ -878,7 +919,7 @@ def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -940,8 +981,10 @@ def sample_search_hashes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1.types.SearchHashesResponse: @@ -994,7 +1037,7 @@ def create_submission( submission: Optional[webrisk.Submission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.Submission: r"""Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of @@ -1059,8 +1102,10 @@ def sample_create_submission(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1.types.Submission: @@ -1119,7 +1164,7 @@ def submit_uri( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the @@ -1175,8 +1220,10 @@ def sample_submit_uri(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1244,7 +1291,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1255,8 +1302,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1297,7 +1346,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1308,8 +1357,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1350,7 +1401,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1366,8 +1417,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1404,7 +1457,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1419,8 +1472,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py index f95d53de806f..849bb3b4d7bd 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.webrisk_v1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceTransport +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.webrisk.v1.WebRiskService", + "rpcName": 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.webrisk.v1.WebRiskService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceGrpcTransport(WebRiskServiceTransport): """gRPC backend transport for WebRiskService. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -310,7 +398,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -341,7 +429,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -375,7 +463,7 @@ def create_submission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_submission" not in self._stubs: - self._stubs["create_submission"] = self.grpc_channel.unary_unary( + self._stubs["create_submission"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/CreateSubmission", request_serializer=webrisk.CreateSubmissionRequest.serialize, response_deserializer=webrisk.Submission.deserialize, @@ -412,7 +500,7 @@ def submit_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_uri" not in self._stubs: - self._stubs["submit_uri"] = self.grpc_channel.unary_unary( + self._stubs["submit_uri"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SubmitUri", request_serializer=webrisk.SubmitUriRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -420,7 +508,7 @@ def submit_uri( return self._stubs["submit_uri"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -432,7 +520,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -449,7 +537,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -466,7 +554,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -485,7 +573,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py index c270d3ab1250..0317daf712e5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.webrisk_v1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceTransport from .grpc import WebRiskServiceGrpcTransport +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.webrisk.v1.WebRiskService", + "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.webrisk.v1.WebRiskService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceGrpcAsyncIOTransport(WebRiskServiceTransport): """gRPC AsyncIO backend transport for WebRiskService. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -290,7 +375,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -321,7 +406,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -354,7 +439,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -388,7 +473,7 @@ def create_submission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_submission" not in self._stubs: - self._stubs["create_submission"] = self.grpc_channel.unary_unary( + self._stubs["create_submission"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/CreateSubmission", request_serializer=webrisk.CreateSubmissionRequest.serialize, response_deserializer=webrisk.Submission.deserialize, @@ -425,7 +510,7 @@ def submit_uri( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_uri" not in self._stubs: - self._stubs["submit_uri"] = self.grpc_channel.unary_unary( + self._stubs["submit_uri"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1.WebRiskService/SubmitUri", request_serializer=webrisk.SubmitUriRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -518,7 +603,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -534,7 +619,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -551,7 +636,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -568,7 +653,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -587,7 +672,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py index 497a155871f2..10f0bc9a8962 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/services/web_risk_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -110,8 +118,10 @@ def post_submit_uri(self, response): def pre_compute_threat_list_diff( self, request: webrisk.ComputeThreatListDiffRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for compute_threat_list_diff Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_compute_threat_list_diff( def pre_create_submission( self, request: webrisk.CreateSubmissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.CreateSubmissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.CreateSubmissionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_submission Override in a subclass to manipulate the request or metadata @@ -154,8 +166,10 @@ def post_create_submission( return response def pre_search_hashes( - self, request: webrisk.SearchHashesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchHashesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_hashes Override in a subclass to manipulate the request or metadata @@ -175,8 +189,10 @@ def post_search_hashes( return response def pre_search_uris( - self, request: webrisk.SearchUrisRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchUrisRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_uris Override in a subclass to manipulate the request or metadata @@ -196,8 +212,10 @@ def post_search_uris( return response def pre_submit_uri( - self, request: webrisk.SubmitUriRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SubmitUriRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SubmitUriRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SubmitUriRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for submit_uri Override in a subclass to manipulate the request or metadata @@ -219,8 +237,10 @@ def post_submit_uri( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -240,8 +260,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -261,8 +283,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -284,8 +308,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -481,7 +507,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Call the compute threat list diff method over HTTP. @@ -491,8 +517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.ComputeThreatListDiffResponse: @@ -502,6 +530,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseComputeThreatListDiff._get_http_options() ) + request, metadata = self._interceptor.pre_compute_threat_list_diff( request, metadata ) @@ -514,6 +543,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.ComputeThreatListDiff", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ComputeThreatListDiff", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._ComputeThreatListDiff._get_response( self._host, @@ -534,7 +590,31 @@ def __call__( pb_resp = webrisk.ComputeThreatListDiffResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_threat_list_diff(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.ComputeThreatListDiffResponse.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.webrisk_v1.WebRiskServiceClient.compute_threat_list_diff", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ComputeThreatListDiff", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSubmission( @@ -572,7 +652,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.Submission: r"""Call the create submission method over HTTP. @@ -583,8 +663,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.Submission: @@ -596,6 +678,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseCreateSubmission._get_http_options() ) + request, metadata = self._interceptor.pre_create_submission( request, metadata ) @@ -612,6 +695,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.CreateSubmission", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CreateSubmission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._CreateSubmission._get_response( self._host, @@ -633,7 +743,29 @@ def __call__( pb_resp = webrisk.Submission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_submission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.Submission.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.webrisk_v1.WebRiskServiceClient.create_submission", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CreateSubmission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchHashes( @@ -670,7 +802,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Call the search hashes method over HTTP. @@ -681,8 +813,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.SearchHashesResponse: @@ -692,6 +826,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSearchHashes._get_http_options() ) + request, metadata = self._interceptor.pre_search_hashes(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseSearchHashes._get_transcoded_request( http_options, request @@ -702,6 +837,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.SearchHashes", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchHashes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SearchHashes._get_response( self._host, @@ -722,7 +884,29 @@ def __call__( pb_resp = webrisk.SearchHashesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_hashes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchHashesResponse.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.webrisk_v1.WebRiskServiceClient.search_hashes", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchHashes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchUris( @@ -759,7 +943,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""Call the search uris method over HTTP. @@ -770,8 +954,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.SearchUrisResponse: @@ -781,6 +967,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSearchUris._get_http_options() ) + request, metadata = self._interceptor.pre_search_uris(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseSearchUris._get_transcoded_request( http_options, request @@ -793,6 +980,33 @@ def __call__( ) ) + 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.webrisk_v1.WebRiskServiceClient.SearchUris", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchUris", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SearchUris._get_response( self._host, @@ -813,7 +1027,29 @@ def __call__( pb_resp = webrisk.SearchUrisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_uris(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchUrisResponse.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.webrisk_v1.WebRiskServiceClient.search_uris", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SearchUris", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SubmitUri( @@ -851,7 +1087,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the submit uri method over HTTP. @@ -862,8 +1098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -876,6 +1114,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseSubmitUri._get_http_options() ) + request, metadata = self._interceptor.pre_submit_uri(request, metadata) transcoded_request = ( _BaseWebRiskServiceRestTransport._BaseSubmitUri._get_transcoded_request( @@ -896,6 +1135,33 @@ def __call__( ) ) + 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.webrisk_v1.WebRiskServiceClient.SubmitUri", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SubmitUri", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._SubmitUri._get_response( self._host, @@ -915,7 +1181,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_submit_uri(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.webrisk_v1.WebRiskServiceClient.submit_uri", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "SubmitUri", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -999,7 +1287,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1009,13 +1297,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWebRiskServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1032,6 +1323,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._CancelOperation._get_response( self._host, @@ -1088,7 +1406,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1098,13 +1416,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWebRiskServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1117,6 +1438,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1172,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1182,8 +1530,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1192,6 +1542,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1202,6 +1553,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._GetOperation._get_response( self._host, @@ -1221,6 +1599,27 @@ def __call__( 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.webrisk_v1.WebRiskServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1261,7 +1660,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1271,8 +1670,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1281,6 +1682,7 @@ def __call__( http_options = ( _BaseWebRiskServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWebRiskServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1291,6 +1693,33 @@ def __call__( 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.webrisk_v1.WebRiskServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceRestTransport._ListOperations._get_response( self._host, @@ -1310,6 +1739,27 @@ def __call__( 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.webrisk_v1.WebRiskServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.webrisk.v1.WebRiskService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py index e0e80324b79b..ff4071527ce1 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport from .transports.grpc_asyncio import WebRiskServiceV1Beta1GrpcAsyncIOTransport +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 WebRiskServiceV1Beta1AsyncClient: """Web Risk v1beta1 API defines an interface to detect malicious @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.webrisk_v1beta1.WebRiskServiceV1Beta1AsyncClient`.", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "credentialsType": None, + }, + ) + async def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -270,7 +302,7 @@ async def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. @@ -327,8 +359,10 @@ async def sample_compute_threat_list_diff(): 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, 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: google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse: @@ -386,7 +420,7 @@ async def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. @@ -439,8 +473,10 @@ async def sample_search_uris(): 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, 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: google.cloud.webrisk_v1beta1.types.SearchUrisResponse: @@ -496,7 +532,7 @@ async def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -554,8 +590,10 @@ async def sample_search_hashes(): 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, 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: google.cloud.webrisk_v1beta1.types.SearchHashesResponse: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py index 51df8d87adbe..a5bf56a5f4f3 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.cloud.webrisk_v1beta1.types import webrisk @@ -565,6 +575,10 @@ def __init__( # 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( @@ -631,6 +645,29 @@ def __init__( 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.webrisk_v1beta1.WebRiskServiceV1Beta1Client`.", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "credentialsType": None, + }, + ) + def compute_threat_list_diff( self, request: Optional[Union[webrisk.ComputeThreatListDiffRequest, dict]] = None, @@ -640,7 +677,7 @@ def compute_threat_list_diff( constraints: Optional[webrisk.ComputeThreatListDiffRequest.Constraints] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Gets the most recent threat list diffs. @@ -697,8 +734,10 @@ def sample_compute_threat_list_diff(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse: @@ -753,7 +792,7 @@ def search_uris( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""This method is used to check whether a URI is on a given threatList. @@ -806,8 +845,10 @@ def sample_search_uris(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1beta1.types.SearchUrisResponse: @@ -860,7 +901,7 @@ def search_hashes( threat_types: Optional[MutableSequence[webrisk.ThreatType]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in @@ -918,8 +959,10 @@ def sample_search_hashes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.webrisk_v1beta1.types.SearchHashesResponse: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py index d4dcfcf4d20e..dfb4ddf9f4f7 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.webrisk_v1beta1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport +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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": 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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceV1Beta1GrpcTransport(WebRiskServiceV1Beta1Transport): """gRPC backend transport for WebRiskServiceV1Beta1. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +342,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -283,7 +369,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -314,7 +400,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -322,7 +408,7 @@ def search_hashes( return self._stubs["search_hashes"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py index 4173775dace8..050d535afe94 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.webrisk_v1beta1.types import webrisk from .base import DEFAULT_CLIENT_INFO, WebRiskServiceV1Beta1Transport from .grpc import WebRiskServiceV1Beta1GrpcTransport +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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "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.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebRiskServiceV1Beta1GrpcAsyncIOTransport(WebRiskServiceV1Beta1Transport): """gRPC AsyncIO backend transport for WebRiskServiceV1Beta1. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +350,7 @@ def compute_threat_list_diff( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_threat_list_diff" not in self._stubs: - self._stubs["compute_threat_list_diff"] = self.grpc_channel.unary_unary( + self._stubs["compute_threat_list_diff"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/ComputeThreatListDiff", request_serializer=webrisk.ComputeThreatListDiffRequest.serialize, response_deserializer=webrisk.ComputeThreatListDiffResponse.deserialize, @@ -292,7 +377,7 @@ def search_uris( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_uris" not in self._stubs: - self._stubs["search_uris"] = self.grpc_channel.unary_unary( + self._stubs["search_uris"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchUris", request_serializer=webrisk.SearchUrisRequest.serialize, response_deserializer=webrisk.SearchUrisResponse.deserialize, @@ -325,7 +410,7 @@ def search_hashes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_hashes" not in self._stubs: - self._stubs["search_hashes"] = self.grpc_channel.unary_unary( + self._stubs["search_hashes"] = self._logged_channel.unary_unary( "/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchHashes", request_serializer=webrisk.SearchHashesRequest.serialize, response_deserializer=webrisk.SearchHashesResponse.deserialize, @@ -388,7 +473,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py index bd060484d592..d55b80c24fb1 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -93,8 +101,10 @@ def post_search_uris(self, response): def pre_compute_threat_list_diff( self, request: webrisk.ComputeThreatListDiffRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + webrisk.ComputeThreatListDiffRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for compute_threat_list_diff Override in a subclass to manipulate the request or metadata @@ -114,8 +124,10 @@ def post_compute_threat_list_diff( return response def pre_search_hashes( - self, request: webrisk.SearchHashesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchHashesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchHashesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_hashes Override in a subclass to manipulate the request or metadata @@ -135,8 +147,10 @@ def post_search_hashes( return response def pre_search_uris( - self, request: webrisk.SearchUrisRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, str]]]: + self, + request: webrisk.SearchUrisRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[webrisk.SearchUrisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_uris Override in a subclass to manipulate the request or metadata @@ -278,7 +292,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.ComputeThreatListDiffResponse: r"""Call the compute threat list diff method over HTTP. @@ -288,8 +302,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.ComputeThreatListDiffResponse: @@ -299,6 +315,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseComputeThreatListDiff._get_http_options() ) + request, metadata = self._interceptor.pre_compute_threat_list_diff( request, metadata ) @@ -311,6 +328,33 @@ def __call__( 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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.ComputeThreatListDiff", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "ComputeThreatListDiff", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebRiskServiceV1Beta1RestTransport._ComputeThreatListDiff._get_response( @@ -333,7 +377,31 @@ def __call__( pb_resp = webrisk.ComputeThreatListDiffResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_threat_list_diff(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.ComputeThreatListDiffResponse.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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.compute_threat_list_diff", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "ComputeThreatListDiff", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchHashes( @@ -371,7 +439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchHashesResponse: r"""Call the search hashes method over HTTP. @@ -382,8 +450,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.SearchHashesResponse: @@ -393,6 +463,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchHashes._get_http_options() ) + request, metadata = self._interceptor.pre_search_hashes(request, metadata) transcoded_request = _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchHashes._get_transcoded_request( http_options, request @@ -403,6 +474,33 @@ def __call__( 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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.SearchHashes", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchHashes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceV1Beta1RestTransport._SearchHashes._get_response( self._host, @@ -423,7 +521,29 @@ def __call__( pb_resp = webrisk.SearchHashesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_hashes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchHashesResponse.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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.search_hashes", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchHashes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchUris( @@ -461,7 +581,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> webrisk.SearchUrisResponse: r"""Call the search uris method over HTTP. @@ -472,8 +592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.webrisk.SearchUrisResponse: @@ -483,6 +605,7 @@ def __call__( http_options = ( _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchUris._get_http_options() ) + request, metadata = self._interceptor.pre_search_uris(request, metadata) transcoded_request = _BaseWebRiskServiceV1Beta1RestTransport._BaseSearchUris._get_transcoded_request( http_options, request @@ -493,6 +616,33 @@ def __call__( 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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.SearchUris", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchUris", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebRiskServiceV1Beta1RestTransport._SearchUris._get_response( self._host, @@ -513,7 +663,29 @@ def __call__( pb_resp = webrisk.SearchUrisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_uris(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = webrisk.SearchUrisResponse.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.webrisk_v1beta1.WebRiskServiceV1Beta1Client.search_uris", + extra={ + "serviceName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1", + "rpcName": "SearchUris", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json index 02fb21b7f7f9..654bd4d32e74 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.ComputeThreatListDiffResponse", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.Submission", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.Submission", @@ -397,7 +397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchHashesResponse", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchHashesResponse", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchUrisResponse", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1.types.SearchUrisResponse", @@ -727,7 +727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json index e93ea959de17..e281efca18fe 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.ComputeThreatListDiffResponse", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchHashesResponse", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchHashesResponse", @@ -397,7 +397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchUrisResponse", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.webrisk_v1beta1.types.SearchUrisResponse", diff --git a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py index 19208898061c..e9bbbf3f9506 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py @@ -2619,6 +2619,7 @@ def test_compute_threat_list_diff_rest_required_fields( response_value._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.compute_threat_list_diff(request) @@ -2682,6 +2683,7 @@ def test_compute_threat_list_diff_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.compute_threat_list_diff(**mock_args) @@ -2823,6 +2825,7 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value._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.search_uris(request) @@ -2888,6 +2891,7 @@ def test_search_uris_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_uris(**mock_args) @@ -3018,6 +3022,7 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value._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.search_hashes(request) @@ -3072,6 +3077,7 @@ def test_search_hashes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_hashes(**mock_args) @@ -3205,6 +3211,7 @@ def test_create_submission_rest_required_fields( response_value._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_submission(request) @@ -3259,6 +3266,7 @@ def test_create_submission_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_submission(**mock_args) @@ -3389,6 +3397,7 @@ def test_submit_uri_rest_required_fields(request_type=webrisk.SubmitUriRequest): response_value._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.submit_uri(request) @@ -3806,6 +3815,7 @@ def test_compute_threat_list_diff_rest_bad_request( 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.compute_threat_list_diff(request) @@ -3842,6 +3852,7 @@ def test_compute_threat_list_diff_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.compute_threat_list_diff(request) # Establish that the response is the type that we expect. @@ -3886,6 +3897,7 @@ def test_compute_threat_list_diff_rest_interceptors(null_interceptor): 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 = webrisk.ComputeThreatListDiffResponse.to_json( webrisk.ComputeThreatListDiffResponse() ) @@ -3930,6 +3942,7 @@ def test_search_uris_rest_bad_request(request_type=webrisk.SearchUrisRequest): 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.search_uris(request) @@ -3963,6 +3976,7 @@ def test_search_uris_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_uris(request) # Establish that the response is the type that we expect. @@ -4000,6 +4014,7 @@ def test_search_uris_rest_interceptors(null_interceptor): 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 = webrisk.SearchUrisResponse.to_json(webrisk.SearchUrisResponse()) req.return_value.content = return_value @@ -4042,6 +4057,7 @@ def test_search_hashes_rest_bad_request(request_type=webrisk.SearchHashesRequest 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.search_hashes(request) @@ -4075,6 +4091,7 @@ def test_search_hashes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_hashes(request) # Establish that the response is the type that we expect. @@ -4112,6 +4129,7 @@ def test_search_hashes_rest_interceptors(null_interceptor): 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 = webrisk.SearchHashesResponse.to_json( webrisk.SearchHashesResponse() ) @@ -4158,6 +4176,7 @@ def test_create_submission_rest_bad_request( 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_submission(request) @@ -4262,6 +4281,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_submission(request) # Establish that the response is the type that we expect. @@ -4303,6 +4323,7 @@ def test_create_submission_rest_interceptors(null_interceptor): 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 = webrisk.Submission.to_json(webrisk.Submission()) req.return_value.content = return_value @@ -4345,6 +4366,7 @@ def test_submit_uri_rest_bad_request(request_type=webrisk.SubmitUriRequest): 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.submit_uri(request) @@ -4375,6 +4397,7 @@ def test_submit_uri_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.submit_uri(request) # Establish that the response is the type that we expect. @@ -4414,6 +4437,7 @@ def test_submit_uri_rest_interceptors(null_interceptor): 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 @@ -4460,6 +4484,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -4490,6 +4515,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -4520,6 +4546,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -4550,6 +4577,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -4580,6 +4608,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4610,6 +4639,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4638,6 +4668,7 @@ def test_list_operations_rest_bad_request( 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) @@ -4668,6 +4699,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py index 7f12fa6d2b5c..a5e283f4ec0b 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py @@ -2077,6 +2077,7 @@ def test_compute_threat_list_diff_rest_required_fields( response_value._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.compute_threat_list_diff(request) @@ -2140,6 +2141,7 @@ def test_compute_threat_list_diff_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.compute_threat_list_diff(**mock_args) @@ -2281,6 +2283,7 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value._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.search_uris(request) @@ -2346,6 +2349,7 @@ def test_search_uris_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_uris(**mock_args) @@ -2476,6 +2480,7 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value._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.search_hashes(request) @@ -2530,6 +2535,7 @@ def test_search_hashes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_hashes(**mock_args) @@ -2851,6 +2857,7 @@ def test_compute_threat_list_diff_rest_bad_request( 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.compute_threat_list_diff(request) @@ -2887,6 +2894,7 @@ def test_compute_threat_list_diff_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.compute_threat_list_diff(request) # Establish that the response is the type that we expect. @@ -2931,6 +2939,7 @@ def test_compute_threat_list_diff_rest_interceptors(null_interceptor): 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 = webrisk.ComputeThreatListDiffResponse.to_json( webrisk.ComputeThreatListDiffResponse() ) @@ -2975,6 +2984,7 @@ def test_search_uris_rest_bad_request(request_type=webrisk.SearchUrisRequest): 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.search_uris(request) @@ -3008,6 +3018,7 @@ def test_search_uris_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_uris(request) # Establish that the response is the type that we expect. @@ -3045,6 +3056,7 @@ def test_search_uris_rest_interceptors(null_interceptor): 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 = webrisk.SearchUrisResponse.to_json(webrisk.SearchUrisResponse()) req.return_value.content = return_value @@ -3087,6 +3099,7 @@ def test_search_hashes_rest_bad_request(request_type=webrisk.SearchHashesRequest 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.search_hashes(request) @@ -3120,6 +3133,7 @@ def test_search_hashes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_hashes(request) # Establish that the response is the type that we expect. @@ -3157,6 +3171,7 @@ def test_search_hashes_rest_interceptors(null_interceptor): 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 = webrisk.SearchHashesResponse.to_json( webrisk.SearchHashesResponse() ) diff --git a/packages/google-cloud-webrisk/webrisk-v1beta1-py.tar.gz b/packages/google-cloud-webrisk/webrisk-v1beta1-py.tar.gz new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py index c65fa657162a..16693fb4fa2a 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +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 WebSecurityScannerAsyncClient: """Web Security Scanner Service identifies security @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.websecurityscanner_v1.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -282,7 +314,7 @@ async def create_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -317,8 +349,10 @@ async def sample_create_scan_config(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -366,7 +400,7 @@ async def delete_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -399,8 +433,10 @@ async def sample_delete_scan_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -439,7 +475,7 @@ async def get_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -474,8 +510,10 @@ async def sample_get_scan_config(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -523,7 +561,7 @@ async def list_scan_configs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -559,8 +597,10 @@ async def sample_list_scan_configs(): 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, 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -621,7 +661,7 @@ async def update_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -657,8 +697,10 @@ async def sample_update_scan_config(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -706,7 +748,7 @@ async def start_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -741,8 +783,10 @@ async def sample_start_scan_run(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -789,7 +833,7 @@ async def get_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -824,8 +868,10 @@ async def sample_get_scan_run(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -872,7 +918,7 @@ async def list_scan_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -909,8 +955,10 @@ async def sample_list_scan_runs(): 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, 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -969,7 +1017,7 @@ async def stop_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1004,8 +1052,10 @@ async def sample_stop_scan_run(): 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, 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1054,7 +1104,7 @@ async def list_crawled_urls( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1090,8 +1140,10 @@ async def sample_list_crawled_urls(): 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, 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1150,7 +1202,7 @@ async def get_finding( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1185,8 +1237,10 @@ async def sample_get_finding(): 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, 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: google.cloud.websecurityscanner_v1.types.Finding: @@ -1233,7 +1287,7 @@ async def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1269,8 +1323,10 @@ async def sample_list_findings(): 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, 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1331,7 +1387,7 @@ async def list_finding_type_stats( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1366,8 +1422,10 @@ async def sample_list_finding_type_stats(): 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, 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: google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py index 85058aa16736..650b71708577 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.cloud.websecurityscanner_v1.services.web_security_scanner import pagers @@ -600,6 +610,10 @@ def __init__( # 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( @@ -666,6 +680,29 @@ def __init__( 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.websecurityscanner_v1.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -674,7 +711,7 @@ def create_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -709,8 +746,10 @@ def sample_create_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -756,7 +795,7 @@ def delete_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -789,8 +828,10 @@ def sample_delete_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -827,7 +868,7 @@ def get_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -862,8 +903,10 @@ def sample_get_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -909,7 +952,7 @@ def list_scan_configs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -945,8 +988,10 @@ def sample_list_scan_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1005,7 +1050,7 @@ def update_scan_config( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1041,8 +1086,10 @@ def sample_update_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanConfig: @@ -1088,7 +1135,7 @@ def start_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1123,8 +1170,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1169,7 +1218,7 @@ def get_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1204,8 +1253,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1250,7 +1301,7 @@ def list_scan_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1287,8 +1338,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1345,7 +1398,7 @@ def stop_scan_run( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1380,8 +1433,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ScanRun: @@ -1428,7 +1483,7 @@ def list_crawled_urls( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1464,8 +1519,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1522,7 +1579,7 @@ def get_finding( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1557,8 +1614,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.Finding: @@ -1603,7 +1662,7 @@ def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -1639,8 +1698,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsPager: @@ -1699,7 +1760,7 @@ def list_finding_type_stats( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1734,8 +1795,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py index 16634ce4da4f..0f8a83b9d71e 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -161,8 +163,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -315,8 +321,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -621,8 +635,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py index ddf38dbfcabf..44322b681ad9 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1.types import ( finding, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +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.websecurityscanner.v1.WebSecurityScanner", + "rpcName": 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.websecurityscanner.v1.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -264,7 +350,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -291,7 +377,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -317,7 +403,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -346,7 +432,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -375,7 +461,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -401,7 +487,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -427,7 +513,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -457,7 +543,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -483,7 +569,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -512,7 +598,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -538,7 +624,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -567,7 +653,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -596,7 +682,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -604,7 +690,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py index d7504dfdb30f..e647944b4179 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1.types import ( finding, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +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.websecurityscanner.v1.WebSecurityScanner", + "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.websecurityscanner.v1.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +358,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -302,7 +387,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -330,7 +415,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -359,7 +444,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -389,7 +474,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -417,7 +502,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -445,7 +530,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -475,7 +560,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -503,7 +588,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -532,7 +617,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -558,7 +643,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -587,7 +672,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -616,7 +701,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -789,7 +874,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py index e391218e0948..0468accd4a1c 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -175,8 +183,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -198,8 +209,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -210,8 +224,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -231,8 +247,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -254,8 +273,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -275,8 +296,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -298,8 +322,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -321,9 +348,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -346,8 +374,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -369,8 +400,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -392,8 +426,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -413,8 +450,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -434,8 +473,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -580,7 +622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -590,8 +632,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_config.ScanConfig: @@ -603,6 +647,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -619,6 +664,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -640,7 +712,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.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.websecurityscanner_v1.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -678,7 +772,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete scan config method over HTTP. @@ -688,13 +782,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -707,6 +804,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -756,7 +880,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -766,8 +890,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -780,6 +906,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -790,6 +917,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -810,7 +964,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.websecurityscanner_v1.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -848,7 +1024,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -858,8 +1034,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_config.ScanConfig: @@ -871,6 +1049,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -881,6 +1060,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -901,7 +1107,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.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.websecurityscanner_v1.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -938,7 +1166,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -948,8 +1176,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -962,6 +1192,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -972,6 +1203,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -992,7 +1250,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1030,7 +1310,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1040,8 +1320,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1051,6 +1333,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1063,6 +1346,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1083,7 +1393,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.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.websecurityscanner_v1.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1121,7 +1455,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1131,8 +1465,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingsResponse: @@ -1142,6 +1478,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1152,6 +1489,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1172,7 +1536,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.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.websecurityscanner_v1.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1210,7 +1598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1220,8 +1608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1231,6 +1621,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1243,6 +1634,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1265,7 +1683,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.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.websecurityscanner_v1.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1303,7 +1747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1313,8 +1757,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanConfigsResponse: @@ -1324,6 +1770,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1336,6 +1783,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1356,7 +1830,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.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.websecurityscanner_v1.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1394,7 +1892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1404,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanRunsResponse: @@ -1415,6 +1915,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1425,6 +1926,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1445,7 +1973,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.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.websecurityscanner_v1.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1484,7 +2036,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1494,8 +2046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1508,6 +2062,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1522,6 +2077,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1543,7 +2125,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1582,7 +2186,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1592,8 +2196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1606,6 +2212,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1620,6 +2227,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1641,7 +2275,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1680,7 +2336,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1690,8 +2346,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_config.ScanConfig: @@ -1703,6 +2361,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1719,6 +2378,33 @@ def __call__( 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.websecurityscanner_v1.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1740,7 +2426,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.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.websecurityscanner_v1.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py index 3e9450a8b77b..782b07f86ef5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +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 WebSecurityScannerAsyncClient: """Cloud Web Security Scanner Service identifies security @@ -279,6 +289,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.websecurityscanner_v1alpha.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -289,7 +321,7 @@ async def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -346,8 +378,10 @@ async def sample_create_scan_config(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -413,7 +447,7 @@ async def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -456,8 +490,10 @@ async def sample_delete_scan_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -511,7 +547,7 @@ async def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -556,8 +592,10 @@ async def sample_get_scan_config(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -621,7 +659,7 @@ async def list_scan_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -666,8 +704,10 @@ async def sample_list_scan_configs(): 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, 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -744,7 +784,7 @@ async def update_scan_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -803,8 +843,10 @@ async def sample_update_scan_config(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -870,7 +912,7 @@ async def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -915,8 +957,10 @@ async def sample_start_scan_run(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -977,7 +1021,7 @@ async def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1022,8 +1066,10 @@ async def sample_get_scan_run(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1084,7 +1130,7 @@ async def list_scan_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1131,8 +1177,10 @@ async def sample_list_scan_runs(): 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, 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -1206,7 +1254,7 @@ async def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1251,8 +1299,10 @@ async def sample_stop_scan_run(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1315,7 +1365,7 @@ async def list_crawled_urls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1361,8 +1411,10 @@ async def sample_list_crawled_urls(): 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, 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1436,7 +1488,7 @@ async def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1481,8 +1533,10 @@ async def sample_get_finding(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.Finding: @@ -1545,7 +1599,7 @@ async def list_findings( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1600,8 +1654,10 @@ async def sample_list_findings(): 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, 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1679,7 +1735,7 @@ async def list_finding_type_stats( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1724,8 +1780,10 @@ async def sample_list_finding_type_stats(): 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, 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: google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py index 788e913ff307..71a7637efedc 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -642,6 +652,10 @@ def __init__( # 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( @@ -708,6 +722,29 @@ def __init__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -718,7 +755,7 @@ def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -775,8 +812,10 @@ def sample_create_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -839,7 +878,7 @@ def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -882,8 +921,10 @@ def sample_delete_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -934,7 +975,7 @@ def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -979,8 +1020,10 @@ def sample_get_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -1041,7 +1084,7 @@ def list_scan_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -1086,8 +1129,10 @@ def sample_list_scan_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1161,7 +1206,7 @@ def update_scan_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1220,8 +1265,10 @@ def sample_update_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanConfig: @@ -1284,7 +1331,7 @@ def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1329,8 +1376,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1388,7 +1437,7 @@ def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1433,8 +1482,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1492,7 +1543,7 @@ def list_scan_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1539,8 +1590,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1611,7 +1664,7 @@ def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1656,8 +1709,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ScanRun: @@ -1717,7 +1772,7 @@ def list_crawled_urls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1763,8 +1818,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1835,7 +1892,7 @@ def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1880,8 +1937,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.Finding: @@ -1941,7 +2000,7 @@ def list_findings( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -1996,8 +2055,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsPager: @@ -2072,7 +2133,7 @@ def list_finding_type_stats( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -2117,8 +2178,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py index bc732c3edd4f..90f9902f9060 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -161,8 +163,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -315,8 +321,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -621,8 +635,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py index 765356d4a10a..7dab5292ce29 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1alpha.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +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.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": 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.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -262,7 +348,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -289,7 +375,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -315,7 +401,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -344,7 +430,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -373,7 +459,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -399,7 +485,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -425,7 +511,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -455,7 +541,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -481,7 +567,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -510,7 +596,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -536,7 +622,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -565,7 +651,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -594,7 +680,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -602,7 +688,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py index b442532d19e2..310814a48787 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1alpha.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1alpha.types import scan_config as gcw_scan_config @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +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.websecurityscanner.v1alpha.WebSecurityScanner", + "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.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -300,7 +385,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -328,7 +413,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -357,7 +442,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -387,7 +472,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -415,7 +500,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -443,7 +528,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -473,7 +558,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -501,7 +586,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -530,7 +615,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -556,7 +641,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -585,7 +670,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -614,7 +699,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -787,7 +872,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py index a3f21e7077c7..b3ab17f88981 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -173,8 +181,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -196,8 +207,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -208,8 +222,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -229,8 +245,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -252,8 +271,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -273,8 +294,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -296,8 +320,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -319,9 +346,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -344,8 +372,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -367,8 +398,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -390,8 +424,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -411,8 +448,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -432,8 +471,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -578,7 +620,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -588,8 +630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcw_scan_config.ScanConfig: @@ -602,6 +646,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -618,6 +663,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -639,7 +711,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.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.websecurityscanner_v1alpha.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -677,7 +771,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete scan config method over HTTP. @@ -687,13 +781,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -706,6 +803,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -755,7 +879,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -765,8 +889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -779,6 +905,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -789,6 +916,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -809,7 +963,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.websecurityscanner_v1alpha.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -847,7 +1023,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -857,8 +1033,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_config.ScanConfig: @@ -871,6 +1049,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -881,6 +1060,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -901,7 +1107,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.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.websecurityscanner_v1alpha.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -938,7 +1166,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -948,8 +1176,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -961,6 +1191,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -971,6 +1202,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -991,7 +1249,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1alpha.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1029,7 +1309,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1039,8 +1319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1050,6 +1332,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1062,6 +1345,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1082,7 +1392,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.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.websecurityscanner_v1alpha.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1120,7 +1454,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1130,8 +1464,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingsResponse: @@ -1141,6 +1477,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1151,6 +1488,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1171,7 +1535,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.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.websecurityscanner_v1alpha.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1209,7 +1597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1219,8 +1607,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1230,6 +1620,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1242,6 +1633,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1264,7 +1682,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.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.websecurityscanner_v1alpha.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1302,7 +1746,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1312,8 +1756,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanConfigsResponse: @@ -1323,6 +1769,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1335,6 +1782,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1355,7 +1829,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.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.websecurityscanner_v1alpha.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1393,7 +1891,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1403,8 +1901,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanRunsResponse: @@ -1414,6 +1914,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1424,6 +1925,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1444,7 +1972,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.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.websecurityscanner_v1alpha.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1483,7 +2035,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1493,8 +2045,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1506,6 +2060,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1520,6 +2075,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1541,7 +2123,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1alpha.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1580,7 +2184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1590,8 +2194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1603,6 +2209,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1617,6 +2224,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1638,7 +2272,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1alpha.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1677,7 +2333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1687,8 +2343,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcw_scan_config.ScanConfig: @@ -1701,6 +2359,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1717,6 +2376,33 @@ def __call__( 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.websecurityscanner_v1alpha.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1738,7 +2424,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.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.websecurityscanner_v1alpha.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py index f3b106ac2584..5994224367ff 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -65,6 +66,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .transports.grpc_asyncio import WebSecurityScannerGrpcAsyncIOTransport +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 WebSecurityScannerAsyncClient: """Cloud Web Security Scanner Service identifies security @@ -284,6 +294,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.websecurityscanner_v1beta.WebSecurityScannerAsyncClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "credentialsType": None, + }, + ) + async def create_scan_config( self, request: Optional[ @@ -294,7 +326,7 @@ async def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -351,8 +383,10 @@ async def sample_create_scan_config(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -417,7 +451,7 @@ async def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -460,8 +494,10 @@ async def sample_delete_scan_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -515,7 +551,7 @@ async def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -560,8 +596,10 @@ async def sample_get_scan_config(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -624,7 +662,7 @@ async def list_scan_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsAsyncPager: r"""Lists ScanConfigs under a given project. @@ -669,8 +707,10 @@ async def sample_list_scan_configs(): 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, 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsAsyncPager: @@ -747,7 +787,7 @@ async def update_scan_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -806,8 +846,10 @@ async def sample_update_scan_config(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -872,7 +914,7 @@ async def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -917,8 +959,10 @@ async def sample_start_scan_run(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -980,7 +1024,7 @@ async def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1025,8 +1069,10 @@ async def sample_get_scan_run(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1088,7 +1134,7 @@ async def list_scan_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsAsyncPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1135,8 +1181,10 @@ async def sample_list_scan_runs(): 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, 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsAsyncPager: @@ -1210,7 +1258,7 @@ async def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1255,8 +1303,10 @@ async def sample_stop_scan_run(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1320,7 +1370,7 @@ async def list_crawled_urls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsAsyncPager: r"""List CrawledUrls under a given ScanRun. @@ -1366,8 +1416,10 @@ async def sample_list_crawled_urls(): 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, 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager: @@ -1441,7 +1493,7 @@ async def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1486,8 +1538,10 @@ async def sample_get_finding(): 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, 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: google.cloud.websecurityscanner_v1beta.types.Finding: @@ -1550,7 +1604,7 @@ async def list_findings( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""List Findings under a given ScanRun. @@ -1605,8 +1659,10 @@ async def sample_list_findings(): 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, 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsAsyncPager: @@ -1684,7 +1740,7 @@ async def list_finding_type_stats( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -1729,8 +1785,10 @@ async def sample_list_finding_type_stats(): 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, 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: google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py index 062ed4055350..5da5353fd2dc 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -647,6 +657,10 @@ def __init__( # 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( @@ -713,6 +727,29 @@ def __init__( 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.websecurityscanner_v1beta.WebSecurityScannerClient`.", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "credentialsType": None, + }, + ) + def create_scan_config( self, request: Optional[ @@ -723,7 +760,7 @@ def create_scan_config( scan_config: Optional[gcw_scan_config.ScanConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Creates a new ScanConfig. @@ -780,8 +817,10 @@ def sample_create_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -843,7 +882,7 @@ def delete_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing ScanConfig and its child resources. @@ -886,8 +925,10 @@ def sample_delete_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -938,7 +979,7 @@ def get_scan_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Gets a ScanConfig. @@ -983,8 +1024,10 @@ def sample_get_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -1044,7 +1087,7 @@ def list_scan_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanConfigsPager: r"""Lists ScanConfigs under a given project. @@ -1089,8 +1132,10 @@ def sample_list_scan_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsPager: @@ -1164,7 +1209,7 @@ def update_scan_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Updates a ScanConfig. This method support partial update of a ScanConfig. @@ -1223,8 +1268,10 @@ def sample_update_scan_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanConfig: @@ -1286,7 +1333,7 @@ def start_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Start a ScanRun according to the given ScanConfig. @@ -1331,8 +1378,10 @@ def sample_start_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1391,7 +1440,7 @@ def get_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Gets a ScanRun. @@ -1436,8 +1485,10 @@ def sample_get_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1496,7 +1547,7 @@ def list_scan_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListScanRunsPager: r"""Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time. @@ -1543,8 +1594,10 @@ def sample_list_scan_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsPager: @@ -1615,7 +1668,7 @@ def stop_scan_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Stops a ScanRun. The stopped ScanRun is returned. @@ -1660,8 +1713,10 @@ def sample_stop_scan_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ScanRun: @@ -1722,7 +1777,7 @@ def list_crawled_urls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCrawledUrlsPager: r"""List CrawledUrls under a given ScanRun. @@ -1768,8 +1823,10 @@ def sample_list_crawled_urls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsPager: @@ -1840,7 +1897,7 @@ def get_finding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Gets a Finding. @@ -1885,8 +1942,10 @@ def sample_get_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.Finding: @@ -1946,7 +2005,7 @@ def list_findings( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""List Findings under a given ScanRun. @@ -2001,8 +2060,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsPager: @@ -2077,7 +2138,7 @@ def list_finding_type_stats( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""List all FindingTypeStats under a given ScanRun. @@ -2122,8 +2183,10 @@ def sample_list_finding_type_stats(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py index f0afb9ae5ca7..30afc61e3aa4 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -147,7 +149,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -161,8 +163,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanConfigsRequest(request) @@ -227,7 +231,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -241,8 +245,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -301,7 +307,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -315,8 +321,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListScanRunsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListCrawledUrlsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) @@ -607,7 +621,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -621,8 +635,10 @@ def __init__( 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, 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`. """ self._method = method self._request = web_security_scanner.ListFindingsRequest(request) diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py index 0de4851178f2..c46489c05b12 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1beta.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport +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.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": 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.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcTransport(WebSecurityScannerTransport): """gRPC backend transport for WebSecurityScanner. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -262,7 +348,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -289,7 +375,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -315,7 +401,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -344,7 +430,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -373,7 +459,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -399,7 +485,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -425,7 +511,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -455,7 +541,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -481,7 +567,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -510,7 +596,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -536,7 +622,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -565,7 +651,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -594,7 +680,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -602,7 +688,7 @@ def list_finding_type_stats( return self._stubs["list_finding_type_stats"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py index d3be3c720ebb..8b740e7dedf1 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.websecurityscanner_v1beta.types import scan_run, web_security_scanner from google.cloud.websecurityscanner_v1beta.types import scan_config as gcw_scan_config @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, WebSecurityScannerTransport from .grpc import WebSecurityScannerGrpcTransport +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.websecurityscanner.v1beta.WebSecurityScanner", + "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.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WebSecurityScannerGrpcAsyncIOTransport(WebSecurityScannerTransport): """gRPC AsyncIO backend transport for WebSecurityScanner. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def create_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_scan_config" not in self._stubs: - self._stubs["create_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["create_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig", request_serializer=web_security_scanner.CreateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -300,7 +385,7 @@ def delete_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_scan_config" not in self._stubs: - self._stubs["delete_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig", request_serializer=web_security_scanner.DeleteScanConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -328,7 +413,7 @@ def get_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_config" not in self._stubs: - self._stubs["get_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig", request_serializer=web_security_scanner.GetScanConfigRequest.serialize, response_deserializer=scan_config.ScanConfig.deserialize, @@ -357,7 +442,7 @@ def list_scan_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_configs" not in self._stubs: - self._stubs["list_scan_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_configs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs", request_serializer=web_security_scanner.ListScanConfigsRequest.serialize, response_deserializer=web_security_scanner.ListScanConfigsResponse.deserialize, @@ -387,7 +472,7 @@ def update_scan_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_scan_config" not in self._stubs: - self._stubs["update_scan_config"] = self.grpc_channel.unary_unary( + self._stubs["update_scan_config"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig", request_serializer=web_security_scanner.UpdateScanConfigRequest.serialize, response_deserializer=gcw_scan_config.ScanConfig.deserialize, @@ -415,7 +500,7 @@ def start_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_scan_run" not in self._stubs: - self._stubs["start_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["start_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun", request_serializer=web_security_scanner.StartScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -443,7 +528,7 @@ def get_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_scan_run" not in self._stubs: - self._stubs["get_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["get_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun", request_serializer=web_security_scanner.GetScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -473,7 +558,7 @@ def list_scan_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_scan_runs" not in self._stubs: - self._stubs["list_scan_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_scan_runs"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns", request_serializer=web_security_scanner.ListScanRunsRequest.serialize, response_deserializer=web_security_scanner.ListScanRunsResponse.deserialize, @@ -501,7 +586,7 @@ def stop_scan_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_scan_run" not in self._stubs: - self._stubs["stop_scan_run"] = self.grpc_channel.unary_unary( + self._stubs["stop_scan_run"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun", request_serializer=web_security_scanner.StopScanRunRequest.serialize, response_deserializer=scan_run.ScanRun.deserialize, @@ -530,7 +615,7 @@ def list_crawled_urls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_crawled_urls" not in self._stubs: - self._stubs["list_crawled_urls"] = self.grpc_channel.unary_unary( + self._stubs["list_crawled_urls"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls", request_serializer=web_security_scanner.ListCrawledUrlsRequest.serialize, response_deserializer=web_security_scanner.ListCrawledUrlsResponse.deserialize, @@ -556,7 +641,7 @@ def get_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_finding" not in self._stubs: - self._stubs["get_finding"] = self.grpc_channel.unary_unary( + self._stubs["get_finding"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding", request_serializer=web_security_scanner.GetFindingRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -585,7 +670,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings", request_serializer=web_security_scanner.ListFindingsRequest.serialize, response_deserializer=web_security_scanner.ListFindingsResponse.deserialize, @@ -614,7 +699,7 @@ def list_finding_type_stats( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_finding_type_stats" not in self._stubs: - self._stubs["list_finding_type_stats"] = self.grpc_channel.unary_unary( + self._stubs["list_finding_type_stats"] = self._logged_channel.unary_unary( "/google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats", request_serializer=web_security_scanner.ListFindingTypeStatsRequest.serialize, response_deserializer=web_security_scanner.ListFindingTypeStatsResponse.deserialize, @@ -787,7 +872,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py index dd1012c8d09f..f97923c261c7 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -173,8 +181,11 @@ def post_update_scan_config(self, response): def pre_create_scan_config( self, request: web_security_scanner.CreateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.CreateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.CreateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_scan_config Override in a subclass to manipulate the request or metadata @@ -196,8 +207,11 @@ def post_create_scan_config( def pre_delete_scan_config( self, request: web_security_scanner.DeleteScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.DeleteScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.DeleteScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_scan_config Override in a subclass to manipulate the request or metadata @@ -208,8 +222,10 @@ def pre_delete_scan_config( def pre_get_finding( self, request: web_security_scanner.GetFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetFindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_finding Override in a subclass to manipulate the request or metadata @@ -229,8 +245,11 @@ def post_get_finding(self, response: finding.Finding) -> finding.Finding: def pre_get_scan_config( self, request: web_security_scanner.GetScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_scan_config Override in a subclass to manipulate the request or metadata @@ -252,8 +271,10 @@ def post_get_scan_config( def pre_get_scan_run( self, request: web_security_scanner.GetScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.GetScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_scan_run Override in a subclass to manipulate the request or metadata @@ -273,8 +294,11 @@ def post_get_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_list_crawled_urls( self, request: web_security_scanner.ListCrawledUrlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListCrawledUrlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListCrawledUrlsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_crawled_urls Override in a subclass to manipulate the request or metadata @@ -296,8 +320,11 @@ def post_list_crawled_urls( def pre_list_findings( self, request: web_security_scanner.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -319,9 +346,10 @@ def post_list_findings( def pre_list_finding_type_stats( self, request: web_security_scanner.ListFindingTypeStatsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - web_security_scanner.ListFindingTypeStatsRequest, Sequence[Tuple[str, str]] + web_security_scanner.ListFindingTypeStatsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_finding_type_stats @@ -344,8 +372,11 @@ def post_list_finding_type_stats( def pre_list_scan_configs( self, request: web_security_scanner.ListScanConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_configs Override in a subclass to manipulate the request or metadata @@ -367,8 +398,11 @@ def post_list_scan_configs( def pre_list_scan_runs( self, request: web_security_scanner.ListScanRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.ListScanRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.ListScanRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_scan_runs Override in a subclass to manipulate the request or metadata @@ -390,8 +424,11 @@ def post_list_scan_runs( def pre_start_scan_run( self, request: web_security_scanner.StartScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StartScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StartScanRunRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_scan_run Override in a subclass to manipulate the request or metadata @@ -411,8 +448,10 @@ def post_start_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_stop_scan_run( self, request: web_security_scanner.StopScanRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.StopScanRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_scan_run Override in a subclass to manipulate the request or metadata @@ -432,8 +471,11 @@ def post_stop_scan_run(self, response: scan_run.ScanRun) -> scan_run.ScanRun: def pre_update_scan_config( self, request: web_security_scanner.UpdateScanConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[web_security_scanner.UpdateScanConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + web_security_scanner.UpdateScanConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_scan_config Override in a subclass to manipulate the request or metadata @@ -578,7 +620,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the create scan config method over HTTP. @@ -588,8 +630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcw_scan_config.ScanConfig: @@ -601,6 +645,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseCreateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_scan_config( request, metadata ) @@ -617,6 +662,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.CreateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._CreateScanConfig._get_response( self._host, @@ -638,7 +710,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.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.websecurityscanner_v1beta.WebSecurityScannerClient.create_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "CreateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteScanConfig( @@ -676,7 +770,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete scan config method over HTTP. @@ -686,13 +780,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWebSecurityScannerRestTransport._BaseDeleteScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_scan_config( request, metadata ) @@ -705,6 +802,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.DeleteScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "DeleteScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._DeleteScanConfig._get_response( self._host, @@ -754,7 +878,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the get finding method over HTTP. @@ -764,8 +888,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -778,6 +904,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_finding(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetFinding._get_transcoded_request( http_options, request @@ -788,6 +915,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.GetFinding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetFinding._get_response( self._host, @@ -808,7 +962,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.websecurityscanner_v1beta.WebSecurityScannerClient.get_finding", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanConfig( @@ -846,7 +1022,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_config.ScanConfig: r"""Call the get scan config method over HTTP. @@ -856,8 +1032,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_config.ScanConfig: @@ -869,6 +1047,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_config(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanConfig._get_transcoded_request( http_options, request @@ -879,6 +1058,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.GetScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanConfig._get_response( self._host, @@ -899,7 +1105,29 @@ def __call__( pb_resp = scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_config.ScanConfig.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.websecurityscanner_v1beta.WebSecurityScannerClient.get_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScanRun( @@ -936,7 +1164,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the get scan run method over HTTP. @@ -946,8 +1174,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -960,6 +1190,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseGetScanRun._get_transcoded_request( http_options, request @@ -970,6 +1201,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.GetScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._GetScanRun._get_response( self._host, @@ -990,7 +1248,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1beta.WebSecurityScannerClient.get_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "GetScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCrawledUrls( @@ -1028,7 +1308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListCrawledUrlsResponse: r"""Call the list crawled urls method over HTTP. @@ -1038,8 +1318,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListCrawledUrlsResponse: @@ -1049,6 +1331,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListCrawledUrls._get_http_options() ) + request, metadata = self._interceptor.pre_list_crawled_urls( request, metadata ) @@ -1061,6 +1344,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.ListCrawledUrls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListCrawledUrls._get_response( self._host, @@ -1081,7 +1391,31 @@ def __call__( pb_resp = web_security_scanner.ListCrawledUrlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_crawled_urls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListCrawledUrlsResponse.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.websecurityscanner_v1beta.WebSecurityScannerClient.list_crawled_urls", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListCrawledUrls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1119,7 +1453,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1129,8 +1463,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingsResponse: @@ -1140,6 +1476,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1150,6 +1487,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.ListFindings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListFindings._get_response( self._host, @@ -1170,7 +1534,31 @@ def __call__( pb_resp = web_security_scanner.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingsResponse.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.websecurityscanner_v1beta.WebSecurityScannerClient.list_findings", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindingTypeStats( @@ -1208,7 +1596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListFindingTypeStatsResponse: r"""Call the list finding type stats method over HTTP. @@ -1218,8 +1606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListFindingTypeStatsResponse: @@ -1229,6 +1619,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListFindingTypeStats._get_http_options() ) + request, metadata = self._interceptor.pre_list_finding_type_stats( request, metadata ) @@ -1241,6 +1632,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.ListFindingTypeStats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WebSecurityScannerRestTransport._ListFindingTypeStats._get_response( @@ -1263,7 +1681,33 @@ def __call__( pb_resp = web_security_scanner.ListFindingTypeStatsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_finding_type_stats(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListFindingTypeStatsResponse.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.websecurityscanner_v1beta.WebSecurityScannerClient.list_finding_type_stats", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListFindingTypeStats", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanConfigs( @@ -1301,7 +1745,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanConfigsResponse: r"""Call the list scan configs method over HTTP. @@ -1311,8 +1755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanConfigsResponse: @@ -1322,6 +1768,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_configs( request, metadata ) @@ -1334,6 +1781,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.ListScanConfigs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanConfigs._get_response( self._host, @@ -1354,7 +1828,31 @@ def __call__( pb_resp = web_security_scanner.ListScanConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanConfigsResponse.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.websecurityscanner_v1beta.WebSecurityScannerClient.list_scan_configs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListScanRuns( @@ -1392,7 +1890,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> web_security_scanner.ListScanRunsResponse: r"""Call the list scan runs method over HTTP. @@ -1402,8 +1900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.web_security_scanner.ListScanRunsResponse: @@ -1413,6 +1913,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_scan_runs(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseListScanRuns._get_transcoded_request( http_options, request @@ -1423,6 +1924,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.ListScanRuns", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._ListScanRuns._get_response( self._host, @@ -1443,7 +1971,31 @@ def __call__( pb_resp = web_security_scanner.ListScanRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_scan_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + web_security_scanner.ListScanRunsResponse.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.websecurityscanner_v1beta.WebSecurityScannerClient.list_scan_runs", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "ListScanRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartScanRun( @@ -1482,7 +2034,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the start scan run method over HTTP. @@ -1492,8 +2044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1506,6 +2060,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_start_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStartScanRun._get_transcoded_request( http_options, request @@ -1520,6 +2075,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.StartScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StartScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StartScanRun._get_response( self._host, @@ -1541,7 +2123,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1beta.WebSecurityScannerClient.start_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StartScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopScanRun( @@ -1580,7 +2184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> scan_run.ScanRun: r"""Call the stop scan run method over HTTP. @@ -1590,8 +2194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.scan_run.ScanRun: @@ -1604,6 +2210,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_http_options() ) + request, metadata = self._interceptor.pre_stop_scan_run(request, metadata) transcoded_request = _BaseWebSecurityScannerRestTransport._BaseStopScanRun._get_transcoded_request( http_options, request @@ -1618,6 +2225,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.StopScanRun", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StopScanRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._StopScanRun._get_response( self._host, @@ -1639,7 +2273,29 @@ def __call__( pb_resp = scan_run.ScanRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_scan_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = scan_run.ScanRun.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.websecurityscanner_v1beta.WebSecurityScannerClient.stop_scan_run", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "StopScanRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateScanConfig( @@ -1678,7 +2334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcw_scan_config.ScanConfig: r"""Call the update scan config method over HTTP. @@ -1688,8 +2344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcw_scan_config.ScanConfig: @@ -1701,6 +2359,7 @@ def __call__( http_options = ( _BaseWebSecurityScannerRestTransport._BaseUpdateScanConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_scan_config( request, metadata ) @@ -1717,6 +2376,33 @@ def __call__( 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.websecurityscanner_v1beta.WebSecurityScannerClient.UpdateScanConfig", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WebSecurityScannerRestTransport._UpdateScanConfig._get_response( self._host, @@ -1738,7 +2424,29 @@ def __call__( pb_resp = gcw_scan_config.ScanConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_scan_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcw_scan_config.ScanConfig.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.websecurityscanner_v1beta.WebSecurityScannerClient.update_scan_config", + extra={ + "serviceName": "google.cloud.websecurityscanner.v1beta.WebSecurityScanner", + "rpcName": "UpdateScanConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json index fbe13417adf8..147488567a91 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -269,7 +269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -343,7 +343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.Finding", @@ -419,7 +419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.Finding", @@ -496,7 +496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -572,7 +572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -649,7 +649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -802,7 +802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -878,7 +878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -955,7 +955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ListFindingTypeStatsResponse", @@ -1108,7 +1108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListFindingsPager", @@ -1261,7 +1261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1337,7 +1337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1414,7 +1414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1567,7 +1567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1643,7 +1643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1720,7 +1720,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1796,7 +1796,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanRun", @@ -1873,7 +1873,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", @@ -1949,7 +1949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json index 2782c45770c8..21a75dfa6018 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.Finding", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.Finding", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ListFindingTypeStatsResponse", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListFindingsPager", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanRun", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1alpha.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json index 50e171a75d7a..a41a6a4c4dd5 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_scan_config" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.Finding", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.Finding", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListCrawledUrlsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ListFindingTypeStatsResponse", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsAsyncPager", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListFindingsPager", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsAsyncPager", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanConfigsPager", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsAsyncPager", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.services.web_security_scanner.pagers.ListScanRunsPager", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanRun", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.websecurityscanner_v1beta.types.ScanConfig", diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py index fe85729b31f5..d07c0978e8c1 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py @@ -6956,6 +6956,7 @@ def test_create_scan_config_rest_bad_request( 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_scan_config(request) @@ -7104,6 +7105,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -7157,6 +7159,7 @@ def test_create_scan_config_rest_interceptors(null_interceptor): 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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7201,6 +7204,7 @@ def test_delete_scan_config_rest_bad_request( 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_scan_config(request) @@ -7231,6 +7235,7 @@ def test_delete_scan_config_rest_call_success(request_type): 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_scan_config(request) # Establish that the response is the type that we expect. @@ -7267,6 +7272,7 @@ def test_delete_scan_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -7307,6 +7313,7 @@ def test_get_scan_config_rest_bad_request( 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_scan_config(request) @@ -7352,6 +7359,7 @@ def test_get_scan_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -7405,6 +7413,7 @@ def test_get_scan_config_rest_interceptors(null_interceptor): 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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7449,6 +7458,7 @@ def test_list_scan_configs_rest_bad_request( 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_scan_configs(request) @@ -7484,6 +7494,7 @@ def test_list_scan_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_configs(request) # Establish that the response is the type that we expect. @@ -7524,6 +7535,7 @@ def test_list_scan_configs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -7570,6 +7582,7 @@ def test_update_scan_config_rest_bad_request( 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_scan_config(request) @@ -7718,6 +7731,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -7771,6 +7785,7 @@ def test_update_scan_config_rest_interceptors(null_interceptor): 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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -7815,6 +7830,7 @@ def test_start_scan_run_rest_bad_request( 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.start_scan_run(request) @@ -7856,6 +7872,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_scan_run(request) # Establish that the response is the type that we expect. @@ -7902,6 +7919,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -7946,6 +7964,7 @@ def test_get_scan_run_rest_bad_request( 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_scan_run(request) @@ -7987,6 +8006,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_run(request) # Establish that the response is the type that we expect. @@ -8033,6 +8053,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -8077,6 +8098,7 @@ def test_list_scan_runs_rest_bad_request( 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_scan_runs(request) @@ -8112,6 +8134,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_runs(request) # Establish that the response is the type that we expect. @@ -8152,6 +8175,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -8198,6 +8222,7 @@ def test_stop_scan_run_rest_bad_request( 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.stop_scan_run(request) @@ -8239,6 +8264,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_scan_run(request) # Establish that the response is the type that we expect. @@ -8285,6 +8311,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -8329,6 +8356,7 @@ def test_list_crawled_urls_rest_bad_request( 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_crawled_urls(request) @@ -8364,6 +8392,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_crawled_urls(request) # Establish that the response is the type that we expect. @@ -8404,6 +8433,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -8452,6 +8482,7 @@ def test_get_finding_rest_bad_request( 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_finding(request) @@ -8499,6 +8530,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -8549,6 +8581,7 @@ def test_get_finding_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -8593,6 +8626,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -8628,6 +8662,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -8668,6 +8703,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -8714,6 +8750,7 @@ def test_list_finding_type_stats_rest_bad_request( 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_finding_type_stats(request) @@ -8749,6 +8786,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -8788,6 +8826,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py index f61eef6d32c7..eca8e50dd406 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py @@ -6520,6 +6520,7 @@ def test_create_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6574,6 +6575,7 @@ def test_create_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -6706,6 +6708,7 @@ def test_delete_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6749,6 +6752,7 @@ def test_delete_scan_config_rest_flattened(): 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"} client.delete_scan_config(**mock_args) @@ -6879,6 +6883,7 @@ def test_get_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6924,6 +6929,7 @@ def test_get_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -7063,6 +7069,7 @@ def test_list_scan_configs_rest_required_fields( response_value._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_scan_configs(request) @@ -7116,6 +7123,7 @@ def test_list_scan_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_configs(**mock_args) @@ -7311,6 +7319,7 @@ def test_update_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -7367,6 +7376,7 @@ def test_update_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -7500,6 +7510,7 @@ def test_start_scan_run_rest_required_fields( response_value._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.start_scan_run(request) @@ -7545,6 +7556,7 @@ def test_start_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_scan_run(**mock_args) @@ -7675,6 +7687,7 @@ def test_get_scan_run_rest_required_fields( response_value._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_scan_run(request) @@ -7722,6 +7735,7 @@ def test_get_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_run(**mock_args) @@ -7860,6 +7874,7 @@ def test_list_scan_runs_rest_required_fields( response_value._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_scan_runs(request) @@ -7913,6 +7928,7 @@ def test_list_scan_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_runs(**mock_args) @@ -8108,6 +8124,7 @@ def test_stop_scan_run_rest_required_fields( response_value._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.stop_scan_run(request) @@ -8155,6 +8172,7 @@ def test_stop_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.stop_scan_run(**mock_args) @@ -8295,6 +8313,7 @@ def test_list_crawled_urls_rest_required_fields( response_value._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_crawled_urls(request) @@ -8350,6 +8369,7 @@ def test_list_crawled_urls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_crawled_urls(**mock_args) @@ -8546,6 +8566,7 @@ def test_get_finding_rest_required_fields( response_value._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_finding(request) @@ -8593,6 +8614,7 @@ def test_get_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -8739,6 +8761,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -8807,6 +8830,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_findings(**mock_args) @@ -9011,6 +9035,7 @@ def test_list_finding_type_stats_rest_required_fields( response_value._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_finding_type_stats(request) @@ -9060,6 +9085,7 @@ def test_list_finding_type_stats_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding_type_stats(**mock_args) @@ -9924,6 +9950,7 @@ def test_create_scan_config_rest_bad_request( 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_scan_config(request) @@ -10070,6 +10097,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10118,6 +10146,7 @@ def test_create_scan_config_rest_interceptors(null_interceptor): 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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10162,6 +10191,7 @@ def test_delete_scan_config_rest_bad_request( 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_scan_config(request) @@ -10192,6 +10222,7 @@ def test_delete_scan_config_rest_call_success(request_type): 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_scan_config(request) # Establish that the response is the type that we expect. @@ -10228,6 +10259,7 @@ def test_delete_scan_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -10268,6 +10300,7 @@ def test_get_scan_config_rest_bad_request( 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_scan_config(request) @@ -10309,6 +10342,7 @@ def test_get_scan_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10357,6 +10391,7 @@ def test_get_scan_config_rest_interceptors(null_interceptor): 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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -10401,6 +10436,7 @@ def test_list_scan_configs_rest_bad_request( 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_scan_configs(request) @@ -10436,6 +10472,7 @@ def test_list_scan_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_configs(request) # Establish that the response is the type that we expect. @@ -10476,6 +10513,7 @@ def test_list_scan_configs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -10522,6 +10560,7 @@ def test_update_scan_config_rest_bad_request( 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_scan_config(request) @@ -10668,6 +10707,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10716,6 +10756,7 @@ def test_update_scan_config_rest_interceptors(null_interceptor): 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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10760,6 +10801,7 @@ def test_start_scan_run_rest_bad_request( 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.start_scan_run(request) @@ -10801,6 +10843,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_scan_run(request) # Establish that the response is the type that we expect. @@ -10847,6 +10890,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -10891,6 +10935,7 @@ def test_get_scan_run_rest_bad_request( 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_scan_run(request) @@ -10932,6 +10977,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_run(request) # Establish that the response is the type that we expect. @@ -10978,6 +11024,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11022,6 +11069,7 @@ def test_list_scan_runs_rest_bad_request( 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_scan_runs(request) @@ -11057,6 +11105,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_runs(request) # Establish that the response is the type that we expect. @@ -11097,6 +11146,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -11143,6 +11193,7 @@ def test_stop_scan_run_rest_bad_request( 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.stop_scan_run(request) @@ -11184,6 +11235,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_scan_run(request) # Establish that the response is the type that we expect. @@ -11230,6 +11282,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11274,6 +11327,7 @@ def test_list_crawled_urls_rest_bad_request( 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_crawled_urls(request) @@ -11309,6 +11363,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_crawled_urls(request) # Establish that the response is the type that we expect. @@ -11349,6 +11404,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -11397,6 +11453,7 @@ def test_get_finding_rest_bad_request( 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_finding(request) @@ -11443,6 +11500,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -11492,6 +11550,7 @@ def test_get_finding_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -11536,6 +11595,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -11571,6 +11631,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -11611,6 +11672,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -11657,6 +11719,7 @@ def test_list_finding_type_stats_rest_bad_request( 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_finding_type_stats(request) @@ -11692,6 +11755,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -11731,6 +11795,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py index 7e41bc395da4..e731e5ab7299 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py @@ -6568,6 +6568,7 @@ def test_create_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6622,6 +6623,7 @@ def test_create_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -6754,6 +6756,7 @@ def test_delete_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6797,6 +6800,7 @@ def test_delete_scan_config_rest_flattened(): 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"} client.delete_scan_config(**mock_args) @@ -6927,6 +6931,7 @@ def test_get_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -6972,6 +6977,7 @@ def test_get_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -7111,6 +7117,7 @@ def test_list_scan_configs_rest_required_fields( response_value._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_scan_configs(request) @@ -7164,6 +7171,7 @@ def test_list_scan_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_configs(**mock_args) @@ -7359,6 +7367,7 @@ def test_update_scan_config_rest_required_fields( response_value._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_scan_config(request) @@ -7415,6 +7424,7 @@ def test_update_scan_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_config(**mock_args) @@ -7548,6 +7558,7 @@ def test_start_scan_run_rest_required_fields( response_value._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.start_scan_run(request) @@ -7593,6 +7604,7 @@ def test_start_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_scan_run(**mock_args) @@ -7723,6 +7735,7 @@ def test_get_scan_run_rest_required_fields( response_value._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_scan_run(request) @@ -7770,6 +7783,7 @@ def test_get_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_run(**mock_args) @@ -7908,6 +7922,7 @@ def test_list_scan_runs_rest_required_fields( response_value._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_scan_runs(request) @@ -7961,6 +7976,7 @@ def test_list_scan_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_scan_runs(**mock_args) @@ -8156,6 +8172,7 @@ def test_stop_scan_run_rest_required_fields( response_value._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.stop_scan_run(request) @@ -8203,6 +8220,7 @@ def test_stop_scan_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.stop_scan_run(**mock_args) @@ -8343,6 +8361,7 @@ def test_list_crawled_urls_rest_required_fields( response_value._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_crawled_urls(request) @@ -8398,6 +8417,7 @@ def test_list_crawled_urls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_crawled_urls(**mock_args) @@ -8594,6 +8614,7 @@ def test_get_finding_rest_required_fields( response_value._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_finding(request) @@ -8641,6 +8662,7 @@ def test_get_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -8787,6 +8809,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -8855,6 +8878,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_findings(**mock_args) @@ -9059,6 +9083,7 @@ def test_list_finding_type_stats_rest_required_fields( response_value._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_finding_type_stats(request) @@ -9108,6 +9133,7 @@ def test_list_finding_type_stats_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding_type_stats(**mock_args) @@ -9978,6 +10004,7 @@ def test_create_scan_config_rest_bad_request( 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_scan_config(request) @@ -10134,6 +10161,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10187,6 +10215,7 @@ def test_create_scan_config_rest_interceptors(null_interceptor): 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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10231,6 +10260,7 @@ def test_delete_scan_config_rest_bad_request( 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_scan_config(request) @@ -10261,6 +10291,7 @@ def test_delete_scan_config_rest_call_success(request_type): 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_scan_config(request) # Establish that the response is the type that we expect. @@ -10297,6 +10328,7 @@ def test_delete_scan_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = web_security_scanner.DeleteScanConfigRequest() metadata = [ @@ -10337,6 +10369,7 @@ def test_get_scan_config_rest_bad_request( 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_scan_config(request) @@ -10380,6 +10413,7 @@ def test_get_scan_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10433,6 +10467,7 @@ def test_get_scan_config_rest_interceptors(null_interceptor): 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 = scan_config.ScanConfig.to_json(scan_config.ScanConfig()) req.return_value.content = return_value @@ -10477,6 +10512,7 @@ def test_list_scan_configs_rest_bad_request( 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_scan_configs(request) @@ -10512,6 +10548,7 @@ def test_list_scan_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_configs(request) # Establish that the response is the type that we expect. @@ -10552,6 +10589,7 @@ def test_list_scan_configs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanConfigsResponse.to_json( web_security_scanner.ListScanConfigsResponse() ) @@ -10598,6 +10636,7 @@ def test_update_scan_config_rest_bad_request( 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_scan_config(request) @@ -10754,6 +10793,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_config(request) # Establish that the response is the type that we expect. @@ -10807,6 +10847,7 @@ def test_update_scan_config_rest_interceptors(null_interceptor): 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 = gcw_scan_config.ScanConfig.to_json(gcw_scan_config.ScanConfig()) req.return_value.content = return_value @@ -10851,6 +10892,7 @@ def test_start_scan_run_rest_bad_request( 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.start_scan_run(request) @@ -10892,6 +10934,7 @@ def test_start_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_scan_run(request) # Establish that the response is the type that we expect. @@ -10938,6 +10981,7 @@ def test_start_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -10982,6 +11026,7 @@ def test_get_scan_run_rest_bad_request( 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_scan_run(request) @@ -11023,6 +11068,7 @@ def test_get_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_run(request) # Establish that the response is the type that we expect. @@ -11069,6 +11115,7 @@ def test_get_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11113,6 +11160,7 @@ def test_list_scan_runs_rest_bad_request( 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_scan_runs(request) @@ -11148,6 +11196,7 @@ def test_list_scan_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_scan_runs(request) # Establish that the response is the type that we expect. @@ -11188,6 +11237,7 @@ def test_list_scan_runs_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListScanRunsResponse.to_json( web_security_scanner.ListScanRunsResponse() ) @@ -11234,6 +11284,7 @@ def test_stop_scan_run_rest_bad_request( 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.stop_scan_run(request) @@ -11275,6 +11326,7 @@ def test_stop_scan_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_scan_run(request) # Establish that the response is the type that we expect. @@ -11321,6 +11373,7 @@ def test_stop_scan_run_rest_interceptors(null_interceptor): 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 = scan_run.ScanRun.to_json(scan_run.ScanRun()) req.return_value.content = return_value @@ -11365,6 +11418,7 @@ def test_list_crawled_urls_rest_bad_request( 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_crawled_urls(request) @@ -11400,6 +11454,7 @@ def test_list_crawled_urls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_crawled_urls(request) # Establish that the response is the type that we expect. @@ -11440,6 +11495,7 @@ def test_list_crawled_urls_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListCrawledUrlsResponse.to_json( web_security_scanner.ListCrawledUrlsResponse() ) @@ -11488,6 +11544,7 @@ def test_get_finding_rest_bad_request( 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_finding(request) @@ -11534,6 +11591,7 @@ def test_get_finding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -11583,6 +11641,7 @@ def test_get_finding_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -11627,6 +11686,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -11662,6 +11722,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -11702,6 +11763,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingsResponse.to_json( web_security_scanner.ListFindingsResponse() ) @@ -11748,6 +11810,7 @@ def test_list_finding_type_stats_rest_bad_request( 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_finding_type_stats(request) @@ -11783,6 +11846,7 @@ def test_list_finding_type_stats_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding_type_stats(request) # Establish that the response is the type that we expect. @@ -11822,6 +11886,7 @@ def test_list_finding_type_stats_rest_interceptors(null_interceptor): 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 = web_security_scanner.ListFindingTypeStatsResponse.to_json( web_security_scanner.ListFindingTypeStatsResponse() ) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py index ece3c3598599..a54a789d2975 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .transports.grpc_asyncio import ExecutionsGrpcAsyncIOTransport +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 ExecutionsAsyncClient: """Executions is used to start and manage running instances of @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workflows.executions_v1.ExecutionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "credentialsType": None, + }, + ) + async def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -262,7 +294,7 @@ async def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsAsyncPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -312,8 +344,10 @@ async def sample_list_executions(): 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, 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: google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsAsyncPager: @@ -390,7 +424,7 @@ async def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -445,8 +479,10 @@ async def sample_create_execution(): 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, 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: google.cloud.workflows.executions_v1.types.Execution: @@ -509,7 +545,7 @@ async def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -556,8 +592,10 @@ async def sample_get_execution(): 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, 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: google.cloud.workflows.executions_v1.types.Execution: @@ -618,7 +656,7 @@ async def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -665,8 +703,10 @@ async def sample_cancel_execution(): 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, 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: google.cloud.workflows.executions_v1.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py index 66a2899d88cc..e97f953c9e22 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -603,6 +613,10 @@ def __init__( # 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( @@ -665,6 +679,29 @@ def __init__( 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.workflows.executions_v1.ExecutionsClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "credentialsType": None, + }, + ) + def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -672,7 +709,7 @@ def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -722,8 +759,10 @@ def sample_list_executions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsPager: @@ -797,7 +836,7 @@ def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -852,8 +891,10 @@ def sample_create_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1.types.Execution: @@ -913,7 +954,7 @@ def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -960,8 +1001,10 @@ def sample_get_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1.types.Execution: @@ -1019,7 +1062,7 @@ def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -1066,8 +1109,10 @@ def sample_cancel_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py index 523a88da088b..ebd469bfee57 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = executions.ListExecutionsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = executions.ListExecutionsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py index 4589058a30c5..f71cf7bad475 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.workflows.executions_v1.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport +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.workflows.executions.v1.Executions", + "rpcName": 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.workflows.executions.v1.Executions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcTransport(ExecutionsTransport): """gRPC backend transport for Executions. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -287,7 +373,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -313,7 +399,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -339,7 +425,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -347,7 +433,7 @@ def cancel_execution( return self._stubs["cancel_execution"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py index 5cda3e22528f..4a44d93b3f12 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workflows.executions_v1.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .grpc import ExecutionsGrpcTransport +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.workflows.executions.v1.Executions", + "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.workflows.executions.v1.Executions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcAsyncIOTransport(ExecutionsTransport): """gRPC AsyncIO backend transport for Executions. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -295,7 +380,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -321,7 +406,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -347,7 +432,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -385,7 +470,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py index 67c7af47b23f..8d2cf92100ea 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .transports.grpc_asyncio import ExecutionsGrpcAsyncIOTransport +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 ExecutionsAsyncClient: """Executions is used to start and manage running instances of @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workflows.executions_v1beta.ExecutionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "credentialsType": None, + }, + ) + async def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -262,7 +294,7 @@ async def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsAsyncPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -314,8 +346,10 @@ async def sample_list_executions(): 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, 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: google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsAsyncPager: @@ -392,7 +426,7 @@ async def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -447,8 +481,10 @@ async def sample_create_execution(): 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, 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: google.cloud.workflows.executions_v1beta.types.Execution: @@ -511,7 +547,7 @@ async def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -558,8 +594,10 @@ async def sample_get_execution(): 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, 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: google.cloud.workflows.executions_v1beta.types.Execution: @@ -620,7 +658,7 @@ async def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -667,8 +705,10 @@ async def sample_cancel_execution(): 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, 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: google.cloud.workflows.executions_v1beta.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py index b760e063c950..2e4ff661809c 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.cloud.workflows.executions_v1beta.services.executions import pagers @@ -603,6 +613,10 @@ def __init__( # 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( @@ -665,6 +679,29 @@ def __init__( 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.workflows.executions_v1beta.ExecutionsClient`.", + extra={ + "serviceName": "google.cloud.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "credentialsType": None, + }, + ) + def list_executions( self, request: Optional[Union[executions.ListExecutionsRequest, dict]] = None, @@ -672,7 +709,7 @@ def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsPager: r"""Returns a list of executions which belong to the workflow with the given name. The method returns @@ -724,8 +761,10 @@ def sample_list_executions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsPager: @@ -799,7 +838,7 @@ def create_execution( execution: Optional[executions.Execution] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Creates a new execution using the latest revision of the given workflow. @@ -854,8 +893,10 @@ def sample_create_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1beta.types.Execution: @@ -915,7 +956,7 @@ def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Returns an execution of the given name. @@ -962,8 +1003,10 @@ def sample_get_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1beta.types.Execution: @@ -1021,7 +1064,7 @@ def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> executions.Execution: r"""Cancels an execution of the given name. @@ -1068,8 +1111,10 @@ def sample_cancel_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows.executions_v1beta.types.Execution: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py index 6ab8021fa8a2..19dec411d569 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = executions.ListExecutionsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = executions.ListExecutionsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py index bc053be2ff61..e3343974ce55 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.workflows.executions_v1beta.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport +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.workflows.executions.v1beta.Executions", + "rpcName": 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.workflows.executions.v1beta.Executions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcTransport(ExecutionsTransport): """gRPC backend transport for Executions. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -288,7 +374,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -314,7 +400,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -340,7 +426,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -348,7 +434,7 @@ def cancel_execution( return self._stubs["cancel_execution"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py index 13d57d0ad17f..af19660c074b 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workflows.executions_v1beta.types import executions from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .grpc import ExecutionsGrpcTransport +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.workflows.executions.v1beta.Executions", + "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.workflows.executions.v1beta.Executions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcAsyncIOTransport(ExecutionsTransport): """gRPC AsyncIO backend transport for Executions. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/ListExecutions", request_serializer=executions.ListExecutionsRequest.serialize, response_deserializer=executions.ListExecutionsResponse.deserialize, @@ -296,7 +381,7 @@ def create_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_execution" not in self._stubs: - self._stubs["create_execution"] = self.grpc_channel.unary_unary( + self._stubs["create_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CreateExecution", request_serializer=executions.CreateExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -322,7 +407,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/GetExecution", request_serializer=executions.GetExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -348,7 +433,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.workflows.executions.v1beta.Executions/CancelExecution", request_serializer=executions.CancelExecutionRequest.serialize, response_deserializer=executions.Execution.deserialize, @@ -386,7 +471,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py index 73e7f1be93f7..6d163e6c1b20 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .transports.grpc_asyncio import WorkflowsGrpcAsyncIOTransport +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 WorkflowsAsyncClient: """Workflows is used to deploy and execute workflow programs. @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workflows_v1.WorkflowsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "credentialsType": None, + }, + ) + async def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkflowsAsyncPager: r"""Lists workflows in a given project and location. The default order is not specified. @@ -317,8 +349,10 @@ async def sample_list_workflows(): 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, 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: google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsAsyncPager: @@ -394,7 +428,7 @@ async def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single workflow. @@ -441,8 +475,10 @@ async def sample_get_workflow(): 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, 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: google.cloud.workflows_v1.types.Workflow: @@ -505,7 +541,7 @@ async def create_workflow( workflow_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -584,8 +620,10 @@ async def sample_create_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -661,7 +699,7 @@ async def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a workflow with the specified name. This method also cancels and deletes all running @@ -713,8 +751,10 @@ async def sample_delete_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -794,7 +834,7 @@ async def update_workflow( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workflow. Running this method has no impact on already running @@ -857,8 +897,10 @@ async def sample_update_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -933,7 +975,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -944,8 +986,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -986,7 +1030,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -997,8 +1041,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1039,7 +1085,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1055,8 +1101,10 @@ async def delete_operation( 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, 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: None """ @@ -1093,7 +1141,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1104,8 +1152,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1146,7 +1196,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1157,8 +1207,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py index 28ee4a70547d..3456ac7e278d 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -611,6 +621,10 @@ def __init__( # 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( @@ -673,6 +687,29 @@ def __init__( 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.workflows_v1.WorkflowsClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "credentialsType": None, + }, + ) + def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -680,7 +717,7 @@ def list_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkflowsPager: r"""Lists workflows in a given project and location. The default order is not specified. @@ -729,8 +766,10 @@ def sample_list_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsPager: @@ -803,7 +842,7 @@ def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single workflow. @@ -850,8 +889,10 @@ def sample_get_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows_v1.types.Workflow: @@ -911,7 +952,7 @@ def create_workflow( workflow_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -990,8 +1031,10 @@ def sample_create_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1064,7 +1107,7 @@ def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a workflow with the specified name. This method also cancels and deletes all running @@ -1116,8 +1159,10 @@ def sample_delete_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1194,7 +1239,7 @@ def update_workflow( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workflow. Running this method has no impact on already running @@ -1257,8 +1302,10 @@ def sample_update_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1343,7 +1390,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1354,8 +1401,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1396,7 +1445,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1407,8 +1456,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1449,7 +1500,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1465,8 +1516,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1503,7 +1556,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1514,8 +1567,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1556,7 +1611,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1567,8 +1622,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py index 2fa3c7ad226b..d5d5b49bd7e8 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workflows.ListWorkflowsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workflows.ListWorkflowsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py index b0ee002b6167..9caa13723fa1 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.workflows_v1.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport +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.workflows.v1.Workflows", + "rpcName": 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.workflows.v1.Workflows", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcTransport(WorkflowsTransport): """gRPC backend transport for Workflows. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def list_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -299,7 +387,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -328,7 +416,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -356,7 +444,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +475,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +483,7 @@ def update_workflow( return self._stubs["update_workflow"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -407,7 +495,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -424,7 +512,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -443,7 +531,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -462,7 +550,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -479,7 +567,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py index 44a12240a3eb..db7184556fa4 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workflows_v1.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .grpc import WorkflowsGrpcTransport +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.workflows.v1.Workflows", + "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.workflows.v1.Workflows", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcAsyncIOTransport(WorkflowsTransport): """gRPC AsyncIO backend transport for Workflows. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def list_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -311,7 +396,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -342,7 +427,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +457,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +490,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -473,7 +558,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -489,7 +574,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -506,7 +591,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -525,7 +610,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -544,7 +629,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -561,7 +646,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py index 2df29537d5b2..edd59bc56b8e 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -111,8 +119,10 @@ def post_update_workflow(self, response): def pre_create_workflow( self, request: workflows.CreateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.CreateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.CreateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workflow Override in a subclass to manipulate the request or metadata @@ -134,8 +144,10 @@ def post_create_workflow( def pre_delete_workflow( self, request: workflows.DeleteWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.DeleteWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.DeleteWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workflow Override in a subclass to manipulate the request or metadata @@ -155,8 +167,10 @@ def post_delete_workflow( return response def pre_get_workflow( - self, request: workflows.GetWorkflowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, str]]]: + self, + request: workflows.GetWorkflowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_workflow Override in a subclass to manipulate the request or metadata @@ -176,8 +190,8 @@ def post_get_workflow(self, response: workflows.Workflow) -> workflows.Workflow: def pre_list_workflows( self, request: workflows.ListWorkflowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_workflows Override in a subclass to manipulate the request or metadata @@ -199,8 +213,10 @@ def post_list_workflows( def pre_update_workflow( self, request: workflows.UpdateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.UpdateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.UpdateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workflow Override in a subclass to manipulate the request or metadata @@ -222,8 +238,10 @@ def post_update_workflow( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -245,8 +263,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -268,8 +288,10 @@ def post_list_locations( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -289,8 +311,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -312,8 +336,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -503,7 +529,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workflow method over HTTP. @@ -515,8 +541,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -529,6 +557,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_create_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_transcoded_request( @@ -549,6 +578,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.CreateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "CreateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._CreateWorkflow._get_response( self._host, @@ -568,7 +624,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workflow(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.workflows_v1.WorkflowsClient.create_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "CreateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkflow( @@ -605,7 +683,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workflow method over HTTP. @@ -617,8 +695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -631,6 +711,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_transcoded_request( @@ -645,6 +726,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.DeleteWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteWorkflow._get_response( self._host, @@ -663,7 +771,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workflow(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.workflows_v1.WorkflowsClient.delete_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkflow(_BaseWorkflowsRestTransport._BaseGetWorkflow, WorkflowsRestStub): @@ -698,7 +828,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Call the get workflow method over HTTP. @@ -710,8 +840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workflows.Workflow: @@ -723,6 +855,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_get_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_transcoded_request( @@ -737,6 +870,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.GetWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetWorkflow._get_response( self._host, @@ -757,7 +917,29 @@ def __call__( pb_resp = workflows.Workflow.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.Workflow.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.workflows_v1.WorkflowsClient.get_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkflows( @@ -794,7 +976,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.ListWorkflowsResponse: r"""Call the list workflows method over HTTP. @@ -806,8 +988,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workflows.ListWorkflowsResponse: @@ -820,6 +1004,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_http_options() ) + request, metadata = self._interceptor.pre_list_workflows(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_transcoded_request( @@ -834,6 +1019,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.ListWorkflows", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListWorkflows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListWorkflows._get_response( self._host, @@ -854,7 +1066,29 @@ def __call__( pb_resp = workflows.ListWorkflowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workflows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.ListWorkflowsResponse.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.workflows_v1.WorkflowsClient.list_workflows", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListWorkflows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkflow( @@ -892,7 +1126,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workflow method over HTTP. @@ -904,8 +1138,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -918,6 +1154,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_update_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_transcoded_request( @@ -938,6 +1175,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.UpdateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "UpdateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._UpdateWorkflow._get_response( self._host, @@ -957,7 +1221,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workflow(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.workflows_v1.WorkflowsClient.update_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "UpdateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1036,7 +1322,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1046,8 +1332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1056,6 +1344,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1070,6 +1359,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.GetLocation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetLocation._get_response( self._host, @@ -1089,6 +1405,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.workflows_v1.WorkflowsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1129,7 +1466,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1139,8 +1476,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1149,6 +1488,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListLocations._get_transcoded_request( @@ -1163,6 +1503,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.ListLocations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListLocations._get_response( self._host, @@ -1182,6 +1549,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.workflows_v1.WorkflowsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1222,7 +1610,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1232,13 +1620,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWorkflowsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1253,6 +1644,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteOperation._get_response( self._host, @@ -1308,7 +1726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1318,8 +1736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1328,6 +1748,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1342,6 +1763,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetOperation._get_response( self._host, @@ -1361,6 +1809,27 @@ def __call__( 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.workflows_v1.WorkflowsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1401,7 +1870,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1411,8 +1880,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1421,6 +1892,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListOperations._get_transcoded_request( @@ -1435,6 +1907,33 @@ def __call__( ) ) + 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.workflows_v1.WorkflowsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListOperations._get_response( self._host, @@ -1454,6 +1953,27 @@ def __call__( 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.workflows_v1.WorkflowsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workflows.v1.Workflows", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py index 91aab3e657c1..c1703f4925a3 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .transports.grpc_asyncio import WorkflowsGrpcAsyncIOTransport +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 WorkflowsAsyncClient: """Workflows is used to deploy and execute workflow programs. @@ -257,6 +267,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workflows_v1beta.WorkflowsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "credentialsType": None, + }, + ) + async def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -264,7 +296,7 @@ async def list_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkflowsAsyncPager: r"""Lists Workflows in a given project and location. The default order is not specified. @@ -313,8 +345,10 @@ async def sample_list_workflows(): 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, 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: google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsAsyncPager: @@ -390,7 +424,7 @@ async def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. @@ -436,8 +470,10 @@ async def sample_get_workflow(): 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, 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: google.cloud.workflows_v1beta.types.Workflow: @@ -500,7 +536,7 @@ async def create_workflow( workflow_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -579,8 +615,10 @@ async def sample_create_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -656,7 +694,7 @@ async def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a workflow with the specified name. This method also cancels and deletes all running @@ -708,8 +746,10 @@ async def sample_delete_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -789,7 +829,7 @@ async def update_workflow( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workflow. Running this method has no impact on already running @@ -852,8 +892,10 @@ async def sample_update_workflow(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py index 8bbe5daaa8c7..52dbc7aecb88 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import empty_pb2 # type: ignore @@ -585,6 +595,10 @@ def __init__( # 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( @@ -647,6 +661,29 @@ def __init__( 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.workflows_v1beta.WorkflowsClient`.", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "credentialsType": None, + }, + ) + def list_workflows( self, request: Optional[Union[workflows.ListWorkflowsRequest, dict]] = None, @@ -654,7 +691,7 @@ def list_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkflowsPager: r"""Lists Workflows in a given project and location. The default order is not specified. @@ -703,8 +740,10 @@ def sample_list_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsPager: @@ -777,7 +816,7 @@ def get_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Gets details of a single Workflow. @@ -823,8 +862,10 @@ def sample_get_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workflows_v1beta.types.Workflow: @@ -884,7 +925,7 @@ def create_workflow( workflow_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workflow. If a workflow with the specified name already exists in the specified project and location, the long @@ -963,8 +1004,10 @@ def sample_create_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1037,7 +1080,7 @@ def delete_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a workflow with the specified name. This method also cancels and deletes all running @@ -1089,8 +1132,10 @@ def sample_delete_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1167,7 +1212,7 @@ def update_workflow( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workflow. Running this method has no impact on already running @@ -1230,8 +1275,10 @@ def sample_update_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py index c64b64bf418e..fa9cca58678b 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workflows.ListWorkflowsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workflows.ListWorkflowsRequest(request) diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py index a55080caad4b..09294f765536 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.workflows_v1beta.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport +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.workflows.v1beta.Workflows", + "rpcName": 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.workflows.v1beta.Workflows", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcTransport(WorkflowsTransport): """gRPC backend transport for Workflows. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def list_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -298,7 +386,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -327,7 +415,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +443,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +474,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -394,7 +482,7 @@ def update_workflow( return self._stubs["update_workflow"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py index 7c057305b3ef..2e7074c5917d 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workflows_v1beta.types import workflows from .base import DEFAULT_CLIENT_INFO, WorkflowsTransport from .grpc import WorkflowsGrpcTransport +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.workflows.v1beta.Workflows", + "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.workflows.v1beta.Workflows", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkflowsGrpcAsyncIOTransport(WorkflowsTransport): """gRPC AsyncIO backend transport for Workflows. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def list_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workflows" not in self._stubs: - self._stubs["list_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_workflows"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/ListWorkflows", request_serializer=workflows.ListWorkflowsRequest.serialize, response_deserializer=workflows.ListWorkflowsResponse.deserialize, @@ -310,7 +395,7 @@ def get_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workflow" not in self._stubs: - self._stubs["get_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/GetWorkflow", request_serializer=workflows.GetWorkflowRequest.serialize, response_deserializer=workflows.Workflow.deserialize, @@ -341,7 +426,7 @@ def create_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workflow" not in self._stubs: - self._stubs["create_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/CreateWorkflow", request_serializer=workflows.CreateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +456,7 @@ def delete_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workflow" not in self._stubs: - self._stubs["delete_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/DeleteWorkflow", request_serializer=workflows.DeleteWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +489,7 @@ def update_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workflow" not in self._stubs: - self._stubs["update_workflow"] = self.grpc_channel.unary_unary( + self._stubs["update_workflow"] = self._logged_channel.unary_unary( "/google.cloud.workflows.v1beta.Workflows/UpdateWorkflow", request_serializer=workflows.UpdateWorkflowRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +532,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py index fa45293023b2..e69848b1336a 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -110,8 +118,10 @@ def post_update_workflow(self, response): def pre_create_workflow( self, request: workflows.CreateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.CreateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.CreateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workflow Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_create_workflow( def pre_delete_workflow( self, request: workflows.DeleteWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.DeleteWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.DeleteWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workflow Override in a subclass to manipulate the request or metadata @@ -154,8 +166,10 @@ def post_delete_workflow( return response def pre_get_workflow( - self, request: workflows.GetWorkflowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, str]]]: + self, + request: workflows.GetWorkflowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.GetWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_workflow Override in a subclass to manipulate the request or metadata @@ -175,8 +189,8 @@ def post_get_workflow(self, response: workflows.Workflow) -> workflows.Workflow: def pre_list_workflows( self, request: workflows.ListWorkflowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[workflows.ListWorkflowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_workflows Override in a subclass to manipulate the request or metadata @@ -198,8 +212,10 @@ def post_list_workflows( def pre_update_workflow( self, request: workflows.UpdateWorkflowRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workflows.UpdateWorkflowRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workflows.UpdateWorkflowRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workflow Override in a subclass to manipulate the request or metadata @@ -389,7 +405,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workflow method over HTTP. @@ -401,8 +417,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -415,6 +433,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_create_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseCreateWorkflow._get_transcoded_request( @@ -435,6 +454,33 @@ def __call__( ) ) + 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.workflows_v1beta.WorkflowsClient.CreateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "CreateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._CreateWorkflow._get_response( self._host, @@ -454,7 +500,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workflow(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.workflows_v1beta.WorkflowsClient.create_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "CreateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkflow( @@ -491,7 +559,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workflow method over HTTP. @@ -503,8 +571,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -517,6 +587,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseDeleteWorkflow._get_transcoded_request( @@ -531,6 +602,33 @@ def __call__( ) ) + 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.workflows_v1beta.WorkflowsClient.DeleteWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "DeleteWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._DeleteWorkflow._get_response( self._host, @@ -549,7 +647,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workflow(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.workflows_v1beta.WorkflowsClient.delete_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "DeleteWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkflow(_BaseWorkflowsRestTransport._BaseGetWorkflow, WorkflowsRestStub): @@ -584,7 +704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.Workflow: r"""Call the get workflow method over HTTP. @@ -596,8 +716,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workflows.Workflow: @@ -609,6 +731,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_get_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseGetWorkflow._get_transcoded_request( @@ -623,6 +746,33 @@ def __call__( ) ) + 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.workflows_v1beta.WorkflowsClient.GetWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "GetWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._GetWorkflow._get_response( self._host, @@ -643,7 +793,29 @@ def __call__( pb_resp = workflows.Workflow.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workflow(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.Workflow.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.workflows_v1beta.WorkflowsClient.get_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "GetWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkflows( @@ -680,7 +852,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workflows.ListWorkflowsResponse: r"""Call the list workflows method over HTTP. @@ -692,8 +864,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workflows.ListWorkflowsResponse: @@ -706,6 +880,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_http_options() ) + request, metadata = self._interceptor.pre_list_workflows(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseListWorkflows._get_transcoded_request( @@ -720,6 +895,33 @@ def __call__( ) ) + 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.workflows_v1beta.WorkflowsClient.ListWorkflows", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "ListWorkflows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._ListWorkflows._get_response( self._host, @@ -740,7 +942,29 @@ def __call__( pb_resp = workflows.ListWorkflowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workflows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workflows.ListWorkflowsResponse.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.workflows_v1beta.WorkflowsClient.list_workflows", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "ListWorkflows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkflow( @@ -778,7 +1002,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workflow method over HTTP. @@ -790,8 +1014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -804,6 +1030,7 @@ def __call__( http_options = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_http_options() ) + request, metadata = self._interceptor.pre_update_workflow(request, metadata) transcoded_request = ( _BaseWorkflowsRestTransport._BaseUpdateWorkflow._get_transcoded_request( @@ -824,6 +1051,33 @@ def __call__( ) ) + 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.workflows_v1beta.WorkflowsClient.UpdateWorkflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "UpdateWorkflow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkflowsRestTransport._UpdateWorkflow._get_response( self._host, @@ -843,7 +1097,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workflow(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.workflows_v1beta.WorkflowsClient.update_workflow", + extra={ + "serviceName": "google.cloud.workflows.v1beta.Workflows", + "rpcName": "UpdateWorkflow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json index 2ee63c867fef..fba2ed08eb7a 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.types.Execution", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsAsyncPager", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1.services.executions.pagers.ListExecutionsPager", diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json index 42b4bc366890..6f534b55fa27 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.types.Execution", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsAsyncPager", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows.executions_v1beta.services.executions.pagers.ListExecutionsPager", diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json index a1f43fefe508..d0498f290f1f 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.types.Workflow", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.types.Workflow", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1.services.workflows.pagers.ListWorkflowsPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json index a8ed8d67b8de..1e4a9ce7a54e 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.types.Workflow", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.types.Workflow", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workflows_v1beta.services.workflows.pagers.ListWorkflowsPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py index f56443c5a54f..c613c1671b54 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py @@ -3022,6 +3022,7 @@ def test_list_workflows_rest_required_fields( response_value._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_workflows(request) @@ -3077,6 +3078,7 @@ def test_list_workflows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflows(**mock_args) @@ -3268,6 +3270,7 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value._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_workflow(request) @@ -3315,6 +3318,7 @@ def test_get_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3456,6 +3460,7 @@ def test_create_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3516,6 +3521,7 @@ def test_create_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3649,6 +3655,7 @@ def test_delete_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3694,6 +3701,7 @@ def test_delete_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3823,6 +3831,7 @@ def test_update_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3869,6 +3878,7 @@ def test_update_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -4286,6 +4296,7 @@ def test_list_workflows_rest_bad_request(request_type=workflows.ListWorkflowsReq 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_workflows(request) @@ -4322,6 +4333,7 @@ def test_list_workflows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflows(request) # Establish that the response is the type that we expect. @@ -4359,6 +4371,7 @@ def test_list_workflows_rest_interceptors(null_interceptor): 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 = workflows.ListWorkflowsResponse.to_json( workflows.ListWorkflowsResponse() ) @@ -4403,6 +4416,7 @@ def test_get_workflow_rest_bad_request(request_type=workflows.GetWorkflowRequest 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_workflow(request) @@ -4445,6 +4459,7 @@ def test_get_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4487,6 +4502,7 @@ def test_get_workflow_rest_interceptors(null_interceptor): 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 = workflows.Workflow.to_json(workflows.Workflow()) req.return_value.content = return_value @@ -4529,6 +4545,7 @@ def test_create_workflow_rest_bad_request(request_type=workflows.CreateWorkflowR 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_workflow(request) @@ -4642,6 +4659,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4681,6 +4699,7 @@ def test_create_workflow_rest_interceptors(null_interceptor): 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 @@ -4723,6 +4742,7 @@ def test_delete_workflow_rest_bad_request(request_type=workflows.DeleteWorkflowR 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_workflow(request) @@ -4753,6 +4773,7 @@ def test_delete_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4792,6 +4813,7 @@ def test_delete_workflow_rest_interceptors(null_interceptor): 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 @@ -4836,6 +4858,7 @@ def test_update_workflow_rest_bad_request(request_type=workflows.UpdateWorkflowR 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_workflow(request) @@ -4951,6 +4974,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4990,6 +5014,7 @@ def test_update_workflow_rest_interceptors(null_interceptor): 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 @@ -5034,6 +5059,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -5064,6 +5090,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -5092,6 +5119,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -5122,6 +5150,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -5152,6 +5181,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -5182,6 +5212,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -5212,6 +5243,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5242,6 +5274,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5272,6 +5305,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5302,6 +5336,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py index 21824db1272f..e327a5532b35 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py @@ -3011,6 +3011,7 @@ def test_list_workflows_rest_required_fields( response_value._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_workflows(request) @@ -3066,6 +3067,7 @@ def test_list_workflows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflows(**mock_args) @@ -3256,6 +3258,7 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value._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_workflow(request) @@ -3303,6 +3306,7 @@ def test_get_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3445,6 +3449,7 @@ def test_create_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3505,6 +3510,7 @@ def test_create_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3639,6 +3645,7 @@ def test_delete_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3684,6 +3691,7 @@ def test_delete_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -3814,6 +3822,7 @@ def test_update_workflow_rest_required_fields( response_value._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_workflow(request) @@ -3860,6 +3869,7 @@ def test_update_workflow_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workflow(**mock_args) @@ -4275,6 +4285,7 @@ def test_list_workflows_rest_bad_request(request_type=workflows.ListWorkflowsReq 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_workflows(request) @@ -4311,6 +4322,7 @@ def test_list_workflows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflows(request) # Establish that the response is the type that we expect. @@ -4348,6 +4360,7 @@ def test_list_workflows_rest_interceptors(null_interceptor): 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 = workflows.ListWorkflowsResponse.to_json( workflows.ListWorkflowsResponse() ) @@ -4392,6 +4405,7 @@ def test_get_workflow_rest_bad_request(request_type=workflows.GetWorkflowRequest 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_workflow(request) @@ -4432,6 +4446,7 @@ def test_get_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4472,6 +4487,7 @@ def test_get_workflow_rest_interceptors(null_interceptor): 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 = workflows.Workflow.to_json(workflows.Workflow()) req.return_value.content = return_value @@ -4514,6 +4530,7 @@ def test_create_workflow_rest_bad_request(request_type=workflows.CreateWorkflowR 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_workflow(request) @@ -4623,6 +4640,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4662,6 +4680,7 @@ def test_create_workflow_rest_interceptors(null_interceptor): 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 @@ -4704,6 +4723,7 @@ def test_delete_workflow_rest_bad_request(request_type=workflows.DeleteWorkflowR 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_workflow(request) @@ -4734,6 +4754,7 @@ def test_delete_workflow_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4773,6 +4794,7 @@ def test_delete_workflow_rest_interceptors(null_interceptor): 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 @@ -4817,6 +4839,7 @@ def test_update_workflow_rest_bad_request(request_type=workflows.UpdateWorkflowR 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_workflow(request) @@ -4928,6 +4951,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workflow(request) # Establish that the response is the type that we expect. @@ -4967,6 +4991,7 @@ def test_update_workflow_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py index 9ed87dd4b5ed..ea6f05edbcf7 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .transports.grpc_asyncio import WorkstationsGrpcAsyncIOTransport +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 WorkstationsAsyncClient: """Service for interacting with Cloud Workstations.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workstations_v1.WorkstationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "credentialsType": None, + }, + ) + async def get_workstation_cluster( self, request: Optional[ @@ -278,7 +310,7 @@ async def get_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -322,8 +354,10 @@ async def sample_get_workstation_cluster(): 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, 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: google.cloud.workstations_v1.types.WorkstationCluster: @@ -389,7 +423,7 @@ async def list_workstation_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationClustersAsyncPager: r"""Returns all workstation clusters in the specified location. @@ -433,8 +467,10 @@ async def sample_list_workstation_clusters(): 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, 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersAsyncPager: @@ -513,7 +549,7 @@ async def create_workstation_cluster( workstation_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation cluster. @@ -574,8 +610,10 @@ async def sample_create_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -660,7 +698,7 @@ async def update_workstation_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation cluster. @@ -715,8 +753,10 @@ async def sample_update_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -798,7 +838,7 @@ async def delete_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation cluster. @@ -846,8 +886,10 @@ async def sample_delete_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -923,7 +965,7 @@ async def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -967,8 +1009,10 @@ async def sample_get_workstation_config(): 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, 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: google.cloud.workstations_v1.types.WorkstationConfig: @@ -1042,7 +1086,7 @@ async def list_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster. @@ -1086,8 +1130,10 @@ async def sample_list_workstation_configs(): 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, 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsAsyncPager: @@ -1164,7 +1210,7 @@ async def list_usable_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1209,8 +1255,10 @@ async def sample_list_usable_workstation_configs(): 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, 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: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager: @@ -1289,7 +1337,7 @@ async def create_workstation_config( workstation_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation configuration. @@ -1348,8 +1396,10 @@ async def sample_create_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1440,7 +1490,7 @@ async def update_workstation_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation configuration. @@ -1493,8 +1543,10 @@ async def sample_update_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1584,7 +1636,7 @@ async def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation configuration. @@ -1632,8 +1684,10 @@ async def sample_delete_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1717,7 +1771,7 @@ async def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -1760,8 +1814,10 @@ async def sample_get_workstation(): 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, 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: google.cloud.workstations_v1.types.Workstation: @@ -1823,7 +1879,7 @@ async def list_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationsAsyncPager: r"""Returns all Workstations using the specified workstation configuration. @@ -1866,8 +1922,10 @@ async def sample_list_workstations(): 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, 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsAsyncPager: @@ -1944,7 +2002,7 @@ async def list_usable_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationsAsyncPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -1989,8 +2047,10 @@ async def sample_list_usable_workstations(): 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, 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: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsAsyncPager: @@ -2067,7 +2127,7 @@ async def create_workstation( workstation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation. @@ -2126,8 +2186,10 @@ async def sample_create_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2205,7 +2267,7 @@ async def update_workstation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation. @@ -2258,8 +2320,10 @@ async def sample_update_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2336,7 +2400,7 @@ async def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation. @@ -2384,8 +2448,10 @@ async def sample_delete_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2458,7 +2524,7 @@ async def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts running a workstation so that users can connect to it. @@ -2506,8 +2572,10 @@ async def sample_start_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2580,7 +2648,7 @@ async def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops running a workstation, reducing costs. @@ -2627,8 +2695,10 @@ async def sample_stop_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2701,7 +2771,7 @@ async def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -2748,8 +2818,10 @@ async def sample_generate_access_token(): 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, 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: google.cloud.workstations_v1.types.GenerateAccessTokenResponse: @@ -2811,7 +2883,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2822,8 +2894,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2864,7 +2938,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2875,8 +2949,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2917,7 +2993,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2933,8 +3009,10 @@ async def delete_operation( 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, 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: None """ @@ -2971,7 +3049,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2986,8 +3064,10 @@ async def cancel_operation( 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, 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: None """ @@ -3024,7 +3104,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3037,8 +3117,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3143,7 +3225,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3157,8 +3239,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3263,7 +3347,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3278,8 +3362,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py index 671a7e62773b..9d5d5ec5887c 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -637,6 +647,10 @@ def __init__( # 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( @@ -699,6 +713,29 @@ def __init__( 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.workstations_v1.WorkstationsClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "credentialsType": None, + }, + ) + def get_workstation_cluster( self, request: Optional[ @@ -708,7 +745,7 @@ def get_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -752,8 +789,10 @@ def sample_get_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.types.WorkstationCluster: @@ -816,7 +855,7 @@ def list_workstation_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationClustersPager: r"""Returns all workstation clusters in the specified location. @@ -860,8 +899,10 @@ def sample_list_workstation_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersPager: @@ -939,7 +980,7 @@ def create_workstation_cluster( workstation_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation cluster. @@ -1000,8 +1041,10 @@ def sample_create_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1085,7 +1128,7 @@ def update_workstation_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation cluster. @@ -1140,8 +1183,10 @@ def sample_update_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1222,7 +1267,7 @@ def delete_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation cluster. @@ -1270,8 +1315,10 @@ def sample_delete_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1346,7 +1393,7 @@ def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -1390,8 +1437,10 @@ def sample_get_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.types.WorkstationConfig: @@ -1462,7 +1511,7 @@ def list_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster. @@ -1506,8 +1555,10 @@ def sample_list_workstation_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsPager: @@ -1581,7 +1632,7 @@ def list_usable_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1626,8 +1677,10 @@ def sample_list_usable_workstation_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsPager: @@ -1705,7 +1758,7 @@ def create_workstation_config( workstation_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation configuration. @@ -1764,8 +1817,10 @@ def sample_create_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1855,7 +1910,7 @@ def update_workstation_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation configuration. @@ -1908,8 +1963,10 @@ def sample_update_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1998,7 +2055,7 @@ def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation configuration. @@ -2046,8 +2103,10 @@ def sample_delete_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2130,7 +2189,7 @@ def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -2173,8 +2232,10 @@ def sample_get_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.types.Workstation: @@ -2233,7 +2294,7 @@ def list_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationsPager: r"""Returns all Workstations using the specified workstation configuration. @@ -2276,8 +2337,10 @@ def sample_list_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsPager: @@ -2351,7 +2414,7 @@ def list_usable_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationsPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -2396,8 +2459,10 @@ def sample_list_usable_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsPager: @@ -2471,7 +2536,7 @@ def create_workstation( workstation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation. @@ -2530,8 +2595,10 @@ def sample_create_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2606,7 +2673,7 @@ def update_workstation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation. @@ -2659,8 +2726,10 @@ def sample_update_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2734,7 +2803,7 @@ def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation. @@ -2782,8 +2851,10 @@ def sample_delete_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2853,7 +2924,7 @@ def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts running a workstation so that users can connect to it. @@ -2901,8 +2972,10 @@ def sample_start_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2972,7 +3045,7 @@ def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops running a workstation, reducing costs. @@ -3019,8 +3092,10 @@ def sample_stop_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3090,7 +3165,7 @@ def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -3137,8 +3212,10 @@ def sample_generate_access_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1.types.GenerateAccessTokenResponse: @@ -3210,7 +3287,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3221,8 +3298,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3263,7 +3342,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3274,8 +3353,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3316,7 +3397,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3332,8 +3413,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3370,7 +3453,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3385,8 +3468,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3423,7 +3508,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3436,8 +3521,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3542,7 +3629,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3556,8 +3643,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3662,7 +3751,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3677,8 +3766,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py index bdbc71e10efc..8783a693eef7 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationClustersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationClustersRequest(request) @@ -221,7 +225,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -235,8 +239,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationConfigsRequest(request) @@ -295,7 +301,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -309,8 +315,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationConfigsRequest(request) @@ -373,7 +381,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -387,8 +395,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListUsableWorkstationConfigsRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListUsableWorkstationConfigsRequest(request) @@ -529,7 +541,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -543,8 +555,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationsRequest(request) @@ -603,7 +617,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -617,8 +631,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationsRequest(request) @@ -681,7 +697,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -695,8 +711,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) @@ -755,7 +773,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -769,8 +787,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py index e0888846d807..04fee83dc51f 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.workstations_v1.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport +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.workstations.v1.Workstations", + "rpcName": 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.workstations.v1.Workstations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcTransport(WorkstationsTransport): """gRPC backend transport for Workstations. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def get_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -304,7 +392,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -332,7 +420,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +450,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +480,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +510,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -446,7 +540,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -480,7 +574,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -508,7 +602,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +630,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -564,7 +658,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +684,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -619,7 +713,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -650,7 +744,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -676,7 +770,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +796,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +822,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +849,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -781,7 +875,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +906,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -820,7 +914,7 @@ def generate_access_token( return self._stubs["generate_access_token"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -832,7 +926,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -849,7 +943,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -866,7 +960,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -885,7 +979,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -910,7 +1004,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -936,7 +1030,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -965,7 +1059,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py index f8facb31e37b..fc4de3587a08 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workstations_v1.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .grpc import WorkstationsGrpcTransport +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.workstations.v1.Workstations", + "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.workstations.v1.Workstations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcAsyncIOTransport(WorkstationsTransport): """gRPC AsyncIO backend transport for Workstations. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -315,7 +400,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -344,7 +429,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +491,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +522,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -461,7 +552,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -495,7 +586,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -524,7 +615,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +644,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +673,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +701,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -640,7 +731,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -671,7 +762,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -699,7 +790,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -727,7 +818,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +846,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -784,7 +875,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +903,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -843,7 +934,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -1077,7 +1168,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1093,7 +1184,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1110,7 +1201,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1127,7 +1218,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1146,7 +1237,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1171,7 +1262,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1197,7 +1288,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1226,7 +1317,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py index e14a7d180d16..c02f4ce26b68 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/services/workstations/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -233,8 +241,10 @@ def post_update_workstation_config(self, response): def pre_create_workstation( self, request: workstations.CreateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workstation Override in a subclass to manipulate the request or metadata @@ -256,8 +266,11 @@ def post_create_workstation( def pre_create_workstation_cluster( self, request: workstations.CreateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -279,8 +292,11 @@ def post_create_workstation_cluster( def pre_create_workstation_config( self, request: workstations.CreateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_config Override in a subclass to manipulate the request or metadata @@ -302,8 +318,10 @@ def post_create_workstation_config( def pre_delete_workstation( self, request: workstations.DeleteWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workstation Override in a subclass to manipulate the request or metadata @@ -325,8 +343,11 @@ def post_delete_workstation( def pre_delete_workstation_cluster( self, request: workstations.DeleteWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -348,8 +369,11 @@ def post_delete_workstation_cluster( def pre_delete_workstation_config( self, request: workstations.DeleteWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_config Override in a subclass to manipulate the request or metadata @@ -371,8 +395,10 @@ def post_delete_workstation_config( def pre_generate_access_token( self, request: workstations.GenerateAccessTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_access_token Override in a subclass to manipulate the request or metadata @@ -394,8 +420,10 @@ def post_generate_access_token( def pre_get_workstation( self, request: workstations.GetWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workstation Override in a subclass to manipulate the request or metadata @@ -417,8 +445,11 @@ def post_get_workstation( def pre_get_workstation_cluster( self, request: workstations.GetWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -440,8 +471,11 @@ def post_get_workstation_cluster( def pre_get_workstation_config( self, request: workstations.GetWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_config Override in a subclass to manipulate the request or metadata @@ -463,9 +497,10 @@ def post_get_workstation_config( def pre_list_usable_workstation_configs( self, request: workstations.ListUsableWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - workstations.ListUsableWorkstationConfigsRequest, Sequence[Tuple[str, str]] + workstations.ListUsableWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_usable_workstation_configs @@ -488,8 +523,11 @@ def post_list_usable_workstation_configs( def pre_list_usable_workstations( self, request: workstations.ListUsableWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListUsableWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListUsableWorkstationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_usable_workstations Override in a subclass to manipulate the request or metadata @@ -511,8 +549,11 @@ def post_list_usable_workstations( def pre_list_workstation_clusters( self, request: workstations.ListWorkstationClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_clusters Override in a subclass to manipulate the request or metadata @@ -534,8 +575,11 @@ def post_list_workstation_clusters( def pre_list_workstation_configs( self, request: workstations.ListWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_configs Override in a subclass to manipulate the request or metadata @@ -557,8 +601,10 @@ def post_list_workstation_configs( def pre_list_workstations( self, request: workstations.ListWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workstations Override in a subclass to manipulate the request or metadata @@ -580,8 +626,10 @@ def post_list_workstations( def pre_start_workstation( self, request: workstations.StartWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StartWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StartWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_workstation Override in a subclass to manipulate the request or metadata @@ -603,8 +651,10 @@ def post_start_workstation( def pre_stop_workstation( self, request: workstations.StopWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StopWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StopWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_workstation Override in a subclass to manipulate the request or metadata @@ -626,8 +676,10 @@ def post_stop_workstation( def pre_update_workstation( self, request: workstations.UpdateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workstation Override in a subclass to manipulate the request or metadata @@ -649,8 +701,11 @@ def post_update_workstation( def pre_update_workstation_cluster( self, request: workstations.UpdateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -672,8 +727,11 @@ def post_update_workstation_cluster( def pre_update_workstation_config( self, request: workstations.UpdateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_config Override in a subclass to manipulate the request or metadata @@ -695,8 +753,10 @@ def post_update_workstation_config( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -716,8 +776,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -737,8 +799,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -760,8 +825,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -781,8 +848,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -802,8 +871,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -825,8 +896,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1021,7 +1094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation method over HTTP. @@ -1032,8 +1105,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1046,6 +1121,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation( request, metadata ) @@ -1062,6 +1138,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.CreateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstation._get_response( self._host, @@ -1081,7 +1184,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation(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.workstations_v1.WorkstationsClient.create_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationCluster( @@ -1120,7 +1245,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation cluster method over HTTP. @@ -1132,8 +1257,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1146,6 +1273,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_cluster( request, metadata ) @@ -1162,6 +1290,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.CreateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._CreateWorkstationCluster._get_response( @@ -1183,7 +1338,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation_cluster(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.workstations_v1.WorkstationsClient.create_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationConfig( @@ -1222,7 +1399,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation config method over HTTP. @@ -1233,8 +1410,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1247,6 +1426,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_config( request, metadata ) @@ -1263,6 +1443,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.CreateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstationConfig._get_response( self._host, @@ -1282,7 +1489,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation_config(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.workstations_v1.WorkstationsClient.create_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CreateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstation( @@ -1319,7 +1548,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation method over HTTP. @@ -1330,8 +1559,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1344,6 +1575,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation( request, metadata ) @@ -1356,6 +1588,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.DeleteWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstation._get_response( self._host, @@ -1374,7 +1633,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation(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.workstations_v1.WorkstationsClient.delete_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationCluster( @@ -1412,7 +1693,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation cluster method over HTTP. @@ -1424,8 +1705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1438,6 +1721,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_cluster( request, metadata ) @@ -1450,6 +1734,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.DeleteWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._DeleteWorkstationCluster._get_response( @@ -1470,7 +1781,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation_cluster(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.workstations_v1.WorkstationsClient.delete_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationConfig( @@ -1508,7 +1841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation config method over HTTP. @@ -1519,8 +1852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1533,6 +1868,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_config( request, metadata ) @@ -1545,6 +1881,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.DeleteWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstationConfig._get_response( self._host, @@ -1563,7 +1926,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation_config(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.workstations_v1.WorkstationsClient.delete_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAccessToken( @@ -1601,7 +1986,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Call the generate access token method over HTTP. @@ -1612,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.GenerateAccessTokenResponse: @@ -1625,6 +2012,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGenerateAccessToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_access_token( request, metadata ) @@ -1641,6 +2029,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.GenerateAccessToken", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GenerateAccessToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GenerateAccessToken._get_response( self._host, @@ -1662,7 +2077,31 @@ def __call__( pb_resp = workstations.GenerateAccessTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_access_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.GenerateAccessTokenResponse.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.workstations_v1.WorkstationsClient.generate_access_token", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GenerateAccessToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstation( @@ -1699,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Call the get workstation method over HTTP. @@ -1709,8 +2148,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.Workstation: @@ -1723,6 +2164,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetWorkstation._get_transcoded_request( http_options, request @@ -1733,6 +2175,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.GetWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstation._get_response( self._host, @@ -1753,7 +2222,29 @@ def __call__( pb_resp = workstations.Workstation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.Workstation.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.workstations_v1.WorkstationsClient.get_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationCluster( @@ -1790,7 +2281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Call the get workstation cluster method over HTTP. @@ -1801,8 +2292,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.WorkstationCluster: @@ -1817,6 +2310,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_cluster( request, metadata ) @@ -1829,6 +2323,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.GetWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationCluster._get_response( self._host, @@ -1849,7 +2370,29 @@ def __call__( pb_resp = workstations.WorkstationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationCluster.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.workstations_v1.WorkstationsClient.get_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationConfig( @@ -1886,7 +2429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Call the get workstation config method over HTTP. @@ -1897,8 +2440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.WorkstationConfig: @@ -1921,6 +2466,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_config( request, metadata ) @@ -1933,6 +2479,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.GetWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationConfig._get_response( self._host, @@ -1953,7 +2526,29 @@ def __call__( pb_resp = workstations.WorkstationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationConfig.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.workstations_v1.WorkstationsClient.get_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstationConfigs( @@ -1991,7 +2586,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationConfigsResponse: r"""Call the list usable workstation configs method over HTTP. @@ -2003,8 +2598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListUsableWorkstationConfigsResponse: @@ -2016,6 +2613,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstation_configs( request, metadata ) @@ -2028,6 +2626,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListUsableWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._ListUsableWorkstationConfigs._get_response( @@ -2050,7 +2675,33 @@ def __call__( pb_resp = workstations.ListUsableWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationConfigsResponse.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.workstations_v1.WorkstationsClient.list_usable_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstations( @@ -2087,7 +2738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationsResponse: r"""Call the list usable workstations method over HTTP. @@ -2098,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListUsableWorkstationsResponse: @@ -2111,6 +2764,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstations( request, metadata ) @@ -2123,6 +2777,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListUsableWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListUsableWorkstations._get_response( self._host, @@ -2143,7 +2824,31 @@ def __call__( pb_resp = workstations.ListUsableWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationsResponse.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.workstations_v1.WorkstationsClient.list_usable_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListUsableWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationClusters( @@ -2181,7 +2886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationClustersResponse: r"""Call the list workstation clusters method over HTTP. @@ -2192,8 +2897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationClustersResponse: @@ -2205,6 +2912,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_clusters( request, metadata ) @@ -2217,6 +2925,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListWorkstationClusters", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationClusters._get_response( self._host, @@ -2237,7 +2972,31 @@ def __call__( pb_resp = workstations.ListWorkstationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationClustersResponse.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.workstations_v1.WorkstationsClient.list_workstation_clusters", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationConfigs( @@ -2274,7 +3033,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationConfigsResponse: r"""Call the list workstation configs method over HTTP. @@ -2285,8 +3044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationConfigsResponse: @@ -2298,6 +3059,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_configs( request, metadata ) @@ -2310,6 +3072,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationConfigs._get_response( self._host, @@ -2330,7 +3119,31 @@ def __call__( pb_resp = workstations.ListWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationConfigsResponse.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.workstations_v1.WorkstationsClient.list_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstations( @@ -2367,7 +3180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationsResponse: r"""Call the list workstations method over HTTP. @@ -2377,8 +3190,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationsResponse: @@ -2390,6 +3205,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstations( request, metadata ) @@ -2402,6 +3218,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstations._get_response( self._host, @@ -2422,7 +3265,31 @@ def __call__( pb_resp = workstations.ListWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.ListWorkstationsResponse.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.workstations_v1.WorkstationsClient.list_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartWorkstation( @@ -2460,7 +3327,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start workstation method over HTTP. @@ -2470,8 +3337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2484,6 +3353,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStartWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_start_workstation( request, metadata ) @@ -2500,6 +3370,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.StartWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StartWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StartWorkstation._get_response( self._host, @@ -2519,7 +3416,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_workstation(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.workstations_v1.WorkstationsClient.start_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StartWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopWorkstation( @@ -2557,7 +3476,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the stop workstation method over HTTP. @@ -2567,8 +3486,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2581,6 +3502,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStopWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_stop_workstation( request, metadata ) @@ -2597,6 +3519,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.StopWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StopWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StopWorkstation._get_response( self._host, @@ -2616,7 +3565,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_workstation(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.workstations_v1.WorkstationsClient.stop_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "StopWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstation( @@ -2654,7 +3625,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation method over HTTP. @@ -2665,8 +3636,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2679,6 +3652,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation( request, metadata ) @@ -2695,6 +3669,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.UpdateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstation._get_response( self._host, @@ -2714,7 +3715,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation(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.workstations_v1.WorkstationsClient.update_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationCluster( @@ -2753,7 +3776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation cluster method over HTTP. @@ -2765,8 +3788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2779,6 +3804,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_cluster( request, metadata ) @@ -2795,6 +3821,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.UpdateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._UpdateWorkstationCluster._get_response( @@ -2816,7 +3869,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation_cluster(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.workstations_v1.WorkstationsClient.update_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationConfig( @@ -2855,7 +3930,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation config method over HTTP. @@ -2866,8 +3941,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2880,6 +3957,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_config( request, metadata ) @@ -2896,6 +3974,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.UpdateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstationConfig._get_response( self._host, @@ -2915,7 +4020,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation_config(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.workstations_v1.WorkstationsClient.update_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "UpdateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3149,7 +4276,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -3159,8 +4286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -3169,6 +4298,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3181,6 +4311,33 @@ def __call__( ) ) + 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.workstations_v1.WorkstationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetIamPolicy._get_response( self._host, @@ -3200,6 +4357,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.workstations_v1.WorkstationsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3241,7 +4419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -3251,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -3261,6 +4441,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3279,6 +4460,33 @@ def __call__( ) ) + 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.workstations_v1.WorkstationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._SetIamPolicy._get_response( self._host, @@ -3299,6 +4507,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.workstations_v1.WorkstationsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3340,7 +4569,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -3350,8 +4579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -3360,6 +4591,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3376,6 +4608,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._TestIamPermissions._get_response( self._host, @@ -3396,6 +4655,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.workstations_v1.WorkstationsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3437,7 +4717,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3447,13 +4727,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWorkstationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4753,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3536,13 +4846,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWorkstationsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4868,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3620,8 +4960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -3630,6 +4972,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3642,6 +4985,33 @@ def __call__( ) ) + 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.workstations_v1.WorkstationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetOperation._get_response( self._host, @@ -3661,6 +5031,27 @@ def __call__( 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.workstations_v1.WorkstationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3701,7 +5092,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3711,8 +5102,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3721,6 +5114,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3731,6 +5125,33 @@ def __call__( 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.workstations_v1.WorkstationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListOperations._get_response( self._host, @@ -3750,6 +5171,27 @@ def __call__( 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.workstations_v1.WorkstationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1.Workstations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py index 2b5369e53dc7..558c8aab67c5 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py index 7085c6243907..75431d479348 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .transports.grpc_asyncio import WorkstationsGrpcAsyncIOTransport +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 WorkstationsAsyncClient: """Service for interacting with Cloud Workstations.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.workstations_v1beta.WorkstationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "credentialsType": None, + }, + ) + async def get_workstation_cluster( self, request: Optional[ @@ -278,7 +310,7 @@ async def get_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -322,8 +354,10 @@ async def sample_get_workstation_cluster(): 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, 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: google.cloud.workstations_v1beta.types.WorkstationCluster: @@ -389,7 +423,7 @@ async def list_workstation_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationClustersAsyncPager: r"""Returns all workstation clusters in the specified location. @@ -433,8 +467,10 @@ async def sample_list_workstation_clusters(): 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, 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersAsyncPager: @@ -513,7 +549,7 @@ async def create_workstation_cluster( workstation_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation cluster. @@ -574,8 +610,10 @@ async def sample_create_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -660,7 +698,7 @@ async def update_workstation_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation cluster. @@ -715,8 +753,10 @@ async def sample_update_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -798,7 +838,7 @@ async def delete_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation cluster. @@ -846,8 +886,10 @@ async def sample_delete_workstation_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -923,7 +965,7 @@ async def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -967,8 +1009,10 @@ async def sample_get_workstation_config(): 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, 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: google.cloud.workstations_v1beta.types.WorkstationConfig: @@ -1042,7 +1086,7 @@ async def list_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster. @@ -1086,8 +1130,10 @@ async def sample_list_workstation_configs(): 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, 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsAsyncPager: @@ -1164,7 +1210,7 @@ async def list_usable_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationConfigsAsyncPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1209,8 +1255,10 @@ async def sample_list_usable_workstation_configs(): 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, 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager: @@ -1289,7 +1337,7 @@ async def create_workstation_config( workstation_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation configuration. @@ -1348,8 +1396,10 @@ async def sample_create_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1440,7 +1490,7 @@ async def update_workstation_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation configuration. @@ -1493,8 +1543,10 @@ async def sample_update_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1584,7 +1636,7 @@ async def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation configuration. @@ -1632,8 +1684,10 @@ async def sample_delete_workstation_config(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1717,7 +1771,7 @@ async def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -1760,8 +1814,10 @@ async def sample_get_workstation(): 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, 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: google.cloud.workstations_v1beta.types.Workstation: @@ -1823,7 +1879,7 @@ async def list_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationsAsyncPager: r"""Returns all Workstations using the specified workstation configuration. @@ -1866,8 +1922,10 @@ async def sample_list_workstations(): 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, 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsAsyncPager: @@ -1944,7 +2002,7 @@ async def list_usable_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationsAsyncPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -1989,8 +2047,10 @@ async def sample_list_usable_workstations(): 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, 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsAsyncPager: @@ -2067,7 +2127,7 @@ async def create_workstation( workstation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new workstation. @@ -2126,8 +2186,10 @@ async def sample_create_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2205,7 +2267,7 @@ async def update_workstation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates an existing workstation. @@ -2258,8 +2320,10 @@ async def sample_update_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2336,7 +2400,7 @@ async def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified workstation. @@ -2384,8 +2448,10 @@ async def sample_delete_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2458,7 +2524,7 @@ async def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts running a workstation so that users can connect to it. @@ -2506,8 +2572,10 @@ async def sample_start_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2580,7 +2648,7 @@ async def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Stops running a workstation, reducing costs. @@ -2627,8 +2695,10 @@ async def sample_stop_workstation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2701,7 +2771,7 @@ async def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -2748,8 +2818,10 @@ async def sample_generate_access_token(): 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, 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: google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse: @@ -2811,7 +2883,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2822,8 +2894,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2864,7 +2938,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2875,8 +2949,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2917,7 +2993,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2933,8 +3009,10 @@ async def delete_operation( 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, 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: None """ @@ -2971,7 +3049,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2986,8 +3064,10 @@ async def cancel_operation( 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, 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: None """ @@ -3024,7 +3104,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3037,8 +3117,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3143,7 +3225,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3157,8 +3239,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3263,7 +3347,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3278,8 +3362,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py index 237884ba8624..88bbd9e36357 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -637,6 +647,10 @@ def __init__( # 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( @@ -699,6 +713,29 @@ def __init__( 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.workstations_v1beta.WorkstationsClient`.", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "credentialsType": None, + }, + ) + def get_workstation_cluster( self, request: Optional[ @@ -708,7 +745,7 @@ def get_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Returns the requested workstation cluster. @@ -752,8 +789,10 @@ def sample_get_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.types.WorkstationCluster: @@ -816,7 +855,7 @@ def list_workstation_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationClustersPager: r"""Returns all workstation clusters in the specified location. @@ -860,8 +899,10 @@ def sample_list_workstation_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersPager: @@ -939,7 +980,7 @@ def create_workstation_cluster( workstation_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation cluster. @@ -1000,8 +1041,10 @@ def sample_create_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1085,7 +1128,7 @@ def update_workstation_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation cluster. @@ -1140,8 +1183,10 @@ def sample_update_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1222,7 +1267,7 @@ def delete_workstation_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation cluster. @@ -1270,8 +1315,10 @@ def sample_delete_workstation_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1346,7 +1393,7 @@ def get_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Returns the requested workstation configuration. @@ -1390,8 +1437,10 @@ def sample_get_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.types.WorkstationConfig: @@ -1462,7 +1511,7 @@ def list_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster. @@ -1506,8 +1555,10 @@ def sample_list_workstation_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsPager: @@ -1581,7 +1632,7 @@ def list_usable_workstation_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationConfigsPager: r"""Returns all workstation configurations in the specified cluster on which the caller has the @@ -1626,8 +1677,10 @@ def sample_list_usable_workstation_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsPager: @@ -1705,7 +1758,7 @@ def create_workstation_config( workstation_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation configuration. @@ -1764,8 +1817,10 @@ def sample_create_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1855,7 +1910,7 @@ def update_workstation_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation configuration. @@ -1908,8 +1963,10 @@ def sample_update_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1998,7 +2055,7 @@ def delete_workstation_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation configuration. @@ -2046,8 +2103,10 @@ def sample_delete_workstation_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2130,7 +2189,7 @@ def get_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Returns the requested workstation. @@ -2173,8 +2232,10 @@ def sample_get_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.types.Workstation: @@ -2233,7 +2294,7 @@ def list_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkstationsPager: r"""Returns all Workstations using the specified workstation configuration. @@ -2276,8 +2337,10 @@ def sample_list_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsPager: @@ -2351,7 +2414,7 @@ def list_usable_workstations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsableWorkstationsPager: r"""Returns all workstations using the specified workstation configuration on which the caller has the @@ -2396,8 +2459,10 @@ def sample_list_usable_workstations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsPager: @@ -2471,7 +2536,7 @@ def create_workstation( workstation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new workstation. @@ -2530,8 +2595,10 @@ def sample_create_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2606,7 +2673,7 @@ def update_workstation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates an existing workstation. @@ -2659,8 +2726,10 @@ def sample_update_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2734,7 +2803,7 @@ def delete_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the specified workstation. @@ -2782,8 +2851,10 @@ def sample_delete_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2853,7 +2924,7 @@ def start_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts running a workstation so that users can connect to it. @@ -2901,8 +2972,10 @@ def sample_start_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2972,7 +3045,7 @@ def stop_workstation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Stops running a workstation, reducing costs. @@ -3019,8 +3092,10 @@ def sample_stop_workstation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3090,7 +3165,7 @@ def generate_access_token( workstation: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Returns a short-lived credential that can be used to send authenticated and authorized traffic to a @@ -3137,8 +3212,10 @@ def sample_generate_access_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse: @@ -3210,7 +3287,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3221,8 +3298,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3263,7 +3342,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3274,8 +3353,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3316,7 +3397,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3332,8 +3413,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3370,7 +3453,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3385,8 +3468,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3423,7 +3508,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3436,8 +3521,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3542,7 +3629,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3556,8 +3643,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3662,7 +3751,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3677,8 +3766,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py index 31116484db45..e6fd0f1f1a9f 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationClustersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationClustersRequest(request) @@ -221,7 +225,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -235,8 +239,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationConfigsRequest(request) @@ -295,7 +301,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -309,8 +315,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationConfigsRequest(request) @@ -373,7 +381,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -387,8 +395,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListUsableWorkstationConfigsRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListUsableWorkstationConfigsRequest(request) @@ -529,7 +541,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -543,8 +555,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListWorkstationsRequest(request) @@ -603,7 +617,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -617,8 +631,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListWorkstationsRequest(request) @@ -681,7 +697,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -695,8 +711,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) @@ -755,7 +773,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -769,8 +787,10 @@ def __init__( 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, 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`. """ self._method = method self._request = workstations.ListUsableWorkstationsRequest(request) diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py index d02a7f3ed2c5..b4b85e238deb 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.workstations_v1beta.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport +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.workstations.v1beta.Workstations", + "rpcName": 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.workstations.v1beta.Workstations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcTransport(WorkstationsTransport): """gRPC backend transport for Workstations. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def get_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -304,7 +392,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -332,7 +420,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +450,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +480,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +510,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -446,7 +540,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -480,7 +574,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -508,7 +602,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +630,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -564,7 +658,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +684,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -619,7 +713,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -650,7 +744,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -676,7 +770,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -702,7 +796,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +822,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +849,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -781,7 +875,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +906,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -820,7 +914,7 @@ def generate_access_token( return self._stubs["generate_access_token"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -832,7 +926,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -849,7 +943,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -866,7 +960,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -885,7 +979,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -910,7 +1004,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -936,7 +1030,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -965,7 +1059,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py index c317f3587fb2..55639e9c605e 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.workstations_v1beta.types import workstations from .base import DEFAULT_CLIENT_INFO, WorkstationsTransport from .grpc import WorkstationsGrpcTransport +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.workstations.v1beta.Workstations", + "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.workstations.v1beta.Workstations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class WorkstationsGrpcAsyncIOTransport(WorkstationsTransport): """gRPC AsyncIO backend transport for Workstations. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_cluster" not in self._stubs: - self._stubs["get_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_cluster"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationCluster", request_serializer=workstations.GetWorkstationClusterRequest.serialize, response_deserializer=workstations.WorkstationCluster.deserialize, @@ -315,7 +400,7 @@ def list_workstation_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_clusters" not in self._stubs: - self._stubs["list_workstation_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_clusters"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationClusters", request_serializer=workstations.ListWorkstationClustersRequest.serialize, response_deserializer=workstations.ListWorkstationClustersResponse.deserialize, @@ -344,7 +429,9 @@ def create_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_cluster" not in self._stubs: - self._stubs["create_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationCluster", request_serializer=workstations.CreateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,9 @@ def update_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_cluster" not in self._stubs: - self._stubs["update_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationCluster", request_serializer=workstations.UpdateWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +491,9 @@ def delete_workstation_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_cluster" not in self._stubs: - self._stubs["delete_workstation_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_workstation_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationCluster", request_serializer=workstations.DeleteWorkstationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +522,7 @@ def get_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation_config" not in self._stubs: - self._stubs["get_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstationConfig", request_serializer=workstations.GetWorkstationConfigRequest.serialize, response_deserializer=workstations.WorkstationConfig.deserialize, @@ -461,7 +552,7 @@ def list_workstation_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstation_configs" not in self._stubs: - self._stubs["list_workstation_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_workstation_configs"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstationConfigs", request_serializer=workstations.ListWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListWorkstationConfigsResponse.deserialize, @@ -495,7 +586,7 @@ def list_usable_workstation_configs( if "list_usable_workstation_configs" not in self._stubs: self._stubs[ "list_usable_workstation_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstationConfigs", request_serializer=workstations.ListUsableWorkstationConfigsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationConfigsResponse.deserialize, @@ -524,7 +615,7 @@ def create_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation_config" not in self._stubs: - self._stubs["create_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstationConfig", request_serializer=workstations.CreateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +644,7 @@ def update_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation_config" not in self._stubs: - self._stubs["update_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstationConfig", request_serializer=workstations.UpdateWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +673,7 @@ def delete_workstation_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation_config" not in self._stubs: - self._stubs["delete_workstation_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation_config"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstationConfig", request_serializer=workstations.DeleteWorkstationConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +701,7 @@ def get_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workstation" not in self._stubs: - self._stubs["get_workstation"] = self.grpc_channel.unary_unary( + self._stubs["get_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GetWorkstation", request_serializer=workstations.GetWorkstationRequest.serialize, response_deserializer=workstations.Workstation.deserialize, @@ -640,7 +731,7 @@ def list_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workstations" not in self._stubs: - self._stubs["list_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListWorkstations", request_serializer=workstations.ListWorkstationsRequest.serialize, response_deserializer=workstations.ListWorkstationsResponse.deserialize, @@ -671,7 +762,7 @@ def list_usable_workstations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_usable_workstations" not in self._stubs: - self._stubs["list_usable_workstations"] = self.grpc_channel.unary_unary( + self._stubs["list_usable_workstations"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/ListUsableWorkstations", request_serializer=workstations.ListUsableWorkstationsRequest.serialize, response_deserializer=workstations.ListUsableWorkstationsResponse.deserialize, @@ -699,7 +790,7 @@ def create_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workstation" not in self._stubs: - self._stubs["create_workstation"] = self.grpc_channel.unary_unary( + self._stubs["create_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/CreateWorkstation", request_serializer=workstations.CreateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -727,7 +818,7 @@ def update_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workstation" not in self._stubs: - self._stubs["update_workstation"] = self.grpc_channel.unary_unary( + self._stubs["update_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/UpdateWorkstation", request_serializer=workstations.UpdateWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -755,7 +846,7 @@ def delete_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workstation" not in self._stubs: - self._stubs["delete_workstation"] = self.grpc_channel.unary_unary( + self._stubs["delete_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/DeleteWorkstation", request_serializer=workstations.DeleteWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -784,7 +875,7 @@ def start_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_workstation" not in self._stubs: - self._stubs["start_workstation"] = self.grpc_channel.unary_unary( + self._stubs["start_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StartWorkstation", request_serializer=workstations.StartWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +903,7 @@ def stop_workstation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_workstation" not in self._stubs: - self._stubs["stop_workstation"] = self.grpc_channel.unary_unary( + self._stubs["stop_workstation"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/StopWorkstation", request_serializer=workstations.StopWorkstationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -843,7 +934,7 @@ def generate_access_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_access_token" not in self._stubs: - self._stubs["generate_access_token"] = self.grpc_channel.unary_unary( + self._stubs["generate_access_token"] = self._logged_channel.unary_unary( "/google.cloud.workstations.v1beta.Workstations/GenerateAccessToken", request_serializer=workstations.GenerateAccessTokenRequest.serialize, response_deserializer=workstations.GenerateAccessTokenResponse.deserialize, @@ -1077,7 +1168,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1093,7 +1184,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1110,7 +1201,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1127,7 +1218,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1146,7 +1237,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1171,7 +1262,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1197,7 +1288,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1226,7 +1317,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py index 7403b20868c9..51f0bc944028 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/services/workstations/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -233,8 +241,10 @@ def post_update_workstation_config(self, response): def pre_create_workstation( self, request: workstations.CreateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workstation Override in a subclass to manipulate the request or metadata @@ -256,8 +266,11 @@ def post_create_workstation( def pre_create_workstation_cluster( self, request: workstations.CreateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -279,8 +292,11 @@ def post_create_workstation_cluster( def pre_create_workstation_config( self, request: workstations.CreateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.CreateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.CreateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_workstation_config Override in a subclass to manipulate the request or metadata @@ -302,8 +318,10 @@ def post_create_workstation_config( def pre_delete_workstation( self, request: workstations.DeleteWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workstation Override in a subclass to manipulate the request or metadata @@ -325,8 +343,11 @@ def post_delete_workstation( def pre_delete_workstation_cluster( self, request: workstations.DeleteWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -348,8 +369,11 @@ def post_delete_workstation_cluster( def pre_delete_workstation_config( self, request: workstations.DeleteWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.DeleteWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.DeleteWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_workstation_config Override in a subclass to manipulate the request or metadata @@ -371,8 +395,10 @@ def post_delete_workstation_config( def pre_generate_access_token( self, request: workstations.GenerateAccessTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GenerateAccessTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_access_token Override in a subclass to manipulate the request or metadata @@ -394,8 +420,10 @@ def post_generate_access_token( def pre_get_workstation( self, request: workstations.GetWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workstation Override in a subclass to manipulate the request or metadata @@ -417,8 +445,11 @@ def post_get_workstation( def pre_get_workstation_cluster( self, request: workstations.GetWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -440,8 +471,11 @@ def post_get_workstation_cluster( def pre_get_workstation_config( self, request: workstations.GetWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.GetWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.GetWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_workstation_config Override in a subclass to manipulate the request or metadata @@ -463,9 +497,10 @@ def post_get_workstation_config( def pre_list_usable_workstation_configs( self, request: workstations.ListUsableWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - workstations.ListUsableWorkstationConfigsRequest, Sequence[Tuple[str, str]] + workstations.ListUsableWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_usable_workstation_configs @@ -488,8 +523,11 @@ def post_list_usable_workstation_configs( def pre_list_usable_workstations( self, request: workstations.ListUsableWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListUsableWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListUsableWorkstationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_usable_workstations Override in a subclass to manipulate the request or metadata @@ -511,8 +549,11 @@ def post_list_usable_workstations( def pre_list_workstation_clusters( self, request: workstations.ListWorkstationClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_clusters Override in a subclass to manipulate the request or metadata @@ -534,8 +575,11 @@ def post_list_workstation_clusters( def pre_list_workstation_configs( self, request: workstations.ListWorkstationConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_workstation_configs Override in a subclass to manipulate the request or metadata @@ -557,8 +601,10 @@ def post_list_workstation_configs( def pre_list_workstations( self, request: workstations.ListWorkstationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.ListWorkstationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.ListWorkstationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workstations Override in a subclass to manipulate the request or metadata @@ -580,8 +626,10 @@ def post_list_workstations( def pre_start_workstation( self, request: workstations.StartWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StartWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StartWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_workstation Override in a subclass to manipulate the request or metadata @@ -603,8 +651,10 @@ def post_start_workstation( def pre_stop_workstation( self, request: workstations.StopWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.StopWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.StopWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_workstation Override in a subclass to manipulate the request or metadata @@ -626,8 +676,10 @@ def post_stop_workstation( def pre_update_workstation( self, request: workstations.UpdateWorkstationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workstation Override in a subclass to manipulate the request or metadata @@ -649,8 +701,11 @@ def post_update_workstation( def pre_update_workstation_cluster( self, request: workstations.UpdateWorkstationClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_cluster Override in a subclass to manipulate the request or metadata @@ -672,8 +727,11 @@ def post_update_workstation_cluster( def pre_update_workstation_config( self, request: workstations.UpdateWorkstationConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[workstations.UpdateWorkstationConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + workstations.UpdateWorkstationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_workstation_config Override in a subclass to manipulate the request or metadata @@ -695,8 +753,10 @@ def post_update_workstation_config( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -716,8 +776,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -737,8 +799,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -760,8 +825,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -781,8 +848,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -802,8 +871,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -825,8 +896,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1021,7 +1094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation method over HTTP. @@ -1032,8 +1105,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1046,6 +1121,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation( request, metadata ) @@ -1062,6 +1138,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.CreateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstation._get_response( self._host, @@ -1081,7 +1184,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation(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.workstations_v1beta.WorkstationsClient.create_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationCluster( @@ -1120,7 +1245,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation cluster method over HTTP. @@ -1132,8 +1257,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1146,6 +1273,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_cluster( request, metadata ) @@ -1162,6 +1290,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.CreateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._CreateWorkstationCluster._get_response( @@ -1183,7 +1338,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation_cluster(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.workstations_v1beta.WorkstationsClient.create_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkstationConfig( @@ -1222,7 +1399,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create workstation config method over HTTP. @@ -1233,8 +1410,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1247,6 +1426,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseCreateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_workstation_config( request, metadata ) @@ -1263,6 +1443,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.CreateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CreateWorkstationConfig._get_response( self._host, @@ -1282,7 +1489,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_workstation_config(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.workstations_v1beta.WorkstationsClient.create_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CreateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstation( @@ -1319,7 +1548,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation method over HTTP. @@ -1330,8 +1559,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1344,6 +1575,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation( request, metadata ) @@ -1356,6 +1588,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.DeleteWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstation._get_response( self._host, @@ -1374,7 +1633,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation(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.workstations_v1beta.WorkstationsClient.delete_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationCluster( @@ -1412,7 +1693,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation cluster method over HTTP. @@ -1424,8 +1705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1438,6 +1721,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_cluster( request, metadata ) @@ -1450,6 +1734,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.DeleteWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._DeleteWorkstationCluster._get_response( @@ -1470,7 +1781,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation_cluster(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.workstations_v1beta.WorkstationsClient.delete_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkstationConfig( @@ -1508,7 +1841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workstation config method over HTTP. @@ -1519,8 +1852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1533,6 +1868,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseDeleteWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workstation_config( request, metadata ) @@ -1545,6 +1881,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.DeleteWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteWorkstationConfig._get_response( self._host, @@ -1563,7 +1926,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_workstation_config(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.workstations_v1beta.WorkstationsClient.delete_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAccessToken( @@ -1601,7 +1986,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.GenerateAccessTokenResponse: r"""Call the generate access token method over HTTP. @@ -1612,8 +1997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.GenerateAccessTokenResponse: @@ -1625,6 +2012,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGenerateAccessToken._get_http_options() ) + request, metadata = self._interceptor.pre_generate_access_token( request, metadata ) @@ -1641,6 +2029,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.GenerateAccessToken", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GenerateAccessToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GenerateAccessToken._get_response( self._host, @@ -1662,7 +2077,31 @@ def __call__( pb_resp = workstations.GenerateAccessTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_access_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.GenerateAccessTokenResponse.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.workstations_v1beta.WorkstationsClient.generate_access_token", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GenerateAccessToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstation( @@ -1699,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.Workstation: r"""Call the get workstation method over HTTP. @@ -1709,8 +2148,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.Workstation: @@ -1723,6 +2164,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetWorkstation._get_transcoded_request( http_options, request @@ -1733,6 +2175,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.GetWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstation._get_response( self._host, @@ -1753,7 +2222,29 @@ def __call__( pb_resp = workstations.Workstation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.Workstation.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.workstations_v1beta.WorkstationsClient.get_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationCluster( @@ -1790,7 +2281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationCluster: r"""Call the get workstation cluster method over HTTP. @@ -1801,8 +2292,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.WorkstationCluster: @@ -1817,6 +2310,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_cluster( request, metadata ) @@ -1829,6 +2323,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.GetWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationCluster._get_response( self._host, @@ -1849,7 +2370,29 @@ def __call__( pb_resp = workstations.WorkstationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationCluster.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.workstations_v1beta.WorkstationsClient.get_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkstationConfig( @@ -1886,7 +2429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.WorkstationConfig: r"""Call the get workstation config method over HTTP. @@ -1897,8 +2440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.WorkstationConfig: @@ -1921,6 +2466,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_workstation_config( request, metadata ) @@ -1933,6 +2479,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.GetWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetWorkstationConfig._get_response( self._host, @@ -1953,7 +2526,29 @@ def __call__( pb_resp = workstations.WorkstationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workstation_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.WorkstationConfig.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.workstations_v1beta.WorkstationsClient.get_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstationConfigs( @@ -1991,7 +2586,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationConfigsResponse: r"""Call the list usable workstation configs method over HTTP. @@ -2003,8 +2598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListUsableWorkstationConfigsResponse: @@ -2016,6 +2613,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstation_configs( request, metadata ) @@ -2028,6 +2626,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListUsableWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._ListUsableWorkstationConfigs._get_response( @@ -2050,7 +2675,33 @@ def __call__( pb_resp = workstations.ListUsableWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationConfigsResponse.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.workstations_v1beta.WorkstationsClient.list_usable_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsableWorkstations( @@ -2087,7 +2738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListUsableWorkstationsResponse: r"""Call the list usable workstations method over HTTP. @@ -2098,8 +2749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListUsableWorkstationsResponse: @@ -2111,6 +2764,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListUsableWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable_workstations( request, metadata ) @@ -2123,6 +2777,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListUsableWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListUsableWorkstations._get_response( self._host, @@ -2143,7 +2824,31 @@ def __call__( pb_resp = workstations.ListUsableWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListUsableWorkstationsResponse.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.workstations_v1beta.WorkstationsClient.list_usable_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListUsableWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationClusters( @@ -2181,7 +2886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationClustersResponse: r"""Call the list workstation clusters method over HTTP. @@ -2192,8 +2897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationClustersResponse: @@ -2205,6 +2912,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_clusters( request, metadata ) @@ -2217,6 +2925,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListWorkstationClusters", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationClusters._get_response( self._host, @@ -2237,7 +2972,31 @@ def __call__( pb_resp = workstations.ListWorkstationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationClustersResponse.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.workstations_v1beta.WorkstationsClient.list_workstation_clusters", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstationConfigs( @@ -2274,7 +3033,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationConfigsResponse: r"""Call the list workstation configs method over HTTP. @@ -2285,8 +3044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationConfigsResponse: @@ -2298,6 +3059,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstation_configs( request, metadata ) @@ -2310,6 +3072,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListWorkstationConfigs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstationConfigs._get_response( self._host, @@ -2330,7 +3119,31 @@ def __call__( pb_resp = workstations.ListWorkstationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstation_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + workstations.ListWorkstationConfigsResponse.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.workstations_v1beta.WorkstationsClient.list_workstation_configs", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkstations( @@ -2367,7 +3180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workstations.ListWorkstationsResponse: r"""Call the list workstations method over HTTP. @@ -2377,8 +3190,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.workstations.ListWorkstationsResponse: @@ -2390,6 +3205,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListWorkstations._get_http_options() ) + request, metadata = self._interceptor.pre_list_workstations( request, metadata ) @@ -2402,6 +3218,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListWorkstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListWorkstations._get_response( self._host, @@ -2422,7 +3265,31 @@ def __call__( pb_resp = workstations.ListWorkstationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workstations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workstations.ListWorkstationsResponse.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.workstations_v1beta.WorkstationsClient.list_workstations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListWorkstations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartWorkstation( @@ -2460,7 +3327,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start workstation method over HTTP. @@ -2470,8 +3337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2484,6 +3353,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStartWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_start_workstation( request, metadata ) @@ -2500,6 +3370,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.StartWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StartWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StartWorkstation._get_response( self._host, @@ -2519,7 +3416,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_workstation(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.workstations_v1beta.WorkstationsClient.start_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StartWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopWorkstation( @@ -2557,7 +3476,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the stop workstation method over HTTP. @@ -2567,8 +3486,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2581,6 +3502,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseStopWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_stop_workstation( request, metadata ) @@ -2597,6 +3519,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.StopWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StopWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._StopWorkstation._get_response( self._host, @@ -2616,7 +3565,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_workstation(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.workstations_v1beta.WorkstationsClient.stop_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "StopWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstation( @@ -2654,7 +3625,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation method over HTTP. @@ -2665,8 +3636,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2679,6 +3652,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstation._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation( request, metadata ) @@ -2695,6 +3669,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.UpdateWorkstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstation._get_response( self._host, @@ -2714,7 +3715,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation(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.workstations_v1beta.WorkstationsClient.update_workstation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationCluster( @@ -2753,7 +3776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation cluster method over HTTP. @@ -2765,8 +3788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2779,6 +3804,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_cluster( request, metadata ) @@ -2795,6 +3821,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.UpdateWorkstationCluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( WorkstationsRestTransport._UpdateWorkstationCluster._get_response( @@ -2816,7 +3869,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation_cluster(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.workstations_v1beta.WorkstationsClient.update_workstation_cluster", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkstationConfig( @@ -2855,7 +3930,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update workstation config method over HTTP. @@ -2866,8 +3941,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2880,6 +3957,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseUpdateWorkstationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_workstation_config( request, metadata ) @@ -2896,6 +3974,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.UpdateWorkstationConfig", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._UpdateWorkstationConfig._get_response( self._host, @@ -2915,7 +4020,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workstation_config(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.workstations_v1beta.WorkstationsClient.update_workstation_config", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "UpdateWorkstationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3149,7 +4276,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -3159,8 +4286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -3169,6 +4298,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3181,6 +4311,33 @@ def __call__( ) ) + 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.workstations_v1beta.WorkstationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetIamPolicy._get_response( self._host, @@ -3200,6 +4357,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.workstations_v1beta.WorkstationsAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3241,7 +4419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -3251,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -3261,6 +4441,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3279,6 +4460,33 @@ def __call__( ) ) + 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.workstations_v1beta.WorkstationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._SetIamPolicy._get_response( self._host, @@ -3299,6 +4507,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.workstations_v1beta.WorkstationsAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3340,7 +4569,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -3350,8 +4579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -3360,6 +4591,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3376,6 +4608,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._TestIamPermissions._get_response( self._host, @@ -3396,6 +4655,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.workstations_v1beta.WorkstationsAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3437,7 +4717,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3447,13 +4727,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWorkstationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3470,6 +4753,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._CancelOperation._get_response( self._host, @@ -3526,7 +4836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3536,13 +4846,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseWorkstationsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3555,6 +4868,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._DeleteOperation._get_response( self._host, @@ -3610,7 +4950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3620,8 +4960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -3630,6 +4972,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3642,6 +4985,33 @@ def __call__( ) ) + 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.workstations_v1beta.WorkstationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._GetOperation._get_response( self._host, @@ -3661,6 +5031,27 @@ def __call__( 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.workstations_v1beta.WorkstationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3701,7 +5092,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3711,8 +5102,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3721,6 +5114,7 @@ def __call__( http_options = ( _BaseWorkstationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseWorkstationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3731,6 +5125,33 @@ def __call__( 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.workstations_v1beta.WorkstationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = WorkstationsRestTransport._ListOperations._get_response( self._host, @@ -3750,6 +5171,27 @@ def __call__( 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.workstations_v1beta.WorkstationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.workstations.v1beta.Workstations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json index e24bb9d99fba..c9f644c1d20c 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.10" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.GenerateAccessTokenResponse", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.GenerateAccessTokenResponse", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationCluster", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationCluster", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationConfig", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.WorkstationConfig", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.Workstation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.types.Workstation", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationConfigsPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListUsableWorkstationsPager", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersAsyncPager", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationClustersPager", @@ -2188,7 +2188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsAsyncPager", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationConfigsPager", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsAsyncPager", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1.services.workstations.pagers.ListWorkstationsPager", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2920,7 +2920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3005,7 +3005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3174,7 +3174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3258,7 +3258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json index 188bb17930e6..2a6523f2cb2d 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.10" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.GenerateAccessTokenResponse", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationCluster", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationCluster", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationConfig", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.WorkstationConfig", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.Workstation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.types.Workstation", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationConfigsPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListUsableWorkstationsPager", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersAsyncPager", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationClustersPager", @@ -2188,7 +2188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsAsyncPager", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationConfigsPager", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsAsyncPager", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.workstations_v1beta.services.workstations.pagers.ListWorkstationsPager", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2920,7 +2920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3005,7 +3005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3174,7 +3174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3258,7 +3258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py index ec343d91d017..2b5a25716e75 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py @@ -9237,6 +9237,7 @@ def test_get_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9284,6 +9285,7 @@ def test_get_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -9427,6 +9429,7 @@ def test_list_workstation_clusters_rest_required_fields( response_value._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_workstation_clusters(request) @@ -9480,6 +9483,7 @@ def test_list_workstation_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_clusters(**mock_args) @@ -9698,6 +9702,7 @@ def test_create_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9763,6 +9768,7 @@ def test_create_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -9906,6 +9912,7 @@ def test_update_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9968,6 +9975,7 @@ def test_update_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -10114,6 +10122,7 @@ def test_delete_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -10168,6 +10177,7 @@ def test_delete_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -10304,6 +10314,7 @@ def test_get_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -10351,6 +10362,7 @@ def test_get_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -10494,6 +10506,7 @@ def test_list_workstation_configs_rest_required_fields( response_value._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_workstation_configs(request) @@ -10549,6 +10562,7 @@ def test_list_workstation_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_configs(**mock_args) @@ -10759,6 +10773,7 @@ def test_list_usable_workstation_configs_rest_required_fields( response_value._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_usable_workstation_configs(request) @@ -10818,6 +10833,7 @@ def test_list_usable_workstation_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_usable_workstation_configs(**mock_args) @@ -11041,6 +11057,7 @@ def test_create_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11108,6 +11125,7 @@ def test_create_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11251,6 +11269,7 @@ def test_update_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11313,6 +11332,7 @@ def test_update_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11459,6 +11479,7 @@ def test_delete_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11513,6 +11534,7 @@ def test_delete_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11644,6 +11666,7 @@ def test_get_workstation_rest_required_fields( response_value._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_workstation(request) @@ -11691,6 +11714,7 @@ def test_get_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -11831,6 +11855,7 @@ def test_list_workstations_rest_required_fields( response_value._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_workstations(request) @@ -11886,6 +11911,7 @@ def test_list_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstations(**mock_args) @@ -12094,6 +12120,7 @@ def test_list_usable_workstations_rest_required_fields( response_value._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_usable_workstations(request) @@ -12149,6 +12176,7 @@ def test_list_usable_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_usable_workstations(**mock_args) @@ -12365,6 +12393,7 @@ def test_create_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12432,6 +12461,7 @@ def test_create_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12574,6 +12604,7 @@ def test_update_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12636,6 +12667,7 @@ def test_update_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12780,6 +12812,7 @@ def test_delete_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12833,6 +12866,7 @@ def test_delete_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12968,6 +13002,7 @@ def test_start_workstation_rest_required_fields( response_value._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.start_workstation(request) @@ -13013,6 +13048,7 @@ def test_start_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_workstation(**mock_args) @@ -13148,6 +13184,7 @@ def test_stop_workstation_rest_required_fields( response_value._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.stop_workstation(request) @@ -13193,6 +13230,7 @@ def test_stop_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.stop_workstation(**mock_args) @@ -13330,6 +13368,7 @@ def test_generate_access_token_rest_required_fields( response_value._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.generate_access_token(request) @@ -13377,6 +13416,7 @@ def test_generate_access_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.generate_access_token(**mock_args) @@ -14591,6 +14631,7 @@ def test_get_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -14636,6 +14677,7 @@ def test_get_workstation_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -14684,6 +14726,7 @@ def test_get_workstation_cluster_rest_interceptors(null_interceptor): 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 = workstations.WorkstationCluster.to_json( workstations.WorkstationCluster() ) @@ -14730,6 +14773,7 @@ def test_list_workstation_clusters_rest_bad_request( 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_workstation_clusters(request) @@ -14766,6 +14810,7 @@ def test_list_workstation_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_clusters(request) # Establish that the response is the type that we expect. @@ -14807,6 +14852,7 @@ def test_list_workstation_clusters_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationClustersResponse.to_json( workstations.ListWorkstationClustersResponse() ) @@ -14853,6 +14899,7 @@ def test_create_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -14986,6 +15033,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15027,6 +15075,7 @@ def test_create_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15075,6 +15124,7 @@ def test_update_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -15212,6 +15262,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15253,6 +15304,7 @@ def test_update_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15299,6 +15351,7 @@ def test_delete_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -15331,6 +15384,7 @@ def test_delete_workstation_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15372,6 +15426,7 @@ def test_delete_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15418,6 +15473,7 @@ def test_get_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -15461,6 +15517,7 @@ def test_get_workstation_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -15507,6 +15564,7 @@ def test_get_workstation_config_rest_interceptors(null_interceptor): 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 = workstations.WorkstationConfig.to_json( workstations.WorkstationConfig() ) @@ -15555,6 +15613,7 @@ def test_list_workstation_configs_rest_bad_request( 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_workstation_configs(request) @@ -15593,6 +15652,7 @@ def test_list_workstation_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15634,6 +15694,7 @@ def test_list_workstation_configs_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationConfigsResponse.to_json( workstations.ListWorkstationConfigsResponse() ) @@ -15682,6 +15743,7 @@ def test_list_usable_workstation_configs_rest_bad_request( 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_usable_workstation_configs(request) @@ -15722,6 +15784,7 @@ def test_list_usable_workstation_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_usable_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15763,6 +15826,7 @@ def test_list_usable_workstation_configs_rest_interceptors(null_interceptor): 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 = workstations.ListUsableWorkstationConfigsResponse.to_json( workstations.ListUsableWorkstationConfigsResponse() ) @@ -15811,6 +15875,7 @@ def test_create_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -15987,6 +16052,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16028,6 +16094,7 @@ def test_create_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16076,6 +16143,7 @@ def test_update_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -16254,6 +16322,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16295,6 +16364,7 @@ def test_update_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16341,6 +16411,7 @@ def test_delete_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -16373,6 +16444,7 @@ def test_delete_workstation_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16414,6 +16486,7 @@ def test_delete_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16460,6 +16533,7 @@ def test_get_workstation_rest_bad_request( 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_workstation(request) @@ -16503,6 +16577,7 @@ def test_get_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -16549,6 +16624,7 @@ def test_get_workstation_rest_interceptors(null_interceptor): 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 = workstations.Workstation.to_json(workstations.Workstation()) req.return_value.content = return_value @@ -16595,6 +16671,7 @@ def test_list_workstations_rest_bad_request( 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_workstations(request) @@ -16633,6 +16710,7 @@ def test_list_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstations(request) # Establish that the response is the type that we expect. @@ -16674,6 +16752,7 @@ def test_list_workstations_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationsResponse.to_json( workstations.ListWorkstationsResponse() ) @@ -16722,6 +16801,7 @@ def test_list_usable_workstations_rest_bad_request( 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_usable_workstations(request) @@ -16760,6 +16840,7 @@ def test_list_usable_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_usable_workstations(request) # Establish that the response is the type that we expect. @@ -16801,6 +16882,7 @@ def test_list_usable_workstations_rest_interceptors(null_interceptor): 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 = workstations.ListUsableWorkstationsResponse.to_json( workstations.ListUsableWorkstationsResponse() ) @@ -16849,6 +16931,7 @@ def test_create_workstation_rest_bad_request( 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_workstation(request) @@ -16963,6 +17046,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17004,6 +17088,7 @@ def test_create_workstation_rest_interceptors(null_interceptor): 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 @@ -17052,6 +17137,7 @@ def test_update_workstation_rest_bad_request( 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_workstation(request) @@ -17168,6 +17254,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17209,6 +17296,7 @@ def test_update_workstation_rest_interceptors(null_interceptor): 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 @@ -17255,6 +17343,7 @@ def test_delete_workstation_rest_bad_request( 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_workstation(request) @@ -17287,6 +17376,7 @@ def test_delete_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17328,6 +17418,7 @@ def test_delete_workstation_rest_interceptors(null_interceptor): 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 @@ -17374,6 +17465,7 @@ def test_start_workstation_rest_bad_request( 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.start_workstation(request) @@ -17406,6 +17498,7 @@ def test_start_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_workstation(request) # Establish that the response is the type that we expect. @@ -17447,6 +17540,7 @@ def test_start_workstation_rest_interceptors(null_interceptor): 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 @@ -17493,6 +17587,7 @@ def test_stop_workstation_rest_bad_request( 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.stop_workstation(request) @@ -17525,6 +17620,7 @@ def test_stop_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_workstation(request) # Establish that the response is the type that we expect. @@ -17566,6 +17662,7 @@ def test_stop_workstation_rest_interceptors(null_interceptor): 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 @@ -17612,6 +17709,7 @@ def test_generate_access_token_rest_bad_request( 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.generate_access_token(request) @@ -17649,6 +17747,7 @@ def test_generate_access_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_access_token(request) # Establish that the response is the type that we expect. @@ -17689,6 +17788,7 @@ def test_generate_access_token_rest_interceptors(null_interceptor): 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 = workstations.GenerateAccessTokenResponse.to_json( workstations.GenerateAccessTokenResponse() ) @@ -17740,6 +17840,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -17772,6 +17873,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -17805,6 +17907,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -17837,6 +17940,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -17870,6 +17974,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -17902,6 +18007,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -17932,6 +18038,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -17962,6 +18069,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -17992,6 +18100,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -18022,6 +18131,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -18052,6 +18162,7 @@ def test_get_operation_rest_bad_request( 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) @@ -18082,6 +18193,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -18112,6 +18224,7 @@ def test_list_operations_rest_bad_request( 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) @@ -18142,6 +18255,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py index b8a654e1e52d..645615e933de 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py @@ -9241,6 +9241,7 @@ def test_get_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9288,6 +9289,7 @@ def test_get_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -9431,6 +9433,7 @@ def test_list_workstation_clusters_rest_required_fields( response_value._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_workstation_clusters(request) @@ -9484,6 +9487,7 @@ def test_list_workstation_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_clusters(**mock_args) @@ -9702,6 +9706,7 @@ def test_create_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9767,6 +9772,7 @@ def test_create_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -9910,6 +9916,7 @@ def test_update_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -9972,6 +9979,7 @@ def test_update_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -10118,6 +10126,7 @@ def test_delete_workstation_cluster_rest_required_fields( response_value._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_workstation_cluster(request) @@ -10172,6 +10181,7 @@ def test_delete_workstation_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_cluster(**mock_args) @@ -10308,6 +10318,7 @@ def test_get_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -10355,6 +10366,7 @@ def test_get_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -10498,6 +10510,7 @@ def test_list_workstation_configs_rest_required_fields( response_value._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_workstation_configs(request) @@ -10553,6 +10566,7 @@ def test_list_workstation_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_configs(**mock_args) @@ -10763,6 +10777,7 @@ def test_list_usable_workstation_configs_rest_required_fields( response_value._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_usable_workstation_configs(request) @@ -10822,6 +10837,7 @@ def test_list_usable_workstation_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_usable_workstation_configs(**mock_args) @@ -11045,6 +11061,7 @@ def test_create_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11112,6 +11129,7 @@ def test_create_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11255,6 +11273,7 @@ def test_update_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11317,6 +11336,7 @@ def test_update_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11463,6 +11483,7 @@ def test_delete_workstation_config_rest_required_fields( response_value._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_workstation_config(request) @@ -11517,6 +11538,7 @@ def test_delete_workstation_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation_config(**mock_args) @@ -11648,6 +11670,7 @@ def test_get_workstation_rest_required_fields( response_value._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_workstation(request) @@ -11695,6 +11718,7 @@ def test_get_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -11835,6 +11859,7 @@ def test_list_workstations_rest_required_fields( response_value._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_workstations(request) @@ -11890,6 +11915,7 @@ def test_list_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstations(**mock_args) @@ -12098,6 +12124,7 @@ def test_list_usable_workstations_rest_required_fields( response_value._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_usable_workstations(request) @@ -12153,6 +12180,7 @@ def test_list_usable_workstations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_usable_workstations(**mock_args) @@ -12369,6 +12397,7 @@ def test_create_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12436,6 +12465,7 @@ def test_create_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12578,6 +12608,7 @@ def test_update_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12640,6 +12671,7 @@ def test_update_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12784,6 +12816,7 @@ def test_delete_workstation_rest_required_fields( response_value._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_workstation(request) @@ -12837,6 +12870,7 @@ def test_delete_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_workstation(**mock_args) @@ -12972,6 +13006,7 @@ def test_start_workstation_rest_required_fields( response_value._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.start_workstation(request) @@ -13017,6 +13052,7 @@ def test_start_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.start_workstation(**mock_args) @@ -13152,6 +13188,7 @@ def test_stop_workstation_rest_required_fields( response_value._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.stop_workstation(request) @@ -13197,6 +13234,7 @@ def test_stop_workstation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.stop_workstation(**mock_args) @@ -13334,6 +13372,7 @@ def test_generate_access_token_rest_required_fields( response_value._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.generate_access_token(request) @@ -13381,6 +13420,7 @@ def test_generate_access_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.generate_access_token(**mock_args) @@ -14596,6 +14636,7 @@ def test_get_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -14641,6 +14682,7 @@ def test_get_workstation_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -14689,6 +14731,7 @@ def test_get_workstation_cluster_rest_interceptors(null_interceptor): 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 = workstations.WorkstationCluster.to_json( workstations.WorkstationCluster() ) @@ -14735,6 +14778,7 @@ def test_list_workstation_clusters_rest_bad_request( 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_workstation_clusters(request) @@ -14771,6 +14815,7 @@ def test_list_workstation_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_clusters(request) # Establish that the response is the type that we expect. @@ -14812,6 +14857,7 @@ def test_list_workstation_clusters_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationClustersResponse.to_json( workstations.ListWorkstationClustersResponse() ) @@ -14858,6 +14904,7 @@ def test_create_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -14991,6 +15038,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15032,6 +15080,7 @@ def test_create_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15080,6 +15129,7 @@ def test_update_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -15217,6 +15267,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15258,6 +15309,7 @@ def test_update_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15304,6 +15356,7 @@ def test_delete_workstation_cluster_rest_bad_request( 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_workstation_cluster(request) @@ -15336,6 +15389,7 @@ def test_delete_workstation_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_cluster(request) # Establish that the response is the type that we expect. @@ -15377,6 +15431,7 @@ def test_delete_workstation_cluster_rest_interceptors(null_interceptor): 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 @@ -15423,6 +15478,7 @@ def test_get_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -15467,6 +15523,7 @@ def test_get_workstation_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -15514,6 +15571,7 @@ def test_get_workstation_config_rest_interceptors(null_interceptor): 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 = workstations.WorkstationConfig.to_json( workstations.WorkstationConfig() ) @@ -15562,6 +15620,7 @@ def test_list_workstation_configs_rest_bad_request( 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_workstation_configs(request) @@ -15600,6 +15659,7 @@ def test_list_workstation_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15641,6 +15701,7 @@ def test_list_workstation_configs_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationConfigsResponse.to_json( workstations.ListWorkstationConfigsResponse() ) @@ -15689,6 +15750,7 @@ def test_list_usable_workstation_configs_rest_bad_request( 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_usable_workstation_configs(request) @@ -15729,6 +15791,7 @@ def test_list_usable_workstation_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_usable_workstation_configs(request) # Establish that the response is the type that we expect. @@ -15770,6 +15833,7 @@ def test_list_usable_workstation_configs_rest_interceptors(null_interceptor): 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 = workstations.ListUsableWorkstationConfigsResponse.to_json( workstations.ListUsableWorkstationConfigsResponse() ) @@ -15818,6 +15882,7 @@ def test_create_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -16007,6 +16072,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16048,6 +16114,7 @@ def test_create_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16096,6 +16163,7 @@ def test_update_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -16287,6 +16355,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16328,6 +16397,7 @@ def test_update_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16374,6 +16444,7 @@ def test_delete_workstation_config_rest_bad_request( 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_workstation_config(request) @@ -16406,6 +16477,7 @@ def test_delete_workstation_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation_config(request) # Establish that the response is the type that we expect. @@ -16447,6 +16519,7 @@ def test_delete_workstation_config_rest_interceptors(null_interceptor): 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 @@ -16493,6 +16566,7 @@ def test_get_workstation_rest_bad_request( 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_workstation(request) @@ -16536,6 +16610,7 @@ def test_get_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -16582,6 +16657,7 @@ def test_get_workstation_rest_interceptors(null_interceptor): 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 = workstations.Workstation.to_json(workstations.Workstation()) req.return_value.content = return_value @@ -16628,6 +16704,7 @@ def test_list_workstations_rest_bad_request( 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_workstations(request) @@ -16666,6 +16743,7 @@ def test_list_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstations(request) # Establish that the response is the type that we expect. @@ -16707,6 +16785,7 @@ def test_list_workstations_rest_interceptors(null_interceptor): 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 = workstations.ListWorkstationsResponse.to_json( workstations.ListWorkstationsResponse() ) @@ -16755,6 +16834,7 @@ def test_list_usable_workstations_rest_bad_request( 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_usable_workstations(request) @@ -16793,6 +16873,7 @@ def test_list_usable_workstations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_usable_workstations(request) # Establish that the response is the type that we expect. @@ -16834,6 +16915,7 @@ def test_list_usable_workstations_rest_interceptors(null_interceptor): 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 = workstations.ListUsableWorkstationsResponse.to_json( workstations.ListUsableWorkstationsResponse() ) @@ -16882,6 +16964,7 @@ def test_create_workstation_rest_bad_request( 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_workstation(request) @@ -16997,6 +17080,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17038,6 +17122,7 @@ def test_create_workstation_rest_interceptors(null_interceptor): 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 @@ -17086,6 +17171,7 @@ def test_update_workstation_rest_bad_request( 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_workstation(request) @@ -17203,6 +17289,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17244,6 +17331,7 @@ def test_update_workstation_rest_interceptors(null_interceptor): 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 @@ -17290,6 +17378,7 @@ def test_delete_workstation_rest_bad_request( 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_workstation(request) @@ -17322,6 +17411,7 @@ def test_delete_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_workstation(request) # Establish that the response is the type that we expect. @@ -17363,6 +17453,7 @@ def test_delete_workstation_rest_interceptors(null_interceptor): 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 @@ -17409,6 +17500,7 @@ def test_start_workstation_rest_bad_request( 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.start_workstation(request) @@ -17441,6 +17533,7 @@ def test_start_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_workstation(request) # Establish that the response is the type that we expect. @@ -17482,6 +17575,7 @@ def test_start_workstation_rest_interceptors(null_interceptor): 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 @@ -17528,6 +17622,7 @@ def test_stop_workstation_rest_bad_request( 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.stop_workstation(request) @@ -17560,6 +17655,7 @@ def test_stop_workstation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.stop_workstation(request) # Establish that the response is the type that we expect. @@ -17601,6 +17697,7 @@ def test_stop_workstation_rest_interceptors(null_interceptor): 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 @@ -17647,6 +17744,7 @@ def test_generate_access_token_rest_bad_request( 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.generate_access_token(request) @@ -17684,6 +17782,7 @@ def test_generate_access_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.generate_access_token(request) # Establish that the response is the type that we expect. @@ -17724,6 +17823,7 @@ def test_generate_access_token_rest_interceptors(null_interceptor): 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 = workstations.GenerateAccessTokenResponse.to_json( workstations.GenerateAccessTokenResponse() ) @@ -17775,6 +17875,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -17807,6 +17908,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -17840,6 +17942,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -17872,6 +17975,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -17905,6 +18009,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -17937,6 +18042,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -17967,6 +18073,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -17997,6 +18104,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -18027,6 +18135,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -18057,6 +18166,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -18087,6 +18197,7 @@ def test_get_operation_rest_bad_request( 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) @@ -18117,6 +18228,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -18147,6 +18259,7 @@ def test_list_operations_rest_bad_request( 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) @@ -18177,6 +18290,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py index 7d28791e7569..558c8aab67c5 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py index 7d28791e7569..558c8aab67c5 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py index 48a080b30e35..64b50b967ab7 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AddressValidationTransport from .transports.grpc_asyncio import AddressValidationGrpcAsyncIOTransport +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 AddressValidationAsyncClient: """The service for validating addresses.""" @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.maps.addressvalidation_v1.AddressValidationAsyncClient`.", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "credentialsType": None, + }, + ) + async def validate_address( self, request: Optional[ @@ -263,7 +295,7 @@ async def validate_address( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Validates an address. @@ -299,8 +331,10 @@ async def sample_validate_address(): 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, 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: google.maps.addressvalidation_v1.types.ValidateAddressResponse: @@ -342,7 +376,7 @@ async def provide_validation_feedback( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Feedback about the outcome of the sequence of validation attempts. This should be the last call made after a sequence of @@ -385,8 +419,10 @@ async def sample_provide_validation_feedback(): 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, 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: google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py index 26d9bce6ad1e..6c41992d85fe 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.maps.addressvalidation_v1.types import address_validation_service from .transports.base import DEFAULT_CLIENT_INFO, AddressValidationTransport @@ -559,6 +569,10 @@ def __init__( # 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( @@ -625,6 +639,29 @@ def __init__( 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.maps.addressvalidation_v1.AddressValidationClient`.", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "credentialsType": None, + }, + ) + def validate_address( self, request: Optional[ @@ -633,7 +670,7 @@ def validate_address( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Validates an address. @@ -669,8 +706,10 @@ def sample_validate_address(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.addressvalidation_v1.types.ValidateAddressResponse: @@ -710,7 +749,7 @@ def provide_validation_feedback( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Feedback about the outcome of the sequence of validation attempts. This should be the last call made after a sequence of @@ -753,8 +792,10 @@ def sample_provide_validation_feedback(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py index 4dc2d5442228..256abd8c1458 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.maps.addressvalidation_v1.types import address_validation_service from .base import DEFAULT_CLIENT_INFO, AddressValidationTransport +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.maps.addressvalidation.v1.AddressValidation", + "rpcName": 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.maps.addressvalidation.v1.AddressValidation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AddressValidationGrpcTransport(AddressValidationTransport): """gRPC backend transport for AddressValidation. @@ -179,7 +260,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +342,7 @@ def validate_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "validate_address" not in self._stubs: - self._stubs["validate_address"] = self.grpc_channel.unary_unary( + self._stubs["validate_address"] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ValidateAddress", request_serializer=address_validation_service.ValidateAddressRequest.serialize, response_deserializer=address_validation_service.ValidateAddressResponse.deserialize, @@ -290,7 +376,9 @@ def provide_validation_feedback( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provide_validation_feedback" not in self._stubs: - self._stubs["provide_validation_feedback"] = self.grpc_channel.unary_unary( + self._stubs[ + "provide_validation_feedback" + ] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ProvideValidationFeedback", request_serializer=address_validation_service.ProvideValidationFeedbackRequest.serialize, response_deserializer=address_validation_service.ProvideValidationFeedbackResponse.deserialize, @@ -298,7 +386,7 @@ def provide_validation_feedback( return self._stubs["provide_validation_feedback"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py index ff32b0186dc7..b992bce26056 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.maps.addressvalidation_v1.types import address_validation_service from .base import DEFAULT_CLIENT_INFO, AddressValidationTransport from .grpc import AddressValidationGrpcTransport +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.maps.addressvalidation.v1.AddressValidation", + "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.maps.addressvalidation.v1.AddressValidation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AddressValidationGrpcAsyncIOTransport(AddressValidationTransport): """gRPC AsyncIO backend transport for AddressValidation. @@ -226,10 +308,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -264,7 +349,7 @@ def validate_address( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "validate_address" not in self._stubs: - self._stubs["validate_address"] = self.grpc_channel.unary_unary( + self._stubs["validate_address"] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ValidateAddress", request_serializer=address_validation_service.ValidateAddressRequest.serialize, response_deserializer=address_validation_service.ValidateAddressResponse.deserialize, @@ -298,7 +383,9 @@ def provide_validation_feedback( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provide_validation_feedback" not in self._stubs: - self._stubs["provide_validation_feedback"] = self.grpc_channel.unary_unary( + self._stubs[ + "provide_validation_feedback" + ] = self._logged_channel.unary_unary( "/google.maps.addressvalidation.v1.AddressValidation/ProvideValidationFeedback", request_serializer=address_validation_service.ProvideValidationFeedbackRequest.serialize, response_deserializer=address_validation_service.ProvideValidationFeedbackResponse.deserialize, @@ -326,7 +413,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py index 1e3dec085175..beeb4f7e6cd7 100644 --- a/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py +++ b/packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/services/address_validation/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -85,10 +93,10 @@ def post_validate_address(self, response): def pre_provide_validation_feedback( self, request: address_validation_service.ProvideValidationFeedbackRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ address_validation_service.ProvideValidationFeedbackRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for provide_validation_feedback @@ -111,9 +119,10 @@ def post_provide_validation_feedback( def pre_validate_address( self, request: address_validation_service.ValidateAddressRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - address_validation_service.ValidateAddressRequest, Sequence[Tuple[str, str]] + address_validation_service.ValidateAddressRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for validate_address @@ -256,7 +265,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ProvideValidationFeedbackResponse: r"""Call the provide validation feedback method over HTTP. @@ -268,8 +277,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.address_validation_service.ProvideValidationFeedbackResponse: @@ -283,6 +294,7 @@ def __call__( http_options = ( _BaseAddressValidationRestTransport._BaseProvideValidationFeedback._get_http_options() ) + request, metadata = self._interceptor.pre_provide_validation_feedback( request, metadata ) @@ -299,6 +311,33 @@ def __call__( 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.maps.addressvalidation_v1.AddressValidationClient.ProvideValidationFeedback", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ProvideValidationFeedback", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AddressValidationRestTransport._ProvideValidationFeedback._get_response( @@ -324,7 +363,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_provide_validation_feedback(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = address_validation_service.ProvideValidationFeedbackResponse.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.maps.addressvalidation_v1.AddressValidationClient.provide_validation_feedback", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ProvideValidationFeedback", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ValidateAddress( @@ -363,7 +426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> address_validation_service.ValidateAddressResponse: r"""Call the validate address method over HTTP. @@ -374,8 +437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.address_validation_service.ValidateAddressResponse: @@ -387,6 +452,7 @@ def __call__( http_options = ( _BaseAddressValidationRestTransport._BaseValidateAddress._get_http_options() ) + request, metadata = self._interceptor.pre_validate_address( request, metadata ) @@ -403,6 +469,33 @@ def __call__( 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.maps.addressvalidation_v1.AddressValidationClient.ValidateAddress", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ValidateAddress", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressValidationRestTransport._ValidateAddress._get_response( self._host, @@ -424,7 +517,33 @@ def __call__( pb_resp = address_validation_service.ValidateAddressResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_address(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + address_validation_service.ValidateAddressResponse.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.maps.addressvalidation_v1.AddressValidationClient.validate_address", + extra={ + "serviceName": "google.maps.addressvalidation.v1.AddressValidation", + "rpcName": "ValidateAddress", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json b/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json index da0b02adbb34..f06f24bcc68e 100644 --- a/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json +++ b/packages/google-maps-addressvalidation/samples/generated_samples/snippet_metadata_google.maps.addressvalidation.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-addressvalidation", - "version": "0.3.15" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ProvideValidationFeedbackResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ValidateAddressResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.addressvalidation_v1.types.ValidateAddressResponse", diff --git a/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py b/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py index 449f14bcc3b6..9b9e29a02da4 100644 --- a/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py +++ b/packages/google-maps-addressvalidation/tests/unit/gapic/addressvalidation_v1/test_address_validation.py @@ -1577,6 +1577,7 @@ def test_validate_address_rest_required_fields( response_value._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.validate_address(request) @@ -1706,6 +1707,7 @@ def test_provide_validation_feedback_rest_required_fields( response_value._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.provide_validation_feedback(request) @@ -1979,6 +1981,7 @@ def test_validate_address_rest_bad_request( 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.validate_address(request) @@ -2016,6 +2019,7 @@ def test_validate_address_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.validate_address(request) # Establish that the response is the type that we expect. @@ -2056,6 +2060,7 @@ def test_validate_address_rest_interceptors(null_interceptor): 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 = address_validation_service.ValidateAddressResponse.to_json( address_validation_service.ValidateAddressResponse() ) @@ -2102,6 +2107,7 @@ def test_provide_validation_feedback_rest_bad_request( 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.provide_validation_feedback(request) @@ -2137,6 +2143,7 @@ def test_provide_validation_feedback_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.provide_validation_feedback(request) # Establish that the response is the type that we expect. @@ -2178,6 +2185,7 @@ def test_provide_validation_feedback_rest_interceptors(null_interceptor): 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 = ( address_validation_service.ProvideValidationFeedbackResponse.to_json( address_validation_service.ProvideValidationFeedbackResponse() diff --git a/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py b/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py +++ b/packages/google-maps-areainsights/google/maps/areainsights/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py index 9a362d2be7e9..abc268950ce4 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AreaInsightsTransport from .transports.grpc_asyncio import AreaInsightsGrpcAsyncIOTransport +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 AreaInsightsAsyncClient: """Service definition for the Places Insights API.""" @@ -249,6 +259,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.maps.areainsights_v1.AreaInsightsAsyncClient`.", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "credentialsType": None, + }, + ) + async def compute_insights( self, request: Optional[ @@ -257,7 +289,7 @@ async def compute_insights( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Compute Insights RPC @@ -305,8 +337,10 @@ async def sample_compute_insights(): 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, 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: google.maps.areainsights_v1.types.ComputeInsightsResponse: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py index 1fa5002fff98..cc74d9930ca8 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.maps.areainsights_v1.types import area_insights_service from .transports.base import DEFAULT_CLIENT_INFO, AreaInsightsTransport @@ -568,6 +578,10 @@ def __init__( # 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( @@ -630,6 +644,29 @@ def __init__( 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.maps.areainsights_v1.AreaInsightsClient`.", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "credentialsType": None, + }, + ) + def compute_insights( self, request: Optional[ @@ -638,7 +675,7 @@ def compute_insights( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Compute Insights RPC @@ -686,8 +723,10 @@ def sample_compute_insights(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.maps.areainsights_v1.types.ComputeInsightsResponse: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py index 9f02613a9af3..2ce72e6206fc 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.maps.areainsights_v1.types import area_insights_service from .base import DEFAULT_CLIENT_INFO, AreaInsightsTransport +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.maps.areainsights.v1.AreaInsights", + "rpcName": 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.maps.areainsights.v1.AreaInsights", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AreaInsightsGrpcTransport(AreaInsightsTransport): """gRPC backend transport for AreaInsights. @@ -179,7 +260,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +354,7 @@ def compute_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_insights" not in self._stubs: - self._stubs["compute_insights"] = self.grpc_channel.unary_unary( + self._stubs["compute_insights"] = self._logged_channel.unary_unary( "/google.maps.areainsights.v1.AreaInsights/ComputeInsights", request_serializer=area_insights_service.ComputeInsightsRequest.serialize, response_deserializer=area_insights_service.ComputeInsightsResponse.deserialize, @@ -276,7 +362,7 @@ def compute_insights( return self._stubs["compute_insights"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py index 43a46e9c3ee8..38c4e5963457 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.maps.areainsights_v1.types import area_insights_service from .base import DEFAULT_CLIENT_INFO, AreaInsightsTransport from .grpc import AreaInsightsGrpcTransport +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.maps.areainsights.v1.AreaInsights", + "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.maps.areainsights.v1.AreaInsights", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AreaInsightsGrpcAsyncIOTransport(AreaInsightsTransport): """gRPC AsyncIO backend transport for AreaInsights. @@ -226,10 +308,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -276,7 +361,7 @@ def compute_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_insights" not in self._stubs: - self._stubs["compute_insights"] = self.grpc_channel.unary_unary( + self._stubs["compute_insights"] = self._logged_channel.unary_unary( "/google.maps.areainsights.v1.AreaInsights/ComputeInsights", request_serializer=area_insights_service.ComputeInsightsRequest.serialize, response_deserializer=area_insights_service.ComputeInsightsResponse.deserialize, @@ -308,7 +393,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py index 0ed30438f8f9..7ada4148c778 100644 --- a/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py +++ b/packages/google-maps-areainsights/google/maps/areainsights_v1/services/area_insights/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,11 @@ def post_compute_insights(self, response): def pre_compute_insights( self, request: area_insights_service.ComputeInsightsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[area_insights_service.ComputeInsightsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + area_insights_service.ComputeInsightsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for compute_insights Override in a subclass to manipulate the request or metadata @@ -219,7 +230,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> area_insights_service.ComputeInsightsResponse: r"""Call the compute insights method over HTTP. @@ -229,8 +240,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.area_insights_service.ComputeInsightsResponse: @@ -240,6 +253,7 @@ def __call__( http_options = ( _BaseAreaInsightsRestTransport._BaseComputeInsights._get_http_options() ) + request, metadata = self._interceptor.pre_compute_insights( request, metadata ) @@ -256,6 +270,33 @@ def __call__( 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.maps.areainsights_v1.AreaInsightsClient.ComputeInsights", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "rpcName": "ComputeInsights", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AreaInsightsRestTransport._ComputeInsights._get_response( self._host, @@ -277,7 +318,31 @@ def __call__( pb_resp = area_insights_service.ComputeInsightsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_insights(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + area_insights_service.ComputeInsightsResponse.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.maps.areainsights_v1.AreaInsightsClient.compute_insights", + extra={ + "serviceName": "google.maps.areainsights.v1.AreaInsights", + "rpcName": "ComputeInsights", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json b/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json index ae71f98810a5..3e131934c793 100644 --- a/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json +++ b/packages/google-maps-areainsights/samples/generated_samples/snippet_metadata_google.maps.areainsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-areainsights", - "version": "0.1.2" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.areainsights_v1.types.ComputeInsightsResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.areainsights_v1.types.ComputeInsightsResponse", diff --git a/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py b/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py index 67fe9d1538a3..9fc86c87b8ea 100644 --- a/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py +++ b/packages/google-maps-areainsights/tests/unit/gapic/areainsights_v1/test_area_insights.py @@ -1318,6 +1318,7 @@ def test_compute_insights_rest_required_fields( response_value._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.compute_insights(request) @@ -1539,6 +1540,7 @@ def test_compute_insights_rest_bad_request( 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.compute_insights(request) @@ -1574,6 +1576,7 @@ def test_compute_insights_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.compute_insights(request) # Establish that the response is the type that we expect. @@ -1614,6 +1617,7 @@ def test_compute_insights_rest_interceptors(null_interceptor): 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 = area_insights_service.ComputeInsightsResponse.to_json( area_insights_service.ComputeInsightsResponse() ) diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py index 91ee9321250f..a4572c9dd5a9 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DeliveryServiceTransport from .transports.grpc_asyncio import DeliveryServiceGrpcAsyncIOTransport +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 DeliveryServiceAsyncClient: """The Last Mile Delivery service.""" @@ -278,6 +288,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `maps.fleetengine.delivery_v1.DeliveryServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "credentialsType": None, + }, + ) + async def create_delivery_vehicle( self, request: Optional[ @@ -289,7 +321,7 @@ async def create_delivery_vehicle( delivery_vehicle_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Creates and returns a new ``DeliveryVehicle``. @@ -365,8 +397,10 @@ async def sample_create_delivery_vehicle(): 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, 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -446,7 +480,7 @@ async def get_delivery_vehicle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Returns the specified ``DeliveryVehicle`` instance. @@ -491,8 +525,10 @@ async def sample_get_delivery_vehicle(): 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, 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -571,7 +607,7 @@ async def update_delivery_vehicle( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Writes updated ``DeliveryVehicle`` data to Fleet Engine, and assigns ``Tasks`` to the ``DeliveryVehicle``. You cannot update @@ -634,8 +670,10 @@ async def sample_update_delivery_vehicle(): 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, 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -712,7 +750,7 @@ async def batch_create_tasks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Creates and returns a batch of new ``Task`` objects. @@ -755,8 +793,10 @@ async def sample_batch_create_tasks(): 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, 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: google.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse: @@ -809,7 +849,7 @@ async def create_task( task_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Creates and returns a new ``Task`` object. @@ -897,8 +937,10 @@ async def sample_create_task(): 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, 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -983,7 +1025,7 @@ async def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Gets information about a ``Task``. @@ -1028,8 +1070,10 @@ async def sample_get_task(): 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, 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -1109,7 +1153,7 @@ async def update_task( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Updates ``Task`` data. @@ -1184,8 +1228,10 @@ async def sample_update_task(): 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, 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -1268,7 +1314,7 @@ async def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksAsyncPager: r"""Gets all ``Task``\ s that meet the specified filtering criteria. @@ -1314,8 +1360,10 @@ async def sample_list_tasks(): 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, 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: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksAsyncPager: @@ -1396,7 +1444,7 @@ async def get_task_tracking_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task_tracking_info.TaskTrackingInfo: r"""Returns the specified ``TaskTrackingInfo`` instance. @@ -1443,8 +1491,10 @@ async def sample_get_task_tracking_info(): 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, 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: google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo: @@ -1514,7 +1564,7 @@ async def list_delivery_vehicles( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeliveryVehiclesAsyncPager: r"""Gets all ``DeliveryVehicle``\ s that meet the specified filtering criteria. @@ -1561,8 +1611,10 @@ async def sample_list_delivery_vehicles(): 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, 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: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesAsyncPager: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py index 157b80bfadf4..0c0ba1dce657 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -625,6 +635,10 @@ def __init__( # 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( @@ -690,6 +704,29 @@ def __init__( 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 `maps.fleetengine.delivery_v1.DeliveryServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "credentialsType": None, + }, + ) + def create_delivery_vehicle( self, request: Optional[ @@ -701,7 +738,7 @@ def create_delivery_vehicle( delivery_vehicle_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Creates and returns a new ``DeliveryVehicle``. @@ -777,8 +814,10 @@ def sample_create_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -855,7 +894,7 @@ def get_delivery_vehicle( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Returns the specified ``DeliveryVehicle`` instance. @@ -900,8 +939,10 @@ def sample_get_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -977,7 +1018,7 @@ def update_delivery_vehicle( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Writes updated ``DeliveryVehicle`` data to Fleet Engine, and assigns ``Tasks`` to the ``DeliveryVehicle``. You cannot update @@ -1040,8 +1081,10 @@ def sample_update_delivery_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.DeliveryVehicle: @@ -1115,7 +1158,7 @@ def batch_create_tasks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Creates and returns a batch of new ``Task`` objects. @@ -1158,8 +1201,10 @@ def sample_batch_create_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse: @@ -1210,7 +1255,7 @@ def create_task( task_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Creates and returns a new ``Task`` object. @@ -1298,8 +1343,10 @@ def sample_create_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -1381,7 +1428,7 @@ def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Gets information about a ``Task``. @@ -1426,8 +1473,10 @@ def sample_get_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -1506,7 +1555,7 @@ def update_task( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Updates ``Task`` data. @@ -1581,8 +1630,10 @@ def sample_update_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.Task: @@ -1662,7 +1713,7 @@ def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksPager: r"""Gets all ``Task``\ s that meet the specified filtering criteria. @@ -1708,8 +1759,10 @@ def sample_list_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksPager: @@ -1787,7 +1840,7 @@ def get_task_tracking_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task_tracking_info.TaskTrackingInfo: r"""Returns the specified ``TaskTrackingInfo`` instance. @@ -1834,8 +1887,10 @@ def sample_get_task_tracking_info(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo: @@ -1902,7 +1957,7 @@ def list_delivery_vehicles( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeliveryVehiclesPager: r"""Gets all ``DeliveryVehicle``\ s that meet the specified filtering criteria. @@ -1949,8 +2004,10 @@ def sample_list_delivery_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesPager: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py index b645b3ca097f..b8cddd19d315 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = delivery_api.ListTasksRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = delivery_api.ListTasksRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = delivery_api.ListDeliveryVehiclesRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = delivery_api.ListDeliveryVehiclesRequest(request) diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py index 7b90392f5a79..abfd09fc1a50 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,7 +23,10 @@ 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.maps.fleetengine_delivery_v1.types import ( delivery_api, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, DeliveryServiceTransport +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": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": 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": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DeliveryServiceGrpcTransport(DeliveryServiceTransport): """gRPC backend transport for DeliveryService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def create_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_delivery_vehicle" not in self._stubs: - self._stubs["create_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateDeliveryVehicle", request_serializer=delivery_api.CreateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -288,7 +374,7 @@ def get_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_delivery_vehicle" not in self._stubs: - self._stubs["get_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetDeliveryVehicle", request_serializer=delivery_api.GetDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -324,7 +410,7 @@ def update_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_delivery_vehicle" not in self._stubs: - self._stubs["update_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateDeliveryVehicle", request_serializer=delivery_api.UpdateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -352,7 +438,7 @@ def batch_create_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_tasks" not in self._stubs: - self._stubs["batch_create_tasks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/BatchCreateTasks", request_serializer=delivery_api.BatchCreateTasksRequest.serialize, response_deserializer=delivery_api.BatchCreateTasksResponse.deserialize, @@ -376,7 +462,7 @@ def create_task(self) -> Callable[[delivery_api.CreateTaskRequest], tasks.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateTask", request_serializer=delivery_api.CreateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -400,7 +486,7 @@ def get_task(self) -> Callable[[delivery_api.GetTaskRequest], tasks.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTask", request_serializer=delivery_api.GetTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -424,7 +510,7 @@ def update_task(self) -> Callable[[delivery_api.UpdateTaskRequest], tasks.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_task" not in self._stubs: - self._stubs["update_task"] = self.grpc_channel.unary_unary( + self._stubs["update_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateTask", request_serializer=delivery_api.UpdateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -450,7 +536,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListTasks", request_serializer=delivery_api.ListTasksRequest.serialize, response_deserializer=delivery_api.ListTasksResponse.deserialize, @@ -478,7 +564,7 @@ def get_task_tracking_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task_tracking_info" not in self._stubs: - self._stubs["get_task_tracking_info"] = self.grpc_channel.unary_unary( + self._stubs["get_task_tracking_info"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTaskTrackingInfo", request_serializer=delivery_api.GetTaskTrackingInfoRequest.serialize, response_deserializer=task_tracking_info.TaskTrackingInfo.deserialize, @@ -508,7 +594,7 @@ def list_delivery_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_delivery_vehicles" not in self._stubs: - self._stubs["list_delivery_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_delivery_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListDeliveryVehicles", request_serializer=delivery_api.ListDeliveryVehiclesRequest.serialize, response_deserializer=delivery_api.ListDeliveryVehiclesResponse.deserialize, @@ -516,7 +602,7 @@ def list_delivery_vehicles( return self._stubs["list_delivery_vehicles"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py index bbd2979ba6a6..a6f8b24a0896 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,8 +25,11 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.maps.fleetengine_delivery_v1.types import ( delivery_api, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, DeliveryServiceTransport from .grpc import DeliveryServiceGrpcTransport +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": "maps.fleetengine.delivery.v1.DeliveryService", + "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": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DeliveryServiceGrpcAsyncIOTransport(DeliveryServiceTransport): """gRPC AsyncIO backend transport for DeliveryService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def create_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_delivery_vehicle" not in self._stubs: - self._stubs["create_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateDeliveryVehicle", request_serializer=delivery_api.CreateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -298,7 +383,7 @@ def get_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_delivery_vehicle" not in self._stubs: - self._stubs["get_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetDeliveryVehicle", request_serializer=delivery_api.GetDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -335,7 +420,7 @@ def update_delivery_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_delivery_vehicle" not in self._stubs: - self._stubs["update_delivery_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_delivery_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateDeliveryVehicle", request_serializer=delivery_api.UpdateDeliveryVehicleRequest.serialize, response_deserializer=delivery_vehicles.DeliveryVehicle.deserialize, @@ -364,7 +449,7 @@ def batch_create_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_tasks" not in self._stubs: - self._stubs["batch_create_tasks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/BatchCreateTasks", request_serializer=delivery_api.BatchCreateTasksRequest.serialize, response_deserializer=delivery_api.BatchCreateTasksResponse.deserialize, @@ -390,7 +475,7 @@ def create_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/CreateTask", request_serializer=delivery_api.CreateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -416,7 +501,7 @@ def get_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTask", request_serializer=delivery_api.GetTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -442,7 +527,7 @@ def update_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_task" not in self._stubs: - self._stubs["update_task"] = self.grpc_channel.unary_unary( + self._stubs["update_task"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/UpdateTask", request_serializer=delivery_api.UpdateTaskRequest.serialize, response_deserializer=tasks.Task.deserialize, @@ -470,7 +555,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListTasks", request_serializer=delivery_api.ListTasksRequest.serialize, response_deserializer=delivery_api.ListTasksResponse.deserialize, @@ -499,7 +584,7 @@ def get_task_tracking_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task_tracking_info" not in self._stubs: - self._stubs["get_task_tracking_info"] = self.grpc_channel.unary_unary( + self._stubs["get_task_tracking_info"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/GetTaskTrackingInfo", request_serializer=delivery_api.GetTaskTrackingInfoRequest.serialize, response_deserializer=task_tracking_info.TaskTrackingInfo.deserialize, @@ -529,7 +614,7 @@ def list_delivery_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_delivery_vehicles" not in self._stubs: - self._stubs["list_delivery_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_delivery_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.delivery.v1.DeliveryService/ListDeliveryVehicles", request_serializer=delivery_api.ListDeliveryVehiclesRequest.serialize, response_deserializer=delivery_api.ListDeliveryVehiclesResponse.deserialize, @@ -687,7 +772,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py index aef58bf5045a..faf87ef68d72 100644 --- a/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py +++ b/packages/google-maps-fleetengine-delivery/google/maps/fleetengine_delivery_v1/services/delivery_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -154,8 +162,10 @@ def post_update_task(self, response): def pre_batch_create_tasks( self, request: delivery_api.BatchCreateTasksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.BatchCreateTasksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.BatchCreateTasksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_tasks Override in a subclass to manipulate the request or metadata @@ -177,8 +187,11 @@ def post_batch_create_tasks( def pre_create_delivery_vehicle( self, request: delivery_api.CreateDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.CreateDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.CreateDeliveryVehicleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -200,8 +213,8 @@ def post_create_delivery_vehicle( def pre_create_task( self, request: delivery_api.CreateTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.CreateTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_task Override in a subclass to manipulate the request or metadata @@ -221,8 +234,10 @@ def post_create_task(self, response: tasks.Task) -> tasks.Task: def pre_get_delivery_vehicle( self, request: delivery_api.GetDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.GetDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.GetDeliveryVehicleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -242,8 +257,10 @@ def post_get_delivery_vehicle( return response def pre_get_task( - self, request: delivery_api.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[delivery_api.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: delivery_api.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -263,8 +280,10 @@ def post_get_task(self, response: tasks.Task) -> tasks.Task: def pre_get_task_tracking_info( self, request: delivery_api.GetTaskTrackingInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.GetTaskTrackingInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.GetTaskTrackingInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_task_tracking_info Override in a subclass to manipulate the request or metadata @@ -286,8 +305,11 @@ def post_get_task_tracking_info( def pre_list_delivery_vehicles( self, request: delivery_api.ListDeliveryVehiclesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.ListDeliveryVehiclesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.ListDeliveryVehiclesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_delivery_vehicles Override in a subclass to manipulate the request or metadata @@ -309,8 +331,8 @@ def post_list_delivery_vehicles( def pre_list_tasks( self, request: delivery_api.ListTasksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.ListTasksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -332,8 +354,11 @@ def post_list_tasks( def pre_update_delivery_vehicle( self, request: delivery_api.UpdateDeliveryVehicleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.UpdateDeliveryVehicleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + delivery_api.UpdateDeliveryVehicleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_delivery_vehicle Override in a subclass to manipulate the request or metadata @@ -355,8 +380,8 @@ def post_update_delivery_vehicle( def pre_update_task( self, request: delivery_api.UpdateTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[delivery_api.UpdateTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[delivery_api.UpdateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_task Override in a subclass to manipulate the request or metadata @@ -495,7 +520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.BatchCreateTasksResponse: r"""Call the batch create tasks method over HTTP. @@ -505,8 +530,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_api.BatchCreateTasksResponse: @@ -516,6 +543,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseBatchCreateTasks._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_tasks( request, metadata ) @@ -532,6 +560,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.BatchCreateTasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "BatchCreateTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._BatchCreateTasks._get_response( self._host, @@ -553,7 +608,31 @@ def __call__( pb_resp = delivery_api.BatchCreateTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_api.BatchCreateTasksResponse.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.batch_create_tasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "BatchCreateTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDeliveryVehicle( @@ -592,7 +671,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the create delivery vehicle method over HTTP. @@ -602,8 +681,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_vehicles.DeliveryVehicle: @@ -625,6 +706,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseCreateDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_create_delivery_vehicle( request, metadata ) @@ -641,6 +723,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.CreateDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DeliveryServiceRestTransport._CreateDeliveryVehicle._get_response( @@ -664,7 +773,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.create_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTask( @@ -702,7 +835,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Call the create task method over HTTP. @@ -712,8 +845,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tasks.Task: @@ -739,6 +874,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseCreateTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_task(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseCreateTask._get_transcoded_request( http_options, request @@ -753,6 +889,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.CreateTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._CreateTask._get_response( self._host, @@ -774,7 +937,29 @@ def __call__( pb_resp = tasks.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tasks.Task.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.create_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "CreateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeliveryVehicle( @@ -812,7 +997,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the get delivery vehicle method over HTTP. @@ -822,8 +1007,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_vehicles.DeliveryVehicle: @@ -845,6 +1032,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_get_delivery_vehicle( request, metadata ) @@ -857,6 +1045,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.GetDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetDeliveryVehicle._get_response( self._host, @@ -877,7 +1092,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.get_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask( @@ -914,7 +1153,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Call the get task method over HTTP. @@ -924,8 +1163,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tasks.Task: @@ -951,6 +1192,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetTask._get_http_options() ) + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseDeliveryServiceRestTransport._BaseGetTask._get_transcoded_request( @@ -965,6 +1207,33 @@ def __call__( ) ) + 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.GetTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetTask._get_response( self._host, @@ -985,7 +1254,29 @@ def __call__( pb_resp = tasks.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tasks.Task.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.get_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTaskTrackingInfo( @@ -1023,7 +1314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task_tracking_info.TaskTrackingInfo: r"""Call the get task tracking info method over HTTP. @@ -1033,8 +1324,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.task_tracking_info.TaskTrackingInfo: @@ -1049,6 +1342,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseGetTaskTrackingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_task_tracking_info( request, metadata ) @@ -1061,6 +1355,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.GetTaskTrackingInfo", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTaskTrackingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._GetTaskTrackingInfo._get_response( self._host, @@ -1081,7 +1402,31 @@ def __call__( pb_resp = task_tracking_info.TaskTrackingInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task_tracking_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task_tracking_info.TaskTrackingInfo.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.get_task_tracking_info", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "GetTaskTrackingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeliveryVehicles( @@ -1119,7 +1464,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.ListDeliveryVehiclesResponse: r"""Call the list delivery vehicles method over HTTP. @@ -1129,8 +1474,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_api.ListDeliveryVehiclesResponse: @@ -1140,6 +1487,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseListDeliveryVehicles._get_http_options() ) + request, metadata = self._interceptor.pre_list_delivery_vehicles( request, metadata ) @@ -1152,6 +1500,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.ListDeliveryVehicles", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListDeliveryVehicles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._ListDeliveryVehicles._get_response( self._host, @@ -1172,7 +1547,31 @@ def __call__( pb_resp = delivery_api.ListDeliveryVehiclesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_delivery_vehicles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + delivery_api.ListDeliveryVehiclesResponse.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.list_delivery_vehicles", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListDeliveryVehicles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks( @@ -1209,7 +1608,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_api.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1219,8 +1618,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_api.ListTasksResponse: @@ -1233,6 +1634,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseListTasks._get_transcoded_request( http_options, request @@ -1245,6 +1647,33 @@ def __call__( ) ) + 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.ListTasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._ListTasks._get_response( self._host, @@ -1265,7 +1694,29 @@ def __call__( pb_resp = delivery_api.ListTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_api.ListTasksResponse.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.list_tasks", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeliveryVehicle( @@ -1304,7 +1755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> delivery_vehicles.DeliveryVehicle: r"""Call the update delivery vehicle method over HTTP. @@ -1314,8 +1765,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.delivery_vehicles.DeliveryVehicle: @@ -1337,6 +1790,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseUpdateDeliveryVehicle._get_http_options() ) + request, metadata = self._interceptor.pre_update_delivery_vehicle( request, metadata ) @@ -1353,6 +1807,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.UpdateDeliveryVehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateDeliveryVehicle", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DeliveryServiceRestTransport._UpdateDeliveryVehicle._get_response( @@ -1376,7 +1857,31 @@ def __call__( pb_resp = delivery_vehicles.DeliveryVehicle.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_delivery_vehicle(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = delivery_vehicles.DeliveryVehicle.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.update_delivery_vehicle", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateDeliveryVehicle", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTask( @@ -1414,7 +1919,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tasks.Task: r"""Call the update task method over HTTP. @@ -1424,8 +1929,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tasks.Task: @@ -1451,6 +1958,7 @@ def __call__( http_options = ( _BaseDeliveryServiceRestTransport._BaseUpdateTask._get_http_options() ) + request, metadata = self._interceptor.pre_update_task(request, metadata) transcoded_request = _BaseDeliveryServiceRestTransport._BaseUpdateTask._get_transcoded_request( http_options, request @@ -1465,6 +1973,33 @@ def __call__( 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 maps.fleetengine.delivery_v1.DeliveryServiceClient.UpdateTask", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DeliveryServiceRestTransport._UpdateTask._get_response( self._host, @@ -1486,7 +2021,29 @@ def __call__( pb_resp = tasks.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tasks.Task.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 maps.fleetengine.delivery_v1.DeliveryServiceClient.update_task", + extra={ + "serviceName": "maps.fleetengine.delivery.v1.DeliveryService", + "rpcName": "UpdateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json b/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json index ea6c4de1fa77..b1bb486cd03d 100644 --- a/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json +++ b/packages/google-maps-fleetengine-delivery/samples/generated_samples/snippet_metadata_maps.fleetengine.delivery.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-fleetengine-delivery", - "version": "0.2.6" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.BatchCreateTasksResponse", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.TaskTrackingInfo", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -1037,7 +1037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesAsyncPager", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListDeliveryVehiclesPager", @@ -1198,7 +1198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksAsyncPager", @@ -1278,7 +1278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.services.delivery_service.pagers.ListTasksPager", @@ -1363,7 +1363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.DeliveryVehicle", @@ -1532,7 +1532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_delivery_v1.types.Task", diff --git a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py index 3baeecd86382..fbd1f540bdbf 100644 --- a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py +++ b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py @@ -4441,6 +4441,7 @@ def test_create_delivery_vehicle_rest_required_fields( response_value._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_delivery_vehicle(request) @@ -4508,6 +4509,7 @@ def test_create_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_delivery_vehicle(**mock_args) @@ -4646,6 +4648,7 @@ def test_get_delivery_vehicle_rest_required_fields( response_value._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_delivery_vehicle(request) @@ -4691,6 +4694,7 @@ def test_get_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_delivery_vehicle(**mock_args) @@ -4829,6 +4833,7 @@ def test_update_delivery_vehicle_rest_required_fields( response_value._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_delivery_vehicle(request) @@ -4890,6 +4895,7 @@ def test_update_delivery_vehicle_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_delivery_vehicle(**mock_args) @@ -5027,6 +5033,7 @@ def test_batch_create_tasks_rest_required_fields( response_value._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.batch_create_tasks(request) @@ -5167,6 +5174,7 @@ def test_create_task_rest_required_fields(request_type=delivery_api.CreateTaskRe response_value._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_task(request) @@ -5234,6 +5242,7 @@ def test_create_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_task(**mock_args) @@ -5365,6 +5374,7 @@ def test_get_task_rest_required_fields(request_type=delivery_api.GetTaskRequest) response_value._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_task(request) @@ -5410,6 +5420,7 @@ def test_get_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_task(**mock_args) @@ -5540,6 +5551,7 @@ def test_update_task_rest_required_fields(request_type=delivery_api.UpdateTaskRe response_value._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_task(request) @@ -5599,6 +5611,7 @@ def test_update_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_task(**mock_args) @@ -5736,6 +5749,7 @@ def test_list_tasks_rest_required_fields(request_type=delivery_api.ListTasksRequ response_value._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_tasks(request) @@ -5791,6 +5805,7 @@ def test_list_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tasks(**mock_args) @@ -5988,6 +6003,7 @@ def test_get_task_tracking_info_rest_required_fields( response_value._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_task_tracking_info(request) @@ -6033,6 +6049,7 @@ def test_get_task_tracking_info_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_task_tracking_info(**mock_args) @@ -6178,6 +6195,7 @@ def test_list_delivery_vehicles_rest_required_fields( response_value._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_delivery_vehicles(request) @@ -6234,6 +6252,7 @@ def test_list_delivery_vehicles_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_delivery_vehicles(**mock_args) @@ -7633,6 +7652,7 @@ def test_create_delivery_vehicle_rest_bad_request( 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_delivery_vehicle(request) @@ -7806,6 +7826,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -7851,6 +7872,7 @@ def test_create_delivery_vehicle_rest_interceptors(null_interceptor): 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 = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -7897,6 +7919,7 @@ def test_get_delivery_vehicle_rest_bad_request( 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_delivery_vehicle(request) @@ -7935,6 +7958,7 @@ def test_get_delivery_vehicle_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -7980,6 +8004,7 @@ def test_get_delivery_vehicle_rest_interceptors(null_interceptor): 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 = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -8028,6 +8053,7 @@ def test_update_delivery_vehicle_rest_bad_request( 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_delivery_vehicle(request) @@ -8203,6 +8229,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_delivery_vehicle(request) # Establish that the response is the type that we expect. @@ -8248,6 +8275,7 @@ def test_update_delivery_vehicle_rest_interceptors(null_interceptor): 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 = delivery_vehicles.DeliveryVehicle.to_json( delivery_vehicles.DeliveryVehicle() ) @@ -8294,6 +8322,7 @@ def test_batch_create_tasks_rest_bad_request( 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.batch_create_tasks(request) @@ -8327,6 +8356,7 @@ def test_batch_create_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_create_tasks(request) # Establish that the response is the type that we expect. @@ -8366,6 +8396,7 @@ def test_batch_create_tasks_rest_interceptors(null_interceptor): 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 = delivery_api.BatchCreateTasksResponse.to_json( delivery_api.BatchCreateTasksResponse() ) @@ -8410,6 +8441,7 @@ def test_create_task_rest_bad_request(request_type=delivery_api.CreateTaskReques 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_task(request) @@ -8605,6 +8637,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_task(request) # Establish that the response is the type that we expect. @@ -8652,6 +8685,7 @@ def test_create_task_rest_interceptors(null_interceptor): 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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -8694,6 +8728,7 @@ def test_get_task_rest_bad_request(request_type=delivery_api.GetTaskRequest): 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_task(request) @@ -8735,6 +8770,7 @@ def test_get_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_task(request) # Establish that the response is the type that we expect. @@ -8782,6 +8818,7 @@ def test_get_task_rest_interceptors(null_interceptor): 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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -8824,6 +8861,7 @@ def test_update_task_rest_bad_request(request_type=delivery_api.UpdateTaskReques 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_task(request) @@ -9019,6 +9057,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_task(request) # Establish that the response is the type that we expect. @@ -9066,6 +9105,7 @@ def test_update_task_rest_interceptors(null_interceptor): 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 = tasks.Task.to_json(tasks.Task()) req.return_value.content = return_value @@ -9108,6 +9148,7 @@ def test_list_tasks_rest_bad_request(request_type=delivery_api.ListTasksRequest) 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_tasks(request) @@ -9144,6 +9185,7 @@ def test_list_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tasks(request) # Establish that the response is the type that we expect. @@ -9183,6 +9225,7 @@ def test_list_tasks_rest_interceptors(null_interceptor): 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 = delivery_api.ListTasksResponse.to_json( delivery_api.ListTasksResponse() ) @@ -9229,6 +9272,7 @@ def test_get_task_tracking_info_rest_bad_request( 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_task_tracking_info(request) @@ -9267,6 +9311,7 @@ def test_get_task_tracking_info_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_task_tracking_info(request) # Establish that the response is the type that we expect. @@ -9310,6 +9355,7 @@ def test_get_task_tracking_info_rest_interceptors(null_interceptor): 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 = task_tracking_info.TaskTrackingInfo.to_json( task_tracking_info.TaskTrackingInfo() ) @@ -9356,6 +9402,7 @@ def test_list_delivery_vehicles_rest_bad_request( 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_delivery_vehicles(request) @@ -9392,6 +9439,7 @@ def test_list_delivery_vehicles_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_delivery_vehicles(request) # Establish that the response is the type that we expect. @@ -9433,6 +9481,7 @@ def test_list_delivery_vehicles_rest_interceptors(null_interceptor): 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 = delivery_api.ListDeliveryVehiclesResponse.to_json( delivery_api.ListDeliveryVehiclesResponse() ) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py index 901f8da01f11..abea31f9f429 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TripServiceTransport from .transports.grpc_asyncio import TripServiceGrpcAsyncIOTransport +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 TripServiceAsyncClient: """Trip management service.""" @@ -255,13 +265,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `maps.fleetengine_v1.TripServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "credentialsType": None, + }, + ) + async def create_trip( self, request: Optional[Union[trip_api.CreateTripRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Creates a trip in the Fleet Engine and returns the new trip. @@ -299,8 +331,10 @@ async def sample_create_trip(): 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, 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: google.maps.fleetengine_v1.types.Trip: @@ -350,7 +384,7 @@ async def get_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Get information about a single trip. @@ -386,8 +420,10 @@ async def sample_get_trip(): 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, 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: google.maps.fleetengine_v1.types.Trip: @@ -435,7 +471,7 @@ async def report_billable_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Report billable trip usage. @@ -469,8 +505,10 @@ async def sample_report_billable_trip(): 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, 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -513,7 +551,7 @@ async def search_trips( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchTripsAsyncPager: r"""Get all the trips for a specific vehicle. @@ -550,8 +588,10 @@ async def sample_search_trips(): 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, 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: google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsAsyncPager: @@ -617,7 +657,7 @@ async def update_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Updates trip data. @@ -653,8 +693,10 @@ async def sample_update_trip(): 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, 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: google.maps.fleetengine_v1.types.Trip: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py index e9c38cbe63e7..dc6dd2dca463 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -574,6 +584,10 @@ def __init__( # 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( @@ -636,13 +650,36 @@ def __init__( 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 `maps.fleetengine_v1.TripServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "credentialsType": None, + }, + ) + def create_trip( self, request: Optional[Union[trip_api.CreateTripRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Creates a trip in the Fleet Engine and returns the new trip. @@ -680,8 +717,10 @@ def sample_create_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Trip: @@ -729,7 +768,7 @@ def get_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Get information about a single trip. @@ -765,8 +804,10 @@ def sample_get_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Trip: @@ -814,7 +855,7 @@ def report_billable_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Report billable trip usage. @@ -848,8 +889,10 @@ def sample_report_billable_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -890,7 +933,7 @@ def search_trips( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchTripsPager: r"""Get all the trips for a specific vehicle. @@ -927,8 +970,10 @@ def sample_search_trips(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsPager: @@ -992,7 +1037,7 @@ def update_trip( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trips.Trip: r"""Updates trip data. @@ -1028,8 +1073,10 @@ def sample_update_trip(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Trip: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py index c77ea169c4df..25bf421ab890 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = trip_api.SearchTripsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = trip_api.SearchTripsRequest(request) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py index 94c71d1babb7..cd4b61872019 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.maps.fleetengine_v1.types import trip_api, trips from .base import DEFAULT_CLIENT_INFO, TripServiceTransport +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": "maps.fleetengine.v1.TripService", + "rpcName": 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": "maps.fleetengine.v1.TripService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TripServiceGrpcTransport(TripServiceTransport): """gRPC backend transport for TripService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -253,7 +339,7 @@ def create_trip(self) -> Callable[[trip_api.CreateTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trip" not in self._stubs: - self._stubs["create_trip"] = self.grpc_channel.unary_unary( + self._stubs["create_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/CreateTrip", request_serializer=trip_api.CreateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -277,7 +363,7 @@ def get_trip(self) -> Callable[[trip_api.GetTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trip" not in self._stubs: - self._stubs["get_trip"] = self.grpc_channel.unary_unary( + self._stubs["get_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/GetTrip", request_serializer=trip_api.GetTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -303,7 +389,7 @@ def report_billable_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_billable_trip" not in self._stubs: - self._stubs["report_billable_trip"] = self.grpc_channel.unary_unary( + self._stubs["report_billable_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/ReportBillableTrip", request_serializer=trip_api.ReportBillableTripRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -329,7 +415,7 @@ def search_trips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_trips" not in self._stubs: - self._stubs["search_trips"] = self.grpc_channel.unary_unary( + self._stubs["search_trips"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/SearchTrips", request_serializer=trip_api.SearchTripsRequest.serialize, response_deserializer=trip_api.SearchTripsResponse.deserialize, @@ -353,7 +439,7 @@ def update_trip(self) -> Callable[[trip_api.UpdateTripRequest], trips.Trip]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trip" not in self._stubs: - self._stubs["update_trip"] = self.grpc_channel.unary_unary( + self._stubs["update_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/UpdateTrip", request_serializer=trip_api.UpdateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -361,7 +447,7 @@ def update_trip(self) -> Callable[[trip_api.UpdateTripRequest], trips.Trip]: return self._stubs["update_trip"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py index 5be75436974d..e8ee4571fe01 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/trip_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.maps.fleetengine_v1.types import trip_api, trips from .base import DEFAULT_CLIENT_INFO, TripServiceTransport from .grpc import TripServiceGrpcTransport +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": "maps.fleetengine.v1.TripService", + "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": "maps.fleetengine.v1.TripService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TripServiceGrpcAsyncIOTransport(TripServiceTransport): """gRPC AsyncIO backend transport for TripService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def create_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trip" not in self._stubs: - self._stubs["create_trip"] = self.grpc_channel.unary_unary( + self._stubs["create_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/CreateTrip", request_serializer=trip_api.CreateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -287,7 +372,7 @@ def get_trip(self) -> Callable[[trip_api.GetTripRequest], Awaitable[trips.Trip]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trip" not in self._stubs: - self._stubs["get_trip"] = self.grpc_channel.unary_unary( + self._stubs["get_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/GetTrip", request_serializer=trip_api.GetTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -313,7 +398,7 @@ def report_billable_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_billable_trip" not in self._stubs: - self._stubs["report_billable_trip"] = self.grpc_channel.unary_unary( + self._stubs["report_billable_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/ReportBillableTrip", request_serializer=trip_api.ReportBillableTripRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -341,7 +426,7 @@ def search_trips( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_trips" not in self._stubs: - self._stubs["search_trips"] = self.grpc_channel.unary_unary( + self._stubs["search_trips"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/SearchTrips", request_serializer=trip_api.SearchTripsRequest.serialize, response_deserializer=trip_api.SearchTripsResponse.deserialize, @@ -367,7 +452,7 @@ def update_trip( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trip" not in self._stubs: - self._stubs["update_trip"] = self.grpc_channel.unary_unary( + self._stubs["update_trip"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.TripService/UpdateTrip", request_serializer=trip_api.UpdateTripRequest.serialize, response_deserializer=trips.Trip.deserialize, @@ -446,7 +531,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py index 55f0e2fbbdb9..190de83c06ed 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VehicleServiceTransport from .transports.grpc_asyncio import VehicleServiceGrpcAsyncIOTransport +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 VehicleServiceAsyncClient: """Vehicle management service.""" @@ -257,13 +267,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `maps.fleetengine_v1.VehicleServiceAsyncClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "credentialsType": None, + }, + ) + async def create_vehicle( self, request: Optional[Union[vehicle_api.CreateVehicleRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider. Each ``Vehicle`` must have a @@ -330,8 +362,10 @@ async def sample_create_vehicle(): 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, 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: google.maps.fleetengine_v1.types.Vehicle: @@ -381,7 +415,7 @@ async def get_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Returns a vehicle from the Fleet Engine. @@ -417,8 +451,10 @@ async def sample_get_vehicle(): 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, 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: google.maps.fleetengine_v1.types.Vehicle: @@ -468,7 +504,7 @@ async def update_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Writes updated vehicle data to the Fleet Engine. @@ -521,8 +557,10 @@ async def sample_update_vehicle(): 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, 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: google.maps.fleetengine_v1.types.Vehicle: @@ -574,7 +612,7 @@ async def update_vehicle_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.UpdateVehicleAttributesResponse: r"""Partially updates a vehicle's attributes. Only the attributes mentioned in the request will be updated, other attributes will @@ -619,8 +657,10 @@ async def sample_update_vehicle_attributes(): 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, 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: google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse: @@ -670,7 +710,7 @@ async def list_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVehiclesAsyncPager: r"""Returns a paginated list of vehicles associated with a provider that match the request options. @@ -709,8 +749,10 @@ async def sample_list_vehicles(): 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, 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: google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesAsyncPager: @@ -775,7 +817,7 @@ async def search_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.SearchVehiclesResponse: r"""Returns a list of vehicles that match the request options. @@ -817,8 +859,10 @@ async def sample_search_vehicles(): 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, 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: google.maps.fleetengine_v1.types.SearchVehiclesResponse: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py index b0237d56bda6..dafbdcee4a2f 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -574,6 +584,10 @@ def __init__( # 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( @@ -639,13 +653,36 @@ def __init__( 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 `maps.fleetengine_v1.VehicleServiceClient`.", + extra={ + "serviceName": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "credentialsType": None, + }, + ) + def create_vehicle( self, request: Optional[Union[vehicle_api.CreateVehicleRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider. Each ``Vehicle`` must have a @@ -712,8 +749,10 @@ def sample_create_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Vehicle: @@ -761,7 +800,7 @@ def get_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Returns a vehicle from the Fleet Engine. @@ -797,8 +836,10 @@ def sample_get_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Vehicle: @@ -846,7 +887,7 @@ def update_vehicle( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicles.Vehicle: r"""Writes updated vehicle data to the Fleet Engine. @@ -899,8 +940,10 @@ def sample_update_vehicle(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.Vehicle: @@ -950,7 +993,7 @@ def update_vehicle_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.UpdateVehicleAttributesResponse: r"""Partially updates a vehicle's attributes. Only the attributes mentioned in the request will be updated, other attributes will @@ -995,8 +1038,10 @@ def sample_update_vehicle_attributes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse: @@ -1046,7 +1091,7 @@ def list_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVehiclesPager: r"""Returns a paginated list of vehicles associated with a provider that match the request options. @@ -1085,8 +1130,10 @@ def sample_list_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesPager: @@ -1149,7 +1196,7 @@ def search_vehicles( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vehicle_api.SearchVehiclesResponse: r"""Returns a list of vehicles that match the request options. @@ -1191,8 +1238,10 @@ def sample_search_vehicles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.maps.fleetengine_v1.types.SearchVehiclesResponse: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py index f57049f143ec..4bee10cc5629 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vehicle_api.ListVehiclesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vehicle_api.ListVehiclesRequest(request) diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py index 4dd10753e65b..4969f1f69320 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.maps.fleetengine_v1.types import vehicle_api, vehicles from .base import DEFAULT_CLIENT_INFO, VehicleServiceTransport +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": "maps.fleetengine.v1.VehicleService", + "rpcName": 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": "maps.fleetengine.v1.VehicleService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VehicleServiceGrpcTransport(VehicleServiceTransport): """gRPC backend transport for VehicleService. @@ -179,7 +260,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -283,7 +369,7 @@ def create_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vehicle" not in self._stubs: - self._stubs["create_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/CreateVehicle", request_serializer=vehicle_api.CreateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -309,7 +395,7 @@ def get_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vehicle" not in self._stubs: - self._stubs["get_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/GetVehicle", request_serializer=vehicle_api.GetVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -352,7 +438,7 @@ def update_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle" not in self._stubs: - self._stubs["update_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicle", request_serializer=vehicle_api.UpdateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -386,7 +472,7 @@ def update_vehicle_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle_attributes" not in self._stubs: - self._stubs["update_vehicle_attributes"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle_attributes"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicleAttributes", request_serializer=vehicle_api.UpdateVehicleAttributesRequest.serialize, response_deserializer=vehicle_api.UpdateVehicleAttributesResponse.deserialize, @@ -413,7 +499,7 @@ def list_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vehicles" not in self._stubs: - self._stubs["list_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/ListVehicles", request_serializer=vehicle_api.ListVehiclesRequest.serialize, response_deserializer=vehicle_api.ListVehiclesResponse.deserialize, @@ -442,7 +528,7 @@ def search_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_vehicles" not in self._stubs: - self._stubs["search_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["search_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/SearchVehicles", request_serializer=vehicle_api.SearchVehiclesRequest.serialize, response_deserializer=vehicle_api.SearchVehiclesResponse.deserialize, @@ -450,7 +536,7 @@ def search_vehicles( return self._stubs["search_vehicles"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py index e22c75be1254..a0ef9113b619 100644 --- a/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py +++ b/packages/google-maps-fleetengine/google/maps/fleetengine_v1/services/vehicle_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.maps.fleetengine_v1.types import vehicle_api, vehicles from .base import DEFAULT_CLIENT_INFO, VehicleServiceTransport from .grpc import VehicleServiceGrpcTransport +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": "maps.fleetengine.v1.VehicleService", + "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": "maps.fleetengine.v1.VehicleService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VehicleServiceGrpcAsyncIOTransport(VehicleServiceTransport): """gRPC AsyncIO backend transport for VehicleService. @@ -226,10 +308,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -291,7 +376,7 @@ def create_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_vehicle" not in self._stubs: - self._stubs["create_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["create_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/CreateVehicle", request_serializer=vehicle_api.CreateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -317,7 +402,7 @@ def get_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vehicle" not in self._stubs: - self._stubs["get_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["get_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/GetVehicle", request_serializer=vehicle_api.GetVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -360,7 +445,7 @@ def update_vehicle( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle" not in self._stubs: - self._stubs["update_vehicle"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicle", request_serializer=vehicle_api.UpdateVehicleRequest.serialize, response_deserializer=vehicles.Vehicle.deserialize, @@ -394,7 +479,7 @@ def update_vehicle_attributes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vehicle_attributes" not in self._stubs: - self._stubs["update_vehicle_attributes"] = self.grpc_channel.unary_unary( + self._stubs["update_vehicle_attributes"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/UpdateVehicleAttributes", request_serializer=vehicle_api.UpdateVehicleAttributesRequest.serialize, response_deserializer=vehicle_api.UpdateVehicleAttributesResponse.deserialize, @@ -423,7 +508,7 @@ def list_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vehicles" not in self._stubs: - self._stubs["list_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["list_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/ListVehicles", request_serializer=vehicle_api.ListVehiclesRequest.serialize, response_deserializer=vehicle_api.ListVehiclesResponse.deserialize, @@ -453,7 +538,7 @@ def search_vehicles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_vehicles" not in self._stubs: - self._stubs["search_vehicles"] = self.grpc_channel.unary_unary( + self._stubs["search_vehicles"] = self._logged_channel.unary_unary( "/maps.fleetengine.v1.VehicleService/SearchVehicles", request_serializer=vehicle_api.SearchVehiclesRequest.serialize, response_deserializer=vehicle_api.SearchVehiclesResponse.deserialize, @@ -546,7 +631,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json b/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json index b0139d358773..6ab744378c79 100644 --- a/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json +++ b/packages/google-maps-fleetengine/samples/generated_samples/snippet_metadata_maps.fleetengine.v1.json @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "report_billable_trip" @@ -422,7 +422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "report_billable_trip" @@ -496,7 +496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsAsyncPager", @@ -572,7 +572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.trip_service.pagers.SearchTripsPager", @@ -649,7 +649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Trip", @@ -802,7 +802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -878,7 +878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -955,7 +955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1108,7 +1108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesAsyncPager", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.services.vehicle_service.pagers.ListVehiclesPager", @@ -1261,7 +1261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.SearchVehiclesResponse", @@ -1337,7 +1337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.SearchVehiclesResponse", @@ -1414,7 +1414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.UpdateVehicleAttributesResponse", @@ -1567,7 +1567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", @@ -1643,7 +1643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.maps.fleetengine_v1.types.Vehicle", From 856e0f07bd5212d60ad64be4c16ac8fafd07850b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:57:03 +0000 Subject: [PATCH 2/3] feat: [Many APIs] Add support for opt-in debug logging (#13347) BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: https://github.com/googleapis/googleapis/commit/f9b8b9150f7fcd600b0acaeef91236b1843f5e49 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca1e0a1e472d6e6f5de883a5cb54724f112ce348 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJldGFpbC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJ1bi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNjaGVkdWxlci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3JldC1tYW5hZ2VyLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyZXNvdXJjZW1hbmFnZXIvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVyLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVybWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtY29udHJvbC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtZGlyZWN0b3J5Ly5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtdXNhZ2UvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2VoZWFsdGgvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNoZWxsLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNwZWVjaC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN0b3JhZ2UtY29udHJvbC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN0b3JhZ2UtdHJhbnNmZXIvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN0b3JhZ2VpbnNpZ2h0cy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXN1cHBvcnQvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRhbGVudC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRlbGNvYXV0b21hdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRleHR0b3NwZWVjaC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/retail/gapic_version.py | 2 +- .../google/cloud/retail_v2/gapic_version.py | 2 +- .../analytics_service/async_client.py | 56 +- .../services/analytics_service/client.py | 61 +- .../analytics_service/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../analytics_service/transports/rest.py | 201 +- .../services/catalog_service/async_client.py | 136 +- .../services/catalog_service/client.py | 141 +- .../services/catalog_service/pagers.py | 16 +- .../catalog_service/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../catalog_service/transports/rest.py | 821 +++- .../completion_service/async_client.py | 64 +- .../services/completion_service/client.py | 69 +- .../completion_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 99 +- .../completion_service/transports/rest.py | 267 +- .../services/control_service/async_client.py | 88 +- .../services/control_service/client.py | 93 +- .../services/control_service/pagers.py | 16 +- .../control_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../control_service/transports/rest.py | 436 +- .../async_client.py | 88 +- .../generative_question_service/client.py | 93 +- .../transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../transports/rest.py | 460 +- .../services/model_service/async_client.py | 112 +- .../services/model_service/client.py | 117 +- .../services/model_service/pagers.py | 16 +- .../services/model_service/transports/grpc.py | 114 +- .../model_service/transports/grpc_asyncio.py | 111 +- .../services/model_service/transports/rest.py | 624 ++- .../prediction_service/async_client.py | 56 +- .../services/prediction_service/client.py | 61 +- .../prediction_service/transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../prediction_service/transports/rest.py | 202 +- .../services/product_service/async_client.py | 144 +- .../services/product_service/client.py | 149 +- .../services/product_service/pagers.py | 16 +- .../product_service/transports/grpc.py | 122 +- .../transports/grpc_asyncio.py | 119 +- .../product_service/transports/rest.py | 884 +++- .../services/search_service/async_client.py | 56 +- .../services/search_service/client.py | 61 +- .../services/search_service/pagers.py | 16 +- .../search_service/transports/grpc.py | 96 +- .../search_service/transports/grpc_asyncio.py | 95 +- .../search_service/transports/rest.py | 200 +- .../serving_config_service/async_client.py | 104 +- .../services/serving_config_service/client.py | 109 +- .../services/serving_config_service/pagers.py | 16 +- .../serving_config_service/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 107 +- .../serving_config_service/transports/rest.py | 571 ++- .../user_event_service/async_client.py | 88 +- .../services/user_event_service/client.py | 93 +- .../user_event_service/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 105 +- .../user_event_service/transports/rest.py | 459 +- .../cloud/retail_v2alpha/gapic_version.py | 2 +- .../analytics_service/async_client.py | 56 +- .../services/analytics_service/client.py | 61 +- .../analytics_service/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../analytics_service/transports/rest.py | 201 +- .../services/branch_service/async_client.py | 64 +- .../services/branch_service/client.py | 69 +- .../branch_service/transports/grpc.py | 98 +- .../branch_service/transports/grpc_asyncio.py | 97 +- .../branch_service/transports/rest.py | 266 +- .../services/catalog_service/async_client.py | 144 +- .../services/catalog_service/client.py | 149 +- .../services/catalog_service/pagers.py | 16 +- .../catalog_service/transports/grpc.py | 118 +- .../transports/grpc_asyncio.py | 117 +- .../catalog_service/transports/rest.py | 888 +++- .../completion_service/async_client.py | 64 +- .../services/completion_service/client.py | 69 +- .../completion_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 99 +- .../completion_service/transports/rest.py | 267 +- .../services/control_service/async_client.py | 88 +- .../services/control_service/client.py | 93 +- .../services/control_service/pagers.py | 16 +- .../control_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../control_service/transports/rest.py | 436 +- .../async_client.py | 88 +- .../generative_question_service/client.py | 93 +- .../transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../transports/rest.py | 460 +- .../async_client.py | 72 +- .../client.py | 77 +- .../transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 101 +- .../transports/rest.py | 302 +- .../services/model_service/async_client.py | 112 +- .../services/model_service/client.py | 117 +- .../services/model_service/pagers.py | 16 +- .../services/model_service/transports/grpc.py | 114 +- .../model_service/transports/grpc_asyncio.py | 111 +- .../services/model_service/transports/rest.py | 624 ++- .../prediction_service/async_client.py | 56 +- .../services/prediction_service/client.py | 61 +- .../prediction_service/transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../prediction_service/transports/rest.py | 202 +- .../services/product_service/async_client.py | 152 +- .../services/product_service/client.py | 157 +- .../services/product_service/pagers.py | 16 +- .../product_service/transports/grpc.py | 124 +- .../transports/grpc_asyncio.py | 121 +- .../product_service/transports/rest.py | 948 +++- .../services/project_service/async_client.py | 112 +- .../services/project_service/client.py | 117 +- .../project_service/transports/grpc.py | 114 +- .../transports/grpc_asyncio.py | 111 +- .../project_service/transports/rest.py | 653 ++- .../services/search_service/async_client.py | 56 +- .../services/search_service/client.py | 61 +- .../services/search_service/pagers.py | 16 +- .../search_service/transports/grpc.py | 96 +- .../search_service/transports/grpc_asyncio.py | 95 +- .../search_service/transports/rest.py | 200 +- .../serving_config_service/async_client.py | 104 +- .../services/serving_config_service/client.py | 109 +- .../services/serving_config_service/pagers.py | 16 +- .../serving_config_service/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 107 +- .../serving_config_service/transports/rest.py | 571 ++- .../user_event_service/async_client.py | 96 +- .../services/user_event_service/client.py | 101 +- .../user_event_service/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 107 +- .../user_event_service/transports/rest.py | 523 ++- .../cloud/retail_v2beta/gapic_version.py | 2 +- .../analytics_service/async_client.py | 56 +- .../services/analytics_service/client.py | 61 +- .../analytics_service/transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../analytics_service/transports/rest.py | 201 +- .../services/catalog_service/async_client.py | 144 +- .../services/catalog_service/client.py | 149 +- .../services/catalog_service/pagers.py | 16 +- .../catalog_service/transports/grpc.py | 118 +- .../transports/grpc_asyncio.py | 117 +- .../catalog_service/transports/rest.py | 888 +++- .../completion_service/async_client.py | 64 +- .../services/completion_service/client.py | 69 +- .../completion_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 99 +- .../completion_service/transports/rest.py | 267 +- .../services/control_service/async_client.py | 88 +- .../services/control_service/client.py | 93 +- .../services/control_service/pagers.py | 16 +- .../control_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../control_service/transports/rest.py | 436 +- .../async_client.py | 88 +- .../generative_question_service/client.py | 93 +- .../transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../transports/rest.py | 460 +- .../services/model_service/async_client.py | 112 +- .../services/model_service/client.py | 117 +- .../services/model_service/pagers.py | 16 +- .../services/model_service/transports/grpc.py | 114 +- .../model_service/transports/grpc_asyncio.py | 111 +- .../services/model_service/transports/rest.py | 624 ++- .../prediction_service/async_client.py | 56 +- .../services/prediction_service/client.py | 61 +- .../prediction_service/transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../prediction_service/transports/rest.py | 202 +- .../services/product_service/async_client.py | 152 +- .../services/product_service/client.py | 157 +- .../services/product_service/pagers.py | 16 +- .../product_service/transports/grpc.py | 124 +- .../transports/grpc_asyncio.py | 121 +- .../product_service/transports/rest.py | 948 +++- .../services/project_service/async_client.py | 64 +- .../services/project_service/client.py | 69 +- .../project_service/transports/grpc.py | 98 +- .../transports/grpc_asyncio.py | 97 +- .../project_service/transports/rest.py | 265 +- .../services/search_service/async_client.py | 56 +- .../services/search_service/client.py | 61 +- .../services/search_service/pagers.py | 16 +- .../search_service/transports/grpc.py | 96 +- .../search_service/transports/grpc_asyncio.py | 95 +- .../search_service/transports/rest.py | 200 +- .../serving_config_service/async_client.py | 104 +- .../services/serving_config_service/client.py | 109 +- .../services/serving_config_service/pagers.py | 16 +- .../serving_config_service/transports/grpc.py | 108 +- .../transports/grpc_asyncio.py | 107 +- .../serving_config_service/transports/rest.py | 571 ++- .../user_event_service/async_client.py | 96 +- .../services/user_event_service/client.py | 101 +- .../user_event_service/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 107 +- .../user_event_service/transports/rest.py | 523 ++- ...ippet_metadata_google.cloud.retail.v2.json | 234 +- ..._metadata_google.cloud.retail.v2alpha.json | 298 +- ...t_metadata_google.cloud.retail.v2beta.json | 254 +- .../gapic/retail_v2/test_analytics_service.py | 8 + .../gapic/retail_v2/test_catalog_service.py | 54 + .../retail_v2/test_completion_service.py | 12 + .../gapic/retail_v2/test_control_service.py | 29 + .../test_generative_question_service.py | 29 + .../gapic/retail_v2/test_model_service.py | 44 + .../retail_v2/test_prediction_service.py | 8 + .../gapic/retail_v2/test_product_service.py | 62 + .../gapic/retail_v2/test_search_service.py | 8 + .../retail_v2/test_serving_config_service.py | 39 + .../retail_v2/test_user_event_service.py | 24 + .../retail_v2alpha/test_analytics_service.py | 8 + .../retail_v2alpha/test_branch_service.py | 14 + .../retail_v2alpha/test_catalog_service.py | 58 + .../retail_v2alpha/test_completion_service.py | 12 + .../retail_v2alpha/test_control_service.py | 29 + .../test_generative_question_service.py | 29 + ...st_merchant_center_account_link_service.py | 19 + .../retail_v2alpha/test_model_service.py | 44 + .../retail_v2alpha/test_prediction_service.py | 8 + .../retail_v2alpha/test_product_service.py | 66 + .../retail_v2alpha/test_project_service.py | 43 + .../retail_v2alpha/test_search_service.py | 8 + .../test_serving_config_service.py | 39 + .../retail_v2alpha/test_user_event_service.py | 28 + .../retail_v2beta/test_analytics_service.py | 8 + .../retail_v2beta/test_catalog_service.py | 58 + .../retail_v2beta/test_completion_service.py | 12 + .../retail_v2beta/test_control_service.py | 29 + .../test_generative_question_service.py | 29 + .../gapic/retail_v2beta/test_model_service.py | 44 + .../retail_v2beta/test_prediction_service.py | 8 + .../retail_v2beta/test_product_service.py | 66 + .../retail_v2beta/test_project_service.py | 14 + .../retail_v2beta/test_search_service.py | 8 + .../test_serving_config_service.py | 39 + .../retail_v2beta/test_user_event_service.py | 28 + .../google/cloud/run/gapic_version.py | 2 +- .../google/cloud/run_v2/gapic_version.py | 2 +- .../run_v2/services/builds/async_client.py | 72 +- .../cloud/run_v2/services/builds/client.py | 77 +- .../run_v2/services/builds/transports/grpc.py | 100 +- .../builds/transports/grpc_asyncio.py | 99 +- .../run_v2/services/builds/transports/rest.py | 305 +- .../services/executions/async_client.py | 96 +- .../run_v2/services/executions/client.py | 101 +- .../run_v2/services/executions/pagers.py | 16 +- .../services/executions/transports/grpc.py | 110 +- .../executions/transports/grpc_asyncio.py | 107 +- .../services/executions/transports/rest.py | 497 +- .../run_v2/services/jobs/async_client.py | 136 +- .../cloud/run_v2/services/jobs/client.py | 141 +- .../cloud/run_v2/services/jobs/pagers.py | 16 +- .../run_v2/services/jobs/transports/grpc.py | 120 +- .../services/jobs/transports/grpc_asyncio.py | 117 +- .../run_v2/services/jobs/transports/rest.py | 818 +++- .../run_v2/services/revisions/async_client.py | 88 +- .../cloud/run_v2/services/revisions/client.py | 93 +- .../cloud/run_v2/services/revisions/pagers.py | 16 +- .../services/revisions/transports/grpc.py | 108 +- .../revisions/transports/grpc_asyncio.py | 105 +- .../services/revisions/transports/rest.py | 429 +- .../run_v2/services/services/async_client.py | 128 +- .../cloud/run_v2/services/services/client.py | 133 +- .../cloud/run_v2/services/services/pagers.py | 16 +- .../services/services/transports/grpc.py | 118 +- .../services/transports/grpc_asyncio.py | 115 +- .../services/services/transports/rest.py | 754 ++- .../run_v2/services/tasks/async_client.py | 80 +- .../cloud/run_v2/services/tasks/client.py | 85 +- .../cloud/run_v2/services/tasks/pagers.py | 16 +- .../run_v2/services/tasks/transports/grpc.py | 102 +- .../services/tasks/transports/grpc_asyncio.py | 101 +- .../run_v2/services/tasks/transports/rest.py | 369 +- .../snippet_metadata_google.cloud.run.v2.json | 110 +- .../tests/unit/gapic/run_v2/test_builds.py | 12 + .../unit/gapic/run_v2/test_executions.py | 28 + .../tests/unit/gapic/run_v2/test_jobs.py | 50 + .../tests/unit/gapic/run_v2/test_revisions.py | 23 + .../tests/unit/gapic/run_v2/test_services.py | 45 + .../tests/unit/gapic/run_v2/test_tasks.py | 18 + .../google/cloud/scheduler/gapic_version.py | 2 +- .../cloud/scheduler_v1/gapic_version.py | 2 +- .../services/cloud_scheduler/async_client.py | 112 +- .../services/cloud_scheduler/client.py | 117 +- .../services/cloud_scheduler/pagers.py | 16 +- .../cloud_scheduler/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../cloud_scheduler/transports/rest.py | 622 ++- .../cloud/scheduler_v1beta1/gapic_version.py | 2 +- .../services/cloud_scheduler/async_client.py | 112 +- .../services/cloud_scheduler/client.py | 117 +- .../services/cloud_scheduler/pagers.py | 16 +- .../cloud_scheduler/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../cloud_scheduler/transports/rest.py | 622 ++- ...et_metadata_google.cloud.scheduler.v1.json | 34 +- ...tadata_google.cloud.scheduler.v1beta1.json | 34 +- .../scheduler_v1/test_cloud_scheduler.py | 44 + .../scheduler_v1beta1/test_cloud_scheduler.py | 44 + .../cloud/secretmanager/gapic_version.py | 2 +- .../cloud/secretmanager_v1/gapic_version.py | 2 +- .../secret_manager_service/async_client.py | 168 +- .../services/secret_manager_service/client.py | 173 +- .../services/secret_manager_service/pagers.py | 32 +- .../secret_manager_service/transports/grpc.py | 124 +- .../transports/grpc_asyncio.py | 123 +- .../secret_manager_service/transports/rest.py | 1079 ++++- .../secretmanager_v1beta1/gapic_version.py | 2 +- .../secret_manager_service/async_client.py | 152 +- .../services/secret_manager_service/client.py | 157 +- .../services/secret_manager_service/pagers.py | 32 +- .../secret_manager_service/transports/grpc.py | 120 +- .../transports/grpc_asyncio.py | 119 +- .../secret_manager_service/transports/rest.py | 953 +++- .../secretmanager_v1beta2/gapic_version.py | 2 +- .../secret_manager_service/async_client.py | 168 +- .../services/secret_manager_service/client.py | 173 +- .../services/secret_manager_service/pagers.py | 32 +- .../secret_manager_service/transports/grpc.py | 124 +- .../transports/grpc_asyncio.py | 123 +- .../secret_manager_service/transports/rest.py | 1079 ++++- ...etadata_google.cloud.secretmanager.v1.json | 62 +- ...ta_google.cloud.secretmanager.v1beta2.json | 62 +- ...metadata_google.cloud.secrets.v1beta1.json | 62 +- .../test_secret_manager_service.py | 76 + .../test_secret_manager_service.py | 72 + .../test_secret_manager_service.py | 76 + .../securesourcemanager/gapic_version.py | 2 +- .../securesourcemanager_v1/gapic_version.py | 2 +- .../secure_source_manager/async_client.py | 232 +- .../services/secure_source_manager/client.py | 237 +- .../services/secure_source_manager/pagers.py | 48 +- .../secure_source_manager/transports/grpc.py | 144 +- .../transports/grpc_asyncio.py | 141 +- .../secure_source_manager/transports/rest.py | 1572 ++++++- ...a_google.cloud.securesourcemanager.v1.json | 66 +- .../test_secure_source_manager.py | 98 + .../cloud/securitycenter/gapic_version.py | 2 +- .../cloud/securitycenter_v1/gapic_version.py | 2 +- .../services/security_center/async_client.py | 568 ++- .../services/security_center/client.py | 573 ++- .../services/security_center/pagers.py | 272 +- .../security_center/transports/grpc.py | 242 +- .../transports/grpc_asyncio.py | 239 +- .../security_center/transports/rest.py | 4141 +++++++++++++++-- .../securitycenter_v1beta1/gapic_version.py | 2 +- .../services/security_center/async_client.py | 176 +- .../services/security_center/client.py | 181 +- .../services/security_center/pagers.py | 80 +- .../security_center/transports/grpc.py | 132 +- .../transports/grpc_asyncio.py | 129 +- .../security_center/transports/rest.py | 1182 ++++- .../securitycenter_v1p1beta1/gapic_version.py | 2 +- .../services/security_center/async_client.py | 216 +- .../services/security_center/client.py | 221 +- .../services/security_center/pagers.py | 96 +- .../security_center/transports/grpc.py | 148 +- .../transports/grpc_asyncio.py | 145 +- .../security_center/transports/rest.py | 1482 +++++- .../cloud/securitycenter_v2/gapic_version.py | 2 +- .../services/security_center/async_client.py | 384 +- .../services/security_center/client.py | 389 +- .../services/security_center/pagers.py | 144 +- .../security_center/transports/grpc.py | 194 +- .../transports/grpc_asyncio.py | 191 +- .../security_center/transports/rest.py | 2711 ++++++++++- ...tadata_google.cloud.securitycenter.v1.json | 254 +- ...a_google.cloud.securitycenter.v1beta1.json | 74 +- ...google.cloud.securitycenter.v1p1beta1.json | 94 +- ...tadata_google.cloud.securitycenter.v2.json | 162 +- .../securitycenter_v1/test_security_center.py | 319 ++ .../test_security_center.py | 87 + .../test_security_center.py | 114 + .../securitycenter_v2/test_security_center.py | 208 + .../securitycentermanagement/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../async_client.py | 216 +- .../security_center_management/client.py | 221 +- .../security_center_management/pagers.py | 112 +- .../transports/grpc.py | 138 +- .../transports/grpc_asyncio.py | 137 +- .../transports/rest.py | 1436 +++++- ...gle.cloud.securitycentermanagement.v1.json | 86 +- .../test_security_center_management.py | 108 + .../cloud/servicecontrol/gapic_version.py | 2 +- .../cloud/servicecontrol_v1/gapic_version.py | 2 +- .../services/quota_controller/async_client.py | 40 +- .../services/quota_controller/client.py | 45 +- .../quota_controller/transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../quota_controller/transports/rest.py | 76 +- .../service_controller/async_client.py | 48 +- .../services/service_controller/client.py | 53 +- .../service_controller/transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../service_controller/transports/rest.py | 142 +- .../cloud/servicecontrol_v2/gapic_version.py | 2 +- .../service_controller/async_client.py | 48 +- .../services/service_controller/client.py | 53 +- .../service_controller/transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../service_controller/transports/rest.py | 142 +- ...metadata_google.api.servicecontrol.v1.json | 14 +- ...metadata_google.api.servicecontrol.v2.json | 10 +- .../test_quota_controller.py | 3 + .../test_service_controller.py | 6 + .../test_service_controller.py | 6 + .../cloud/servicedirectory/gapic_version.py | 2 +- .../servicedirectory_v1/gapic_version.py | 2 +- .../services/lookup_service/async_client.py | 56 +- .../services/lookup_service/client.py | 61 +- .../lookup_service/transports/grpc.py | 96 +- .../lookup_service/transports/grpc_asyncio.py | 95 +- .../lookup_service/transports/rest.py | 202 +- .../registration_service/async_client.py | 192 +- .../services/registration_service/client.py | 197 +- .../services/registration_service/pagers.py | 48 +- .../registration_service/transports/grpc.py | 130 +- .../transports/grpc_asyncio.py | 129 +- .../registration_service/transports/rest.py | 1242 ++++- .../servicedirectory_v1beta1/gapic_version.py | 2 +- .../services/lookup_service/async_client.py | 56 +- .../services/lookup_service/client.py | 61 +- .../lookup_service/transports/grpc.py | 96 +- .../lookup_service/transports/grpc_asyncio.py | 95 +- .../lookup_service/transports/rest.py | 202 +- .../registration_service/async_client.py | 192 +- .../services/registration_service/client.py | 197 +- .../services/registration_service/pagers.py | 48 +- .../registration_service/transports/grpc.py | 130 +- .../transports/grpc_asyncio.py | 129 +- .../registration_service/transports/rest.py | 1242 ++++- ...data_google.cloud.servicedirectory.v1.json | 78 +- ...google.cloud.servicedirectory.v1beta1.json | 78 +- .../test_lookup_service.py | 8 + .../test_registration_service.py | 91 + .../test_lookup_service.py | 8 + .../test_registration_service.py | 91 + .../cloud/service_usage/gapic_version.py | 2 +- .../cloud/service_usage_v1/gapic_version.py | 2 +- .../services/service_usage/async_client.py | 96 +- .../services/service_usage/client.py | 101 +- .../services/service_usage/pagers.py | 16 +- .../services/service_usage/transports/grpc.py | 110 +- .../service_usage/transports/grpc_asyncio.py | 107 +- .../services/service_usage/transports/rest.py | 522 ++- ...t_metadata_google.api.serviceusage.v1.json | 26 +- .../service_usage_v1/test_service_usage.py | 22 + .../services/service_health/async_client.py | 96 +- .../services/service_health/client.py | 101 +- .../services/service_health/pagers.py | 48 +- .../service_health/transports/grpc.py | 106 +- .../service_health/transports/grpc_asyncio.py | 105 +- .../service_health/transports/rest.py | 532 ++- ...etadata_google.cloud.servicehealth.v1.json | 24 +- .../servicehealth_v1/test_service_health.py | 34 + .../google/cloud/shell/gapic_version.py | 2 +- .../google/cloud/shell_v1/gapic_version.py | 2 +- .../cloud_shell_service/async_client.py | 72 +- .../services/cloud_shell_service/client.py | 77 +- .../cloud_shell_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 101 +- .../cloud_shell_service/transports/rest.py | 328 +- ...nippet_metadata_google.cloud.shell.v1.json | 22 +- .../shell_v1/test_cloud_shell_service.py | 17 + .../google/cloud/speech/gapic_version.py | 2 +- .../google/cloud/speech_v1/gapic_version.py | 2 +- .../services/adaptation/async_client.py | 128 +- .../speech_v1/services/adaptation/client.py | 133 +- .../speech_v1/services/adaptation/pagers.py | 32 +- .../services/adaptation/transports/grpc.py | 114 +- .../adaptation/transports/grpc_asyncio.py | 113 +- .../services/adaptation/transports/rest.py | 732 ++- .../speech_v1/services/speech/async_client.py | 72 +- .../cloud/speech_v1/services/speech/client.py | 77 +- .../services/speech/transports/grpc.py | 104 +- .../speech/transports/grpc_asyncio.py | 101 +- .../services/speech/transports/rest.py | 265 +- .../cloud/speech_v1p1beta1/gapic_version.py | 2 +- .../services/adaptation/async_client.py | 128 +- .../services/adaptation/client.py | 133 +- .../services/adaptation/pagers.py | 32 +- .../services/adaptation/transports/grpc.py | 114 +- .../adaptation/transports/grpc_asyncio.py | 113 +- .../services/adaptation/transports/rest.py | 732 ++- .../services/speech/async_client.py | 72 +- .../services/speech/client.py | 77 +- .../services/speech/transports/grpc.py | 104 +- .../speech/transports/grpc_asyncio.py | 101 +- .../services/speech/transports/rest.py | 265 +- .../google/cloud/speech_v2/gapic_version.py | 2 +- .../speech_v2/services/speech/async_client.py | 264 +- .../cloud/speech_v2/services/speech/client.py | 269 +- .../cloud/speech_v2/services/speech/pagers.py | 48 +- .../services/speech/transports/grpc.py | 152 +- .../speech/transports/grpc_asyncio.py | 149 +- .../services/speech/transports/rest.py | 1758 ++++++- ...ippet_metadata_google.cloud.speech.v1.json | 54 +- ...etadata_google.cloud.speech.v1p1beta1.json | 54 +- ...ippet_metadata_google.cloud.speech.v2.json | 94 +- .../unit/gapic/speech_v1/test_adaptation.py | 54 + .../tests/unit/gapic/speech_v1/test_speech.py | 14 + .../gapic/speech_v1p1beta1/test_adaptation.py | 54 + .../gapic/speech_v1p1beta1/test_speech.py | 14 + .../tests/unit/gapic/speech_v2/test_speech.py | 122 + .../cloud/storage_control/gapic_version.py | 2 +- .../cloud/storage_control_v2/gapic_version.py | 2 +- .../services/storage_control/async_client.py | 112 +- .../services/storage_control/client.py | 117 +- .../services/storage_control/pagers.py | 32 +- .../storage_control/transports/grpc.py | 114 +- .../transports/grpc_asyncio.py | 111 +- ...et_metadata_google.storage.control.v2.json | 42 +- .../cloud/storage_transfer/gapic_version.py | 2 +- .../storage_transfer_v1/gapic_version.py | 2 +- .../storage_transfer_service/async_client.py | 168 +- .../storage_transfer_service/client.py | 173 +- .../storage_transfer_service/pagers.py | 32 +- .../transports/grpc.py | 130 +- .../transports/grpc_asyncio.py | 127 +- .../transports/rest.py | 984 +++- ...et_metadata_google.storagetransfer.v1.json | 58 +- .../test_storage_transfer_service.py | 67 + .../cloud/storageinsights/gapic_version.py | 2 +- .../cloud/storageinsights_v1/gapic_version.py | 2 +- .../services/storage_insights/async_client.py | 136 +- .../services/storage_insights/client.py | 141 +- .../services/storage_insights/pagers.py | 32 +- .../storage_insights/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../storage_insights/transports/rest.py | 781 +++- ...adata_google.cloud.storageinsights.v1.json | 30 +- .../test_storage_insights.py | 47 + .../google/cloud/support/gapic_version.py | 2 +- .../google/cloud/support_v2/gapic_version.py | 2 +- .../case_attachment_service/async_client.py | 40 +- .../case_attachment_service/client.py | 45 +- .../case_attachment_service/pagers.py | 16 +- .../transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../transports/rest.py | 77 +- .../services/case_service/async_client.py | 96 +- .../services/case_service/client.py | 101 +- .../services/case_service/pagers.py | 48 +- .../services/case_service/transports/grpc.py | 108 +- .../case_service/transports/grpc_asyncio.py | 107 +- .../services/case_service/transports/rest.py | 517 +- .../services/comment_service/async_client.py | 48 +- .../services/comment_service/client.py | 53 +- .../services/comment_service/pagers.py | 16 +- .../comment_service/transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../comment_service/transports/rest.py | 140 +- ...ppet_metadata_google.cloud.support.v2.json | 46 +- .../test_case_attachment_service.py | 5 + .../gapic/support_v2/test_case_service.py | 34 + .../gapic/support_v2/test_comment_service.py | 10 + .../google/cloud/talent/gapic_version.py | 2 +- .../google/cloud/talent_v4/gapic_version.py | 2 +- .../services/company_service/async_client.py | 80 +- .../services/company_service/client.py | 85 +- .../services/company_service/pagers.py | 16 +- .../company_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 101 +- .../company_service/transports/rest.py | 373 +- .../services/completion/async_client.py | 48 +- .../talent_v4/services/completion/client.py | 53 +- .../services/completion/transports/grpc.py | 94 +- .../completion/transports/grpc_asyncio.py | 93 +- .../services/completion/transports/rest.py | 139 +- .../services/event_service/async_client.py | 48 +- .../services/event_service/client.py | 53 +- .../services/event_service/transports/grpc.py | 94 +- .../event_service/transports/grpc_asyncio.py | 93 +- .../services/event_service/transports/rest.py | 137 +- .../services/job_service/async_client.py | 120 +- .../talent_v4/services/job_service/client.py | 125 +- .../talent_v4/services/job_service/pagers.py | 16 +- .../services/job_service/transports/grpc.py | 116 +- .../job_service/transports/grpc_asyncio.py | 113 +- .../services/job_service/transports/rest.py | 687 ++- .../services/tenant_service/async_client.py | 80 +- .../services/tenant_service/client.py | 85 +- .../services/tenant_service/pagers.py | 16 +- .../tenant_service/transports/grpc.py | 102 +- .../tenant_service/transports/grpc_asyncio.py | 101 +- .../tenant_service/transports/rest.py | 373 +- .../cloud/talent_v4beta1/gapic_version.py | 2 +- .../services/company_service/async_client.py | 80 +- .../services/company_service/client.py | 85 +- .../services/company_service/pagers.py | 16 +- .../company_service/transports/grpc.py | 102 +- .../transports/grpc_asyncio.py | 101 +- .../company_service/transports/rest.py | 373 +- .../services/completion/async_client.py | 48 +- .../services/completion/client.py | 53 +- .../services/completion/transports/grpc.py | 94 +- .../completion/transports/grpc_asyncio.py | 93 +- .../services/completion/transports/rest.py | 139 +- .../services/event_service/async_client.py | 48 +- .../services/event_service/client.py | 53 +- .../services/event_service/transports/grpc.py | 94 +- .../event_service/transports/grpc_asyncio.py | 93 +- .../services/event_service/transports/rest.py | 137 +- .../services/job_service/async_client.py | 120 +- .../services/job_service/client.py | 125 +- .../services/job_service/pagers.py | 48 +- .../services/job_service/transports/grpc.py | 116 +- .../job_service/transports/grpc_asyncio.py | 113 +- .../services/job_service/transports/rest.py | 665 ++- .../services/tenant_service/async_client.py | 80 +- .../services/tenant_service/client.py | 85 +- .../services/tenant_service/pagers.py | 16 +- .../tenant_service/transports/grpc.py | 102 +- .../tenant_service/transports/grpc_asyncio.py | 101 +- .../tenant_service/transports/rest.py | 373 +- ...ippet_metadata_google.cloud.talent.v4.json | 90 +- ..._metadata_google.cloud.talent.v4beta1.json | 90 +- .../gapic/talent_v4/test_company_service.py | 27 + .../unit/gapic/talent_v4/test_completion.py | 6 + .../gapic/talent_v4/test_event_service.py | 7 + .../unit/gapic/talent_v4/test_job_service.py | 50 + .../gapic/talent_v4/test_tenant_service.py | 27 + .../talent_v4beta1/test_company_service.py | 27 + .../gapic/talent_v4beta1/test_completion.py | 6 + .../talent_v4beta1/test_event_service.py | 7 + .../gapic/talent_v4beta1/test_job_service.py | 50 + .../talent_v4beta1/test_tenant_service.py | 27 + .../cloud/telcoautomation/gapic_version.py | 2 +- .../cloud/telcoautomation_v1/gapic_version.py | 2 +- .../services/telco_automation/async_client.py | 368 +- .../services/telco_automation/client.py | 373 +- .../services/telco_automation/pagers.py | 160 +- .../telco_automation/transports/grpc.py | 192 +- .../transports/grpc_asyncio.py | 189 +- .../telco_automation/transports/rest.py | 2646 ++++++++++- .../telcoautomation_v1alpha1/gapic_version.py | 2 +- .../services/telco_automation/async_client.py | 368 +- .../services/telco_automation/client.py | 373 +- .../services/telco_automation/pagers.py | 160 +- .../telco_automation/transports/grpc.py | 192 +- .../transports/grpc_asyncio.py | 189 +- .../telco_automation/transports/rest.py | 2646 ++++++++++- ...adata_google.cloud.telcoautomation.v1.json | 146 +- ...google.cloud.telcoautomation.v1alpha1.json | 146 +- .../test_telco_automation.py | 192 + .../test_telco_automation.py | 192 + .../cloud/texttospeech/gapic_version.py | 2 +- .../cloud/texttospeech_v1/gapic_version.py | 2 +- .../services/text_to_speech/async_client.py | 72 +- .../services/text_to_speech/client.py | 77 +- .../text_to_speech/transports/grpc.py | 100 +- .../text_to_speech/transports/grpc_asyncio.py | 99 +- .../text_to_speech/transports/rest.py | 268 +- .../async_client.py | 56 +- .../client.py | 61 +- .../transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../transports/rest.py | 201 +- .../texttospeech_v1beta1/gapic_version.py | 2 +- .../services/text_to_speech/async_client.py | 72 +- .../services/text_to_speech/client.py | 77 +- .../text_to_speech/transports/grpc.py | 100 +- .../text_to_speech/transports/grpc_asyncio.py | 99 +- .../text_to_speech/transports/rest.py | 268 +- .../async_client.py | 56 +- .../client.py | 61 +- .../transports/grpc.py | 100 +- .../transports/grpc_asyncio.py | 97 +- .../transports/rest.py | 201 +- ...metadata_google.cloud.texttospeech.v1.json | 18 +- ...ata_google.cloud.texttospeech.v1beta1.json | 18 +- .../texttospeech_v1/test_text_to_speech.py | 13 + ...st_text_to_speech_long_audio_synthesize.py | 8 + .../test_text_to_speech.py | 13 + ...st_text_to_speech_long_audio_synthesize.py | 8 + 687 files changed, 93551 insertions(+), 14908 deletions(-) diff --git a/packages/google-cloud-retail/google/cloud/retail/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail/gapic_version.py index 2152db608ae5..558c8aab67c5 100644 --- a/packages/google-cloud-retail/google/cloud/retail/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py index 2152db608ae5..558c8aab67c5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/async_client.py index 38c074203a1d..f9ed662e406c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .transports.grpc_asyncio import AnalyticsServiceGrpcAsyncIOTransport +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 AnalyticsServiceAsyncClient: """Service for managing & accessing retail search business @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.AnalyticsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "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.retail.v2.AnalyticsService", + "credentialsType": None, + }, + ) + async def export_analytics_metrics( self, request: Optional[ @@ -269,7 +301,7 @@ async def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports analytics metrics. @@ -318,8 +350,10 @@ async def sample_export_analytics_metrics(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -378,7 +412,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -389,8 +423,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -431,7 +467,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -442,8 +478,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/client.py index 8487ed7049ce..a70574add3e6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -565,6 +575,10 @@ def __init__( # 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( @@ -631,6 +645,29 @@ def __init__( 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.retail_v2.AnalyticsServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "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.retail.v2.AnalyticsService", + "credentialsType": None, + }, + ) + def export_analytics_metrics( self, request: Optional[ @@ -639,7 +676,7 @@ def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports analytics metrics. @@ -688,8 +725,10 @@ def sample_export_analytics_metrics(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc.py index e86196c631c3..e1f7c9e68d9d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport +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.retail.v2.AnalyticsService", + "rpcName": 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.retail.v2.AnalyticsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcTransport(AnalyticsServiceTransport): """gRPC backend transport for AnalyticsService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -286,7 +374,7 @@ def export_analytics_metrics( return self._stubs["export_analytics_metrics"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -298,7 +386,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -317,7 +405,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc_asyncio.py index 4b704d96e0cf..d662b9aa5a56 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .grpc import AnalyticsServiceGrpcTransport +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.retail.v2.AnalyticsService", + "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.retail.v2.AnalyticsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcAsyncIOTransport(AnalyticsServiceTransport): """gRPC AsyncIO backend transport for AnalyticsService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +417,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -348,7 +433,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -367,7 +452,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/rest.py index d61deb5b36cf..7bf0c24abd39 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/analytics_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,11 @@ def post_export_analytics_metrics(self, response): def pre_export_analytics_metrics( self, request: export_config.ExportAnalyticsMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportAnalyticsMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportAnalyticsMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for export_analytics_metrics Override in a subclass to manipulate the request or metadata @@ -102,8 +113,10 @@ def post_export_analytics_metrics( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +138,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -331,7 +346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export analytics metrics method over HTTP. @@ -342,8 +357,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -356,6 +373,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseExportAnalyticsMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_export_analytics_metrics( request, metadata ) @@ -372,6 +390,33 @@ def __call__( 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.retail_v2.AnalyticsServiceClient.ExportAnalyticsMetrics", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsServiceRestTransport._ExportAnalyticsMetrics._get_response( @@ -393,7 +438,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_analytics_metrics(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.retail_v2.AnalyticsServiceClient.export_analytics_metrics", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -444,7 +511,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -454,8 +521,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -464,6 +533,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -474,6 +544,33 @@ def __call__( 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.retail_v2.AnalyticsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._GetOperation._get_response( self._host, @@ -493,6 +590,27 @@ def __call__( 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.retail_v2.AnalyticsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -533,7 +651,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -543,8 +661,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -553,6 +673,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -563,6 +684,33 @@ def __call__( 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.retail_v2.AnalyticsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._ListOperations._get_response( self._host, @@ -582,6 +730,27 @@ def __call__( 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.retail_v2.AnalyticsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.AnalyticsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/async_client.py index 8548628b5378..f1c6585cf32c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .transports.grpc_asyncio import CatalogServiceGrpcAsyncIOTransport +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 CatalogServiceAsyncClient: """Service for managing catalog configuration.""" @@ -271,6 +281,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.CatalogServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "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.retail.v2.CatalogService", + "credentialsType": None, + }, + ) + async def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -278,7 +310,7 @@ async def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsAsyncPager: r"""Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project. @@ -330,8 +362,10 @@ async def sample_list_catalogs(): 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, 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: google.cloud.retail_v2.services.catalog_service.pagers.ListCatalogsAsyncPager: @@ -408,7 +442,7 @@ async def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2.Catalog]s. @@ -475,8 +509,10 @@ async def sample_update_catalog(): 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, 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: google.cloud.retail_v2.types.Catalog: @@ -539,7 +575,7 @@ async def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], @@ -613,8 +649,10 @@ async def sample_set_default_branch(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -666,7 +704,7 @@ async def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] @@ -711,8 +749,10 @@ async def sample_get_default_branch(): 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, 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: google.cloud.retail_v2.types.GetDefaultBranchResponse: @@ -775,7 +815,7 @@ async def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. @@ -821,8 +861,10 @@ async def sample_get_completion_config(): 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, 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: google.cloud.retail_v2.types.CompletionConfig: @@ -887,7 +929,7 @@ async def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. @@ -960,8 +1002,10 @@ async def sample_update_completion_config(): 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, 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: google.cloud.retail_v2.types.CompletionConfig: @@ -1029,7 +1073,7 @@ async def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. @@ -1075,8 +1119,10 @@ async def sample_get_attributes_config(): 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, 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1138,7 +1184,7 @@ async def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. @@ -1209,8 +1255,10 @@ async def sample_update_attributes_config(): 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, 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1274,7 +1322,7 @@ async def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to @@ -1322,8 +1370,10 @@ async def sample_add_catalog_attribute(): 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, 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1371,7 +1421,7 @@ async def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from @@ -1416,8 +1466,10 @@ async def sample_remove_catalog_attribute(): 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, 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1465,7 +1517,7 @@ async def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in @@ -1515,8 +1567,10 @@ async def sample_replace_catalog_attribute(): 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, 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1562,7 +1616,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1573,8 +1627,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1615,7 +1671,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1626,8 +1682,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/client.py index acafb228a06c..d0dd424a320d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -653,6 +663,10 @@ def __init__( # 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( @@ -718,6 +732,29 @@ def __init__( 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.retail_v2.CatalogServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "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.retail.v2.CatalogService", + "credentialsType": None, + }, + ) + def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -725,7 +762,7 @@ def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsPager: r"""Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project. @@ -777,8 +814,10 @@ def sample_list_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.services.catalog_service.pagers.ListCatalogsPager: @@ -852,7 +891,7 @@ def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2.Catalog]s. @@ -919,8 +958,10 @@ def sample_update_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Catalog: @@ -980,7 +1021,7 @@ def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], @@ -1054,8 +1095,10 @@ def sample_set_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1104,7 +1147,7 @@ def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] @@ -1149,8 +1192,10 @@ def sample_get_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.GetDefaultBranchResponse: @@ -1210,7 +1255,7 @@ def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. @@ -1256,8 +1301,10 @@ def sample_get_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.CompletionConfig: @@ -1319,7 +1366,7 @@ def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. @@ -1392,8 +1439,10 @@ def sample_update_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.CompletionConfig: @@ -1458,7 +1507,7 @@ def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. @@ -1504,8 +1553,10 @@ def sample_get_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1564,7 +1615,7 @@ def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. @@ -1635,8 +1686,10 @@ def sample_update_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1697,7 +1750,7 @@ def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to @@ -1745,8 +1798,10 @@ def sample_add_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1792,7 +1847,7 @@ def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from @@ -1837,8 +1892,10 @@ def sample_remove_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1884,7 +1941,7 @@ def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in @@ -1934,8 +1991,10 @@ def sample_replace_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.AttributesConfig: @@ -1994,7 +2053,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2005,8 +2064,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2047,7 +2108,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2058,8 +2119,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/pagers.py index 385f6028d4e8..563e7e621d67 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc.py index 9e9efef7c50f..fcd790e65b31 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import catalog from google.cloud.retail_v2.types import catalog as gcr_catalog @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport +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.retail.v2.CatalogService", + "rpcName": 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.retail.v2.CatalogService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcTransport(CatalogServiceTransport): """gRPC backend transport for CatalogService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -287,7 +373,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -347,7 +433,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -378,7 +464,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -407,7 +493,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -436,7 +522,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -465,7 +551,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -503,7 +589,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -537,7 +623,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -571,7 +657,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -607,7 +693,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -615,7 +701,7 @@ def replace_catalog_attribute( return self._stubs["replace_catalog_attribute"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -627,7 +713,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -646,7 +732,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc_asyncio.py index 65618a6c85ca..c1edef463853 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import catalog from google.cloud.retail_v2.types import catalog as gcr_catalog @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .grpc import CatalogServiceGrpcTransport +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.retail.v2.CatalogService", + "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.retail.v2.CatalogService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcAsyncIOTransport(CatalogServiceTransport): """gRPC AsyncIO backend transport for CatalogService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -298,7 +383,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -360,7 +445,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +476,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -421,7 +506,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -451,7 +536,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -481,7 +566,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -520,7 +605,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -555,7 +640,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -590,7 +675,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -627,7 +712,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -710,7 +795,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -726,7 +811,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -745,7 +830,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/rest.py index 03e139c24575..4be2d925f4b7 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/catalog_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -158,8 +166,11 @@ def post_update_completion_config(self, response): def pre_add_catalog_attribute( self, request: catalog_service.AddCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.AddCatalogAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.AddCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_catalog_attribute Override in a subclass to manipulate the request or metadata @@ -181,8 +192,11 @@ def post_add_catalog_attribute( def pre_get_attributes_config( self, request: catalog_service.GetAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetAttributesConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_attributes_config Override in a subclass to manipulate the request or metadata @@ -204,8 +218,11 @@ def post_get_attributes_config( def pre_get_completion_config( self, request: catalog_service.GetCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetCompletionConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_completion_config Override in a subclass to manipulate the request or metadata @@ -227,8 +244,10 @@ def post_get_completion_config( def pre_get_default_branch( self, request: catalog_service.GetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_default_branch Override in a subclass to manipulate the request or metadata @@ -250,8 +269,10 @@ def post_get_default_branch( def pre_list_catalogs( self, request: catalog_service.ListCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.ListCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.ListCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_catalogs Override in a subclass to manipulate the request or metadata @@ -273,9 +294,10 @@ def post_list_catalogs( def pre_remove_catalog_attribute( self, request: catalog_service.RemoveCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.RemoveCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.RemoveCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_catalog_attribute @@ -298,9 +320,10 @@ def post_remove_catalog_attribute( def pre_replace_catalog_attribute( self, request: catalog_service.ReplaceCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.ReplaceCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.ReplaceCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for replace_catalog_attribute @@ -323,8 +346,10 @@ def post_replace_catalog_attribute( def pre_set_default_branch( self, request: catalog_service.SetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_default_branch Override in a subclass to manipulate the request or metadata @@ -335,9 +360,10 @@ def pre_set_default_branch( def pre_update_attributes_config( self, request: catalog_service.UpdateAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateAttributesConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_attributes_config @@ -360,8 +386,10 @@ def post_update_attributes_config( def pre_update_catalog( self, request: catalog_service.UpdateCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_catalog Override in a subclass to manipulate the request or metadata @@ -381,9 +409,10 @@ def post_update_catalog(self, response: gcr_catalog.Catalog) -> gcr_catalog.Cata def pre_update_completion_config( self, request: catalog_service.UpdateCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateCompletionConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_completion_config @@ -406,8 +435,10 @@ def post_update_completion_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -429,8 +460,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -572,7 +605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the add catalog attribute method over HTTP. @@ -584,8 +617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -595,6 +630,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseAddCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_add_catalog_attribute( request, metadata ) @@ -611,6 +647,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.AddCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "AddCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._AddCatalogAttribute._get_response( self._host, @@ -632,7 +695,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2.CatalogServiceClient.add_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "AddCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttributesConfig( @@ -670,7 +755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the get attributes config method over HTTP. @@ -682,8 +767,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -693,6 +780,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_attributes_config( request, metadata ) @@ -705,6 +793,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.GetAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetAttributesConfig._get_response( self._host, @@ -725,7 +840,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2.CatalogServiceClient.get_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCompletionConfig( @@ -763,7 +900,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the get completion config method over HTTP. @@ -775,8 +912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -789,6 +928,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_completion_config( request, metadata ) @@ -801,6 +941,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.GetCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetCompletionConfig._get_response( self._host, @@ -821,7 +988,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2.CatalogServiceClient.get_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDefaultBranch( @@ -858,7 +1047,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Call the get default branch method over HTTP. @@ -869,8 +1058,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.GetDefaultBranchResponse: @@ -882,6 +1073,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_get_default_branch( request, metadata ) @@ -894,6 +1086,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.GetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetDefaultBranch._get_response( self._host, @@ -914,7 +1133,31 @@ def __call__( pb_resp = catalog_service.GetDefaultBranchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_default_branch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.GetDefaultBranchResponse.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.retail_v2.CatalogServiceClient.get_default_branch", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetDefaultBranch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogs( @@ -951,7 +1194,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.ListCatalogsResponse: r"""Call the list catalogs method over HTTP. @@ -963,8 +1206,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.ListCatalogsResponse: @@ -977,6 +1222,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalogs(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListCatalogs._get_transcoded_request( http_options, request @@ -987,6 +1233,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.ListCatalogs", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ListCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListCatalogs._get_response( self._host, @@ -1007,7 +1280,31 @@ def __call__( pb_resp = catalog_service.ListCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.ListCatalogsResponse.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.retail_v2.CatalogServiceClient.list_catalogs", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ListCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveCatalogAttribute( @@ -1046,7 +1343,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the remove catalog attribute method over HTTP. @@ -1058,8 +1355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1069,6 +1368,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseRemoveCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_remove_catalog_attribute( request, metadata ) @@ -1085,6 +1385,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.RemoveCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._RemoveCatalogAttribute._get_response( @@ -1108,7 +1435,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2.CatalogServiceClient.remove_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReplaceCatalogAttribute( @@ -1147,7 +1496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the replace catalog attribute method over HTTP. @@ -1159,8 +1508,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1170,6 +1521,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseReplaceCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_replace_catalog_attribute( request, metadata ) @@ -1186,6 +1538,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.ReplaceCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._ReplaceCatalogAttribute._get_response( @@ -1209,7 +1588,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_replace_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2.CatalogServiceClient.replace_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDefaultBranch( @@ -1247,7 +1648,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the set default branch method over HTTP. @@ -1258,13 +1659,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCatalogServiceRestTransport._BaseSetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_set_default_branch( request, metadata ) @@ -1281,6 +1685,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.SetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "SetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._SetDefaultBranch._get_response( self._host, @@ -1333,7 +1764,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the update attributes config method over HTTP. @@ -1345,8 +1776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1356,6 +1789,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_attributes_config( request, metadata ) @@ -1372,6 +1806,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.UpdateAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateAttributesConfig._get_response( @@ -1395,7 +1856,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2.CatalogServiceClient.update_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCatalog( @@ -1433,7 +1916,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Call the update catalog method over HTTP. @@ -1445,8 +1928,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_catalog.Catalog: @@ -1456,6 +1941,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_update_catalog(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_transcoded_request( http_options, request @@ -1470,6 +1956,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.UpdateCatalog", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._UpdateCatalog._get_response( self._host, @@ -1491,7 +2004,29 @@ def __call__( pb_resp = gcr_catalog.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_catalog.Catalog.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.retail_v2.CatalogServiceClient.update_catalog", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCompletionConfig( @@ -1530,7 +2065,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the update completion config method over HTTP. @@ -1542,8 +2077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -1556,6 +2093,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_completion_config( request, metadata ) @@ -1572,6 +2110,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.UpdateCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateCompletionConfig._get_response( @@ -1595,7 +2160,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2.CatalogServiceClient.update_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "UpdateCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1743,7 +2330,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1753,8 +2340,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1763,6 +2352,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1773,6 +2363,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetOperation._get_response( self._host, @@ -1792,6 +2409,27 @@ def __call__( 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.retail_v2.CatalogServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1832,7 +2470,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1842,8 +2480,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1852,6 +2492,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1862,6 +2503,33 @@ def __call__( 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.retail_v2.CatalogServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListOperations._get_response( self._host, @@ -1881,6 +2549,27 @@ def __call__( 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.retail_v2.CatalogServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.CatalogService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/async_client.py index 067ed974e49b..740e5aaf41ae 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .transports.grpc_asyncio import CompletionServiceGrpcAsyncIOTransport +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 CompletionServiceAsyncClient: """Autocomplete service for retail. @@ -267,13 +277,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.CompletionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "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.retail.v2.CompletionService", + "credentialsType": None, + }, + ) + async def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -314,8 +346,10 @@ async def sample_complete_query(): 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, 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: google.cloud.retail_v2.types.CompleteQueryResponse: @@ -361,7 +395,7 @@ async def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of processed completion dataset. @@ -418,8 +452,10 @@ async def sample_import_completion_data(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -479,7 +515,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -490,8 +526,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -532,7 +570,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -543,8 +581,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/client.py index bc3e7dc72b84..63d95438b42f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -591,6 +601,10 @@ def __init__( # 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( @@ -657,13 +671,36 @@ def __init__( 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.retail_v2.CompletionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "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.retail.v2.CompletionService", + "credentialsType": None, + }, + ) + def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -704,8 +741,10 @@ def sample_complete_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.CompleteQueryResponse: @@ -749,7 +788,7 @@ def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of processed completion dataset. @@ -806,8 +845,10 @@ def sample_import_completion_data(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -878,7 +919,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -889,8 +930,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -931,7 +974,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -942,8 +985,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc.py index 55d7ae7d71dd..384ead9fd08b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport +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.retail.v2.CompletionService", + "rpcName": 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.retail.v2.CompletionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcTransport(CompletionServiceTransport): """gRPC backend transport for CompletionService. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -320,7 +408,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -328,7 +416,7 @@ def import_completion_data( return self._stubs["import_completion_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -340,7 +428,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -359,7 +447,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc_asyncio.py index 52703fa6b586..ddd3f29d69b4 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .grpc import CompletionServiceGrpcTransport +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.retail.v2.CompletionService", + "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.retail.v2.CompletionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcAsyncIOTransport(CompletionServiceTransport): """gRPC AsyncIO backend transport for CompletionService. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -330,7 +415,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +453,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -384,7 +469,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -403,7 +488,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/rest.py index de8886e84397..c36cf8588f7d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/completion_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -87,8 +95,10 @@ def post_import_completion_data(self, response): def pre_complete_query( self, request: completion_service.CompleteQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[completion_service.CompleteQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + completion_service.CompleteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_query Override in a subclass to manipulate the request or metadata @@ -110,8 +120,11 @@ def post_complete_query( def pre_import_completion_data( self, request: import_config.ImportCompletionDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportCompletionDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportCompletionDataRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for import_completion_data Override in a subclass to manipulate the request or metadata @@ -133,8 +146,10 @@ def post_import_completion_data( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -156,8 +171,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -363,7 +380,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Call the complete query method over HTTP. @@ -373,8 +390,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.completion_service.CompleteQueryResponse: @@ -384,6 +403,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_http_options() ) + request, metadata = self._interceptor.pre_complete_query(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_transcoded_request( http_options, request @@ -394,6 +414,33 @@ def __call__( 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.retail_v2.CompletionServiceClient.CompleteQuery", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "CompleteQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._CompleteQuery._get_response( self._host, @@ -414,7 +461,31 @@ def __call__( pb_resp = completion_service.CompleteQueryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = completion_service.CompleteQueryResponse.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.retail_v2.CompletionServiceClient.complete_query", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "CompleteQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportCompletionData( @@ -453,7 +524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import completion data method over HTTP. @@ -464,8 +535,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -478,6 +551,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseImportCompletionData._get_http_options() ) + request, metadata = self._interceptor.pre_import_completion_data( request, metadata ) @@ -494,6 +568,33 @@ def __call__( 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.retail_v2.CompletionServiceClient.ImportCompletionData", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "ImportCompletionData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CompletionServiceRestTransport._ImportCompletionData._get_response( @@ -515,7 +616,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_completion_data(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.retail_v2.CompletionServiceClient.import_completion_data", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "ImportCompletionData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -577,7 +700,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -587,8 +710,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -597,6 +722,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -607,6 +733,33 @@ def __call__( 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.retail_v2.CompletionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._GetOperation._get_response( self._host, @@ -626,6 +779,27 @@ def __call__( 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.retail_v2.CompletionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -667,7 +841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -677,8 +851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -687,6 +863,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -697,6 +874,33 @@ def __call__( 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.retail_v2.CompletionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._ListOperations._get_response( self._host, @@ -716,6 +920,27 @@ def __call__( 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.retail_v2.CompletionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.CompletionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/async_client.py index 89361f717088..4e66fd92e4ff 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .transports.grpc_asyncio import ControlServiceGrpcAsyncIOTransport +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 ControlServiceAsyncClient: """Service for modifying Control.""" @@ -263,6 +273,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.ControlServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "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.retail.v2.ControlService", + "credentialsType": None, + }, + ) + async def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -272,7 +304,7 @@ async def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -340,8 +372,10 @@ async def sample_create_control(): 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, 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: google.cloud.retail_v2.types.Control: @@ -408,7 +442,7 @@ async def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -452,8 +486,10 @@ async def sample_delete_control(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -506,7 +542,7 @@ async def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -568,8 +604,10 @@ async def sample_update_control(): 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, 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: google.cloud.retail_v2.types.Control: @@ -636,7 +674,7 @@ async def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -680,8 +718,10 @@ async def sample_get_control(): 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, 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: google.cloud.retail_v2.types.Control: @@ -744,7 +784,7 @@ async def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsAsyncPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2.Catalog]. @@ -789,8 +829,10 @@ async def sample_list_controls(): 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, 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: google.cloud.retail_v2.services.control_service.pagers.ListControlsAsyncPager: @@ -864,7 +906,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -875,8 +917,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -917,7 +961,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -928,8 +972,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/client.py index 23996655f831..2a5578694972 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -609,6 +619,10 @@ def __init__( # 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( @@ -674,6 +688,29 @@ def __init__( 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.retail_v2.ControlServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "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.retail.v2.ControlService", + "credentialsType": None, + }, + ) + def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -683,7 +720,7 @@ def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -751,8 +788,10 @@ def sample_create_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Control: @@ -816,7 +855,7 @@ def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -860,8 +899,10 @@ def sample_delete_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -911,7 +952,7 @@ def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -973,8 +1014,10 @@ def sample_update_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Control: @@ -1038,7 +1081,7 @@ def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -1082,8 +1125,10 @@ def sample_get_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Control: @@ -1143,7 +1188,7 @@ def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2.Catalog]. @@ -1188,8 +1233,10 @@ def sample_list_controls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.services.control_service.pagers.ListControlsPager: @@ -1273,7 +1320,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1284,8 +1331,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1326,7 +1375,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1337,8 +1386,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/pagers.py index 47fca54add5e..4f1a7e36548e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc.py index f67012a97423..9ba2d9425d77 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import control from google.cloud.retail_v2.types import control as gcr_control @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport +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.retail.v2.ControlService", + "rpcName": 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.retail.v2.ControlService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcTransport(ControlServiceTransport): """gRPC backend transport for ControlService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -290,7 +376,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -321,7 +407,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -347,7 +433,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -376,7 +462,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -384,7 +470,7 @@ def list_controls( return self._stubs["list_controls"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -396,7 +482,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -415,7 +501,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc_asyncio.py index 427cd7f79de9..4af6fad1c55c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import control from google.cloud.retail_v2.types import control as gcr_control @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .grpc import ControlServiceGrpcTransport +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.retail.v2.ControlService", + "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.retail.v2.ControlService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcAsyncIOTransport(ControlServiceTransport): """gRPC AsyncIO backend transport for ControlService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -300,7 +385,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -333,7 +418,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -359,7 +444,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -389,7 +474,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -442,7 +527,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -458,7 +543,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -477,7 +562,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/rest.py index 72cc87de8b89..2eb5ac2151c1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/control_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -110,8 +118,10 @@ def post_update_control(self, response): def pre_create_control( self, request: control_service.CreateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.CreateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.CreateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_control Override in a subclass to manipulate the request or metadata @@ -131,8 +141,10 @@ def post_create_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_delete_control( self, request: control_service.DeleteControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.DeleteControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.DeleteControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_control Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def pre_delete_control( def pre_get_control( self, request: control_service.GetControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.GetControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.GetControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_control Override in a subclass to manipulate the request or metadata @@ -164,8 +178,10 @@ def post_get_control(self, response: control.Control) -> control.Control: def pre_list_controls( self, request: control_service.ListControlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.ListControlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.ListControlsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_controls Override in a subclass to manipulate the request or metadata @@ -187,8 +203,10 @@ def post_list_controls( def pre_update_control( self, request: control_service.UpdateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.UpdateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.UpdateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_control Override in a subclass to manipulate the request or metadata @@ -208,8 +226,10 @@ def post_update_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -231,8 +251,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -373,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the create control method over HTTP. @@ -383,8 +405,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -398,6 +422,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseCreateControl._get_http_options() ) + request, metadata = self._interceptor.pre_create_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseCreateControl._get_transcoded_request( http_options, request @@ -412,6 +437,33 @@ def __call__( 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.retail_v2.ControlServiceClient.CreateControl", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "CreateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._CreateControl._get_response( self._host, @@ -433,7 +485,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2.ControlServiceClient.create_control", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "CreateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteControl( @@ -470,7 +544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete control method over HTTP. @@ -480,13 +554,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseControlServiceRestTransport._BaseDeleteControl._get_http_options() ) + request, metadata = self._interceptor.pre_delete_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseDeleteControl._get_transcoded_request( http_options, request @@ -497,6 +574,33 @@ def __call__( 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.retail_v2.ControlServiceClient.DeleteControl", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "DeleteControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._DeleteControl._get_response( self._host, @@ -546,7 +650,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Call the get control method over HTTP. @@ -556,8 +660,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control.Control: @@ -571,6 +677,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetControl._get_http_options() ) + request, metadata = self._interceptor.pre_get_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetControl._get_transcoded_request( http_options, request @@ -583,6 +690,33 @@ def __call__( ) ) + 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.retail_v2.ControlServiceClient.GetControl", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "GetControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetControl._get_response( self._host, @@ -603,7 +737,29 @@ def __call__( pb_resp = control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control.Control.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.retail_v2.ControlServiceClient.get_control", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "GetControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListControls( @@ -640,7 +796,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control_service.ListControlsResponse: r"""Call the list controls method over HTTP. @@ -650,8 +806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control_service.ListControlsResponse: @@ -661,6 +819,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListControls._get_http_options() ) + request, metadata = self._interceptor.pre_list_controls(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListControls._get_transcoded_request( http_options, request @@ -671,6 +830,33 @@ def __call__( 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.retail_v2.ControlServiceClient.ListControls", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "ListControls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListControls._get_response( self._host, @@ -691,7 +877,31 @@ def __call__( pb_resp = control_service.ListControlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_controls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control_service.ListControlsResponse.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.retail_v2.ControlServiceClient.list_controls", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "ListControls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateControl( @@ -729,7 +939,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the update control method over HTTP. @@ -739,8 +949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -754,6 +966,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseUpdateControl._get_http_options() ) + request, metadata = self._interceptor.pre_update_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseUpdateControl._get_transcoded_request( http_options, request @@ -768,6 +981,33 @@ def __call__( 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.retail_v2.ControlServiceClient.UpdateControl", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "UpdateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._UpdateControl._get_response( self._host, @@ -789,7 +1029,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2.ControlServiceClient.update_control", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "UpdateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -872,7 +1134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -882,8 +1144,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -892,6 +1156,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -902,6 +1167,33 @@ def __call__( 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.retail_v2.ControlServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetOperation._get_response( self._host, @@ -921,6 +1213,27 @@ def __call__( 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.retail_v2.ControlServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -961,7 +1274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -971,8 +1284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -981,6 +1296,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -991,6 +1307,33 @@ def __call__( 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.retail_v2.ControlServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListOperations._get_response( self._host, @@ -1010,6 +1353,27 @@ def __call__( 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.retail_v2.ControlServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ControlService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/async_client.py index 6d32ddd95250..11f4a305952c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .transports.grpc_asyncio import GenerativeQuestionServiceGrpcAsyncIOTransport +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 GenerativeQuestionServiceAsyncClient: """Service for managing LLM generated questions in search @@ -276,6 +286,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.GenerativeQuestionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "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.retail.v2.GenerativeQuestionService", + "credentialsType": None, + }, + ) + async def update_generative_questions_feature_config( self, request: Optional[ @@ -291,7 +323,7 @@ async def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -349,8 +381,10 @@ async def sample_update_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig: @@ -432,7 +466,7 @@ async def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -479,8 +513,10 @@ async def sample_get_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig: @@ -552,7 +588,7 @@ async def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -596,8 +632,10 @@ async def sample_list_generative_question_configs(): 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, 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: google.cloud.retail_v2.types.ListGenerativeQuestionConfigsResponse: @@ -667,7 +705,7 @@ async def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -725,8 +763,10 @@ async def sample_update_generative_question_config(): 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, 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: google.cloud.retail_v2.types.GenerativeQuestionConfig: @@ -810,7 +850,7 @@ async def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -867,8 +907,10 @@ async def sample_batch_update_generative_question_configs(): 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, 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: google.cloud.retail_v2.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -937,7 +979,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -948,8 +990,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -990,7 +1034,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1001,8 +1045,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/client.py index fb38431d796c..520c30ce2d69 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -594,6 +604,10 @@ def __init__( # 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( @@ -660,6 +674,29 @@ def __init__( 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.retail_v2.GenerativeQuestionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "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.retail.v2.GenerativeQuestionService", + "credentialsType": None, + }, + ) + def update_generative_questions_feature_config( self, request: Optional[ @@ -675,7 +712,7 @@ def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -733,8 +770,10 @@ def sample_update_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig: @@ -815,7 +854,7 @@ def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -862,8 +901,10 @@ def sample_get_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig: @@ -934,7 +975,7 @@ def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -978,8 +1019,10 @@ def sample_list_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ListGenerativeQuestionConfigsResponse: @@ -1048,7 +1091,7 @@ def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -1106,8 +1149,10 @@ def sample_update_generative_question_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.GenerativeQuestionConfig: @@ -1190,7 +1235,7 @@ def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -1247,8 +1292,10 @@ def sample_batch_update_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -1329,7 +1376,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1340,8 +1387,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1382,7 +1431,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1393,8 +1442,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc.py index 5e76434ca7e2..d6f556a552e5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import ( generative_question, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport +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.retail.v2.GenerativeQuestionService", + "rpcName": 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.retail.v2.GenerativeQuestionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcTransport(GenerativeQuestionServiceTransport): """gRPC backend transport for GenerativeQuestionService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -299,7 +385,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -331,7 +417,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -363,7 +449,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -395,7 +481,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -403,7 +489,7 @@ def batch_update_generative_question_configs( return self._stubs["batch_update_generative_question_configs"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -415,7 +501,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -434,7 +520,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc_asyncio.py index 721c0fa23e5a..1fa18d240fc7 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import ( generative_question, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .grpc import GenerativeQuestionServiceGrpcTransport +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.retail.v2.GenerativeQuestionService", + "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.retail.v2.GenerativeQuestionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcAsyncIOTransport(GenerativeQuestionServiceTransport): """gRPC AsyncIO backend transport for GenerativeQuestionService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -307,7 +392,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -339,7 +424,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -371,7 +456,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -405,7 +490,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -458,7 +543,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -474,7 +559,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -493,7 +578,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/rest.py index 7b5973e1e9d8..0dac17153323 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/generative_question_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -114,10 +122,10 @@ def post_update_generative_questions_feature_config(self, response): def pre_batch_update_generative_question_configs( self, request: generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_update_generative_question_configs @@ -141,10 +149,10 @@ def post_batch_update_generative_question_configs( def pre_get_generative_questions_feature_config( self, request: generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_generative_questions_feature_config @@ -167,10 +175,10 @@ def post_get_generative_questions_feature_config( def pre_list_generative_question_configs( self, request: generative_question_service.ListGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.ListGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_generative_question_configs @@ -194,10 +202,10 @@ def post_list_generative_question_configs( def pre_update_generative_question_config( self, request: generative_question_service.UpdateGenerativeQuestionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_question_config @@ -220,10 +228,10 @@ def post_update_generative_question_config( def pre_update_generative_questions_feature_config( self, request: generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_questions_feature_config @@ -246,8 +254,10 @@ def post_update_generative_questions_feature_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -269,8 +279,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -417,7 +429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Call the batch update generative question configs method over HTTP. @@ -430,8 +442,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: @@ -443,6 +457,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseBatchUpdateGenerativeQuestionConfigs._get_http_options() ) + ( request, metadata, @@ -462,6 +477,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.BatchUpdateGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._BatchUpdateGenerativeQuestionConfigs._get_response( self._host, @@ -487,7 +529,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.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.retail_v2.GenerativeQuestionServiceClient.batch_update_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGenerativeQuestionsFeatureConfig( @@ -527,7 +593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the get generative questions feature config method over HTTP. @@ -540,8 +606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -553,6 +621,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -568,6 +637,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.GetGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._GetGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -588,7 +684,33 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_generative_questions_feature_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2.GenerativeQuestionServiceClient.get_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGenerativeQuestionConfigs( @@ -628,7 +750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Call the list generative question configs method over HTTP. @@ -639,8 +761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.ListGenerativeQuestionConfigsResponse: @@ -650,6 +774,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListGenerativeQuestionConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_generative_question_configs( request, metadata ) @@ -662,6 +787,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.ListGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._ListGenerativeQuestionConfigs._get_response( self._host, @@ -686,7 +838,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.ListGenerativeQuestionConfigsResponse.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.retail_v2.GenerativeQuestionServiceClient.list_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionConfig( @@ -727,7 +903,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Call the update generative question config method over HTTP. @@ -739,8 +915,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionConfig: @@ -752,6 +930,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_generative_question_config( request, metadata ) @@ -768,6 +947,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.UpdateGenerativeQuestionConfig", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionConfig._get_response( self._host, @@ -789,7 +995,31 @@ def __call__( pb_resp = generative_question.GenerativeQuestionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_question_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionConfig.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.retail_v2.GenerativeQuestionServiceClient.update_generative_question_config", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionsFeatureConfig( @@ -830,7 +1060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the update generative questions feature config method over HTTP. @@ -843,8 +1073,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -856,6 +1088,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -875,6 +1108,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.UpdateGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -896,9 +1156,35 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_questions_feature_config( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2.GenerativeQuestionServiceClient.update_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -995,7 +1281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1005,8 +1291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1015,6 +1303,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1025,6 +1314,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._GetOperation._get_response( @@ -1046,6 +1362,27 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1087,7 +1424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1097,8 +1434,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1107,6 +1446,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1117,6 +1457,33 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._ListOperations._get_response( @@ -1138,6 +1505,27 @@ def __call__( 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.retail_v2.GenerativeQuestionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/async_client.py index 7a192b41fdfa..56b7d3894986 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +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 ModelServiceAsyncClient: """Service for performing CRUD operations on models. Recommendation @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "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.retail.v2.ModelService", + "credentialsType": None, + }, + ) + async def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -282,7 +314,7 @@ async def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new model. @@ -343,8 +375,10 @@ async def sample_create_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -421,7 +455,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -465,8 +499,10 @@ async def sample_get_model(): 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, 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: google.cloud.retail_v2.types.Model: @@ -531,7 +567,7 @@ async def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -575,8 +611,10 @@ async def sample_pause_model(): 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, 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: google.cloud.retail_v2.types.Model: @@ -641,7 +679,7 @@ async def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -685,8 +723,10 @@ async def sample_resume_model(): 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, 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: google.cloud.retail_v2.types.Model: @@ -751,7 +791,7 @@ async def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -792,8 +832,10 @@ async def sample_delete_model(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -845,7 +887,7 @@ async def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsAsyncPager: r"""Lists all the models linked to this event store. @@ -890,8 +932,10 @@ async def sample_list_models(): 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, 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: google.cloud.retail_v2.services.model_service.pagers.ListModelsAsyncPager: @@ -967,7 +1011,7 @@ async def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1026,8 +1070,10 @@ async def sample_update_model(): 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, 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: google.cloud.retail_v2.types.Model: @@ -1096,7 +1142,7 @@ async def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Tunes an existing model. @@ -1147,8 +1193,10 @@ async def sample_tune_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1219,7 +1267,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1230,8 +1278,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1272,7 +1322,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1283,8 +1333,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/client.py index a4a4082c19b8..9b65fbbaa00f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -684,6 +698,29 @@ def __init__( 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.retail_v2.ModelServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "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.retail.v2.ModelService", + "credentialsType": None, + }, + ) + def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -692,7 +729,7 @@ def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new model. @@ -753,8 +790,10 @@ def sample_create_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -828,7 +867,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -872,8 +911,10 @@ def sample_get_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2.types.Model: @@ -935,7 +976,7 @@ def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -979,8 +1020,10 @@ def sample_pause_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2.types.Model: @@ -1042,7 +1085,7 @@ def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -1086,8 +1129,10 @@ def sample_resume_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2.types.Model: @@ -1149,7 +1194,7 @@ def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -1190,8 +1235,10 @@ def sample_delete_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1240,7 +1287,7 @@ def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsPager: r"""Lists all the models linked to this event store. @@ -1285,8 +1332,10 @@ def sample_list_models(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2.services.model_service.pagers.ListModelsPager: @@ -1359,7 +1408,7 @@ def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1418,8 +1467,10 @@ def sample_update_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2.types.Model: @@ -1485,7 +1536,7 @@ def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Tunes an existing model. @@ -1536,8 +1587,10 @@ def sample_tune_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1618,7 +1671,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1629,8 +1682,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1671,7 +1726,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1682,8 +1737,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/pagers.py index dfb16eeefa89..b5a960d93d42 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc.py index 1527148e8db0..bf60de367b80 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import model from google.cloud.retail_v2.types import model as gcr_model @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +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.retail.v2.ModelService", + "rpcName": 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.retail.v2.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -196,7 +277,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -284,7 +372,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -308,7 +396,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -332,7 +420,7 @@ def pause_model(self) -> Callable[[model_service.PauseModelRequest], model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -356,7 +444,7 @@ def resume_model(self) -> Callable[[model_service.ResumeModelRequest], model.Mod # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -382,7 +470,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -408,7 +496,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -436,7 +524,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -462,7 +550,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -470,7 +558,7 @@ def tune_model( return self._stubs["tune_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -482,7 +570,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -501,7 +589,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc_asyncio.py index 0f86ece481fd..ae4097342115 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import model from google.cloud.retail_v2.types import model as gcr_model @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +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.retail.v2.ModelService", + "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.retail.v2.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -243,10 +325,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -296,7 +381,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -322,7 +407,7 @@ def get_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -348,7 +433,7 @@ def pause_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -374,7 +459,7 @@ def resume_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -400,7 +485,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -428,7 +513,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -456,7 +541,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -484,7 +569,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +637,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -568,7 +653,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -587,7 +672,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/rest.py index 3d0a5dc12f09..6317dee1177c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/model_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -134,8 +142,10 @@ def post_update_model(self, response): def pre_create_model( self, request: model_service.CreateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.CreateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -157,8 +167,10 @@ def post_create_model( def pre_delete_model( self, request: model_service.DeleteModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.DeleteModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -169,8 +181,8 @@ def pre_delete_model( def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -213,8 +227,10 @@ def post_list_models( def pre_pause_model( self, request: model_service.PauseModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.PauseModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.PauseModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_model Override in a subclass to manipulate the request or metadata @@ -234,8 +250,10 @@ def post_pause_model(self, response: model.Model) -> model.Model: def pre_resume_model( self, request: model_service.ResumeModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ResumeModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ResumeModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_model Override in a subclass to manipulate the request or metadata @@ -255,8 +273,8 @@ def post_resume_model(self, response: model.Model) -> model.Model: def pre_tune_model( self, request: model_service.TuneModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for tune_model Override in a subclass to manipulate the request or metadata @@ -278,8 +296,10 @@ def post_tune_model( def pre_update_model( self, request: model_service.UpdateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.UpdateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.UpdateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_model Override in a subclass to manipulate the request or metadata @@ -299,8 +319,10 @@ def post_update_model(self, response: gcr_model.Model) -> gcr_model.Model: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -322,8 +344,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -536,7 +560,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -546,8 +570,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -560,6 +586,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseCreateModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseCreateModel._get_transcoded_request( @@ -580,6 +607,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.CreateModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CreateModel._get_response( self._host, @@ -599,7 +653,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.retail_v2.ModelServiceClient.create_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteModel( @@ -636,7 +712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete model method over HTTP. @@ -646,13 +722,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_transcoded_request( @@ -667,6 +746,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.DeleteModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._DeleteModel._get_response( self._host, @@ -714,7 +820,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -724,8 +830,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -741,6 +849,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -755,6 +864,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -775,7 +911,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2.ModelServiceClient.get_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -812,7 +970,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -823,8 +981,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model_service.ListModelsResponse: @@ -834,6 +994,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -848,6 +1009,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -868,7 +1056,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.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.retail_v2.ModelServiceClient.list_models", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseModel( @@ -906,7 +1118,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the pause model method over HTTP. @@ -917,8 +1129,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -934,6 +1148,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BasePauseModel._get_http_options() ) + request, metadata = self._interceptor.pre_pause_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BasePauseModel._get_transcoded_request( @@ -954,6 +1169,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.PauseModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "PauseModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._PauseModel._get_response( self._host, @@ -975,7 +1217,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2.ModelServiceClient.pause_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "PauseModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeModel( @@ -1013,7 +1277,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the resume model method over HTTP. @@ -1024,8 +1288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -1041,6 +1307,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseResumeModel._get_http_options() ) + request, metadata = self._interceptor.pre_resume_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseResumeModel._get_transcoded_request( @@ -1061,6 +1328,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.ResumeModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ResumeModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ResumeModel._get_response( self._host, @@ -1082,7 +1376,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2.ModelServiceClient.resume_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ResumeModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TuneModel( @@ -1120,7 +1436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the tune model method over HTTP. @@ -1133,8 +1449,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1147,6 +1465,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseTuneModel._get_http_options() ) + request, metadata = self._interceptor.pre_tune_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseTuneModel._get_transcoded_request( @@ -1165,6 +1484,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.TuneModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "TuneModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._TuneModel._get_response( self._host, @@ -1184,7 +1530,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tune_model(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.retail_v2.ModelServiceClient.tune_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "TuneModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateModel( @@ -1222,7 +1590,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Call the update model method over HTTP. @@ -1233,8 +1601,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_model.Model: @@ -1250,6 +1620,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_http_options() ) + request, metadata = self._interceptor.pre_update_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_transcoded_request( @@ -1270,6 +1641,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.UpdateModel", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "UpdateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._UpdateModel._get_response( self._host, @@ -1291,7 +1689,29 @@ def __call__( pb_resp = gcr_model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_model.Model.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.retail_v2.ModelServiceClient.update_model", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "UpdateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1390,7 +1810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1400,8 +1820,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1410,6 +1832,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1422,6 +1845,33 @@ def __call__( ) ) + 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.retail_v2.ModelServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetOperation._get_response( self._host, @@ -1441,6 +1891,27 @@ def __call__( 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.retail_v2.ModelServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1481,7 +1952,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1491,8 +1962,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1501,6 +1974,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1511,6 +1985,33 @@ def __call__( 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.retail_v2.ModelServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListOperations._get_response( self._host, @@ -1530,6 +2031,27 @@ def __call__( 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.retail_v2.ModelServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ModelService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/async_client.py index ccd1b99fc22f..f96ccd0c5eec 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """Service for making recommendation prediction.""" @@ -260,13 +270,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "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.retail.v2.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -307,8 +339,10 @@ async def sample_predict(): 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, 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: google.cloud.retail_v2.types.PredictResponse: @@ -352,7 +386,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -363,8 +397,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -405,7 +441,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -416,8 +452,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/client.py index 80c43984f517..4983d8ec1e2d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -588,6 +598,10 @@ def __init__( # 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( @@ -654,13 +668,36 @@ def __init__( 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.retail_v2.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "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.retail.v2.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -701,8 +738,10 @@ def sample_predict(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.PredictResponse: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc.py index 93a7e24ffed7..7e585cd02a94 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.retail.v2.PredictionService", + "rpcName": 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.retail.v2.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -265,7 +351,7 @@ def predict( return self._stubs["predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -277,7 +363,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -296,7 +382,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc_asyncio.py index 0a7ddfa0f69a..1a81c328ded2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.retail.v2.PredictionService", + "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.retail.v2.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -299,7 +384,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -315,7 +400,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -334,7 +419,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/rest.py index bf7fff1d00ce..250c4afedc33 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/prediction_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,10 @@ def post_predict(self, response): def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_predict( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +137,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -277,8 +291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_service.PredictResponse: @@ -288,6 +304,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + 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.retail_v2.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.retail_v2.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -408,6 +479,33 @@ def __call__( 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.retail_v2.PredictionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._GetOperation._get_response( self._host, @@ -427,6 +525,27 @@ def __call__( 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.retail_v2.PredictionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -468,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -478,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -488,6 +609,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -498,6 +620,33 @@ def __call__( 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.retail_v2.PredictionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._ListOperations._get_response( self._host, @@ -517,6 +666,27 @@ def __call__( 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.retail_v2.PredictionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.PredictionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/async_client.py index 7aed6ad0e89f..fa48b92ff70c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .transports.grpc_asyncio import ProductServiceGrpcAsyncIOTransport +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 ProductServiceAsyncClient: """Service for ingesting [Product][google.cloud.retail.v2.Product] @@ -270,6 +280,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.ProductServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "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.retail.v2.ProductService", + "credentialsType": None, + }, + ) + async def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -279,7 +311,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2.Product]. @@ -359,8 +391,10 @@ async def sample_create_product(): 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, 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: google.cloud.retail_v2.types.Product: @@ -426,7 +460,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2.Product]. @@ -481,8 +515,10 @@ async def sample_get_product(): 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, 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: google.cloud.retail_v2.types.Product: @@ -544,7 +580,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Gets a list of [Product][google.cloud.retail.v2.Product]s. @@ -597,8 +633,10 @@ async def sample_list_products(): 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, 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: google.cloud.retail_v2.services.product_service.pagers.ListProductsAsyncPager: @@ -675,7 +713,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2.Product]. @@ -750,8 +788,10 @@ async def sample_update_product(): 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, 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: google.cloud.retail_v2.types.Product: @@ -817,7 +857,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2.Product]. @@ -882,8 +922,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -934,7 +976,7 @@ async def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2.Product]s under a branch. @@ -995,8 +1037,10 @@ async def sample_purge_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1053,7 +1097,7 @@ async def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. @@ -1105,8 +1149,10 @@ async def sample_import_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1168,7 +1214,7 @@ async def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the @@ -1348,8 +1394,10 @@ async def sample_set_inventory(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1428,7 +1476,7 @@ async def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] @@ -1516,8 +1564,10 @@ async def sample_add_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1592,7 +1642,7 @@ async def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] @@ -1680,8 +1730,10 @@ async def sample_remove_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1756,7 +1808,7 @@ async def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, @@ -1842,8 +1894,10 @@ async def sample_add_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1920,7 +1974,7 @@ async def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at @@ -2004,8 +2058,10 @@ async def sample_remove_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2079,7 +2135,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2090,8 +2146,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2132,7 +2190,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2143,8 +2201,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/client.py index 78452acd955b..51e2d412cc76 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -620,6 +630,10 @@ def __init__( # 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( @@ -685,6 +699,29 @@ def __init__( 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.retail_v2.ProductServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "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.retail.v2.ProductService", + "credentialsType": None, + }, + ) + def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -694,7 +731,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2.Product]. @@ -774,8 +811,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Product: @@ -838,7 +877,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2.Product]. @@ -893,8 +932,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Product: @@ -953,7 +994,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Gets a list of [Product][google.cloud.retail.v2.Product]s. @@ -1006,8 +1047,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.services.product_service.pagers.ListProductsPager: @@ -1081,7 +1124,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2.Product]. @@ -1156,8 +1199,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.Product: @@ -1220,7 +1265,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2.Product]. @@ -1285,8 +1330,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1334,7 +1381,7 @@ def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2.Product]s under a branch. @@ -1395,8 +1442,10 @@ def sample_purge_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1451,7 +1500,7 @@ def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. @@ -1503,8 +1552,10 @@ def sample_import_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1564,7 +1615,7 @@ def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the @@ -1744,8 +1795,10 @@ def sample_set_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1821,7 +1874,7 @@ def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] @@ -1909,8 +1962,10 @@ def sample_add_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1982,7 +2037,7 @@ def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] @@ -2070,8 +2125,10 @@ def sample_remove_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2145,7 +2202,7 @@ def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, @@ -2231,8 +2288,10 @@ def sample_add_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2306,7 +2365,7 @@ def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at @@ -2390,8 +2449,10 @@ def sample_remove_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2475,7 +2536,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2486,8 +2547,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2528,7 +2591,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2539,8 +2602,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/pagers.py index c94b7eb05f0b..4b0e6dddd02b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc.py index b3d19d46c316..451ff273f7f6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import import_config from google.cloud.retail_v2.types import product @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport +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.retail.v2.ProductService", + "rpcName": 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.retail.v2.ProductService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcTransport(ProductServiceTransport): """gRPC backend transport for ProductService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -301,7 +389,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -329,7 +417,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -355,7 +443,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -381,7 +469,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -426,7 +514,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +548,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -538,7 +626,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -597,7 +685,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -656,7 +744,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -715,7 +803,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -771,7 +859,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -779,7 +867,7 @@ def remove_local_inventories( return self._stubs["remove_local_inventories"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -791,7 +879,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -810,7 +898,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc_asyncio.py index 2e86340fb479..8a8cda623f08 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import import_config from google.cloud.retail_v2.types import product @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .grpc import ProductServiceGrpcTransport +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.retail.v2.ProductService", + "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.retail.v2.ProductService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcAsyncIOTransport(ProductServiceTransport): """gRPC AsyncIO backend transport for ProductService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -313,7 +398,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -342,7 +427,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -370,7 +455,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -396,7 +481,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +528,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -559,7 +644,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -619,7 +704,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +764,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -739,7 +824,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -796,7 +881,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -894,7 +979,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -910,7 +995,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -929,7 +1014,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/rest.py index 790d46c69729..470745be7bb0 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/product_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -167,8 +175,11 @@ def post_update_product(self, response): def pre_add_fulfillment_places( self, request: product_service.AddFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddFulfillmentPlacesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_fulfillment_places Override in a subclass to manipulate the request or metadata @@ -190,8 +201,11 @@ def post_add_fulfillment_places( def pre_add_local_inventories( self, request: product_service.AddLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddLocalInventoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_local_inventories Override in a subclass to manipulate the request or metadata @@ -213,8 +227,10 @@ def post_add_local_inventories( def pre_create_product( self, request: product_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.CreateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -234,8 +250,10 @@ def post_create_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_delete_product( self, request: product_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.DeleteProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -246,8 +264,10 @@ def pre_delete_product( def pre_get_product( self, request: product_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.GetProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -267,8 +287,10 @@ def post_get_product(self, response: product.Product) -> product.Product: def pre_import_products( self, request: import_config.ImportProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_products Override in a subclass to manipulate the request or metadata @@ -290,8 +312,10 @@ def post_import_products( def pre_list_products( self, request: product_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.ListProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -313,8 +337,10 @@ def post_list_products( def pre_purge_products( self, request: purge_config.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -336,9 +362,10 @@ def post_purge_products( def pre_remove_fulfillment_places( self, request: product_service.RemoveFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveFulfillmentPlacesRequest, Sequence[Tuple[str, str]] + product_service.RemoveFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_fulfillment_places @@ -361,9 +388,10 @@ def post_remove_fulfillment_places( def pre_remove_local_inventories( self, request: product_service.RemoveLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveLocalInventoriesRequest, Sequence[Tuple[str, str]] + product_service.RemoveLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_local_inventories @@ -386,8 +414,10 @@ def post_remove_local_inventories( def pre_set_inventory( self, request: product_service.SetInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.SetInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.SetInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_inventory Override in a subclass to manipulate the request or metadata @@ -409,8 +439,10 @@ def post_set_inventory( def pre_update_product( self, request: product_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.UpdateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -430,8 +462,10 @@ def post_update_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -453,8 +487,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -658,7 +694,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add fulfillment places method over HTTP. @@ -670,8 +706,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -684,6 +722,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_add_fulfillment_places( request, metadata ) @@ -700,6 +739,33 @@ def __call__( 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.retail_v2.ProductServiceClient.AddFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "AddFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddFulfillmentPlaces._get_response( self._host, @@ -719,7 +785,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_fulfillment_places(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.retail_v2.ProductServiceClient.add_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "AddFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddLocalInventories( @@ -758,7 +846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add local inventories method over HTTP. @@ -770,8 +858,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -784,6 +874,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_add_local_inventories( request, metadata ) @@ -800,6 +891,33 @@ def __call__( 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.retail_v2.ProductServiceClient.AddLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "AddLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddLocalInventories._get_response( self._host, @@ -819,7 +937,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_local_inventories(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.retail_v2.ProductServiceClient.add_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "AddLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProduct( @@ -857,7 +997,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the create product method over HTTP. @@ -869,8 +1009,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -883,6 +1025,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -897,6 +1040,33 @@ def __call__( 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.retail_v2.ProductServiceClient.CreateProduct", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._CreateProduct._get_response( self._host, @@ -918,7 +1088,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2.ProductServiceClient.create_product", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -955,7 +1147,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -967,13 +1159,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductServiceRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -984,6 +1179,33 @@ def __call__( 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.retail_v2.ProductServiceClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._DeleteProduct._get_response( self._host, @@ -1033,7 +1255,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Call the get product method over HTTP. @@ -1045,8 +1267,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product.Product: @@ -1059,6 +1283,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetProduct._get_transcoded_request( http_options, request @@ -1071,6 +1296,33 @@ def __call__( ) ) + 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.retail_v2.ProductServiceClient.GetProduct", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetProduct._get_response( self._host, @@ -1091,7 +1343,29 @@ def __call__( pb_resp = product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product.Product.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.retail_v2.ProductServiceClient.get_product", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProducts( @@ -1129,7 +1403,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import products method over HTTP. @@ -1139,8 +1413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1153,6 +1429,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseImportProducts._get_http_options() ) + request, metadata = self._interceptor.pre_import_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseImportProducts._get_transcoded_request( http_options, request @@ -1167,6 +1444,33 @@ def __call__( 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.retail_v2.ProductServiceClient.ImportProducts", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ImportProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ImportProducts._get_response( self._host, @@ -1186,7 +1490,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_products(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.retail_v2.ProductServiceClient.import_products", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ImportProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1223,7 +1549,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1235,8 +1561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_service.ListProductsResponse: @@ -1249,6 +1577,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1259,6 +1588,33 @@ def __call__( 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.retail_v2.ProductServiceClient.ListProducts", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListProducts._get_response( self._host, @@ -1279,7 +1635,31 @@ def __call__( pb_resp = product_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_service.ListProductsResponse.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.retail_v2.ProductServiceClient.list_products", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -1317,7 +1697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -1328,8 +1708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1342,6 +1724,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -1356,6 +1739,33 @@ def __call__( 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.retail_v2.ProductServiceClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._PurgeProducts._get_response( self._host, @@ -1375,7 +1785,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(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.retail_v2.ProductServiceClient.purge_products", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveFulfillmentPlaces( @@ -1414,7 +1846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove fulfillment places method over HTTP. @@ -1426,8 +1858,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1440,6 +1874,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_remove_fulfillment_places( request, metadata ) @@ -1456,6 +1891,33 @@ def __call__( 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.retail_v2.ProductServiceClient.RemoveFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveFulfillmentPlaces._get_response( @@ -1477,7 +1939,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_fulfillment_places(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.retail_v2.ProductServiceClient.remove_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveLocalInventories( @@ -1516,7 +2000,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove local inventories method over HTTP. @@ -1528,8 +2012,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1542,6 +2028,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_remove_local_inventories( request, metadata ) @@ -1558,6 +2045,33 @@ def __call__( 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.retail_v2.ProductServiceClient.RemoveLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "RemoveLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveLocalInventories._get_response( @@ -1579,7 +2093,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_local_inventories(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.retail_v2.ProductServiceClient.remove_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "RemoveLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetInventory( @@ -1617,7 +2153,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the set inventory method over HTTP. @@ -1629,8 +2165,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1643,6 +2181,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseSetInventory._get_http_options() ) + request, metadata = self._interceptor.pre_set_inventory(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseSetInventory._get_transcoded_request( http_options, request @@ -1657,6 +2196,33 @@ def __call__( 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.retail_v2.ProductServiceClient.SetInventory", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "SetInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._SetInventory._get_response( self._host, @@ -1676,7 +2242,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_inventory(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.retail_v2.ProductServiceClient.set_inventory", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "SetInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProduct( @@ -1714,7 +2302,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the update product method over HTTP. @@ -1726,8 +2314,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -1740,6 +2330,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -1754,6 +2345,33 @@ def __call__( 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.retail_v2.ProductServiceClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._UpdateProduct._get_response( self._host, @@ -1775,7 +2393,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2.ProductServiceClient.update_product", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1922,7 +2562,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1932,8 +2572,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1942,6 +2584,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1952,6 +2595,33 @@ def __call__( 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.retail_v2.ProductServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetOperation._get_response( self._host, @@ -1971,6 +2641,27 @@ def __call__( 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.retail_v2.ProductServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2011,7 +2702,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2021,8 +2712,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2031,6 +2724,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2041,6 +2735,33 @@ def __call__( 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.retail_v2.ProductServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListOperations._get_response( self._host, @@ -2060,6 +2781,27 @@ def __call__( 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.retail_v2.ProductServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ProductService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/async_client.py index 249c2fcde448..89745abba79d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .transports.grpc_asyncio import SearchServiceGrpcAsyncIOTransport +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 SearchServiceAsyncClient: """Service for search. @@ -270,13 +280,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.SearchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "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.retail.v2.SearchService", + "credentialsType": None, + }, + ) + async def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAsyncPager: r"""Performs a search. @@ -320,8 +352,10 @@ async def sample_search(): 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, 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: google.cloud.retail_v2.services.search_service.pagers.SearchAsyncPager: @@ -382,7 +416,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -393,8 +427,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -435,7 +471,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -446,8 +482,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/client.py index eab9ecee654d..9a19247a91bd 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -660,6 +670,10 @@ def __init__( # 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( @@ -725,13 +739,36 @@ def __init__( 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.retail_v2.SearchServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "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.retail.v2.SearchService", + "credentialsType": None, + }, + ) + def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchPager: r"""Performs a search. @@ -775,8 +812,10 @@ def sample_search(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.services.search_service.pagers.SearchPager: @@ -850,7 +889,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -861,8 +900,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -903,7 +944,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -914,8 +955,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/pagers.py index aa82176861ac..c04bb4cc18cb 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = search_service.SearchRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = search_service.SearchRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc.py index c26aa352db53..4939184f5855 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport +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.retail.v2.SearchService", + "rpcName": 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.retail.v2.SearchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcTransport(SearchServiceTransport): """gRPC backend transport for SearchService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -271,7 +357,7 @@ def search( return self._stubs["search"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -283,7 +369,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -302,7 +388,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc_asyncio.py index 14fb279bc410..bb45f53f5d31 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .grpc import SearchServiceGrpcTransport +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.retail.v2.SearchService", + "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.retail.v2.SearchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcAsyncIOTransport(SearchServiceTransport): """gRPC AsyncIO backend transport for SearchService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +358,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -306,7 +391,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -322,7 +407,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -341,7 +426,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/rest.py index 4999066a6667..9a7b6575ca30 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/search_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -77,8 +85,10 @@ def post_search(self, response): """ def pre_search( - self, request: search_service.SearchRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, str]]]: + self, + request: search_service.SearchRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search Override in a subclass to manipulate the request or metadata @@ -100,8 +110,10 @@ def post_search( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -123,8 +135,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> search_service.SearchResponse: r"""Call the search method over HTTP. @@ -279,8 +293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.search_service.SearchResponse: @@ -293,6 +309,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseSearch._get_http_options() ) + request, metadata = self._interceptor.pre_search(request, metadata) transcoded_request = ( _BaseSearchServiceRestTransport._BaseSearch._get_transcoded_request( @@ -311,6 +328,33 @@ def __call__( ) ) + 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.retail_v2.SearchServiceClient.Search", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "Search", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._Search._get_response( self._host, @@ -332,7 +376,29 @@ def __call__( pb_resp = search_service.SearchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = search_service.SearchResponse.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.retail_v2.SearchServiceClient.search", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "Search", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -381,7 +447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -391,8 +457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -401,6 +469,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -411,6 +480,33 @@ def __call__( 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.retail_v2.SearchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._GetOperation._get_response( self._host, @@ -430,6 +526,27 @@ def __call__( 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.retail_v2.SearchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -470,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -480,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -490,6 +609,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -500,6 +620,33 @@ def __call__( 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.retail_v2.SearchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._ListOperations._get_response( self._host, @@ -519,6 +666,27 @@ def __call__( 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.retail_v2.SearchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.SearchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/async_client.py index e9e72935d1d0..d2dfb7335f41 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .transports.grpc_asyncio import ServingConfigServiceGrpcAsyncIOTransport +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 ServingConfigServiceAsyncClient: """Service for modifying ServingConfig.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.ServingConfigServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "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.retail.v2.ServingConfigService", + "credentialsType": None, + }, + ) + async def create_serving_config( self, request: Optional[ @@ -280,7 +312,7 @@ async def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -353,8 +385,10 @@ async def sample_create_serving_config(): 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, 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: google.cloud.retail_v2.types.ServingConfig: @@ -423,7 +457,7 @@ async def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -468,8 +502,10 @@ async def sample_delete_serving_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -524,7 +560,7 @@ async def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -584,8 +620,10 @@ async def sample_update_serving_config(): 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, 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: google.cloud.retail_v2.types.ServingConfig: @@ -654,7 +692,7 @@ async def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -701,8 +739,10 @@ async def sample_get_serving_config(): 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, 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: google.cloud.retail_v2.types.ServingConfig: @@ -767,7 +807,7 @@ async def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsAsyncPager: r"""Lists all ServingConfigs linked to this catalog. @@ -812,8 +852,10 @@ async def sample_list_serving_configs(): 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, 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: google.cloud.retail_v2.services.serving_config_service.pagers.ListServingConfigsAsyncPager: @@ -888,7 +930,7 @@ async def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -939,8 +981,10 @@ async def sample_add_control(): 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, 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: google.cloud.retail_v2.types.ServingConfig: @@ -1007,7 +1051,7 @@ async def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1054,8 +1098,10 @@ async def sample_remove_control(): 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, 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: google.cloud.retail_v2.types.ServingConfig: @@ -1119,7 +1165,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1130,8 +1176,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1172,7 +1220,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1183,8 +1231,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/client.py index 2833e0f596ff..042cc00f555f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -613,6 +623,10 @@ def __init__( # 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( @@ -679,6 +693,29 @@ def __init__( 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.retail_v2.ServingConfigServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "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.retail.v2.ServingConfigService", + "credentialsType": None, + }, + ) + def create_serving_config( self, request: Optional[ @@ -690,7 +727,7 @@ def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -763,8 +800,10 @@ def sample_create_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ServingConfig: @@ -830,7 +869,7 @@ def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -875,8 +914,10 @@ def sample_delete_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -928,7 +969,7 @@ def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -988,8 +1029,10 @@ def sample_update_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ServingConfig: @@ -1055,7 +1098,7 @@ def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -1102,8 +1145,10 @@ def sample_get_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ServingConfig: @@ -1165,7 +1210,7 @@ def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsPager: r"""Lists all ServingConfigs linked to this catalog. @@ -1210,8 +1255,10 @@ def sample_list_serving_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.services.serving_config_service.pagers.ListServingConfigsPager: @@ -1283,7 +1330,7 @@ def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -1334,8 +1381,10 @@ def sample_add_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ServingConfig: @@ -1399,7 +1448,7 @@ def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1446,8 +1495,10 @@ def sample_remove_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.ServingConfig: @@ -1521,7 +1572,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1532,8 +1583,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1574,7 +1627,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1585,8 +1638,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/pagers.py index 3a9c58f431a1..9efd0fc2206c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc.py index fa7d58994e24..27058afcef9a 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import serving_config from google.cloud.retail_v2.types import serving_config as gcr_serving_config @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport +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.retail.v2.ServingConfigService", + "rpcName": 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.retail.v2.ServingConfigService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcTransport(ServingConfigServiceTransport): """gRPC backend transport for ServingConfigService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -295,7 +381,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -324,7 +410,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -355,7 +441,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -384,7 +470,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -418,7 +504,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -448,7 +534,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -456,7 +542,7 @@ def remove_control( return self._stubs["remove_control"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -468,7 +554,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -487,7 +573,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc_asyncio.py index a796434d4513..102de4c9e92b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import serving_config from google.cloud.retail_v2.types import serving_config as gcr_serving_config @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .grpc import ServingConfigServiceGrpcTransport +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.retail.v2.ServingConfigService", + "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.retail.v2.ServingConfigService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcAsyncIOTransport(ServingConfigServiceTransport): """gRPC AsyncIO backend transport for ServingConfigService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -305,7 +390,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -334,7 +419,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -366,7 +451,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -395,7 +480,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -430,7 +515,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -461,7 +546,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -524,7 +609,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -540,7 +625,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -559,7 +644,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/rest.py index 68ea3e710f9c..b649454968b0 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/serving_config_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -126,8 +134,11 @@ def post_update_serving_config(self, response): def pre_add_control( self, request: serving_config_service.AddControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.AddControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.AddControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_control Override in a subclass to manipulate the request or metadata @@ -149,9 +160,10 @@ def post_add_control( def pre_create_serving_config( self, request: serving_config_service.CreateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.CreateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.CreateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_serving_config @@ -174,9 +186,10 @@ def post_create_serving_config( def pre_delete_serving_config( self, request: serving_config_service.DeleteServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.DeleteServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.DeleteServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_serving_config @@ -188,9 +201,10 @@ def pre_delete_serving_config( def pre_get_serving_config( self, request: serving_config_service.GetServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.GetServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.GetServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_serving_config @@ -213,9 +227,10 @@ def post_get_serving_config( def pre_list_serving_configs( self, request: serving_config_service.ListServingConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.ListServingConfigsRequest, Sequence[Tuple[str, str]] + serving_config_service.ListServingConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_serving_configs @@ -238,8 +253,11 @@ def post_list_serving_configs( def pre_remove_control( self, request: serving_config_service.RemoveControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.RemoveControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.RemoveControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_control Override in a subclass to manipulate the request or metadata @@ -261,9 +279,10 @@ def post_remove_control( def pre_update_serving_config( self, request: serving_config_service.UpdateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.UpdateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.UpdateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_serving_config @@ -286,8 +305,10 @@ def post_update_serving_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -309,8 +330,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -452,7 +475,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the add control method over HTTP. @@ -462,8 +485,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -477,6 +502,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseAddControl._get_http_options() ) + request, metadata = self._interceptor.pre_add_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseAddControl._get_transcoded_request( http_options, request @@ -491,6 +517,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.AddControl", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "AddControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._AddControl._get_response( self._host, @@ -512,7 +565,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2.ServingConfigServiceClient.add_control", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "AddControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServingConfig( @@ -551,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the create serving config method over HTTP. @@ -562,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -577,6 +656,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseCreateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_serving_config( request, metadata ) @@ -593,6 +673,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.CreateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "CreateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._CreateServingConfig._get_response( @@ -616,7 +723,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2.ServingConfigServiceClient.create_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "CreateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteServingConfig( @@ -654,7 +785,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete serving config method over HTTP. @@ -665,13 +796,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseServingConfigServiceRestTransport._BaseDeleteServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_serving_config( request, metadata ) @@ -684,6 +818,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.DeleteServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "DeleteServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._DeleteServingConfig._get_response( @@ -736,7 +897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Call the get serving config method over HTTP. @@ -746,8 +907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config.ServingConfig: @@ -761,6 +924,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_serving_config( request, metadata ) @@ -773,6 +937,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.GetServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "GetServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._GetServingConfig._get_response( @@ -795,7 +986,29 @@ def __call__( pb_resp = serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = serving_config.ServingConfig.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.retail_v2.ServingConfigServiceClient.get_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "GetServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServingConfigs( @@ -833,7 +1046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config_service.ListServingConfigsResponse: r"""Call the list serving configs method over HTTP. @@ -844,8 +1057,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config_service.ListServingConfigsResponse: @@ -857,6 +1072,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListServingConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_serving_configs( request, metadata ) @@ -869,6 +1085,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.ListServingConfigs", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "ListServingConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._ListServingConfigs._get_response( @@ -891,7 +1134,33 @@ def __call__( pb_resp = serving_config_service.ListServingConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_serving_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + serving_config_service.ListServingConfigsResponse.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.retail_v2.ServingConfigServiceClient.list_serving_configs", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "ListServingConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveControl( @@ -930,7 +1199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the remove control method over HTTP. @@ -940,8 +1209,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -955,6 +1226,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_http_options() ) + request, metadata = self._interceptor.pre_remove_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_transcoded_request( http_options, request @@ -969,6 +1241,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.RemoveControl", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "RemoveControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._RemoveControl._get_response( self._host, @@ -990,7 +1289,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2.ServingConfigServiceClient.remove_control", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "RemoveControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateServingConfig( @@ -1029,7 +1352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the update serving config method over HTTP. @@ -1040,8 +1363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -1055,6 +1380,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseUpdateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_serving_config( request, metadata ) @@ -1071,6 +1397,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.UpdateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "UpdateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._UpdateServingConfig._get_response( @@ -1094,7 +1447,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2.ServingConfigServiceClient.update_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "UpdateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1207,7 +1584,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1217,8 +1594,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1227,6 +1606,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1237,6 +1617,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._GetOperation._get_response( self._host, @@ -1256,6 +1663,27 @@ def __call__( 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.retail_v2.ServingConfigServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1297,7 +1725,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1307,8 +1735,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1317,6 +1747,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1327,6 +1758,33 @@ def __call__( 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.retail_v2.ServingConfigServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._ListOperations._get_response( self._host, @@ -1346,6 +1804,27 @@ def __call__( 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.retail_v2.ServingConfigServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.ServingConfigService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/async_client.py index 481c96bbaae1..833f6fe43f54 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -62,6 +63,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .transports.grpc_asyncio import UserEventServiceGrpcAsyncIOTransport +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 UserEventServiceAsyncClient: """Service for ingesting end user actions on the customer @@ -273,13 +283,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2.UserEventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "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.retail.v2.UserEventService", + "credentialsType": None, + }, + ) + async def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -321,8 +353,10 @@ async def sample_write_user_event(): 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, 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: google.cloud.retail_v2.types.UserEvent: @@ -372,7 +406,7 @@ async def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -417,8 +451,10 @@ async def sample_collect_user_event(): 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, 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: google.api.httpbody_pb2.HttpBody: @@ -508,7 +544,7 @@ async def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -554,8 +590,10 @@ async def sample_purge_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -612,7 +650,7 @@ async def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -664,8 +702,10 @@ async def sample_import_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -726,7 +766,7 @@ async def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -777,8 +817,10 @@ async def sample_rejoin_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -835,7 +877,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -846,8 +888,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -888,7 +932,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -899,8 +943,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/client.py index f8c127dd847f..c0b09ef6c4ae 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import httpbody_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -621,6 +631,10 @@ def __init__( # 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( @@ -687,13 +701,36 @@ def __init__( 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.retail_v2.UserEventServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "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.retail.v2.UserEventService", + "credentialsType": None, + }, + ) + def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -735,8 +772,10 @@ def sample_write_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2.types.UserEvent: @@ -784,7 +823,7 @@ def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -829,8 +868,10 @@ def sample_collect_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api.httpbody_pb2.HttpBody: @@ -918,7 +959,7 @@ def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -964,8 +1005,10 @@ def sample_purge_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1020,7 +1063,7 @@ def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -1072,8 +1115,10 @@ def sample_import_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1132,7 +1177,7 @@ def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -1183,8 +1228,10 @@ def sample_rejoin_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1252,7 +1299,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1263,8 +1310,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1305,7 +1354,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1316,8 +1365,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc.py index 624e55605837..8496f2c6139b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import ( import_config, @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport +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.retail.v2.UserEventService", + "rpcName": 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.retail.v2.UserEventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcTransport(UserEventServiceTransport): """gRPC backend transport for UserEventService. @@ -189,7 +270,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -253,7 +339,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -309,7 +397,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -339,7 +427,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +459,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -409,7 +497,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -417,7 +505,7 @@ def rejoin_user_events( return self._stubs["rejoin_user_events"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -429,7 +517,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -448,7 +536,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc_asyncio.py index 63fdd579a30d..99c1c9b42dd0 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2.types import ( import_config, @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .grpc import UserEventServiceGrpcTransport +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.retail.v2.UserEventService", + "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.retail.v2.UserEventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcAsyncIOTransport(UserEventServiceTransport): """gRPC AsyncIO backend transport for UserEventService. @@ -236,10 +318,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -262,7 +347,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -323,7 +408,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -355,7 +440,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -389,7 +474,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +513,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -501,7 +586,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -517,7 +602,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -536,7 +621,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/rest.py index 0d9b71c6ec3b..7d43276f9ca6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/services/user_event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ 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, @@ -117,8 +125,11 @@ def post_write_user_event(self, response): def pre_collect_user_event( self, request: user_event_service.CollectUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.CollectUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.CollectUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for collect_user_event Override in a subclass to manipulate the request or metadata @@ -140,8 +151,10 @@ def post_collect_user_event( def pre_import_user_events( self, request: import_config.ImportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_user_events Override in a subclass to manipulate the request or metadata @@ -163,8 +176,10 @@ def post_import_user_events( def pre_purge_user_events( self, request: purge_config.PurgeUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_user_events Override in a subclass to manipulate the request or metadata @@ -186,8 +201,11 @@ def post_purge_user_events( def pre_rejoin_user_events( self, request: user_event_service.RejoinUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.RejoinUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.RejoinUserEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for rejoin_user_events Override in a subclass to manipulate the request or metadata @@ -209,8 +227,11 @@ def post_rejoin_user_events( def pre_write_user_event( self, request: user_event_service.WriteUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.WriteUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.WriteUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for write_user_event Override in a subclass to manipulate the request or metadata @@ -232,8 +253,10 @@ def post_write_user_event( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -255,8 +278,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -459,7 +484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the collect user event method over HTTP. @@ -470,8 +495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.httpbody_pb2.HttpBody: @@ -530,6 +557,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseCollectUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_collect_user_event( request, metadata ) @@ -542,6 +570,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.CollectUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "CollectUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._CollectUserEvent._get_response( self._host, @@ -562,7 +617,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_collect_user_event(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.retail_v2.UserEventServiceClient.collect_user_event", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "CollectUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportUserEvents( @@ -601,7 +678,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import user events method over HTTP. @@ -612,8 +689,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -626,6 +705,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseImportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_import_user_events( request, metadata ) @@ -642,6 +722,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.ImportUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "ImportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ImportUserEvents._get_response( self._host, @@ -661,7 +768,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_user_events(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.retail_v2.UserEventServiceClient.import_user_events", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "ImportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeUserEvents( @@ -700,7 +829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge user events method over HTTP. @@ -711,8 +840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -725,6 +856,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BasePurgeUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_purge_user_events( request, metadata ) @@ -741,6 +873,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.PurgeUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "PurgeUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._PurgeUserEvents._get_response( self._host, @@ -760,7 +919,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_user_events(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.retail_v2.UserEventServiceClient.purge_user_events", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "PurgeUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RejoinUserEvents( @@ -799,7 +980,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the rejoin user events method over HTTP. @@ -810,8 +991,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -824,6 +1007,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseRejoinUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_rejoin_user_events( request, metadata ) @@ -840,6 +1024,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.RejoinUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "RejoinUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._RejoinUserEvents._get_response( self._host, @@ -859,7 +1070,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rejoin_user_events(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.retail_v2.UserEventServiceClient.rejoin_user_events", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "RejoinUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _WriteUserEvent( @@ -897,7 +1130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Call the write user event method over HTTP. @@ -908,8 +1141,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.user_event.UserEvent: @@ -923,6 +1158,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseWriteUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_write_user_event( request, metadata ) @@ -939,6 +1175,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.WriteUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "WriteUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._WriteUserEvent._get_response( self._host, @@ -960,7 +1223,29 @@ def __call__( pb_resp = user_event.UserEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_write_user_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = user_event.UserEvent.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.retail_v2.UserEventServiceClient.write_user_event", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "WriteUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1043,7 +1328,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1053,8 +1338,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1063,6 +1350,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1073,6 +1361,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._GetOperation._get_response( self._host, @@ -1092,6 +1407,27 @@ def __call__( 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.retail_v2.UserEventServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1132,7 +1468,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1142,8 +1478,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1152,6 +1490,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1162,6 +1501,33 @@ def __call__( 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.retail_v2.UserEventServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ListOperations._get_response( self._host, @@ -1181,6 +1547,27 @@ def __call__( 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.retail_v2.UserEventServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2.UserEventService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py index 2152db608ae5..558c8aab67c5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/async_client.py index 4576fcceb181..eb094aa0aabe 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .transports.grpc_asyncio import AnalyticsServiceGrpcAsyncIOTransport +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 AnalyticsServiceAsyncClient: """Service for managing & accessing retail search business @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.AnalyticsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "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.retail.v2alpha.AnalyticsService", + "credentialsType": None, + }, + ) + async def export_analytics_metrics( self, request: Optional[ @@ -269,7 +301,7 @@ async def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports analytics metrics. @@ -318,8 +350,10 @@ async def sample_export_analytics_metrics(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -378,7 +412,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -389,8 +423,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -431,7 +467,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -442,8 +478,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/client.py index 22d14f531ef5..ad57e899870f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -565,6 +575,10 @@ def __init__( # 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( @@ -631,6 +645,29 @@ def __init__( 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.retail_v2alpha.AnalyticsServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "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.retail.v2alpha.AnalyticsService", + "credentialsType": None, + }, + ) + def export_analytics_metrics( self, request: Optional[ @@ -639,7 +676,7 @@ def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports analytics metrics. @@ -688,8 +725,10 @@ def sample_export_analytics_metrics(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc.py index cee6ef2412ec..4bb067263490 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport +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.retail.v2alpha.AnalyticsService", + "rpcName": 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.retail.v2alpha.AnalyticsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcTransport(AnalyticsServiceTransport): """gRPC backend transport for AnalyticsService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -286,7 +374,7 @@ def export_analytics_metrics( return self._stubs["export_analytics_metrics"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -298,7 +386,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -317,7 +405,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc_asyncio.py index 43cb36b2d910..9ca8af5c1bae 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .grpc import AnalyticsServiceGrpcTransport +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.retail.v2alpha.AnalyticsService", + "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.retail.v2alpha.AnalyticsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcAsyncIOTransport(AnalyticsServiceTransport): """gRPC AsyncIO backend transport for AnalyticsService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +417,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -348,7 +433,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -367,7 +452,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/rest.py index 0485606ea30f..0012225008d2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/analytics_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,11 @@ def post_export_analytics_metrics(self, response): def pre_export_analytics_metrics( self, request: export_config.ExportAnalyticsMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportAnalyticsMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportAnalyticsMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for export_analytics_metrics Override in a subclass to manipulate the request or metadata @@ -102,8 +113,10 @@ def post_export_analytics_metrics( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +138,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -335,7 +350,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export analytics metrics method over HTTP. @@ -346,8 +361,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -360,6 +377,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseExportAnalyticsMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_export_analytics_metrics( request, metadata ) @@ -376,6 +394,33 @@ def __call__( 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.retail_v2alpha.AnalyticsServiceClient.ExportAnalyticsMetrics", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsServiceRestTransport._ExportAnalyticsMetrics._get_response( @@ -397,7 +442,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_analytics_metrics(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.retail_v2alpha.AnalyticsServiceClient.export_analytics_metrics", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -448,7 +515,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -458,8 +525,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -468,6 +537,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -478,6 +548,33 @@ def __call__( 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.retail_v2alpha.AnalyticsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._GetOperation._get_response( self._host, @@ -497,6 +594,27 @@ def __call__( 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.retail_v2alpha.AnalyticsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -537,7 +655,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -547,8 +665,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -557,6 +677,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -567,6 +688,33 @@ def __call__( 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.retail_v2alpha.AnalyticsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._ListOperations._get_response( self._host, @@ -586,6 +734,27 @@ def __call__( 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.retail_v2alpha.AnalyticsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.AnalyticsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/async_client.py index bdb252bcdf77..7477563aa07b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, BranchServiceTransport from .transports.grpc_asyncio import BranchServiceGrpcAsyncIOTransport +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 BranchServiceAsyncClient: """Service for [Branch][google.cloud.retail.v2alpha.Branch] Management @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.BranchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "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.retail.v2alpha.BranchService", + "credentialsType": None, + }, + ) + async def list_branches( self, request: Optional[Union[branch_service.ListBranchesRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_branches( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch_service.ListBranchesResponse: r"""Lists all instances of [Branch][google.cloud.retail.v2alpha.Branch] under the specified @@ -322,8 +354,10 @@ async def sample_list_branches(): 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, 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: google.cloud.retail_v2alpha.types.ListBranchesResponse: @@ -385,7 +419,7 @@ async def get_branch( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch.Branch: r"""Retrieves a [Branch][google.cloud.retail.v2alpha.Branch]. @@ -434,8 +468,10 @@ async def sample_get_branch(): 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, 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: google.cloud.retail_v2alpha.types.Branch: @@ -495,7 +531,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -506,8 +542,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -548,7 +586,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -559,8 +597,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/client.py index 45273a120b77..915a4be3e171 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -636,6 +646,10 @@ def __init__( # 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( @@ -701,6 +715,29 @@ def __init__( 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.retail_v2alpha.BranchServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "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.retail.v2alpha.BranchService", + "credentialsType": None, + }, + ) + def list_branches( self, request: Optional[Union[branch_service.ListBranchesRequest, dict]] = None, @@ -708,7 +745,7 @@ def list_branches( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch_service.ListBranchesResponse: r"""Lists all instances of [Branch][google.cloud.retail.v2alpha.Branch] under the specified @@ -755,8 +792,10 @@ def sample_list_branches(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ListBranchesResponse: @@ -815,7 +854,7 @@ def get_branch( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch.Branch: r"""Retrieves a [Branch][google.cloud.retail.v2alpha.Branch]. @@ -864,8 +903,10 @@ def sample_get_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Branch: @@ -935,7 +976,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -946,8 +987,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -988,7 +1031,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -999,8 +1042,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc.py index ba62b2210f91..83ef8c26c5b1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import branch, branch_service from .base import DEFAULT_CLIENT_INFO, BranchServiceTransport +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.retail.v2alpha.BranchService", + "rpcName": 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.retail.v2alpha.BranchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BranchServiceGrpcTransport(BranchServiceTransport): """gRPC backend transport for BranchService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +351,7 @@ def list_branches( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_branches" not in self._stubs: - self._stubs["list_branches"] = self.grpc_channel.unary_unary( + self._stubs["list_branches"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.BranchService/ListBranches", request_serializer=branch_service.ListBranchesRequest.serialize, response_deserializer=branch_service.ListBranchesResponse.deserialize, @@ -289,7 +375,7 @@ def get_branch(self) -> Callable[[branch_service.GetBranchRequest], branch.Branc # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_branch" not in self._stubs: - self._stubs["get_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.BranchService/GetBranch", request_serializer=branch_service.GetBranchRequest.serialize, response_deserializer=branch.Branch.deserialize, @@ -297,7 +383,7 @@ def get_branch(self) -> Callable[[branch_service.GetBranchRequest], branch.Branc return self._stubs["get_branch"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -309,7 +395,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -328,7 +414,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc_asyncio.py index ba36d03cc32a..b1157fd90e21 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import branch, branch_service from .base import DEFAULT_CLIENT_INFO, BranchServiceTransport from .grpc import BranchServiceGrpcTransport +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.retail.v2alpha.BranchService", + "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.retail.v2alpha.BranchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BranchServiceGrpcAsyncIOTransport(BranchServiceTransport): """gRPC AsyncIO backend transport for BranchService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def list_branches( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_branches" not in self._stubs: - self._stubs["list_branches"] = self.grpc_channel.unary_unary( + self._stubs["list_branches"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.BranchService/ListBranches", request_serializer=branch_service.ListBranchesRequest.serialize, response_deserializer=branch_service.ListBranchesResponse.deserialize, @@ -300,7 +385,7 @@ def get_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_branch" not in self._stubs: - self._stubs["get_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.BranchService/GetBranch", request_serializer=branch_service.GetBranchRequest.serialize, response_deserializer=branch.Branch.deserialize, @@ -338,7 +423,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -354,7 +439,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -373,7 +458,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/rest.py index f89f96c01630..b66c1fa163f6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/branch_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -87,8 +95,10 @@ def post_list_branches(self, response): def pre_get_branch( self, request: branch_service.GetBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[branch_service.GetBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + branch_service.GetBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_branch Override in a subclass to manipulate the request or metadata @@ -108,8 +118,10 @@ def post_get_branch(self, response: branch.Branch) -> branch.Branch: def pre_list_branches( self, request: branch_service.ListBranchesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[branch_service.ListBranchesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + branch_service.ListBranchesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_branches Override in a subclass to manipulate the request or metadata @@ -131,8 +143,10 @@ def post_list_branches( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -154,8 +168,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -301,7 +317,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch.Branch: r"""Call the get branch method over HTTP. @@ -313,8 +329,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.branch.Branch: @@ -326,6 +344,7 @@ def __call__( http_options = ( _BaseBranchServiceRestTransport._BaseGetBranch._get_http_options() ) + request, metadata = self._interceptor.pre_get_branch(request, metadata) transcoded_request = ( _BaseBranchServiceRestTransport._BaseGetBranch._get_transcoded_request( @@ -340,6 +359,33 @@ def __call__( ) ) + 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.retail_v2alpha.BranchServiceClient.GetBranch", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "GetBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BranchServiceRestTransport._GetBranch._get_response( self._host, @@ -360,7 +406,29 @@ def __call__( pb_resp = branch.Branch.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_branch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = branch.Branch.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.retail_v2alpha.BranchServiceClient.get_branch", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "GetBranch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBranches( @@ -397,7 +465,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> branch_service.ListBranchesResponse: r"""Call the list branches method over HTTP. @@ -409,8 +477,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.branch_service.ListBranchesResponse: @@ -423,6 +493,7 @@ def __call__( http_options = ( _BaseBranchServiceRestTransport._BaseListBranches._get_http_options() ) + request, metadata = self._interceptor.pre_list_branches(request, metadata) transcoded_request = _BaseBranchServiceRestTransport._BaseListBranches._get_transcoded_request( http_options, request @@ -433,6 +504,33 @@ def __call__( 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.retail_v2alpha.BranchServiceClient.ListBranches", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "ListBranches", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BranchServiceRestTransport._ListBranches._get_response( self._host, @@ -453,7 +551,31 @@ def __call__( pb_resp = branch_service.ListBranchesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_branches(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = branch_service.ListBranchesResponse.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.retail_v2alpha.BranchServiceClient.list_branches", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "ListBranches", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -510,7 +632,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -520,8 +642,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -530,6 +654,7 @@ def __call__( http_options = ( _BaseBranchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseBranchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -540,6 +665,33 @@ def __call__( 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.retail_v2alpha.BranchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BranchServiceRestTransport._GetOperation._get_response( self._host, @@ -559,6 +711,27 @@ def __call__( 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.retail_v2alpha.BranchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -599,7 +772,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -609,8 +782,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -619,6 +794,7 @@ def __call__( http_options = ( _BaseBranchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseBranchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -629,6 +805,33 @@ def __call__( 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.retail_v2alpha.BranchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BranchServiceRestTransport._ListOperations._get_response( self._host, @@ -648,6 +851,27 @@ def __call__( 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.retail_v2alpha.BranchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.BranchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/async_client.py index 76878b2445d5..f335411b2087 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .transports.grpc_asyncio import CatalogServiceGrpcAsyncIOTransport +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 CatalogServiceAsyncClient: """Service for managing catalog configuration.""" @@ -271,6 +281,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.CatalogServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "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.retail.v2alpha.CatalogService", + "credentialsType": None, + }, + ) + async def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -278,7 +310,7 @@ async def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsAsyncPager: r"""Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project. @@ -330,8 +362,10 @@ async def sample_list_catalogs(): 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, 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: google.cloud.retail_v2alpha.services.catalog_service.pagers.ListCatalogsAsyncPager: @@ -408,7 +442,7 @@ async def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. @@ -477,8 +511,10 @@ async def sample_update_catalog(): 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, 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: google.cloud.retail_v2alpha.types.Catalog: @@ -541,7 +577,7 @@ async def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], @@ -615,8 +651,10 @@ async def sample_set_default_branch(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -668,7 +706,7 @@ async def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] @@ -713,8 +751,10 @@ async def sample_get_default_branch(): 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, 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: google.cloud.retail_v2alpha.types.GetDefaultBranchResponse: @@ -777,7 +817,7 @@ async def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. @@ -823,8 +863,10 @@ async def sample_get_completion_config(): 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, 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: google.cloud.retail_v2alpha.types.CompletionConfig: @@ -889,7 +931,7 @@ async def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. @@ -962,8 +1004,10 @@ async def sample_update_completion_config(): 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, 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: google.cloud.retail_v2alpha.types.CompletionConfig: @@ -1031,7 +1075,7 @@ async def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. @@ -1077,8 +1121,10 @@ async def sample_get_attributes_config(): 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, 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1140,7 +1186,7 @@ async def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. @@ -1211,8 +1257,10 @@ async def sample_update_attributes_config(): 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, 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1276,7 +1324,7 @@ async def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -1325,8 +1373,10 @@ async def sample_add_catalog_attribute(): 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, 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1374,7 +1424,7 @@ async def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -1420,8 +1470,10 @@ async def sample_remove_catalog_attribute(): 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, 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1469,7 +1521,7 @@ async def batch_remove_catalog_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Removes all specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s @@ -1511,8 +1563,10 @@ async def sample_batch_remove_catalog_attributes(): 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, 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: google.cloud.retail_v2alpha.types.BatchRemoveCatalogAttributesResponse: @@ -1562,7 +1616,7 @@ async def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -1613,8 +1667,10 @@ async def sample_replace_catalog_attribute(): 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, 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1660,7 +1716,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1671,8 +1727,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1713,7 +1771,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1724,8 +1782,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/client.py index 0953efc92f06..23272b63c370 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -653,6 +663,10 @@ def __init__( # 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( @@ -718,6 +732,29 @@ def __init__( 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.retail_v2alpha.CatalogServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "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.retail.v2alpha.CatalogService", + "credentialsType": None, + }, + ) + def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -725,7 +762,7 @@ def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsPager: r"""Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project. @@ -777,8 +814,10 @@ def sample_list_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.services.catalog_service.pagers.ListCatalogsPager: @@ -852,7 +891,7 @@ def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. @@ -921,8 +960,10 @@ def sample_update_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Catalog: @@ -982,7 +1023,7 @@ def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], @@ -1056,8 +1097,10 @@ def sample_set_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1106,7 +1149,7 @@ def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] @@ -1151,8 +1194,10 @@ def sample_get_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.GetDefaultBranchResponse: @@ -1212,7 +1257,7 @@ def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. @@ -1258,8 +1303,10 @@ def sample_get_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.CompletionConfig: @@ -1321,7 +1368,7 @@ def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. @@ -1394,8 +1441,10 @@ def sample_update_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.CompletionConfig: @@ -1460,7 +1509,7 @@ def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. @@ -1506,8 +1555,10 @@ def sample_get_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1566,7 +1617,7 @@ def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. @@ -1637,8 +1688,10 @@ def sample_update_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1699,7 +1752,7 @@ def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -1748,8 +1801,10 @@ def sample_add_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1795,7 +1850,7 @@ def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -1841,8 +1896,10 @@ def sample_remove_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -1888,7 +1945,7 @@ def batch_remove_catalog_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Removes all specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s @@ -1930,8 +1987,10 @@ def sample_batch_remove_catalog_attributes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.BatchRemoveCatalogAttributesResponse: @@ -1981,7 +2040,7 @@ def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] @@ -2032,8 +2091,10 @@ def sample_replace_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AttributesConfig: @@ -2092,7 +2153,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2103,8 +2164,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2145,7 +2208,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2156,8 +2219,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/pagers.py index 700aba610f7b..b76bf41ecbe1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc.py index ae04f0d971ad..ce46c26fdc6a 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import catalog from google.cloud.retail_v2alpha.types import catalog as gcr_catalog @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport +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.retail.v2alpha.CatalogService", + "rpcName": 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.retail.v2alpha.CatalogService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcTransport(CatalogServiceTransport): """gRPC backend transport for CatalogService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -287,7 +373,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -347,7 +433,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -378,7 +464,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -407,7 +493,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -436,7 +522,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -465,7 +551,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -503,7 +589,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -538,7 +624,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -573,7 +659,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -608,7 +694,7 @@ def batch_remove_catalog_attributes( if "batch_remove_catalog_attributes" not in self._stubs: self._stubs[ "batch_remove_catalog_attributes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/BatchRemoveCatalogAttributes", request_serializer=catalog_service.BatchRemoveCatalogAttributesRequest.serialize, response_deserializer=catalog_service.BatchRemoveCatalogAttributesResponse.deserialize, @@ -645,7 +731,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -653,7 +739,7 @@ def replace_catalog_attribute( return self._stubs["replace_catalog_attribute"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -665,7 +751,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -684,7 +770,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc_asyncio.py index 1a3120463217..5e6d537fb020 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import catalog from google.cloud.retail_v2alpha.types import catalog as gcr_catalog @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .grpc import CatalogServiceGrpcTransport +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.retail.v2alpha.CatalogService", + "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.retail.v2alpha.CatalogService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcAsyncIOTransport(CatalogServiceTransport): """gRPC AsyncIO backend transport for CatalogService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -298,7 +383,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -360,7 +445,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +476,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -421,7 +506,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -451,7 +536,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -481,7 +566,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -520,7 +605,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -556,7 +641,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -592,7 +677,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -627,7 +712,7 @@ def batch_remove_catalog_attributes( if "batch_remove_catalog_attributes" not in self._stubs: self._stubs[ "batch_remove_catalog_attributes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/BatchRemoveCatalogAttributes", request_serializer=catalog_service.BatchRemoveCatalogAttributesRequest.serialize, response_deserializer=catalog_service.BatchRemoveCatalogAttributesResponse.deserialize, @@ -665,7 +750,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -753,7 +838,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -769,7 +854,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -788,7 +873,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/rest.py index 1214c4675a68..f423b8de1495 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/catalog_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -166,8 +174,11 @@ def post_update_completion_config(self, response): def pre_add_catalog_attribute( self, request: catalog_service.AddCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.AddCatalogAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.AddCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_catalog_attribute Override in a subclass to manipulate the request or metadata @@ -189,9 +200,10 @@ def post_add_catalog_attribute( def pre_batch_remove_catalog_attributes( self, request: catalog_service.BatchRemoveCatalogAttributesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.BatchRemoveCatalogAttributesRequest, Sequence[Tuple[str, str]] + catalog_service.BatchRemoveCatalogAttributesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_remove_catalog_attributes @@ -214,8 +226,11 @@ def post_batch_remove_catalog_attributes( def pre_get_attributes_config( self, request: catalog_service.GetAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetAttributesConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_attributes_config Override in a subclass to manipulate the request or metadata @@ -237,8 +252,11 @@ def post_get_attributes_config( def pre_get_completion_config( self, request: catalog_service.GetCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetCompletionConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_completion_config Override in a subclass to manipulate the request or metadata @@ -260,8 +278,10 @@ def post_get_completion_config( def pre_get_default_branch( self, request: catalog_service.GetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_default_branch Override in a subclass to manipulate the request or metadata @@ -283,8 +303,10 @@ def post_get_default_branch( def pre_list_catalogs( self, request: catalog_service.ListCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.ListCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.ListCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_catalogs Override in a subclass to manipulate the request or metadata @@ -306,9 +328,10 @@ def post_list_catalogs( def pre_remove_catalog_attribute( self, request: catalog_service.RemoveCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.RemoveCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.RemoveCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_catalog_attribute @@ -331,9 +354,10 @@ def post_remove_catalog_attribute( def pre_replace_catalog_attribute( self, request: catalog_service.ReplaceCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.ReplaceCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.ReplaceCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for replace_catalog_attribute @@ -356,8 +380,10 @@ def post_replace_catalog_attribute( def pre_set_default_branch( self, request: catalog_service.SetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_default_branch Override in a subclass to manipulate the request or metadata @@ -368,9 +394,10 @@ def pre_set_default_branch( def pre_update_attributes_config( self, request: catalog_service.UpdateAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateAttributesConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_attributes_config @@ -393,8 +420,10 @@ def post_update_attributes_config( def pre_update_catalog( self, request: catalog_service.UpdateCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_catalog Override in a subclass to manipulate the request or metadata @@ -414,9 +443,10 @@ def post_update_catalog(self, response: gcr_catalog.Catalog) -> gcr_catalog.Cata def pre_update_completion_config( self, request: catalog_service.UpdateCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateCompletionConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_completion_config @@ -439,8 +469,10 @@ def post_update_completion_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -462,8 +494,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -605,7 +639,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the add catalog attribute method over HTTP. @@ -617,8 +651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -628,6 +664,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseAddCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_add_catalog_attribute( request, metadata ) @@ -644,6 +681,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.AddCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "AddCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._AddCatalogAttribute._get_response( self._host, @@ -665,7 +729,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2alpha.CatalogServiceClient.add_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "AddCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchRemoveCatalogAttributes( @@ -704,7 +790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Call the batch remove catalog attributes method over HTTP. @@ -717,8 +803,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.BatchRemoveCatalogAttributesResponse: @@ -730,6 +818,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseBatchRemoveCatalogAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_remove_catalog_attributes( request, metadata ) @@ -746,6 +835,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.BatchRemoveCatalogAttributes", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "BatchRemoveCatalogAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._BatchRemoveCatalogAttributes._get_response( @@ -769,7 +885,33 @@ def __call__( pb_resp = catalog_service.BatchRemoveCatalogAttributesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_remove_catalog_attributes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + catalog_service.BatchRemoveCatalogAttributesResponse.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.retail_v2alpha.CatalogServiceClient.batch_remove_catalog_attributes", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "BatchRemoveCatalogAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttributesConfig( @@ -807,7 +949,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the get attributes config method over HTTP. @@ -819,8 +961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -830,6 +974,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_attributes_config( request, metadata ) @@ -842,6 +987,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.GetAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetAttributesConfig._get_response( self._host, @@ -862,7 +1034,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2alpha.CatalogServiceClient.get_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCompletionConfig( @@ -900,7 +1094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the get completion config method over HTTP. @@ -912,8 +1106,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -926,6 +1122,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_completion_config( request, metadata ) @@ -938,6 +1135,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.GetCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetCompletionConfig._get_response( self._host, @@ -958,7 +1182,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2alpha.CatalogServiceClient.get_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDefaultBranch( @@ -995,7 +1241,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Call the get default branch method over HTTP. @@ -1006,8 +1252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.GetDefaultBranchResponse: @@ -1019,6 +1267,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_get_default_branch( request, metadata ) @@ -1031,6 +1280,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.GetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetDefaultBranch._get_response( self._host, @@ -1051,7 +1327,31 @@ def __call__( pb_resp = catalog_service.GetDefaultBranchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_default_branch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.GetDefaultBranchResponse.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.retail_v2alpha.CatalogServiceClient.get_default_branch", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetDefaultBranch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogs( @@ -1088,7 +1388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.ListCatalogsResponse: r"""Call the list catalogs method over HTTP. @@ -1100,8 +1400,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.ListCatalogsResponse: @@ -1114,6 +1416,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalogs(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListCatalogs._get_transcoded_request( http_options, request @@ -1124,6 +1427,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.ListCatalogs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ListCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListCatalogs._get_response( self._host, @@ -1144,7 +1474,31 @@ def __call__( pb_resp = catalog_service.ListCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.ListCatalogsResponse.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.retail_v2alpha.CatalogServiceClient.list_catalogs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ListCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveCatalogAttribute( @@ -1183,7 +1537,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the remove catalog attribute method over HTTP. @@ -1195,8 +1549,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1206,6 +1562,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseRemoveCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_remove_catalog_attribute( request, metadata ) @@ -1222,6 +1579,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.RemoveCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._RemoveCatalogAttribute._get_response( @@ -1245,7 +1629,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2alpha.CatalogServiceClient.remove_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReplaceCatalogAttribute( @@ -1284,7 +1690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the replace catalog attribute method over HTTP. @@ -1296,8 +1702,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1307,6 +1715,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseReplaceCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_replace_catalog_attribute( request, metadata ) @@ -1323,6 +1732,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.ReplaceCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._ReplaceCatalogAttribute._get_response( @@ -1346,7 +1782,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_replace_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2alpha.CatalogServiceClient.replace_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDefaultBranch( @@ -1384,7 +1842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the set default branch method over HTTP. @@ -1395,13 +1853,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCatalogServiceRestTransport._BaseSetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_set_default_branch( request, metadata ) @@ -1418,6 +1879,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.SetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "SetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._SetDefaultBranch._get_response( self._host, @@ -1470,7 +1958,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the update attributes config method over HTTP. @@ -1482,8 +1970,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1493,6 +1983,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_attributes_config( request, metadata ) @@ -1509,6 +2000,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.UpdateAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateAttributesConfig._get_response( @@ -1532,7 +2050,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2alpha.CatalogServiceClient.update_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCatalog( @@ -1570,7 +2110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Call the update catalog method over HTTP. @@ -1582,8 +2122,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_catalog.Catalog: @@ -1593,6 +2135,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_update_catalog(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_transcoded_request( http_options, request @@ -1607,6 +2150,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.UpdateCatalog", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._UpdateCatalog._get_response( self._host, @@ -1628,7 +2198,29 @@ def __call__( pb_resp = gcr_catalog.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_catalog.Catalog.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.retail_v2alpha.CatalogServiceClient.update_catalog", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCompletionConfig( @@ -1667,7 +2259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the update completion config method over HTTP. @@ -1679,8 +2271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -1693,6 +2287,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_completion_config( request, metadata ) @@ -1709,6 +2304,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.UpdateCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateCompletionConfig._get_response( @@ -1732,7 +2354,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2alpha.CatalogServiceClient.update_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "UpdateCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1891,7 +2535,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1901,8 +2545,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1911,6 +2557,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1921,6 +2568,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetOperation._get_response( self._host, @@ -1940,6 +2614,27 @@ def __call__( 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.retail_v2alpha.CatalogServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1980,7 +2675,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1990,8 +2685,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2000,6 +2697,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2010,6 +2708,33 @@ def __call__( 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.retail_v2alpha.CatalogServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListOperations._get_response( self._host, @@ -2029,6 +2754,27 @@ def __call__( 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.retail_v2alpha.CatalogServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CatalogService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/async_client.py index d5277fdcd8b6..4a670a414c41 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .transports.grpc_asyncio import CompletionServiceGrpcAsyncIOTransport +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 CompletionServiceAsyncClient: """Autocomplete service for retail. @@ -267,13 +277,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.CompletionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "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.retail.v2alpha.CompletionService", + "credentialsType": None, + }, + ) + async def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -314,8 +346,10 @@ async def sample_complete_query(): 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, 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: google.cloud.retail_v2alpha.types.CompleteQueryResponse: @@ -361,7 +395,7 @@ async def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of processed completion dataset. @@ -418,8 +452,10 @@ async def sample_import_completion_data(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -479,7 +515,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -490,8 +526,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -532,7 +570,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -543,8 +581,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/client.py index 0c0a4886984c..d8082e6699b6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -591,6 +601,10 @@ def __init__( # 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( @@ -657,13 +671,36 @@ def __init__( 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.retail_v2alpha.CompletionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "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.retail.v2alpha.CompletionService", + "credentialsType": None, + }, + ) + def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -704,8 +741,10 @@ def sample_complete_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.CompleteQueryResponse: @@ -749,7 +788,7 @@ def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of processed completion dataset. @@ -806,8 +845,10 @@ def sample_import_completion_data(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -878,7 +919,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -889,8 +930,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -931,7 +974,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -942,8 +985,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc.py index f7d0dcd39d74..7060327947b8 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport +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.retail.v2alpha.CompletionService", + "rpcName": 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.retail.v2alpha.CompletionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcTransport(CompletionServiceTransport): """gRPC backend transport for CompletionService. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -320,7 +408,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -328,7 +416,7 @@ def import_completion_data( return self._stubs["import_completion_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -340,7 +428,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -359,7 +447,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc_asyncio.py index 299b8098fafa..16eec808a395 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .grpc import CompletionServiceGrpcTransport +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.retail.v2alpha.CompletionService", + "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.retail.v2alpha.CompletionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcAsyncIOTransport(CompletionServiceTransport): """gRPC AsyncIO backend transport for CompletionService. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -330,7 +415,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +453,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -384,7 +469,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -403,7 +488,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/rest.py index 2a968445dbc4..dfdabead1caf 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/completion_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -87,8 +95,10 @@ def post_import_completion_data(self, response): def pre_complete_query( self, request: completion_service.CompleteQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[completion_service.CompleteQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + completion_service.CompleteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_query Override in a subclass to manipulate the request or metadata @@ -110,8 +120,11 @@ def post_complete_query( def pre_import_completion_data( self, request: import_config.ImportCompletionDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportCompletionDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportCompletionDataRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for import_completion_data Override in a subclass to manipulate the request or metadata @@ -133,8 +146,10 @@ def post_import_completion_data( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -156,8 +171,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -367,7 +384,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Call the complete query method over HTTP. @@ -377,8 +394,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.completion_service.CompleteQueryResponse: @@ -388,6 +407,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_http_options() ) + request, metadata = self._interceptor.pre_complete_query(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_transcoded_request( http_options, request @@ -398,6 +418,33 @@ def __call__( 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.retail_v2alpha.CompletionServiceClient.CompleteQuery", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "CompleteQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._CompleteQuery._get_response( self._host, @@ -418,7 +465,31 @@ def __call__( pb_resp = completion_service.CompleteQueryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = completion_service.CompleteQueryResponse.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.retail_v2alpha.CompletionServiceClient.complete_query", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "CompleteQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportCompletionData( @@ -457,7 +528,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import completion data method over HTTP. @@ -468,8 +539,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -482,6 +555,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseImportCompletionData._get_http_options() ) + request, metadata = self._interceptor.pre_import_completion_data( request, metadata ) @@ -498,6 +572,33 @@ def __call__( 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.retail_v2alpha.CompletionServiceClient.ImportCompletionData", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "ImportCompletionData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CompletionServiceRestTransport._ImportCompletionData._get_response( @@ -519,7 +620,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_completion_data(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.retail_v2alpha.CompletionServiceClient.import_completion_data", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "ImportCompletionData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -581,7 +704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -591,8 +714,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -601,6 +726,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -611,6 +737,33 @@ def __call__( 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.retail_v2alpha.CompletionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._GetOperation._get_response( self._host, @@ -630,6 +783,27 @@ def __call__( 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.retail_v2alpha.CompletionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -671,7 +845,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -681,8 +855,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -691,6 +867,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -701,6 +878,33 @@ def __call__( 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.retail_v2alpha.CompletionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._ListOperations._get_response( self._host, @@ -720,6 +924,27 @@ def __call__( 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.retail_v2alpha.CompletionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.CompletionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/async_client.py index 82ad66f96f56..2686da93f26c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .transports.grpc_asyncio import ControlServiceGrpcAsyncIOTransport +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 ControlServiceAsyncClient: """Service for modifying Control.""" @@ -263,6 +273,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.ControlServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "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.retail.v2alpha.ControlService", + "credentialsType": None, + }, + ) + async def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -272,7 +304,7 @@ async def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -341,8 +373,10 @@ async def sample_create_control(): 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, 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: google.cloud.retail_v2alpha.types.Control: @@ -409,7 +443,7 @@ async def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -453,8 +487,10 @@ async def sample_delete_control(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -507,7 +543,7 @@ async def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -570,8 +606,10 @@ async def sample_update_control(): 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, 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: google.cloud.retail_v2alpha.types.Control: @@ -638,7 +676,7 @@ async def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -682,8 +720,10 @@ async def sample_get_control(): 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, 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: google.cloud.retail_v2alpha.types.Control: @@ -746,7 +786,7 @@ async def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsAsyncPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2alpha.Catalog]. @@ -791,8 +831,10 @@ async def sample_list_controls(): 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, 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: google.cloud.retail_v2alpha.services.control_service.pagers.ListControlsAsyncPager: @@ -866,7 +908,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -877,8 +919,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -919,7 +963,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -930,8 +974,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/client.py index a56f52e23a74..852f59054240 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -609,6 +619,10 @@ def __init__( # 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( @@ -674,6 +688,29 @@ def __init__( 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.retail_v2alpha.ControlServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "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.retail.v2alpha.ControlService", + "credentialsType": None, + }, + ) + def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -683,7 +720,7 @@ def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -752,8 +789,10 @@ def sample_create_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Control: @@ -817,7 +856,7 @@ def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -861,8 +900,10 @@ def sample_delete_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -912,7 +953,7 @@ def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -975,8 +1016,10 @@ def sample_update_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Control: @@ -1040,7 +1083,7 @@ def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -1084,8 +1127,10 @@ def sample_get_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Control: @@ -1145,7 +1190,7 @@ def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2alpha.Catalog]. @@ -1190,8 +1235,10 @@ def sample_list_controls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.services.control_service.pagers.ListControlsPager: @@ -1275,7 +1322,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1286,8 +1333,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1328,7 +1377,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1339,8 +1388,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/pagers.py index 7fe8585bd9a0..39213e9577d6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc.py index 8e4f4ff55d23..33133edd22ff 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import control from google.cloud.retail_v2alpha.types import control as gcr_control @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport +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.retail.v2alpha.ControlService", + "rpcName": 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.retail.v2alpha.ControlService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcTransport(ControlServiceTransport): """gRPC backend transport for ControlService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -290,7 +376,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -321,7 +407,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -347,7 +433,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -376,7 +462,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -384,7 +470,7 @@ def list_controls( return self._stubs["list_controls"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -396,7 +482,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -415,7 +501,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc_asyncio.py index 851daf618229..91e563d61c5d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import control from google.cloud.retail_v2alpha.types import control as gcr_control @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .grpc import ControlServiceGrpcTransport +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.retail.v2alpha.ControlService", + "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.retail.v2alpha.ControlService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcAsyncIOTransport(ControlServiceTransport): """gRPC AsyncIO backend transport for ControlService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -300,7 +385,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -333,7 +418,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -359,7 +444,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -389,7 +474,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -442,7 +527,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -458,7 +543,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -477,7 +562,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/rest.py index ad409376f21d..2e9decfc8e7d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/control_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -110,8 +118,10 @@ def post_update_control(self, response): def pre_create_control( self, request: control_service.CreateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.CreateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.CreateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_control Override in a subclass to manipulate the request or metadata @@ -131,8 +141,10 @@ def post_create_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_delete_control( self, request: control_service.DeleteControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.DeleteControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.DeleteControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_control Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def pre_delete_control( def pre_get_control( self, request: control_service.GetControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.GetControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.GetControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_control Override in a subclass to manipulate the request or metadata @@ -164,8 +178,10 @@ def post_get_control(self, response: control.Control) -> control.Control: def pre_list_controls( self, request: control_service.ListControlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.ListControlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.ListControlsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_controls Override in a subclass to manipulate the request or metadata @@ -187,8 +203,10 @@ def post_list_controls( def pre_update_control( self, request: control_service.UpdateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.UpdateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.UpdateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_control Override in a subclass to manipulate the request or metadata @@ -208,8 +226,10 @@ def post_update_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -231,8 +251,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -373,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the create control method over HTTP. @@ -383,8 +405,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -398,6 +422,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseCreateControl._get_http_options() ) + request, metadata = self._interceptor.pre_create_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseCreateControl._get_transcoded_request( http_options, request @@ -412,6 +437,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.CreateControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "CreateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._CreateControl._get_response( self._host, @@ -433,7 +485,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2alpha.ControlServiceClient.create_control", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "CreateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteControl( @@ -470,7 +544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete control method over HTTP. @@ -480,13 +554,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseControlServiceRestTransport._BaseDeleteControl._get_http_options() ) + request, metadata = self._interceptor.pre_delete_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseDeleteControl._get_transcoded_request( http_options, request @@ -497,6 +574,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.DeleteControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "DeleteControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._DeleteControl._get_response( self._host, @@ -546,7 +650,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Call the get control method over HTTP. @@ -556,8 +660,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control.Control: @@ -571,6 +677,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetControl._get_http_options() ) + request, metadata = self._interceptor.pre_get_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetControl._get_transcoded_request( http_options, request @@ -583,6 +690,33 @@ def __call__( ) ) + 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.retail_v2alpha.ControlServiceClient.GetControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "GetControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetControl._get_response( self._host, @@ -603,7 +737,29 @@ def __call__( pb_resp = control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control.Control.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.retail_v2alpha.ControlServiceClient.get_control", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "GetControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListControls( @@ -640,7 +796,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control_service.ListControlsResponse: r"""Call the list controls method over HTTP. @@ -650,8 +806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control_service.ListControlsResponse: @@ -661,6 +819,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListControls._get_http_options() ) + request, metadata = self._interceptor.pre_list_controls(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListControls._get_transcoded_request( http_options, request @@ -671,6 +830,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.ListControls", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "ListControls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListControls._get_response( self._host, @@ -691,7 +877,31 @@ def __call__( pb_resp = control_service.ListControlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_controls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control_service.ListControlsResponse.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.retail_v2alpha.ControlServiceClient.list_controls", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "ListControls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateControl( @@ -729,7 +939,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the update control method over HTTP. @@ -739,8 +949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -754,6 +966,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseUpdateControl._get_http_options() ) + request, metadata = self._interceptor.pre_update_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseUpdateControl._get_transcoded_request( http_options, request @@ -768,6 +981,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.UpdateControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "UpdateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._UpdateControl._get_response( self._host, @@ -789,7 +1029,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2alpha.ControlServiceClient.update_control", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "UpdateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -872,7 +1134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -882,8 +1144,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -892,6 +1156,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -902,6 +1167,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetOperation._get_response( self._host, @@ -921,6 +1213,27 @@ def __call__( 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.retail_v2alpha.ControlServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -961,7 +1274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -971,8 +1284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -981,6 +1296,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -991,6 +1307,33 @@ def __call__( 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.retail_v2alpha.ControlServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListOperations._get_response( self._host, @@ -1010,6 +1353,27 @@ def __call__( 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.retail_v2alpha.ControlServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ControlService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/async_client.py index 89b7bd19a6ab..6d7e8f148c35 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .transports.grpc_asyncio import GenerativeQuestionServiceGrpcAsyncIOTransport +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 GenerativeQuestionServiceAsyncClient: """Service for managing LLM generated questions in search @@ -276,6 +286,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.GenerativeQuestionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "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.retail.v2alpha.GenerativeQuestionService", + "credentialsType": None, + }, + ) + async def update_generative_questions_feature_config( self, request: Optional[ @@ -291,7 +323,7 @@ async def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -349,8 +381,10 @@ async def sample_update_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig: @@ -432,7 +466,7 @@ async def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -479,8 +513,10 @@ async def sample_get_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig: @@ -552,7 +588,7 @@ async def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -596,8 +632,10 @@ async def sample_list_generative_question_configs(): 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, 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: google.cloud.retail_v2alpha.types.ListGenerativeQuestionConfigsResponse: @@ -667,7 +705,7 @@ async def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -725,8 +763,10 @@ async def sample_update_generative_question_config(): 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, 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: google.cloud.retail_v2alpha.types.GenerativeQuestionConfig: @@ -810,7 +850,7 @@ async def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -867,8 +907,10 @@ async def sample_batch_update_generative_question_configs(): 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, 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: google.cloud.retail_v2alpha.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -937,7 +979,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -948,8 +990,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -990,7 +1034,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1001,8 +1045,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/client.py index 5ce1211f066b..27e23f2b0553 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -594,6 +604,10 @@ def __init__( # 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( @@ -660,6 +674,29 @@ def __init__( 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.retail_v2alpha.GenerativeQuestionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "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.retail.v2alpha.GenerativeQuestionService", + "credentialsType": None, + }, + ) + def update_generative_questions_feature_config( self, request: Optional[ @@ -675,7 +712,7 @@ def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -733,8 +770,10 @@ def sample_update_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig: @@ -815,7 +854,7 @@ def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -862,8 +901,10 @@ def sample_get_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig: @@ -934,7 +975,7 @@ def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -978,8 +1019,10 @@ def sample_list_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ListGenerativeQuestionConfigsResponse: @@ -1048,7 +1091,7 @@ def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -1106,8 +1149,10 @@ def sample_update_generative_question_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.GenerativeQuestionConfig: @@ -1190,7 +1235,7 @@ def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -1247,8 +1292,10 @@ def sample_batch_update_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -1329,7 +1376,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1340,8 +1387,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1382,7 +1431,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1393,8 +1442,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc.py index 7776c6e3c4b3..74cbce8bb4f9 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import ( generative_question, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport +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.retail.v2alpha.GenerativeQuestionService", + "rpcName": 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.retail.v2alpha.GenerativeQuestionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcTransport(GenerativeQuestionServiceTransport): """gRPC backend transport for GenerativeQuestionService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -299,7 +385,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -331,7 +417,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -363,7 +449,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -395,7 +481,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -403,7 +489,7 @@ def batch_update_generative_question_configs( return self._stubs["batch_update_generative_question_configs"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -415,7 +501,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -434,7 +520,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc_asyncio.py index 15e22eff4245..05ab6d5b9973 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import ( generative_question, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .grpc import GenerativeQuestionServiceGrpcTransport +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.retail.v2alpha.GenerativeQuestionService", + "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.retail.v2alpha.GenerativeQuestionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcAsyncIOTransport(GenerativeQuestionServiceTransport): """gRPC AsyncIO backend transport for GenerativeQuestionService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -307,7 +392,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -339,7 +424,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -371,7 +456,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -405,7 +490,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -458,7 +543,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -474,7 +559,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -493,7 +578,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/rest.py index baef8a16930f..f094e752e2ba 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/generative_question_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -114,10 +122,10 @@ def post_update_generative_questions_feature_config(self, response): def pre_batch_update_generative_question_configs( self, request: generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_update_generative_question_configs @@ -141,10 +149,10 @@ def post_batch_update_generative_question_configs( def pre_get_generative_questions_feature_config( self, request: generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_generative_questions_feature_config @@ -167,10 +175,10 @@ def post_get_generative_questions_feature_config( def pre_list_generative_question_configs( self, request: generative_question_service.ListGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.ListGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_generative_question_configs @@ -194,10 +202,10 @@ def post_list_generative_question_configs( def pre_update_generative_question_config( self, request: generative_question_service.UpdateGenerativeQuestionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_question_config @@ -220,10 +228,10 @@ def post_update_generative_question_config( def pre_update_generative_questions_feature_config( self, request: generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_questions_feature_config @@ -246,8 +254,10 @@ def post_update_generative_questions_feature_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -269,8 +279,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -417,7 +429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Call the batch update generative question configs method over HTTP. @@ -430,8 +442,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: @@ -443,6 +457,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseBatchUpdateGenerativeQuestionConfigs._get_http_options() ) + ( request, metadata, @@ -462,6 +477,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.BatchUpdateGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._BatchUpdateGenerativeQuestionConfigs._get_response( self._host, @@ -487,7 +529,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.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.retail_v2alpha.GenerativeQuestionServiceClient.batch_update_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGenerativeQuestionsFeatureConfig( @@ -527,7 +593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the get generative questions feature config method over HTTP. @@ -540,8 +606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -553,6 +621,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -568,6 +637,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.GetGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._GetGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -588,7 +684,33 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_generative_questions_feature_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2alpha.GenerativeQuestionServiceClient.get_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGenerativeQuestionConfigs( @@ -628,7 +750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Call the list generative question configs method over HTTP. @@ -639,8 +761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.ListGenerativeQuestionConfigsResponse: @@ -650,6 +774,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListGenerativeQuestionConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_generative_question_configs( request, metadata ) @@ -662,6 +787,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.ListGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._ListGenerativeQuestionConfigs._get_response( self._host, @@ -686,7 +838,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.ListGenerativeQuestionConfigsResponse.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.retail_v2alpha.GenerativeQuestionServiceClient.list_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionConfig( @@ -727,7 +903,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Call the update generative question config method over HTTP. @@ -739,8 +915,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionConfig: @@ -752,6 +930,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_generative_question_config( request, metadata ) @@ -768,6 +947,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.UpdateGenerativeQuestionConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionConfig._get_response( self._host, @@ -789,7 +995,31 @@ def __call__( pb_resp = generative_question.GenerativeQuestionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_question_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionConfig.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.retail_v2alpha.GenerativeQuestionServiceClient.update_generative_question_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionsFeatureConfig( @@ -830,7 +1060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the update generative questions feature config method over HTTP. @@ -843,8 +1073,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -856,6 +1088,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -875,6 +1108,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.UpdateGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -896,9 +1156,35 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_questions_feature_config( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2alpha.GenerativeQuestionServiceClient.update_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -995,7 +1281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1005,8 +1291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1015,6 +1303,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1025,6 +1314,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._GetOperation._get_response( @@ -1046,6 +1362,27 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1087,7 +1424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1097,8 +1434,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1107,6 +1446,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1117,6 +1457,33 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._ListOperations._get_response( @@ -1138,6 +1505,27 @@ def __call__( 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.retail_v2alpha.GenerativeQuestionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/async_client.py index b94b2042464f..217d90e28164 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -62,6 +63,15 @@ MerchantCenterAccountLinkServiceGrpcAsyncIOTransport, ) +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 MerchantCenterAccountLinkServiceAsyncClient: """Merchant Center Link service to link a Branch to a Merchant @@ -289,6 +299,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.MerchantCenterAccountLinkServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "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.retail.v2alpha.MerchantCenterAccountLinkService", + "credentialsType": None, + }, + ) + async def list_merchant_center_account_links( self, request: Optional[ @@ -301,7 +333,7 @@ async def list_merchant_center_account_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse: r"""Lists all [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s @@ -350,8 +382,10 @@ async def sample_list_merchant_center_account_links(): 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, 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: google.cloud.retail_v2alpha.types.ListMerchantCenterAccountLinksResponse: @@ -426,7 +460,7 @@ async def create_merchant_center_account_link( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. @@ -495,8 +529,10 @@ async def sample_create_merchant_center_account_link(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -581,7 +617,7 @@ async def delete_merchant_center_account_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. @@ -627,8 +663,10 @@ async def sample_delete_merchant_center_account_link(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -684,7 +722,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -695,8 +733,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -737,7 +777,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -748,8 +788,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/client.py index f423d43df81a..ce918ca13bb3 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -629,6 +639,10 @@ def __init__( # 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( @@ -699,6 +713,29 @@ def __init__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "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.retail.v2alpha.MerchantCenterAccountLinkService", + "credentialsType": None, + }, + ) + def list_merchant_center_account_links( self, request: Optional[ @@ -711,7 +748,7 @@ def list_merchant_center_account_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse: r"""Lists all [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s @@ -760,8 +797,10 @@ def sample_list_merchant_center_account_links(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ListMerchantCenterAccountLinksResponse: @@ -835,7 +874,7 @@ def create_merchant_center_account_link( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. @@ -904,8 +943,10 @@ def sample_create_merchant_center_account_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -989,7 +1030,7 @@ def delete_merchant_center_account_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. @@ -1035,8 +1076,10 @@ def sample_delete_merchant_center_account_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1104,7 +1147,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1115,8 +1158,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1157,7 +1202,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1168,8 +1213,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc.py index c1c7ac54275f..364ebb837136 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import merchant_center_account_link_service from .base import DEFAULT_CLIENT_INFO, MerchantCenterAccountLinkServiceTransport +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.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": 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.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MerchantCenterAccountLinkServiceGrpcTransport( MerchantCenterAccountLinkServiceTransport @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -283,7 +371,7 @@ def list_merchant_center_account_links( if "list_merchant_center_account_links" not in self._stubs: self._stubs[ "list_merchant_center_account_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/ListMerchantCenterAccountLinks", request_serializer=merchant_center_account_link_service.ListMerchantCenterAccountLinksRequest.serialize, response_deserializer=merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse.deserialize, @@ -316,7 +404,7 @@ def create_merchant_center_account_link( if "create_merchant_center_account_link" not in self._stubs: self._stubs[ "create_merchant_center_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/CreateMerchantCenterAccountLink", request_serializer=merchant_center_account_link_service.CreateMerchantCenterAccountLinkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -352,7 +440,7 @@ def delete_merchant_center_account_link( if "delete_merchant_center_account_link" not in self._stubs: self._stubs[ "delete_merchant_center_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/DeleteMerchantCenterAccountLink", request_serializer=merchant_center_account_link_service.DeleteMerchantCenterAccountLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -360,7 +448,7 @@ def delete_merchant_center_account_link( return self._stubs["delete_merchant_center_account_link"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -372,7 +460,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -391,7 +479,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc_asyncio.py index 192c96f377ef..03a647694782 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import merchant_center_account_link_service from .base import DEFAULT_CLIENT_INFO, MerchantCenterAccountLinkServiceTransport from .grpc import MerchantCenterAccountLinkServiceGrpcTransport +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.retail.v2alpha.MerchantCenterAccountLinkService", + "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.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MerchantCenterAccountLinkServiceGrpcAsyncIOTransport( MerchantCenterAccountLinkServiceTransport @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -295,7 +380,7 @@ def list_merchant_center_account_links( if "list_merchant_center_account_links" not in self._stubs: self._stubs[ "list_merchant_center_account_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/ListMerchantCenterAccountLinks", request_serializer=merchant_center_account_link_service.ListMerchantCenterAccountLinksRequest.serialize, response_deserializer=merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse.deserialize, @@ -328,7 +413,7 @@ def create_merchant_center_account_link( if "create_merchant_center_account_link" not in self._stubs: self._stubs[ "create_merchant_center_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/CreateMerchantCenterAccountLink", request_serializer=merchant_center_account_link_service.CreateMerchantCenterAccountLinkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -364,7 +449,7 @@ def delete_merchant_center_account_link( if "delete_merchant_center_account_link" not in self._stubs: self._stubs[ "delete_merchant_center_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.MerchantCenterAccountLinkService/DeleteMerchantCenterAccountLink", request_serializer=merchant_center_account_link_service.DeleteMerchantCenterAccountLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -407,7 +492,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -423,7 +508,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -442,7 +527,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/rest.py index a1373fc58aad..a676d3562f6c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/merchant_center_account_link_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -92,10 +100,10 @@ def post_list_merchant_center_account_links(self, response): def pre_create_merchant_center_account_link( self, request: merchant_center_account_link_service.CreateMerchantCenterAccountLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ merchant_center_account_link_service.CreateMerchantCenterAccountLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_merchant_center_account_link @@ -118,10 +126,10 @@ def post_create_merchant_center_account_link( def pre_delete_merchant_center_account_link( self, request: merchant_center_account_link_service.DeleteMerchantCenterAccountLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ merchant_center_account_link_service.DeleteMerchantCenterAccountLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_merchant_center_account_link @@ -133,10 +141,10 @@ def pre_delete_merchant_center_account_link( def pre_list_merchant_center_account_links( self, request: merchant_center_account_link_service.ListMerchantCenterAccountLinksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ merchant_center_account_link_service.ListMerchantCenterAccountLinksRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_merchant_center_account_links @@ -160,8 +168,10 @@ def post_list_merchant_center_account_links( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -183,8 +193,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -398,7 +410,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create merchant center account link method over HTTP. @@ -411,8 +423,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -425,6 +439,7 @@ def __call__( http_options = ( _BaseMerchantCenterAccountLinkServiceRestTransport._BaseCreateMerchantCenterAccountLink._get_http_options() ) + ( request, metadata, @@ -444,6 +459,33 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.CreateMerchantCenterAccountLink", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "CreateMerchantCenterAccountLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MerchantCenterAccountLinkServiceRestTransport._CreateMerchantCenterAccountLink._get_response( self._host, @@ -463,7 +505,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_merchant_center_account_link(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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.create_merchant_center_account_link", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "CreateMerchantCenterAccountLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteMerchantCenterAccountLink( @@ -503,7 +567,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete merchant center account link method over HTTP. @@ -516,13 +580,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseMerchantCenterAccountLinkServiceRestTransport._BaseDeleteMerchantCenterAccountLink._get_http_options() ) + ( request, metadata, @@ -538,6 +605,33 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.DeleteMerchantCenterAccountLink", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "DeleteMerchantCenterAccountLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MerchantCenterAccountLinkServiceRestTransport._DeleteMerchantCenterAccountLink._get_response( self._host, @@ -590,7 +684,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse ): @@ -605,8 +699,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse: @@ -619,6 +715,7 @@ def __call__( http_options = ( _BaseMerchantCenterAccountLinkServiceRestTransport._BaseListMerchantCenterAccountLinks._get_http_options() ) + ( request, metadata, @@ -634,6 +731,33 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.ListMerchantCenterAccountLinks", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "ListMerchantCenterAccountLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MerchantCenterAccountLinkServiceRestTransport._ListMerchantCenterAccountLinks._get_response( self._host, @@ -658,7 +782,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_merchant_center_account_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse.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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.list_merchant_center_account_links", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "ListMerchantCenterAccountLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -733,7 +881,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -743,8 +891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -753,6 +903,7 @@ def __call__( http_options = ( _BaseMerchantCenterAccountLinkServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseMerchantCenterAccountLinkServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -763,6 +914,33 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MerchantCenterAccountLinkServiceRestTransport._GetOperation._get_response( self._host, @@ -782,6 +960,27 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -823,7 +1022,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -833,8 +1032,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -843,6 +1044,7 @@ def __call__( http_options = ( _BaseMerchantCenterAccountLinkServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseMerchantCenterAccountLinkServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -853,6 +1055,33 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MerchantCenterAccountLinkServiceRestTransport._ListOperations._get_response( self._host, @@ -872,6 +1101,27 @@ def __call__( 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.retail_v2alpha.MerchantCenterAccountLinkServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/async_client.py index 69a82aebcbce..683f49ab357b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +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 ModelServiceAsyncClient: """Service for performing CRUD operations on models. Recommendation @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "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.retail.v2alpha.ModelService", + "credentialsType": None, + }, + ) + async def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -282,7 +314,7 @@ async def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new model. @@ -346,8 +378,10 @@ async def sample_create_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -424,7 +458,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -469,8 +503,10 @@ async def sample_get_model(): 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, 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: google.cloud.retail_v2alpha.types.Model: @@ -535,7 +571,7 @@ async def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -579,8 +615,10 @@ async def sample_pause_model(): 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, 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: google.cloud.retail_v2alpha.types.Model: @@ -645,7 +683,7 @@ async def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -689,8 +727,10 @@ async def sample_resume_model(): 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, 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: google.cloud.retail_v2alpha.types.Model: @@ -755,7 +795,7 @@ async def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -797,8 +837,10 @@ async def sample_delete_model(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -850,7 +892,7 @@ async def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsAsyncPager: r"""Lists all the models linked to this event store. @@ -895,8 +937,10 @@ async def sample_list_models(): 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, 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: google.cloud.retail_v2alpha.services.model_service.pagers.ListModelsAsyncPager: @@ -972,7 +1016,7 @@ async def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1034,8 +1078,10 @@ async def sample_update_model(): 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, 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: google.cloud.retail_v2alpha.types.Model: @@ -1104,7 +1150,7 @@ async def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Tunes an existing model. @@ -1155,8 +1201,10 @@ async def sample_tune_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1227,7 +1275,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1238,8 +1286,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1280,7 +1330,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1291,8 +1341,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/client.py index 67d5862881dd..7c75aeafc75e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -684,6 +698,29 @@ def __init__( 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.retail_v2alpha.ModelServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "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.retail.v2alpha.ModelService", + "credentialsType": None, + }, + ) + def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -692,7 +729,7 @@ def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new model. @@ -756,8 +793,10 @@ def sample_create_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -831,7 +870,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -876,8 +915,10 @@ def sample_get_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2alpha.types.Model: @@ -939,7 +980,7 @@ def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -983,8 +1024,10 @@ def sample_pause_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2alpha.types.Model: @@ -1046,7 +1089,7 @@ def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -1090,8 +1133,10 @@ def sample_resume_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2alpha.types.Model: @@ -1153,7 +1198,7 @@ def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -1195,8 +1240,10 @@ def sample_delete_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1245,7 +1292,7 @@ def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsPager: r"""Lists all the models linked to this event store. @@ -1290,8 +1337,10 @@ def sample_list_models(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2alpha.services.model_service.pagers.ListModelsPager: @@ -1364,7 +1413,7 @@ def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1426,8 +1475,10 @@ def sample_update_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2alpha.types.Model: @@ -1493,7 +1544,7 @@ def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Tunes an existing model. @@ -1544,8 +1595,10 @@ def sample_tune_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1626,7 +1679,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1637,8 +1690,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1679,7 +1734,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1690,8 +1745,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/pagers.py index 66c3564b307e..f605fa8e3ddd 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc.py index 56c21d13e42d..37bd62820ab3 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import model from google.cloud.retail_v2alpha.types import model as gcr_model @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +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.retail.v2alpha.ModelService", + "rpcName": 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.retail.v2alpha.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -196,7 +277,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -284,7 +372,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -308,7 +396,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -332,7 +420,7 @@ def pause_model(self) -> Callable[[model_service.PauseModelRequest], model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -356,7 +444,7 @@ def resume_model(self) -> Callable[[model_service.ResumeModelRequest], model.Mod # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -382,7 +470,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -408,7 +496,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -436,7 +524,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -462,7 +550,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -470,7 +558,7 @@ def tune_model( return self._stubs["tune_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -482,7 +570,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -501,7 +589,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc_asyncio.py index 5d900fffde56..d1b42f907db5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import model from google.cloud.retail_v2alpha.types import model as gcr_model @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +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.retail.v2alpha.ModelService", + "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.retail.v2alpha.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -243,10 +325,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -296,7 +381,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -322,7 +407,7 @@ def get_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -348,7 +433,7 @@ def pause_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -374,7 +459,7 @@ def resume_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -400,7 +485,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -428,7 +513,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -456,7 +541,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -484,7 +569,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +637,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -568,7 +653,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -587,7 +672,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/rest.py index 00071804a735..0d7620150100 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/model_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -134,8 +142,10 @@ def post_update_model(self, response): def pre_create_model( self, request: model_service.CreateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.CreateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -157,8 +167,10 @@ def post_create_model( def pre_delete_model( self, request: model_service.DeleteModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.DeleteModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -169,8 +181,8 @@ def pre_delete_model( def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -213,8 +227,10 @@ def post_list_models( def pre_pause_model( self, request: model_service.PauseModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.PauseModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.PauseModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_model Override in a subclass to manipulate the request or metadata @@ -234,8 +250,10 @@ def post_pause_model(self, response: model.Model) -> model.Model: def pre_resume_model( self, request: model_service.ResumeModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ResumeModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ResumeModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_model Override in a subclass to manipulate the request or metadata @@ -255,8 +273,8 @@ def post_resume_model(self, response: model.Model) -> model.Model: def pre_tune_model( self, request: model_service.TuneModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for tune_model Override in a subclass to manipulate the request or metadata @@ -278,8 +296,10 @@ def post_tune_model( def pre_update_model( self, request: model_service.UpdateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.UpdateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.UpdateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_model Override in a subclass to manipulate the request or metadata @@ -299,8 +319,10 @@ def post_update_model(self, response: gcr_model.Model) -> gcr_model.Model: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -322,8 +344,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -540,7 +564,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -550,8 +574,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -564,6 +590,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseCreateModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseCreateModel._get_transcoded_request( @@ -584,6 +611,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.CreateModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CreateModel._get_response( self._host, @@ -603,7 +657,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.retail_v2alpha.ModelServiceClient.create_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteModel( @@ -640,7 +716,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete model method over HTTP. @@ -650,13 +726,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_transcoded_request( @@ -671,6 +750,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.DeleteModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._DeleteModel._get_response( self._host, @@ -718,7 +824,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -728,8 +834,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -746,6 +854,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -760,6 +869,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -780,7 +916,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2alpha.ModelServiceClient.get_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -817,7 +975,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -828,8 +986,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model_service.ListModelsResponse: @@ -839,6 +999,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -853,6 +1014,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -873,7 +1061,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.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.retail_v2alpha.ModelServiceClient.list_models", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseModel( @@ -911,7 +1123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the pause model method over HTTP. @@ -922,8 +1134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -940,6 +1154,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BasePauseModel._get_http_options() ) + request, metadata = self._interceptor.pre_pause_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BasePauseModel._get_transcoded_request( @@ -960,6 +1175,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.PauseModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "PauseModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._PauseModel._get_response( self._host, @@ -981,7 +1223,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2alpha.ModelServiceClient.pause_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "PauseModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeModel( @@ -1019,7 +1283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the resume model method over HTTP. @@ -1030,8 +1294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -1048,6 +1314,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseResumeModel._get_http_options() ) + request, metadata = self._interceptor.pre_resume_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseResumeModel._get_transcoded_request( @@ -1068,6 +1335,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.ResumeModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ResumeModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ResumeModel._get_response( self._host, @@ -1089,7 +1383,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2alpha.ModelServiceClient.resume_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ResumeModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TuneModel( @@ -1127,7 +1443,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the tune model method over HTTP. @@ -1140,8 +1456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1154,6 +1472,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseTuneModel._get_http_options() ) + request, metadata = self._interceptor.pre_tune_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseTuneModel._get_transcoded_request( @@ -1172,6 +1491,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.TuneModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "TuneModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._TuneModel._get_response( self._host, @@ -1191,7 +1537,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tune_model(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.retail_v2alpha.ModelServiceClient.tune_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "TuneModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateModel( @@ -1229,7 +1597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Call the update model method over HTTP. @@ -1240,8 +1608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_model.Model: @@ -1258,6 +1628,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_http_options() ) + request, metadata = self._interceptor.pre_update_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_transcoded_request( @@ -1278,6 +1649,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.UpdateModel", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "UpdateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._UpdateModel._get_response( self._host, @@ -1299,7 +1697,29 @@ def __call__( pb_resp = gcr_model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_model.Model.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.retail_v2alpha.ModelServiceClient.update_model", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "UpdateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1398,7 +1818,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1408,8 +1828,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1418,6 +1840,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1430,6 +1853,33 @@ def __call__( ) ) + 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.retail_v2alpha.ModelServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetOperation._get_response( self._host, @@ -1449,6 +1899,27 @@ def __call__( 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.retail_v2alpha.ModelServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1489,7 +1960,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1499,8 +1970,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1509,6 +1982,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1519,6 +1993,33 @@ def __call__( 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.retail_v2alpha.ModelServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListOperations._get_response( self._host, @@ -1538,6 +2039,27 @@ def __call__( 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.retail_v2alpha.ModelServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ModelService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/async_client.py index 07fc3bc061f4..c11444d7f847 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """Service for making recommendation prediction.""" @@ -260,13 +270,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "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.retail.v2alpha.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -307,8 +339,10 @@ async def sample_predict(): 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, 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: google.cloud.retail_v2alpha.types.PredictResponse: @@ -352,7 +386,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -363,8 +397,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -405,7 +441,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -416,8 +452,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/client.py index 2491b6a48cad..c4f21cb0be00 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -588,6 +598,10 @@ def __init__( # 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( @@ -654,13 +668,36 @@ def __init__( 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.retail_v2alpha.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "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.retail.v2alpha.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -701,8 +738,10 @@ def sample_predict(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.PredictResponse: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc.py index e482180e963f..81af38185270 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.retail.v2alpha.PredictionService", + "rpcName": 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.retail.v2alpha.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -265,7 +351,7 @@ def predict( return self._stubs["predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -277,7 +363,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -296,7 +382,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc_asyncio.py index d4cdbcea31d4..6c3b9366776e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.retail.v2alpha.PredictionService", + "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.retail.v2alpha.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -299,7 +384,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -315,7 +400,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -334,7 +419,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/rest.py index a6a6a8ac6623..e5047b444943 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/prediction_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,10 @@ def post_predict(self, response): def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_predict( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +137,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -277,8 +291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_service.PredictResponse: @@ -288,6 +304,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + 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.retail_v2alpha.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.retail_v2alpha.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -408,6 +479,33 @@ def __call__( 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.retail_v2alpha.PredictionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._GetOperation._get_response( self._host, @@ -427,6 +525,27 @@ def __call__( 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.retail_v2alpha.PredictionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -468,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -478,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -488,6 +609,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -498,6 +620,33 @@ def __call__( 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.retail_v2alpha.PredictionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._ListOperations._get_response( self._host, @@ -517,6 +666,27 @@ def __call__( 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.retail_v2alpha.PredictionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.PredictionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/async_client.py index cb1998073ee9..572de0f5dbcf 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .transports.grpc_asyncio import ProductServiceGrpcAsyncIOTransport +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 ProductServiceAsyncClient: """Service for ingesting [Product][google.cloud.retail.v2alpha.Product] @@ -270,6 +280,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.ProductServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "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.retail.v2alpha.ProductService", + "credentialsType": None, + }, + ) + async def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -279,7 +311,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2alpha.Product]. @@ -361,8 +393,10 @@ async def sample_create_product(): 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, 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: google.cloud.retail_v2alpha.types.Product: @@ -428,7 +462,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2alpha.Product]. @@ -483,8 +517,10 @@ async def sample_get_product(): 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, 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: google.cloud.retail_v2alpha.types.Product: @@ -546,7 +582,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. @@ -599,8 +635,10 @@ async def sample_list_products(): 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, 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: google.cloud.retail_v2alpha.services.product_service.pagers.ListProductsAsyncPager: @@ -677,7 +715,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2alpha.Product]. @@ -752,8 +790,10 @@ async def sample_update_product(): 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, 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: google.cloud.retail_v2alpha.types.Product: @@ -819,7 +859,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2alpha.Product]. @@ -885,8 +925,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -937,7 +979,7 @@ async def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. @@ -998,8 +1040,10 @@ async def sample_purge_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1056,7 +1100,7 @@ async def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. @@ -1108,8 +1152,10 @@ async def sample_import_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1169,7 +1215,7 @@ async def export_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports multiple [Product][google.cloud.retail.v2alpha.Product]s. @@ -1215,8 +1261,10 @@ async def sample_export_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1276,7 +1324,7 @@ async def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting @@ -1457,8 +1505,10 @@ async def sample_set_inventory(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1537,7 +1587,7 @@ async def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] @@ -1625,8 +1675,10 @@ async def sample_add_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1701,7 +1753,7 @@ async def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] @@ -1789,8 +1841,10 @@ async def sample_remove_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1865,7 +1919,7 @@ async def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of @@ -1951,8 +2005,10 @@ async def sample_add_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2029,7 +2085,7 @@ async def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of @@ -2113,8 +2169,10 @@ async def sample_remove_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2188,7 +2246,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2199,8 +2257,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2241,7 +2301,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2252,8 +2312,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/client.py index 2b99d87bb068..25a3db649cff 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -620,6 +630,10 @@ def __init__( # 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( @@ -685,6 +699,29 @@ def __init__( 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.retail_v2alpha.ProductServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "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.retail.v2alpha.ProductService", + "credentialsType": None, + }, + ) + def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -694,7 +731,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2alpha.Product]. @@ -776,8 +813,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Product: @@ -840,7 +879,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2alpha.Product]. @@ -895,8 +934,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Product: @@ -955,7 +996,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. @@ -1008,8 +1049,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.services.product_service.pagers.ListProductsPager: @@ -1083,7 +1126,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2alpha.Product]. @@ -1158,8 +1201,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Product: @@ -1222,7 +1267,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2alpha.Product]. @@ -1288,8 +1333,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1337,7 +1384,7 @@ def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. @@ -1398,8 +1445,10 @@ def sample_purge_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1454,7 +1503,7 @@ def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. @@ -1506,8 +1555,10 @@ def sample_import_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1565,7 +1616,7 @@ def export_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports multiple [Product][google.cloud.retail.v2alpha.Product]s. @@ -1611,8 +1662,10 @@ def sample_export_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1670,7 +1723,7 @@ def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting @@ -1851,8 +1904,10 @@ def sample_set_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1928,7 +1983,7 @@ def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] @@ -2016,8 +2071,10 @@ def sample_add_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2089,7 +2146,7 @@ def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] @@ -2177,8 +2234,10 @@ def sample_remove_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2252,7 +2311,7 @@ def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of @@ -2338,8 +2397,10 @@ def sample_add_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2413,7 +2474,7 @@ def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of @@ -2497,8 +2558,10 @@ def sample_remove_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2582,7 +2645,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2593,8 +2656,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2635,7 +2700,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2646,8 +2711,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/pagers.py index 0d7bce26e1d4..ad29eca7af9b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc.py index 8614dd3dfd8b..c8306c25a262 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import export_config, import_config from google.cloud.retail_v2alpha.types import product @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport +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.retail.v2alpha.ProductService", + "rpcName": 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.retail.v2alpha.ProductService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcTransport(ProductServiceTransport): """gRPC backend transport for ProductService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -301,7 +389,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -329,7 +417,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -355,7 +443,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -381,7 +469,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -426,7 +514,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +548,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -487,7 +575,7 @@ def export_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_products" not in self._stubs: - self._stubs["export_products"] = self.grpc_channel.unary_unary( + self._stubs["export_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ExportProducts", request_serializer=export_config.ExportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -565,7 +653,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +712,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -683,7 +771,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -742,7 +830,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -798,7 +886,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -806,7 +894,7 @@ def remove_local_inventories( return self._stubs["remove_local_inventories"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -818,7 +906,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -837,7 +925,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc_asyncio.py index 2528eaf5b441..6f6b7d8301fc 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import export_config, import_config from google.cloud.retail_v2alpha.types import product @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .grpc import ProductServiceGrpcTransport +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.retail.v2alpha.ProductService", + "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.retail.v2alpha.ProductService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcAsyncIOTransport(ProductServiceTransport): """gRPC AsyncIO backend transport for ProductService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -313,7 +398,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -342,7 +427,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -370,7 +455,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -396,7 +481,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +528,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -508,7 +593,7 @@ def export_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_products" not in self._stubs: - self._stubs["export_products"] = self.grpc_channel.unary_unary( + self._stubs["export_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/ExportProducts", request_serializer=export_config.ExportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -588,7 +673,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -648,7 +733,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -708,7 +793,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -768,7 +853,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -825,7 +910,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -928,7 +1013,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -944,7 +1029,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -963,7 +1048,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/rest.py index 0db441a1c382..bec06b3f8b1f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/product_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -175,8 +183,11 @@ def post_update_product(self, response): def pre_add_fulfillment_places( self, request: product_service.AddFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddFulfillmentPlacesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_fulfillment_places Override in a subclass to manipulate the request or metadata @@ -198,8 +209,11 @@ def post_add_fulfillment_places( def pre_add_local_inventories( self, request: product_service.AddLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddLocalInventoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_local_inventories Override in a subclass to manipulate the request or metadata @@ -221,8 +235,10 @@ def post_add_local_inventories( def pre_create_product( self, request: product_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.CreateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -242,8 +258,10 @@ def post_create_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_delete_product( self, request: product_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.DeleteProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -254,8 +272,10 @@ def pre_delete_product( def pre_export_products( self, request: export_config.ExportProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_products Override in a subclass to manipulate the request or metadata @@ -277,8 +297,10 @@ def post_export_products( def pre_get_product( self, request: product_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.GetProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -298,8 +320,10 @@ def post_get_product(self, response: product.Product) -> product.Product: def pre_import_products( self, request: import_config.ImportProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_products Override in a subclass to manipulate the request or metadata @@ -321,8 +345,10 @@ def post_import_products( def pre_list_products( self, request: product_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.ListProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -344,8 +370,10 @@ def post_list_products( def pre_purge_products( self, request: purge_config.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -367,9 +395,10 @@ def post_purge_products( def pre_remove_fulfillment_places( self, request: product_service.RemoveFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveFulfillmentPlacesRequest, Sequence[Tuple[str, str]] + product_service.RemoveFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_fulfillment_places @@ -392,9 +421,10 @@ def post_remove_fulfillment_places( def pre_remove_local_inventories( self, request: product_service.RemoveLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveLocalInventoriesRequest, Sequence[Tuple[str, str]] + product_service.RemoveLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_local_inventories @@ -417,8 +447,10 @@ def post_remove_local_inventories( def pre_set_inventory( self, request: product_service.SetInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.SetInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.SetInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_inventory Override in a subclass to manipulate the request or metadata @@ -440,8 +472,10 @@ def post_set_inventory( def pre_update_product( self, request: product_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.UpdateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -461,8 +495,10 @@ def post_update_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -484,8 +520,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -693,7 +731,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add fulfillment places method over HTTP. @@ -705,8 +743,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -719,6 +759,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_add_fulfillment_places( request, metadata ) @@ -735,6 +776,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.AddFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "AddFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddFulfillmentPlaces._get_response( self._host, @@ -754,7 +822,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_fulfillment_places(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.retail_v2alpha.ProductServiceClient.add_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "AddFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddLocalInventories( @@ -793,7 +883,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add local inventories method over HTTP. @@ -805,8 +895,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -819,6 +911,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_add_local_inventories( request, metadata ) @@ -835,6 +928,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.AddLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "AddLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddLocalInventories._get_response( self._host, @@ -854,7 +974,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_local_inventories(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.retail_v2alpha.ProductServiceClient.add_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "AddLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProduct( @@ -892,7 +1034,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the create product method over HTTP. @@ -904,8 +1046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -918,6 +1062,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -932,6 +1077,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.CreateProduct", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._CreateProduct._get_response( self._host, @@ -953,7 +1125,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2alpha.ProductServiceClient.create_product", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -990,7 +1184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -1002,13 +1196,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductServiceRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1019,6 +1216,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._DeleteProduct._get_response( self._host, @@ -1069,7 +1293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export products method over HTTP. @@ -1080,8 +1304,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1094,6 +1320,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseExportProducts._get_http_options() ) + request, metadata = self._interceptor.pre_export_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseExportProducts._get_transcoded_request( http_options, request @@ -1108,6 +1335,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.ExportProducts", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ExportProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ExportProducts._get_response( self._host, @@ -1127,7 +1381,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_products(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.retail_v2alpha.ProductServiceClient.export_products", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ExportProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProduct( @@ -1164,7 +1440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Call the get product method over HTTP. @@ -1176,8 +1452,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product.Product: @@ -1190,6 +1468,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetProduct._get_transcoded_request( http_options, request @@ -1202,6 +1481,33 @@ def __call__( ) ) + 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.retail_v2alpha.ProductServiceClient.GetProduct", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetProduct._get_response( self._host, @@ -1222,7 +1528,29 @@ def __call__( pb_resp = product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product.Product.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.retail_v2alpha.ProductServiceClient.get_product", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProducts( @@ -1260,7 +1588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import products method over HTTP. @@ -1270,8 +1598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1284,6 +1614,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseImportProducts._get_http_options() ) + request, metadata = self._interceptor.pre_import_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseImportProducts._get_transcoded_request( http_options, request @@ -1298,6 +1629,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.ImportProducts", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ImportProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ImportProducts._get_response( self._host, @@ -1317,7 +1675,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_products(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.retail_v2alpha.ProductServiceClient.import_products", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ImportProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1354,7 +1734,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1366,8 +1746,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_service.ListProductsResponse: @@ -1380,6 +1762,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1390,6 +1773,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.ListProducts", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListProducts._get_response( self._host, @@ -1410,7 +1820,31 @@ def __call__( pb_resp = product_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_service.ListProductsResponse.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.retail_v2alpha.ProductServiceClient.list_products", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -1448,7 +1882,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -1459,8 +1893,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1473,6 +1909,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -1487,6 +1924,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._PurgeProducts._get_response( self._host, @@ -1506,7 +1970,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(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.retail_v2alpha.ProductServiceClient.purge_products", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveFulfillmentPlaces( @@ -1545,7 +2031,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove fulfillment places method over HTTP. @@ -1557,8 +2043,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1571,6 +2059,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_remove_fulfillment_places( request, metadata ) @@ -1587,6 +2076,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.RemoveFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveFulfillmentPlaces._get_response( @@ -1608,7 +2124,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_fulfillment_places(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.retail_v2alpha.ProductServiceClient.remove_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveLocalInventories( @@ -1647,7 +2185,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove local inventories method over HTTP. @@ -1659,8 +2197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1673,6 +2213,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_remove_local_inventories( request, metadata ) @@ -1689,6 +2230,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.RemoveLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "RemoveLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveLocalInventories._get_response( @@ -1710,7 +2278,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_local_inventories(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.retail_v2alpha.ProductServiceClient.remove_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "RemoveLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetInventory( @@ -1748,7 +2338,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the set inventory method over HTTP. @@ -1760,8 +2350,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1774,6 +2366,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseSetInventory._get_http_options() ) + request, metadata = self._interceptor.pre_set_inventory(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseSetInventory._get_transcoded_request( http_options, request @@ -1788,6 +2381,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.SetInventory", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "SetInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._SetInventory._get_response( self._host, @@ -1807,7 +2427,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_inventory(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.retail_v2alpha.ProductServiceClient.set_inventory", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "SetInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProduct( @@ -1845,7 +2487,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the update product method over HTTP. @@ -1857,8 +2499,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -1871,6 +2515,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -1885,6 +2530,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._UpdateProduct._get_response( self._host, @@ -1906,7 +2578,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2alpha.ProductServiceClient.update_product", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2061,7 +2755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2071,8 +2765,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2081,6 +2777,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2091,6 +2788,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetOperation._get_response( self._host, @@ -2110,6 +2834,27 @@ def __call__( 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.retail_v2alpha.ProductServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2150,7 +2895,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2160,8 +2905,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2170,6 +2917,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2180,6 +2928,33 @@ def __call__( 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.retail_v2alpha.ProductServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListOperations._get_response( self._host, @@ -2199,6 +2974,27 @@ def __call__( 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.retail_v2alpha.ProductServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProductService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/async_client.py index c685346acd27..51781ac40951 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProjectServiceTransport from .transports.grpc_asyncio import ProjectServiceGrpcAsyncIOTransport +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 ProjectServiceAsyncClient: """Service for settings at Project level.""" @@ -270,6 +280,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.ProjectServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "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.retail.v2alpha.ProjectService", + "credentialsType": None, + }, + ) + async def get_project( self, request: Optional[Union[project_service.GetProjectRequest, dict]] = None, @@ -277,7 +309,7 @@ async def get_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.Project: r"""Gets the project. @@ -323,8 +355,10 @@ async def sample_get_project(): 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, 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: google.cloud.retail_v2alpha.types.Project: @@ -385,7 +419,7 @@ async def accept_terms( project: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_project.Project: r"""Accepts service terms for this project. By making requests to this API, you agree to the terms @@ -431,8 +465,10 @@ async def sample_accept_terms(): 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, 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: google.cloud.retail_v2alpha.types.Project: @@ -492,7 +528,7 @@ async def enroll_solution( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""The method enrolls a solution of type [Retail Search][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH] @@ -541,8 +577,10 @@ async def sample_enroll_solution(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -602,7 +640,7 @@ async def list_enrolled_solutions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project_service.ListEnrolledSolutionsResponse: r"""Lists all the retail API solutions the project has enrolled. @@ -647,8 +685,10 @@ async def sample_list_enrolled_solutions(): 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, 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: google.cloud.retail_v2alpha.types.ListEnrolledSolutionsResponse: @@ -709,7 +749,7 @@ async def get_logging_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Gets the [LoggingConfig][google.cloud.retail.v2alpha.LoggingConfig] of @@ -756,8 +796,10 @@ async def sample_get_logging_config(): 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, 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: google.cloud.retail_v2alpha.types.LoggingConfig: @@ -822,7 +864,7 @@ async def update_logging_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Updates the [LoggingConfig][google.cloud.retail.v2alpha.LoggingConfig] of @@ -894,8 +936,10 @@ async def sample_update_logging_config(): 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, 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: google.cloud.retail_v2alpha.types.LoggingConfig: @@ -961,7 +1005,7 @@ async def get_alert_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Get the [AlertConfig][google.cloud.retail.v2alpha.AlertConfig] of the requested project. @@ -1007,8 +1051,10 @@ async def sample_get_alert_config(): 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, 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: google.cloud.retail_v2alpha.types.AlertConfig: @@ -1068,7 +1114,7 @@ async def update_alert_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Update the alert config of the requested project. @@ -1133,8 +1179,10 @@ async def sample_update_alert_config(): 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, 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: google.cloud.retail_v2alpha.types.AlertConfig: @@ -1196,7 +1244,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1207,8 +1255,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1249,7 +1299,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1260,8 +1310,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/client.py index f3af993e0f4c..d9440a962415 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -609,6 +619,10 @@ def __init__( # 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( @@ -674,6 +688,29 @@ def __init__( 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.retail_v2alpha.ProjectServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "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.retail.v2alpha.ProjectService", + "credentialsType": None, + }, + ) + def get_project( self, request: Optional[Union[project_service.GetProjectRequest, dict]] = None, @@ -681,7 +718,7 @@ def get_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.Project: r"""Gets the project. @@ -727,8 +764,10 @@ def sample_get_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Project: @@ -786,7 +825,7 @@ def accept_terms( project: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_project.Project: r"""Accepts service terms for this project. By making requests to this API, you agree to the terms @@ -832,8 +871,10 @@ def sample_accept_terms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.Project: @@ -890,7 +931,7 @@ def enroll_solution( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""The method enrolls a solution of type [Retail Search][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH] @@ -939,8 +980,10 @@ def sample_enroll_solution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -998,7 +1041,7 @@ def list_enrolled_solutions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project_service.ListEnrolledSolutionsResponse: r"""Lists all the retail API solutions the project has enrolled. @@ -1043,8 +1086,10 @@ def sample_list_enrolled_solutions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ListEnrolledSolutionsResponse: @@ -1102,7 +1147,7 @@ def get_logging_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Gets the [LoggingConfig][google.cloud.retail.v2alpha.LoggingConfig] of @@ -1149,8 +1194,10 @@ def sample_get_logging_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.LoggingConfig: @@ -1212,7 +1259,7 @@ def update_logging_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Updates the [LoggingConfig][google.cloud.retail.v2alpha.LoggingConfig] of @@ -1284,8 +1331,10 @@ def sample_update_logging_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.LoggingConfig: @@ -1348,7 +1397,7 @@ def get_alert_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Get the [AlertConfig][google.cloud.retail.v2alpha.AlertConfig] of the requested project. @@ -1394,8 +1443,10 @@ def sample_get_alert_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AlertConfig: @@ -1452,7 +1503,7 @@ def update_alert_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Update the alert config of the requested project. @@ -1517,8 +1568,10 @@ def sample_update_alert_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.AlertConfig: @@ -1590,7 +1643,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1601,8 +1654,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1643,7 +1698,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1654,8 +1709,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc.py index b57d588e13c6..e8af10583c8e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import project from google.cloud.retail_v2alpha.types import project as gcr_project @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, ProjectServiceTransport +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.retail.v2alpha.ProjectService", + "rpcName": 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.retail.v2alpha.ProjectService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectServiceGrpcTransport(ProjectServiceTransport): """gRPC backend transport for ProjectService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def get_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project" not in self._stubs: - self._stubs["get_project"] = self.grpc_channel.unary_unary( + self._stubs["get_project"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetProject", request_serializer=project_service.GetProjectRequest.serialize, response_deserializer=project.Project.deserialize, @@ -304,7 +392,7 @@ def accept_terms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "accept_terms" not in self._stubs: - self._stubs["accept_terms"] = self.grpc_channel.unary_unary( + self._stubs["accept_terms"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/AcceptTerms", request_serializer=project_service.AcceptTermsRequest.serialize, response_deserializer=gcr_project.Project.deserialize, @@ -338,7 +426,7 @@ def enroll_solution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enroll_solution" not in self._stubs: - self._stubs["enroll_solution"] = self.grpc_channel.unary_unary( + self._stubs["enroll_solution"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/EnrollSolution", request_serializer=project_service.EnrollSolutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +456,7 @@ def list_enrolled_solutions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_enrolled_solutions" not in self._stubs: - self._stubs["list_enrolled_solutions"] = self.grpc_channel.unary_unary( + self._stubs["list_enrolled_solutions"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/ListEnrolledSolutions", request_serializer=project_service.ListEnrolledSolutionsRequest.serialize, response_deserializer=project_service.ListEnrolledSolutionsResponse.deserialize, @@ -396,7 +484,7 @@ def get_logging_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_config" not in self._stubs: - self._stubs["get_logging_config"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetLoggingConfig", request_serializer=project_service.GetLoggingConfigRequest.serialize, response_deserializer=project.LoggingConfig.deserialize, @@ -424,7 +512,7 @@ def update_logging_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_config" not in self._stubs: - self._stubs["update_logging_config"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/UpdateLoggingConfig", request_serializer=project_service.UpdateLoggingConfigRequest.serialize, response_deserializer=project.LoggingConfig.deserialize, @@ -451,7 +539,7 @@ def get_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_alert_config" not in self._stubs: - self._stubs["get_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["get_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetAlertConfig", request_serializer=project_service.GetAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -477,7 +565,7 @@ def update_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_alert_config" not in self._stubs: - self._stubs["update_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["update_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/UpdateAlertConfig", request_serializer=project_service.UpdateAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -485,7 +573,7 @@ def update_alert_config( return self._stubs["update_alert_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -497,7 +585,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -516,7 +604,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc_asyncio.py index d0995e7b52ad..fd4789055904 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import project from google.cloud.retail_v2alpha.types import project as gcr_project @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, ProjectServiceTransport from .grpc import ProjectServiceGrpcTransport +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.retail.v2alpha.ProjectService", + "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.retail.v2alpha.ProjectService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectServiceGrpcAsyncIOTransport(ProjectServiceTransport): """gRPC AsyncIO backend transport for ProjectService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project" not in self._stubs: - self._stubs["get_project"] = self.grpc_channel.unary_unary( + self._stubs["get_project"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetProject", request_serializer=project_service.GetProjectRequest.serialize, response_deserializer=project.Project.deserialize, @@ -314,7 +399,7 @@ def accept_terms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "accept_terms" not in self._stubs: - self._stubs["accept_terms"] = self.grpc_channel.unary_unary( + self._stubs["accept_terms"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/AcceptTerms", request_serializer=project_service.AcceptTermsRequest.serialize, response_deserializer=gcr_project.Project.deserialize, @@ -350,7 +435,7 @@ def enroll_solution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enroll_solution" not in self._stubs: - self._stubs["enroll_solution"] = self.grpc_channel.unary_unary( + self._stubs["enroll_solution"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/EnrollSolution", request_serializer=project_service.EnrollSolutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -380,7 +465,7 @@ def list_enrolled_solutions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_enrolled_solutions" not in self._stubs: - self._stubs["list_enrolled_solutions"] = self.grpc_channel.unary_unary( + self._stubs["list_enrolled_solutions"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/ListEnrolledSolutions", request_serializer=project_service.ListEnrolledSolutionsRequest.serialize, response_deserializer=project_service.ListEnrolledSolutionsResponse.deserialize, @@ -410,7 +495,7 @@ def get_logging_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_logging_config" not in self._stubs: - self._stubs["get_logging_config"] = self.grpc_channel.unary_unary( + self._stubs["get_logging_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetLoggingConfig", request_serializer=project_service.GetLoggingConfigRequest.serialize, response_deserializer=project.LoggingConfig.deserialize, @@ -440,7 +525,7 @@ def update_logging_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_logging_config" not in self._stubs: - self._stubs["update_logging_config"] = self.grpc_channel.unary_unary( + self._stubs["update_logging_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/UpdateLoggingConfig", request_serializer=project_service.UpdateLoggingConfigRequest.serialize, response_deserializer=project.LoggingConfig.deserialize, @@ -469,7 +554,7 @@ def get_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_alert_config" not in self._stubs: - self._stubs["get_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["get_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/GetAlertConfig", request_serializer=project_service.GetAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -497,7 +582,7 @@ def update_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_alert_config" not in self._stubs: - self._stubs["update_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["update_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ProjectService/UpdateAlertConfig", request_serializer=project_service.UpdateAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -565,7 +650,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -581,7 +666,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -600,7 +685,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/rest.py index f93e12a60dad..3ab41facc383 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/project_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -137,8 +145,10 @@ def post_update_logging_config(self, response): def pre_accept_terms( self, request: project_service.AcceptTermsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.AcceptTermsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.AcceptTermsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for accept_terms Override in a subclass to manipulate the request or metadata @@ -158,8 +168,10 @@ def post_accept_terms(self, response: gcr_project.Project) -> gcr_project.Projec def pre_enroll_solution( self, request: project_service.EnrollSolutionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.EnrollSolutionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.EnrollSolutionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enroll_solution Override in a subclass to manipulate the request or metadata @@ -181,8 +193,10 @@ def post_enroll_solution( def pre_get_alert_config( self, request: project_service.GetAlertConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.GetAlertConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.GetAlertConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_alert_config Override in a subclass to manipulate the request or metadata @@ -204,8 +218,10 @@ def post_get_alert_config( def pre_get_logging_config( self, request: project_service.GetLoggingConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.GetLoggingConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.GetLoggingConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_logging_config Override in a subclass to manipulate the request or metadata @@ -227,8 +243,10 @@ def post_get_logging_config( def pre_get_project( self, request: project_service.GetProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.GetProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.GetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_project Override in a subclass to manipulate the request or metadata @@ -248,8 +266,11 @@ def post_get_project(self, response: project.Project) -> project.Project: def pre_list_enrolled_solutions( self, request: project_service.ListEnrolledSolutionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.ListEnrolledSolutionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.ListEnrolledSolutionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_enrolled_solutions Override in a subclass to manipulate the request or metadata @@ -271,8 +292,11 @@ def post_list_enrolled_solutions( def pre_update_alert_config( self, request: project_service.UpdateAlertConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.UpdateAlertConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.UpdateAlertConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_alert_config Override in a subclass to manipulate the request or metadata @@ -294,8 +318,11 @@ def post_update_alert_config( def pre_update_logging_config( self, request: project_service.UpdateLoggingConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.UpdateLoggingConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.UpdateLoggingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_logging_config Override in a subclass to manipulate the request or metadata @@ -317,8 +344,10 @@ def post_update_logging_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -340,8 +369,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -547,7 +578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_project.Project: r"""Call the accept terms method over HTTP. @@ -557,8 +588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_project.Project: @@ -570,6 +603,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseAcceptTerms._get_http_options() ) + request, metadata = self._interceptor.pre_accept_terms(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseAcceptTerms._get_transcoded_request( http_options, request @@ -584,6 +618,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.AcceptTerms", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "AcceptTerms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._AcceptTerms._get_response( self._host, @@ -605,7 +666,29 @@ def __call__( pb_resp = gcr_project.Project.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_accept_terms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_project.Project.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.retail_v2alpha.ProjectServiceClient.accept_terms", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "AcceptTerms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnrollSolution( @@ -643,7 +726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the enroll solution method over HTTP. @@ -653,8 +736,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -667,6 +752,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseEnrollSolution._get_http_options() ) + request, metadata = self._interceptor.pre_enroll_solution(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseEnrollSolution._get_transcoded_request( http_options, request @@ -681,6 +767,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.EnrollSolution", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "EnrollSolution", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._EnrollSolution._get_response( self._host, @@ -700,7 +813,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enroll_solution(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.retail_v2alpha.ProjectServiceClient.enroll_solution", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "EnrollSolution", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAlertConfig( @@ -737,7 +872,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Call the get alert config method over HTTP. @@ -749,8 +884,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.AlertConfig: @@ -760,6 +897,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetAlertConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_alert_config( request, metadata ) @@ -772,6 +910,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.GetAlertConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetAlertConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetAlertConfig._get_response( self._host, @@ -792,7 +957,29 @@ def __call__( pb_resp = project.AlertConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_alert_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.AlertConfig.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.retail_v2alpha.ProjectServiceClient.get_alert_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetAlertConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetLoggingConfig( @@ -829,7 +1016,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Call the get logging config method over HTTP. @@ -841,8 +1028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.LoggingConfig: @@ -855,6 +1044,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetLoggingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_logging_config( request, metadata ) @@ -867,6 +1057,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.GetLoggingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetLoggingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetLoggingConfig._get_response( self._host, @@ -887,7 +1104,29 @@ def __call__( pb_resp = project.LoggingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_logging_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.LoggingConfig.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.retail_v2alpha.ProjectServiceClient.get_logging_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetLoggingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProject( @@ -924,7 +1163,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.Project: r"""Call the get project method over HTTP. @@ -934,8 +1173,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.Project: @@ -947,6 +1188,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetProject._get_http_options() ) + request, metadata = self._interceptor.pre_get_project(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseGetProject._get_transcoded_request( http_options, request @@ -959,6 +1201,33 @@ def __call__( ) ) + 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.retail_v2alpha.ProjectServiceClient.GetProject", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetProject._get_response( self._host, @@ -979,7 +1248,29 @@ def __call__( pb_resp = project.Project.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.Project.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.retail_v2alpha.ProjectServiceClient.get_project", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEnrolledSolutions( @@ -1017,7 +1308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project_service.ListEnrolledSolutionsResponse: r"""Call the list enrolled solutions method over HTTP. @@ -1028,8 +1319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project_service.ListEnrolledSolutionsResponse: @@ -1041,6 +1334,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseListEnrolledSolutions._get_http_options() ) + request, metadata = self._interceptor.pre_list_enrolled_solutions( request, metadata ) @@ -1053,6 +1347,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.ListEnrolledSolutions", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "ListEnrolledSolutions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._ListEnrolledSolutions._get_response( self._host, @@ -1073,7 +1394,31 @@ def __call__( pb_resp = project_service.ListEnrolledSolutionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_enrolled_solutions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + project_service.ListEnrolledSolutionsResponse.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.retail_v2alpha.ProjectServiceClient.list_enrolled_solutions", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "ListEnrolledSolutions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAlertConfig( @@ -1111,7 +1456,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Call the update alert config method over HTTP. @@ -1123,8 +1468,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.AlertConfig: @@ -1134,6 +1481,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseUpdateAlertConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_alert_config( request, metadata ) @@ -1150,6 +1498,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.UpdateAlertConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "UpdateAlertConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._UpdateAlertConfig._get_response( self._host, @@ -1171,7 +1546,29 @@ def __call__( pb_resp = project.AlertConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_alert_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.AlertConfig.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.retail_v2alpha.ProjectServiceClient.update_alert_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "UpdateAlertConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateLoggingConfig( @@ -1210,7 +1607,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.LoggingConfig: r"""Call the update logging config method over HTTP. @@ -1222,8 +1619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.LoggingConfig: @@ -1236,6 +1635,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseUpdateLoggingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_logging_config( request, metadata ) @@ -1252,6 +1652,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.UpdateLoggingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "UpdateLoggingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._UpdateLoggingConfig._get_response( self._host, @@ -1273,7 +1700,29 @@ def __call__( pb_resp = project.LoggingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_logging_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.LoggingConfig.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.retail_v2alpha.ProjectServiceClient.update_logging_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "UpdateLoggingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1381,7 +1830,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1391,8 +1840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1401,6 +1852,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1411,6 +1863,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetOperation._get_response( self._host, @@ -1430,6 +1909,27 @@ def __call__( 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.retail_v2alpha.ProjectServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1470,7 +1970,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1480,8 +1980,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1490,6 +1992,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1500,6 +2003,33 @@ def __call__( 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.retail_v2alpha.ProjectServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._ListOperations._get_response( self._host, @@ -1519,6 +2049,27 @@ def __call__( 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.retail_v2alpha.ProjectServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ProjectService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/async_client.py index ad83e3379105..a9077a52f1d8 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .transports.grpc_asyncio import SearchServiceGrpcAsyncIOTransport +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 SearchServiceAsyncClient: """Service for search. @@ -270,13 +280,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.SearchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "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.retail.v2alpha.SearchService", + "credentialsType": None, + }, + ) + async def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAsyncPager: r"""Performs a search. @@ -320,8 +352,10 @@ async def sample_search(): 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, 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: google.cloud.retail_v2alpha.services.search_service.pagers.SearchAsyncPager: @@ -382,7 +416,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -393,8 +427,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -435,7 +471,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -446,8 +482,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/client.py index 6bd5849af2cc..6ba6dd2abe8e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -660,6 +670,10 @@ def __init__( # 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( @@ -725,13 +739,36 @@ def __init__( 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.retail_v2alpha.SearchServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "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.retail.v2alpha.SearchService", + "credentialsType": None, + }, + ) + def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchPager: r"""Performs a search. @@ -775,8 +812,10 @@ def sample_search(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.services.search_service.pagers.SearchPager: @@ -850,7 +889,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -861,8 +900,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -903,7 +944,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -914,8 +955,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/pagers.py index 192bb07f5344..7df1703d2bb1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = search_service.SearchRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = search_service.SearchRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc.py index 59dd9938eccf..af74786a597b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport +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.retail.v2alpha.SearchService", + "rpcName": 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.retail.v2alpha.SearchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcTransport(SearchServiceTransport): """gRPC backend transport for SearchService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -271,7 +357,7 @@ def search( return self._stubs["search"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -283,7 +369,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -302,7 +388,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc_asyncio.py index 66b1a48177d6..99941e005103 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .grpc import SearchServiceGrpcTransport +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.retail.v2alpha.SearchService", + "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.retail.v2alpha.SearchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcAsyncIOTransport(SearchServiceTransport): """gRPC AsyncIO backend transport for SearchService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +358,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -306,7 +391,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -322,7 +407,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -341,7 +426,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/rest.py index 529e0bf6d3e8..92a29e0a5eac 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/search_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -77,8 +85,10 @@ def post_search(self, response): """ def pre_search( - self, request: search_service.SearchRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, str]]]: + self, + request: search_service.SearchRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search Override in a subclass to manipulate the request or metadata @@ -100,8 +110,10 @@ def post_search( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -123,8 +135,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> search_service.SearchResponse: r"""Call the search method over HTTP. @@ -279,8 +293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.search_service.SearchResponse: @@ -293,6 +309,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseSearch._get_http_options() ) + request, metadata = self._interceptor.pre_search(request, metadata) transcoded_request = ( _BaseSearchServiceRestTransport._BaseSearch._get_transcoded_request( @@ -311,6 +328,33 @@ def __call__( ) ) + 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.retail_v2alpha.SearchServiceClient.Search", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "Search", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._Search._get_response( self._host, @@ -332,7 +376,29 @@ def __call__( pb_resp = search_service.SearchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = search_service.SearchResponse.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.retail_v2alpha.SearchServiceClient.search", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "Search", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -381,7 +447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -391,8 +457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -401,6 +469,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -411,6 +480,33 @@ def __call__( 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.retail_v2alpha.SearchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._GetOperation._get_response( self._host, @@ -430,6 +526,27 @@ def __call__( 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.retail_v2alpha.SearchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -470,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -480,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -490,6 +609,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -500,6 +620,33 @@ def __call__( 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.retail_v2alpha.SearchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._ListOperations._get_response( self._host, @@ -519,6 +666,27 @@ def __call__( 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.retail_v2alpha.SearchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.SearchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/async_client.py index 457241851c43..9590d471cdf6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .transports.grpc_asyncio import ServingConfigServiceGrpcAsyncIOTransport +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 ServingConfigServiceAsyncClient: """Service for modifying ServingConfig.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.ServingConfigServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "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.retail.v2alpha.ServingConfigService", + "credentialsType": None, + }, + ) + async def create_serving_config( self, request: Optional[ @@ -280,7 +312,7 @@ async def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -353,8 +385,10 @@ async def sample_create_serving_config(): 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, 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -423,7 +457,7 @@ async def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -468,8 +502,10 @@ async def sample_delete_serving_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -524,7 +560,7 @@ async def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -584,8 +620,10 @@ async def sample_update_serving_config(): 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, 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -654,7 +692,7 @@ async def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -701,8 +739,10 @@ async def sample_get_serving_config(): 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, 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -767,7 +807,7 @@ async def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsAsyncPager: r"""Lists all ServingConfigs linked to this catalog. @@ -812,8 +852,10 @@ async def sample_list_serving_configs(): 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, 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: google.cloud.retail_v2alpha.services.serving_config_service.pagers.ListServingConfigsAsyncPager: @@ -888,7 +930,7 @@ async def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -939,8 +981,10 @@ async def sample_add_control(): 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, 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1007,7 +1051,7 @@ async def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1054,8 +1098,10 @@ async def sample_remove_control(): 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, 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1119,7 +1165,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1130,8 +1176,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1172,7 +1220,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1183,8 +1231,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/client.py index d4c3b82a05b6..0843e6a3a57d 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -613,6 +623,10 @@ def __init__( # 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( @@ -679,6 +693,29 @@ def __init__( 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.retail_v2alpha.ServingConfigServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "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.retail.v2alpha.ServingConfigService", + "credentialsType": None, + }, + ) + def create_serving_config( self, request: Optional[ @@ -690,7 +727,7 @@ def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -763,8 +800,10 @@ def sample_create_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -830,7 +869,7 @@ def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -875,8 +914,10 @@ def sample_delete_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -928,7 +969,7 @@ def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -988,8 +1029,10 @@ def sample_update_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1055,7 +1098,7 @@ def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -1102,8 +1145,10 @@ def sample_get_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1165,7 +1210,7 @@ def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsPager: r"""Lists all ServingConfigs linked to this catalog. @@ -1210,8 +1255,10 @@ def sample_list_serving_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.services.serving_config_service.pagers.ListServingConfigsPager: @@ -1283,7 +1330,7 @@ def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -1334,8 +1381,10 @@ def sample_add_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1399,7 +1448,7 @@ def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1446,8 +1495,10 @@ def sample_remove_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.ServingConfig: @@ -1521,7 +1572,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1532,8 +1583,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1574,7 +1627,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1585,8 +1638,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/pagers.py index a74db475fe12..f4b0f5d51831 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc.py index 0404aa9ddea8..3c5a62b883f2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import serving_config as gcr_serving_config from google.cloud.retail_v2alpha.types import serving_config @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport +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.retail.v2alpha.ServingConfigService", + "rpcName": 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.retail.v2alpha.ServingConfigService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcTransport(ServingConfigServiceTransport): """gRPC backend transport for ServingConfigService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -295,7 +381,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -324,7 +410,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -355,7 +441,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -384,7 +470,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -418,7 +504,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -448,7 +534,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -456,7 +542,7 @@ def remove_control( return self._stubs["remove_control"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -468,7 +554,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -487,7 +573,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc_asyncio.py index e6b61e34d7e0..0427ec1f2bd1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import serving_config as gcr_serving_config from google.cloud.retail_v2alpha.types import serving_config @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .grpc import ServingConfigServiceGrpcTransport +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.retail.v2alpha.ServingConfigService", + "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.retail.v2alpha.ServingConfigService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcAsyncIOTransport(ServingConfigServiceTransport): """gRPC AsyncIO backend transport for ServingConfigService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -305,7 +390,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -334,7 +419,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -366,7 +451,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -395,7 +480,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -430,7 +515,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -461,7 +546,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -524,7 +609,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -540,7 +625,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -559,7 +644,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/rest.py index fb306f4328cf..77e9d020776a 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/serving_config_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -126,8 +134,11 @@ def post_update_serving_config(self, response): def pre_add_control( self, request: serving_config_service.AddControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.AddControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.AddControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_control Override in a subclass to manipulate the request or metadata @@ -149,9 +160,10 @@ def post_add_control( def pre_create_serving_config( self, request: serving_config_service.CreateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.CreateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.CreateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_serving_config @@ -174,9 +186,10 @@ def post_create_serving_config( def pre_delete_serving_config( self, request: serving_config_service.DeleteServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.DeleteServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.DeleteServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_serving_config @@ -188,9 +201,10 @@ def pre_delete_serving_config( def pre_get_serving_config( self, request: serving_config_service.GetServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.GetServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.GetServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_serving_config @@ -213,9 +227,10 @@ def post_get_serving_config( def pre_list_serving_configs( self, request: serving_config_service.ListServingConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.ListServingConfigsRequest, Sequence[Tuple[str, str]] + serving_config_service.ListServingConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_serving_configs @@ -238,8 +253,11 @@ def post_list_serving_configs( def pre_remove_control( self, request: serving_config_service.RemoveControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.RemoveControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.RemoveControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_control Override in a subclass to manipulate the request or metadata @@ -261,9 +279,10 @@ def post_remove_control( def pre_update_serving_config( self, request: serving_config_service.UpdateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.UpdateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.UpdateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_serving_config @@ -286,8 +305,10 @@ def post_update_serving_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -309,8 +330,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -452,7 +475,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the add control method over HTTP. @@ -462,8 +485,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -477,6 +502,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseAddControl._get_http_options() ) + request, metadata = self._interceptor.pre_add_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseAddControl._get_transcoded_request( http_options, request @@ -491,6 +517,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.AddControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "AddControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._AddControl._get_response( self._host, @@ -512,7 +565,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2alpha.ServingConfigServiceClient.add_control", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "AddControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServingConfig( @@ -551,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the create serving config method over HTTP. @@ -562,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -577,6 +656,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseCreateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_serving_config( request, metadata ) @@ -593,6 +673,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.CreateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "CreateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._CreateServingConfig._get_response( @@ -616,7 +723,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2alpha.ServingConfigServiceClient.create_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "CreateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteServingConfig( @@ -654,7 +785,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete serving config method over HTTP. @@ -665,13 +796,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseServingConfigServiceRestTransport._BaseDeleteServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_serving_config( request, metadata ) @@ -684,6 +818,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.DeleteServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "DeleteServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._DeleteServingConfig._get_response( @@ -736,7 +897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Call the get serving config method over HTTP. @@ -746,8 +907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config.ServingConfig: @@ -761,6 +924,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_serving_config( request, metadata ) @@ -773,6 +937,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.GetServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "GetServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._GetServingConfig._get_response( @@ -795,7 +986,29 @@ def __call__( pb_resp = serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = serving_config.ServingConfig.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.retail_v2alpha.ServingConfigServiceClient.get_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "GetServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServingConfigs( @@ -833,7 +1046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config_service.ListServingConfigsResponse: r"""Call the list serving configs method over HTTP. @@ -844,8 +1057,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config_service.ListServingConfigsResponse: @@ -857,6 +1072,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListServingConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_serving_configs( request, metadata ) @@ -869,6 +1085,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.ListServingConfigs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "ListServingConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._ListServingConfigs._get_response( @@ -891,7 +1134,33 @@ def __call__( pb_resp = serving_config_service.ListServingConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_serving_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + serving_config_service.ListServingConfigsResponse.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.retail_v2alpha.ServingConfigServiceClient.list_serving_configs", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "ListServingConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveControl( @@ -930,7 +1199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the remove control method over HTTP. @@ -940,8 +1209,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -955,6 +1226,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_http_options() ) + request, metadata = self._interceptor.pre_remove_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_transcoded_request( http_options, request @@ -969,6 +1241,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.RemoveControl", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "RemoveControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._RemoveControl._get_response( self._host, @@ -990,7 +1289,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2alpha.ServingConfigServiceClient.remove_control", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "RemoveControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateServingConfig( @@ -1029,7 +1352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the update serving config method over HTTP. @@ -1040,8 +1363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -1055,6 +1380,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseUpdateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_serving_config( request, metadata ) @@ -1071,6 +1397,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.UpdateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "UpdateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._UpdateServingConfig._get_response( @@ -1094,7 +1447,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2alpha.ServingConfigServiceClient.update_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "UpdateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1207,7 +1584,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1217,8 +1594,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1227,6 +1606,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1237,6 +1617,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._GetOperation._get_response( self._host, @@ -1256,6 +1663,27 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1297,7 +1725,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1307,8 +1735,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1317,6 +1747,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1327,6 +1758,33 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._ListOperations._get_response( self._host, @@ -1346,6 +1804,27 @@ def __call__( 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.retail_v2alpha.ServingConfigServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.ServingConfigService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/async_client.py index cbc7e4654d09..ee654a101e21 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .transports.grpc_asyncio import UserEventServiceGrpcAsyncIOTransport +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 UserEventServiceAsyncClient: """Service for ingesting end user actions on the customer @@ -274,13 +284,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2alpha.UserEventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "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.retail.v2alpha.UserEventService", + "credentialsType": None, + }, + ) + async def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -322,8 +354,10 @@ async def sample_write_user_event(): 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, 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: google.cloud.retail_v2alpha.types.UserEvent: @@ -373,7 +407,7 @@ async def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -418,8 +452,10 @@ async def sample_collect_user_event(): 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, 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: google.api.httpbody_pb2.HttpBody: @@ -509,7 +545,7 @@ async def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -555,8 +591,10 @@ async def sample_purge_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -613,7 +651,7 @@ async def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -665,8 +703,10 @@ async def sample_import_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -725,7 +765,7 @@ async def export_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports user events. @@ -772,8 +812,10 @@ async def sample_export_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -834,7 +876,7 @@ async def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -885,8 +927,10 @@ async def sample_rejoin_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -943,7 +987,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -954,8 +998,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -996,7 +1042,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1007,8 +1053,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/client.py index 76df0aa8fde7..6c15825b8e72 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import httpbody_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -688,13 +702,36 @@ def __init__( 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.retail_v2alpha.UserEventServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "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.retail.v2alpha.UserEventService", + "credentialsType": None, + }, + ) + def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -736,8 +773,10 @@ def sample_write_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2alpha.types.UserEvent: @@ -785,7 +824,7 @@ def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -830,8 +869,10 @@ def sample_collect_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api.httpbody_pb2.HttpBody: @@ -919,7 +960,7 @@ def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -965,8 +1006,10 @@ def sample_purge_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1021,7 +1064,7 @@ def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -1073,8 +1116,10 @@ def sample_import_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1131,7 +1176,7 @@ def export_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports user events. @@ -1178,8 +1223,10 @@ def sample_export_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1238,7 +1285,7 @@ def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -1289,8 +1336,10 @@ def sample_rejoin_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1358,7 +1407,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1369,8 +1418,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1411,7 +1462,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1422,8 +1473,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc.py index cf586fbb4a3f..ce09dabaa846 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import ( export_config, @@ -35,6 +41,81 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport +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.retail.v2alpha.UserEventService", + "rpcName": 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.retail.v2alpha.UserEventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcTransport(UserEventServiceTransport): """gRPC backend transport for UserEventService. @@ -190,7 +271,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -310,7 +398,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -340,7 +428,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +460,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def export_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_user_events" not in self._stubs: - self._stubs["export_user_events"] = self.grpc_channel.unary_unary( + self._stubs["export_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/ExportUserEvents", request_serializer=export_config.ExportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +527,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +535,7 @@ def rejoin_user_events( return self._stubs["rejoin_user_events"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -459,7 +547,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -478,7 +566,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc_asyncio.py index 5287e873c308..b6befb8d52c3 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2alpha.types import ( export_config, @@ -39,6 +45,82 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .grpc import UserEventServiceGrpcTransport +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.retail.v2alpha.UserEventService", + "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.retail.v2alpha.UserEventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcAsyncIOTransport(UserEventServiceTransport): """gRPC AsyncIO backend transport for UserEventService. @@ -237,10 +319,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -290,7 +375,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -324,7 +409,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -356,7 +441,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -390,7 +475,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +506,7 @@ def export_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_user_events" not in self._stubs: - self._stubs["export_user_events"] = self.grpc_channel.unary_unary( + self._stubs["export_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/ExportUserEvents", request_serializer=export_config.ExportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +545,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2alpha.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -538,7 +623,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -554,7 +639,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -573,7 +658,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/rest.py index 63aab1f8e526..167e65b03814 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/services/user_event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -46,6 +46,14 @@ 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, @@ -126,8 +134,11 @@ def post_write_user_event(self, response): def pre_collect_user_event( self, request: user_event_service.CollectUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.CollectUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.CollectUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for collect_user_event Override in a subclass to manipulate the request or metadata @@ -149,8 +160,10 @@ def post_collect_user_event( def pre_export_user_events( self, request: export_config.ExportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_user_events Override in a subclass to manipulate the request or metadata @@ -172,8 +185,10 @@ def post_export_user_events( def pre_import_user_events( self, request: import_config.ImportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_user_events Override in a subclass to manipulate the request or metadata @@ -195,8 +210,10 @@ def post_import_user_events( def pre_purge_user_events( self, request: purge_config.PurgeUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_user_events Override in a subclass to manipulate the request or metadata @@ -218,8 +235,11 @@ def post_purge_user_events( def pre_rejoin_user_events( self, request: user_event_service.RejoinUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.RejoinUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.RejoinUserEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for rejoin_user_events Override in a subclass to manipulate the request or metadata @@ -241,8 +261,11 @@ def post_rejoin_user_events( def pre_write_user_event( self, request: user_event_service.WriteUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.WriteUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.WriteUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for write_user_event Override in a subclass to manipulate the request or metadata @@ -264,8 +287,10 @@ def post_write_user_event( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -287,8 +312,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -495,7 +522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the collect user event method over HTTP. @@ -506,8 +533,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.httpbody_pb2.HttpBody: @@ -566,6 +595,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseCollectUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_collect_user_event( request, metadata ) @@ -578,6 +608,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.CollectUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "CollectUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._CollectUserEvent._get_response( self._host, @@ -598,7 +655,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_collect_user_event(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.retail_v2alpha.UserEventServiceClient.collect_user_event", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "CollectUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportUserEvents( @@ -637,7 +716,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export user events method over HTTP. @@ -647,8 +726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -661,6 +742,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseExportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_export_user_events( request, metadata ) @@ -677,6 +759,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.ExportUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ExportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ExportUserEvents._get_response( self._host, @@ -696,7 +805,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_user_events(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.retail_v2alpha.UserEventServiceClient.export_user_events", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ExportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportUserEvents( @@ -735,7 +866,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import user events method over HTTP. @@ -746,8 +877,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -760,6 +893,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseImportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_import_user_events( request, metadata ) @@ -776,6 +910,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.ImportUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ImportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ImportUserEvents._get_response( self._host, @@ -795,7 +956,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_user_events(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.retail_v2alpha.UserEventServiceClient.import_user_events", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ImportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeUserEvents( @@ -834,7 +1017,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge user events method over HTTP. @@ -845,8 +1028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -859,6 +1044,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BasePurgeUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_purge_user_events( request, metadata ) @@ -875,6 +1061,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.PurgeUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "PurgeUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._PurgeUserEvents._get_response( self._host, @@ -894,7 +1107,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_user_events(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.retail_v2alpha.UserEventServiceClient.purge_user_events", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "PurgeUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RejoinUserEvents( @@ -933,7 +1168,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the rejoin user events method over HTTP. @@ -944,8 +1179,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -958,6 +1195,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseRejoinUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_rejoin_user_events( request, metadata ) @@ -974,6 +1212,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.RejoinUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "RejoinUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._RejoinUserEvents._get_response( self._host, @@ -993,7 +1258,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rejoin_user_events(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.retail_v2alpha.UserEventServiceClient.rejoin_user_events", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "RejoinUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _WriteUserEvent( @@ -1031,7 +1318,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Call the write user event method over HTTP. @@ -1042,8 +1329,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.user_event.UserEvent: @@ -1057,6 +1346,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseWriteUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_write_user_event( request, metadata ) @@ -1073,6 +1363,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.WriteUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "WriteUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._WriteUserEvent._get_response( self._host, @@ -1094,7 +1411,29 @@ def __call__( pb_resp = user_event.UserEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_write_user_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = user_event.UserEvent.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.retail_v2alpha.UserEventServiceClient.write_user_event", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "WriteUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1185,7 +1524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1195,8 +1534,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1205,6 +1546,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1215,6 +1557,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._GetOperation._get_response( self._host, @@ -1234,6 +1603,27 @@ def __call__( 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.retail_v2alpha.UserEventServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1274,7 +1664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1284,8 +1674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1294,6 +1686,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1304,6 +1697,33 @@ def __call__( 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.retail_v2alpha.UserEventServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ListOperations._get_response( self._host, @@ -1323,6 +1743,27 @@ def __call__( 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.retail_v2alpha.UserEventServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2alpha.UserEventService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py index 2152db608ae5..558c8aab67c5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/async_client.py index 4cc4d2031232..7ddb41560181 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .transports.grpc_asyncio import AnalyticsServiceGrpcAsyncIOTransport +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 AnalyticsServiceAsyncClient: """Service for managing & accessing retail search business @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.AnalyticsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "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.retail.v2beta.AnalyticsService", + "credentialsType": None, + }, + ) + async def export_analytics_metrics( self, request: Optional[ @@ -269,7 +301,7 @@ async def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports analytics metrics. @@ -318,8 +350,10 @@ async def sample_export_analytics_metrics(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -378,7 +412,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -389,8 +423,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -431,7 +467,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -442,8 +478,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/client.py index 75ecdb5bd5df..a798234a4af4 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -565,6 +575,10 @@ def __init__( # 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( @@ -631,6 +645,29 @@ def __init__( 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.retail_v2beta.AnalyticsServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "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.retail.v2beta.AnalyticsService", + "credentialsType": None, + }, + ) + def export_analytics_metrics( self, request: Optional[ @@ -639,7 +676,7 @@ def export_analytics_metrics( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports analytics metrics. @@ -688,8 +725,10 @@ def sample_export_analytics_metrics(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc.py index 5f4a62ce62ec..c6305ba40b23 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport +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.retail.v2beta.AnalyticsService", + "rpcName": 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.retail.v2beta.AnalyticsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcTransport(AnalyticsServiceTransport): """gRPC backend transport for AnalyticsService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -286,7 +374,7 @@ def export_analytics_metrics( return self._stubs["export_analytics_metrics"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -298,7 +386,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -317,7 +405,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc_asyncio.py index 86bec7d35f74..140279dc425e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import export_config from .base import DEFAULT_CLIENT_INFO, AnalyticsServiceTransport from .grpc import AnalyticsServiceGrpcTransport +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.retail.v2beta.AnalyticsService", + "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.retail.v2beta.AnalyticsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsServiceGrpcAsyncIOTransport(AnalyticsServiceTransport): """gRPC AsyncIO backend transport for AnalyticsService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def export_analytics_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_analytics_metrics" not in self._stubs: - self._stubs["export_analytics_metrics"] = self.grpc_channel.unary_unary( + self._stubs["export_analytics_metrics"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.AnalyticsService/ExportAnalyticsMetrics", request_serializer=export_config.ExportAnalyticsMetricsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +417,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -348,7 +433,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -367,7 +452,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/rest.py index 6024921d80b4..cb05445877d1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/analytics_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,11 @@ def post_export_analytics_metrics(self, response): def pre_export_analytics_metrics( self, request: export_config.ExportAnalyticsMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportAnalyticsMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportAnalyticsMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for export_analytics_metrics Override in a subclass to manipulate the request or metadata @@ -102,8 +113,10 @@ def post_export_analytics_metrics( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +138,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -331,7 +346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export analytics metrics method over HTTP. @@ -342,8 +357,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -356,6 +373,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseExportAnalyticsMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_export_analytics_metrics( request, metadata ) @@ -372,6 +390,33 @@ def __call__( 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.retail_v2beta.AnalyticsServiceClient.ExportAnalyticsMetrics", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsServiceRestTransport._ExportAnalyticsMetrics._get_response( @@ -393,7 +438,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_analytics_metrics(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.retail_v2beta.AnalyticsServiceClient.export_analytics_metrics", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "ExportAnalyticsMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -444,7 +511,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -454,8 +521,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -464,6 +533,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -474,6 +544,33 @@ def __call__( 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.retail_v2beta.AnalyticsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._GetOperation._get_response( self._host, @@ -493,6 +590,27 @@ def __call__( 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.retail_v2beta.AnalyticsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -533,7 +651,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -543,8 +661,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -553,6 +673,7 @@ def __call__( http_options = ( _BaseAnalyticsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAnalyticsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -563,6 +684,33 @@ def __call__( 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.retail_v2beta.AnalyticsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsServiceRestTransport._ListOperations._get_response( self._host, @@ -582,6 +730,27 @@ def __call__( 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.retail_v2beta.AnalyticsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.AnalyticsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/async_client.py index d1a2a44e0d23..f803f5517ff3 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .transports.grpc_asyncio import CatalogServiceGrpcAsyncIOTransport +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 CatalogServiceAsyncClient: """Service for managing catalog configuration.""" @@ -271,6 +281,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.CatalogServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "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.retail.v2beta.CatalogService", + "credentialsType": None, + }, + ) + async def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -278,7 +310,7 @@ async def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsAsyncPager: r"""Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project. @@ -330,8 +362,10 @@ async def sample_list_catalogs(): 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, 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: google.cloud.retail_v2beta.services.catalog_service.pagers.ListCatalogsAsyncPager: @@ -408,7 +442,7 @@ async def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. @@ -475,8 +509,10 @@ async def sample_update_catalog(): 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, 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: google.cloud.retail_v2beta.types.Catalog: @@ -539,7 +575,7 @@ async def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], @@ -613,8 +649,10 @@ async def sample_set_default_branch(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -666,7 +704,7 @@ async def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] @@ -711,8 +749,10 @@ async def sample_get_default_branch(): 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, 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: google.cloud.retail_v2beta.types.GetDefaultBranchResponse: @@ -775,7 +815,7 @@ async def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. @@ -821,8 +861,10 @@ async def sample_get_completion_config(): 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, 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: google.cloud.retail_v2beta.types.CompletionConfig: @@ -887,7 +929,7 @@ async def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. @@ -960,8 +1002,10 @@ async def sample_update_completion_config(): 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, 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: google.cloud.retail_v2beta.types.CompletionConfig: @@ -1029,7 +1073,7 @@ async def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. @@ -1075,8 +1119,10 @@ async def sample_get_attributes_config(): 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, 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1138,7 +1184,7 @@ async def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. @@ -1209,8 +1255,10 @@ async def sample_update_attributes_config(): 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, 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1274,7 +1322,7 @@ async def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -1323,8 +1371,10 @@ async def sample_add_catalog_attribute(): 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, 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1372,7 +1422,7 @@ async def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -1418,8 +1468,10 @@ async def sample_remove_catalog_attribute(): 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, 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1467,7 +1519,7 @@ async def batch_remove_catalog_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Removes all specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s @@ -1509,8 +1561,10 @@ async def sample_batch_remove_catalog_attributes(): 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, 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: google.cloud.retail_v2beta.types.BatchRemoveCatalogAttributesResponse: @@ -1560,7 +1614,7 @@ async def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -1611,8 +1665,10 @@ async def sample_replace_catalog_attribute(): 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, 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1658,7 +1714,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1669,8 +1725,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1711,7 +1769,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1722,8 +1780,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/client.py index 79f3b304d077..bc34c289c0f2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -653,6 +663,10 @@ def __init__( # 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( @@ -718,6 +732,29 @@ def __init__( 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.retail_v2beta.CatalogServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "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.retail.v2beta.CatalogService", + "credentialsType": None, + }, + ) + def list_catalogs( self, request: Optional[Union[catalog_service.ListCatalogsRequest, dict]] = None, @@ -725,7 +762,7 @@ def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsPager: r"""Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project. @@ -777,8 +814,10 @@ def sample_list_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.services.catalog_service.pagers.ListCatalogsPager: @@ -852,7 +891,7 @@ def update_catalog( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. @@ -919,8 +958,10 @@ def sample_update_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Catalog: @@ -980,7 +1021,7 @@ def set_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], @@ -1054,8 +1095,10 @@ def sample_set_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1104,7 +1147,7 @@ def get_default_branch( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] @@ -1149,8 +1192,10 @@ def sample_get_default_branch(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.GetDefaultBranchResponse: @@ -1210,7 +1255,7 @@ def get_completion_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. @@ -1256,8 +1301,10 @@ def sample_get_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.CompletionConfig: @@ -1319,7 +1366,7 @@ def update_completion_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. @@ -1392,8 +1439,10 @@ def sample_update_completion_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.CompletionConfig: @@ -1458,7 +1507,7 @@ def get_attributes_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. @@ -1504,8 +1553,10 @@ def sample_get_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1564,7 +1615,7 @@ def update_attributes_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. @@ -1635,8 +1686,10 @@ def sample_update_attributes_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1697,7 +1750,7 @@ def add_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -1746,8 +1799,10 @@ def sample_add_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1793,7 +1848,7 @@ def remove_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -1839,8 +1894,10 @@ def sample_remove_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -1886,7 +1943,7 @@ def batch_remove_catalog_attributes( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Removes all specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s @@ -1928,8 +1985,10 @@ def sample_batch_remove_catalog_attributes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.BatchRemoveCatalogAttributesResponse: @@ -1979,7 +2038,7 @@ def replace_catalog_attribute( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] @@ -2030,8 +2089,10 @@ def sample_replace_catalog_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AttributesConfig: @@ -2090,7 +2151,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2101,8 +2162,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2143,7 +2206,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2154,8 +2217,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/pagers.py index 801dd48513d6..192ccaa4ca01 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = catalog_service.ListCatalogsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc.py index c4d145da885a..6bbdfc540ab0 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import catalog from google.cloud.retail_v2beta.types import catalog as gcr_catalog @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport +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.retail.v2beta.CatalogService", + "rpcName": 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.retail.v2beta.CatalogService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcTransport(CatalogServiceTransport): """gRPC backend transport for CatalogService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -287,7 +373,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -347,7 +433,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -378,7 +464,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -407,7 +493,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -436,7 +522,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -465,7 +551,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -503,7 +589,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -538,7 +624,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -573,7 +659,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -608,7 +694,7 @@ def batch_remove_catalog_attributes( if "batch_remove_catalog_attributes" not in self._stubs: self._stubs[ "batch_remove_catalog_attributes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/BatchRemoveCatalogAttributes", request_serializer=catalog_service.BatchRemoveCatalogAttributesRequest.serialize, response_deserializer=catalog_service.BatchRemoveCatalogAttributesResponse.deserialize, @@ -645,7 +731,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -653,7 +739,7 @@ def replace_catalog_attribute( return self._stubs["replace_catalog_attribute"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -665,7 +751,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -684,7 +770,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc_asyncio.py index 1ff9cfae5188..feece81294ca 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import catalog from google.cloud.retail_v2beta.types import catalog as gcr_catalog @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .grpc import CatalogServiceGrpcTransport +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.retail.v2beta.CatalogService", + "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.retail.v2beta.CatalogService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcAsyncIOTransport(CatalogServiceTransport): """gRPC AsyncIO backend transport for CatalogService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/ListCatalogs", request_serializer=catalog_service.ListCatalogsRequest.serialize, response_deserializer=catalog_service.ListCatalogsResponse.deserialize, @@ -298,7 +383,7 @@ def update_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog" not in self._stubs: - self._stubs["update_catalog"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateCatalog", request_serializer=catalog_service.UpdateCatalogRequest.serialize, response_deserializer=gcr_catalog.Catalog.deserialize, @@ -360,7 +445,7 @@ def set_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_default_branch" not in self._stubs: - self._stubs["set_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["set_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/SetDefaultBranch", request_serializer=catalog_service.SetDefaultBranchRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +476,7 @@ def get_default_branch( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_default_branch" not in self._stubs: - self._stubs["get_default_branch"] = self.grpc_channel.unary_unary( + self._stubs["get_default_branch"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetDefaultBranch", request_serializer=catalog_service.GetDefaultBranchRequest.serialize, response_deserializer=catalog_service.GetDefaultBranchResponse.deserialize, @@ -421,7 +506,7 @@ def get_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_completion_config" not in self._stubs: - self._stubs["get_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["get_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetCompletionConfig", request_serializer=catalog_service.GetCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -451,7 +536,7 @@ def update_completion_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_completion_config" not in self._stubs: - self._stubs["update_completion_config"] = self.grpc_channel.unary_unary( + self._stubs["update_completion_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig", request_serializer=catalog_service.UpdateCompletionConfigRequest.serialize, response_deserializer=catalog.CompletionConfig.deserialize, @@ -481,7 +566,7 @@ def get_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attributes_config" not in self._stubs: - self._stubs["get_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["get_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/GetAttributesConfig", request_serializer=catalog_service.GetAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -520,7 +605,7 @@ def update_attributes_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attributes_config" not in self._stubs: - self._stubs["update_attributes_config"] = self.grpc_channel.unary_unary( + self._stubs["update_attributes_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig", request_serializer=catalog_service.UpdateAttributesConfigRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -556,7 +641,7 @@ def add_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_catalog_attribute" not in self._stubs: - self._stubs["add_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["add_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/AddCatalogAttribute", request_serializer=catalog_service.AddCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -592,7 +677,7 @@ def remove_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_catalog_attribute" not in self._stubs: - self._stubs["remove_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["remove_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute", request_serializer=catalog_service.RemoveCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -627,7 +712,7 @@ def batch_remove_catalog_attributes( if "batch_remove_catalog_attributes" not in self._stubs: self._stubs[ "batch_remove_catalog_attributes" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/BatchRemoveCatalogAttributes", request_serializer=catalog_service.BatchRemoveCatalogAttributesRequest.serialize, response_deserializer=catalog_service.BatchRemoveCatalogAttributesResponse.deserialize, @@ -665,7 +750,7 @@ def replace_catalog_attribute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_catalog_attribute" not in self._stubs: - self._stubs["replace_catalog_attribute"] = self.grpc_channel.unary_unary( + self._stubs["replace_catalog_attribute"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute", request_serializer=catalog_service.ReplaceCatalogAttributeRequest.serialize, response_deserializer=catalog.AttributesConfig.deserialize, @@ -753,7 +838,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -769,7 +854,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -788,7 +873,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/rest.py index 45aa7614bca5..adbf95bf2b9a 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/catalog_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -166,8 +174,11 @@ def post_update_completion_config(self, response): def pre_add_catalog_attribute( self, request: catalog_service.AddCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.AddCatalogAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.AddCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_catalog_attribute Override in a subclass to manipulate the request or metadata @@ -189,9 +200,10 @@ def post_add_catalog_attribute( def pre_batch_remove_catalog_attributes( self, request: catalog_service.BatchRemoveCatalogAttributesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.BatchRemoveCatalogAttributesRequest, Sequence[Tuple[str, str]] + catalog_service.BatchRemoveCatalogAttributesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_remove_catalog_attributes @@ -214,8 +226,11 @@ def post_batch_remove_catalog_attributes( def pre_get_attributes_config( self, request: catalog_service.GetAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetAttributesConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_attributes_config Override in a subclass to manipulate the request or metadata @@ -237,8 +252,11 @@ def post_get_attributes_config( def pre_get_completion_config( self, request: catalog_service.GetCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetCompletionConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_completion_config Override in a subclass to manipulate the request or metadata @@ -260,8 +278,10 @@ def post_get_completion_config( def pre_get_default_branch( self, request: catalog_service.GetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_default_branch Override in a subclass to manipulate the request or metadata @@ -283,8 +303,10 @@ def post_get_default_branch( def pre_list_catalogs( self, request: catalog_service.ListCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.ListCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.ListCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_catalogs Override in a subclass to manipulate the request or metadata @@ -306,9 +328,10 @@ def post_list_catalogs( def pre_remove_catalog_attribute( self, request: catalog_service.RemoveCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.RemoveCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.RemoveCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_catalog_attribute @@ -331,9 +354,10 @@ def post_remove_catalog_attribute( def pre_replace_catalog_attribute( self, request: catalog_service.ReplaceCatalogAttributeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.ReplaceCatalogAttributeRequest, Sequence[Tuple[str, str]] + catalog_service.ReplaceCatalogAttributeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for replace_catalog_attribute @@ -356,8 +380,10 @@ def post_replace_catalog_attribute( def pre_set_default_branch( self, request: catalog_service.SetDefaultBranchRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.SetDefaultBranchRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_default_branch Override in a subclass to manipulate the request or metadata @@ -368,9 +394,10 @@ def pre_set_default_branch( def pre_update_attributes_config( self, request: catalog_service.UpdateAttributesConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateAttributesConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateAttributesConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_attributes_config @@ -393,8 +420,10 @@ def post_update_attributes_config( def pre_update_catalog( self, request: catalog_service.UpdateCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.UpdateCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_catalog Override in a subclass to manipulate the request or metadata @@ -414,9 +443,10 @@ def post_update_catalog(self, response: gcr_catalog.Catalog) -> gcr_catalog.Cata def pre_update_completion_config( self, request: catalog_service.UpdateCompletionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - catalog_service.UpdateCompletionConfigRequest, Sequence[Tuple[str, str]] + catalog_service.UpdateCompletionConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_completion_config @@ -439,8 +469,10 @@ def post_update_completion_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -462,8 +494,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -605,7 +639,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the add catalog attribute method over HTTP. @@ -617,8 +651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -628,6 +664,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseAddCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_add_catalog_attribute( request, metadata ) @@ -644,6 +681,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.AddCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "AddCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._AddCatalogAttribute._get_response( self._host, @@ -665,7 +729,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2beta.CatalogServiceClient.add_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "AddCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchRemoveCatalogAttributes( @@ -704,7 +790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.BatchRemoveCatalogAttributesResponse: r"""Call the batch remove catalog attributes method over HTTP. @@ -717,8 +803,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.BatchRemoveCatalogAttributesResponse: @@ -730,6 +818,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseBatchRemoveCatalogAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_remove_catalog_attributes( request, metadata ) @@ -746,6 +835,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.BatchRemoveCatalogAttributes", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "BatchRemoveCatalogAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._BatchRemoveCatalogAttributes._get_response( @@ -769,7 +885,33 @@ def __call__( pb_resp = catalog_service.BatchRemoveCatalogAttributesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_remove_catalog_attributes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + catalog_service.BatchRemoveCatalogAttributesResponse.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.retail_v2beta.CatalogServiceClient.batch_remove_catalog_attributes", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "BatchRemoveCatalogAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttributesConfig( @@ -807,7 +949,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the get attributes config method over HTTP. @@ -819,8 +961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -830,6 +974,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_attributes_config( request, metadata ) @@ -842,6 +987,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.GetAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetAttributesConfig._get_response( self._host, @@ -862,7 +1034,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2beta.CatalogServiceClient.get_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCompletionConfig( @@ -900,7 +1094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the get completion config method over HTTP. @@ -912,8 +1106,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -926,6 +1122,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_completion_config( request, metadata ) @@ -938,6 +1135,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.GetCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetCompletionConfig._get_response( self._host, @@ -958,7 +1182,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2beta.CatalogServiceClient.get_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDefaultBranch( @@ -995,7 +1241,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.GetDefaultBranchResponse: r"""Call the get default branch method over HTTP. @@ -1006,8 +1252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.GetDefaultBranchResponse: @@ -1019,6 +1267,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_get_default_branch( request, metadata ) @@ -1031,6 +1280,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.GetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetDefaultBranch._get_response( self._host, @@ -1051,7 +1327,31 @@ def __call__( pb_resp = catalog_service.GetDefaultBranchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_default_branch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.GetDefaultBranchResponse.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.retail_v2beta.CatalogServiceClient.get_default_branch", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetDefaultBranch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogs( @@ -1088,7 +1388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.ListCatalogsResponse: r"""Call the list catalogs method over HTTP. @@ -1100,8 +1400,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.ListCatalogsResponse: @@ -1114,6 +1416,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalogs(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListCatalogs._get_transcoded_request( http_options, request @@ -1124,6 +1427,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.ListCatalogs", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ListCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListCatalogs._get_response( self._host, @@ -1144,7 +1474,31 @@ def __call__( pb_resp = catalog_service.ListCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.ListCatalogsResponse.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.retail_v2beta.CatalogServiceClient.list_catalogs", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ListCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveCatalogAttribute( @@ -1183,7 +1537,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the remove catalog attribute method over HTTP. @@ -1195,8 +1549,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1206,6 +1562,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseRemoveCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_remove_catalog_attribute( request, metadata ) @@ -1222,6 +1579,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.RemoveCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._RemoveCatalogAttribute._get_response( @@ -1245,7 +1629,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2beta.CatalogServiceClient.remove_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "RemoveCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReplaceCatalogAttribute( @@ -1284,7 +1690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the replace catalog attribute method over HTTP. @@ -1296,8 +1702,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1307,6 +1715,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseReplaceCatalogAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_replace_catalog_attribute( request, metadata ) @@ -1323,6 +1732,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.ReplaceCatalogAttribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._ReplaceCatalogAttribute._get_response( @@ -1346,7 +1782,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_replace_catalog_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2beta.CatalogServiceClient.replace_catalog_attribute", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ReplaceCatalogAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDefaultBranch( @@ -1384,7 +1842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the set default branch method over HTTP. @@ -1395,13 +1853,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCatalogServiceRestTransport._BaseSetDefaultBranch._get_http_options() ) + request, metadata = self._interceptor.pre_set_default_branch( request, metadata ) @@ -1418,6 +1879,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.SetDefaultBranch", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "SetDefaultBranch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._SetDefaultBranch._get_response( self._host, @@ -1470,7 +1958,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.AttributesConfig: r"""Call the update attributes config method over HTTP. @@ -1482,8 +1970,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.AttributesConfig: @@ -1493,6 +1983,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateAttributesConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_attributes_config( request, metadata ) @@ -1509,6 +2000,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.UpdateAttributesConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateAttributesConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateAttributesConfig._get_response( @@ -1532,7 +2050,29 @@ def __call__( pb_resp = catalog.AttributesConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attributes_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.AttributesConfig.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.retail_v2beta.CatalogServiceClient.update_attributes_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateAttributesConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCatalog( @@ -1570,7 +2110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_catalog.Catalog: r"""Call the update catalog method over HTTP. @@ -1582,8 +2122,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_catalog.Catalog: @@ -1593,6 +2135,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_update_catalog(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseUpdateCatalog._get_transcoded_request( http_options, request @@ -1607,6 +2150,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.UpdateCatalog", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._UpdateCatalog._get_response( self._host, @@ -1628,7 +2198,29 @@ def __call__( pb_resp = gcr_catalog.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_catalog.Catalog.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.retail_v2beta.CatalogServiceClient.update_catalog", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCompletionConfig( @@ -1667,7 +2259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CompletionConfig: r"""Call the update completion config method over HTTP. @@ -1679,8 +2271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CompletionConfig: @@ -1693,6 +2287,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCompletionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_completion_config( request, metadata ) @@ -1709,6 +2304,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.UpdateCompletionConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateCompletionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CatalogServiceRestTransport._UpdateCompletionConfig._get_response( @@ -1732,7 +2354,29 @@ def __call__( pb_resp = catalog.CompletionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_completion_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CompletionConfig.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.retail_v2beta.CatalogServiceClient.update_completion_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "UpdateCompletionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1891,7 +2535,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1901,8 +2545,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1911,6 +2557,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1921,6 +2568,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetOperation._get_response( self._host, @@ -1940,6 +2614,27 @@ def __call__( 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.retail_v2beta.CatalogServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1980,7 +2675,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1990,8 +2685,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2000,6 +2697,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCatalogServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2010,6 +2708,33 @@ def __call__( 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.retail_v2beta.CatalogServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListOperations._get_response( self._host, @@ -2029,6 +2754,27 @@ def __call__( 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.retail_v2beta.CatalogServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.CatalogService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/async_client.py index 1ed934a46df9..ef79abf145b7 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .transports.grpc_asyncio import CompletionServiceGrpcAsyncIOTransport +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 CompletionServiceAsyncClient: """Autocomplete service for retail. @@ -267,13 +277,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.CompletionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "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.retail.v2beta.CompletionService", + "credentialsType": None, + }, + ) + async def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -314,8 +346,10 @@ async def sample_complete_query(): 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, 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: google.cloud.retail_v2beta.types.CompleteQueryResponse: @@ -361,7 +395,7 @@ async def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of processed completion dataset. @@ -418,8 +452,10 @@ async def sample_import_completion_data(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -479,7 +515,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -490,8 +526,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -532,7 +570,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -543,8 +581,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/client.py index 44f4c7d190bc..83ab75290984 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -591,6 +601,10 @@ def __init__( # 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( @@ -657,13 +671,36 @@ def __init__( 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.retail_v2beta.CompletionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "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.retail.v2beta.CompletionService", + "credentialsType": None, + }, + ) + def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. @@ -704,8 +741,10 @@ def sample_complete_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.CompleteQueryResponse: @@ -749,7 +788,7 @@ def import_completion_data( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of processed completion dataset. @@ -806,8 +845,10 @@ def sample_import_completion_data(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -878,7 +919,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -889,8 +930,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -931,7 +974,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -942,8 +985,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc.py index 0df7ca3d4177..d33627458ec2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport +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.retail.v2beta.CompletionService", + "rpcName": 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.retail.v2beta.CompletionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcTransport(CompletionServiceTransport): """gRPC backend transport for CompletionService. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -320,7 +408,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -328,7 +416,7 @@ def import_completion_data( return self._stubs["import_completion_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -340,7 +428,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -359,7 +447,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc_asyncio.py index 82ba31aad692..96ff3b041fa9 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import completion_service, import_config from .base import DEFAULT_CLIENT_INFO, CompletionServiceTransport from .grpc import CompletionServiceGrpcTransport +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.retail.v2beta.CompletionService", + "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.retail.v2beta.CompletionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionServiceGrpcAsyncIOTransport(CompletionServiceTransport): """gRPC AsyncIO backend transport for CompletionService. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CompletionService/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -330,7 +415,7 @@ def import_completion_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_completion_data" not in self._stubs: - self._stubs["import_completion_data"] = self.grpc_channel.unary_unary( + self._stubs["import_completion_data"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.CompletionService/ImportCompletionData", request_serializer=import_config.ImportCompletionDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +453,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -384,7 +469,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -403,7 +488,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/rest.py index 2a7b6cb407b8..dc74f47f8e37 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/completion_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -87,8 +95,10 @@ def post_import_completion_data(self, response): def pre_complete_query( self, request: completion_service.CompleteQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[completion_service.CompleteQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + completion_service.CompleteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_query Override in a subclass to manipulate the request or metadata @@ -110,8 +120,11 @@ def post_complete_query( def pre_import_completion_data( self, request: import_config.ImportCompletionDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportCompletionDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportCompletionDataRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for import_completion_data Override in a subclass to manipulate the request or metadata @@ -133,8 +146,10 @@ def post_import_completion_data( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -156,8 +171,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -363,7 +380,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Call the complete query method over HTTP. @@ -373,8 +390,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.completion_service.CompleteQueryResponse: @@ -384,6 +403,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_http_options() ) + request, metadata = self._interceptor.pre_complete_query(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseCompleteQuery._get_transcoded_request( http_options, request @@ -394,6 +414,33 @@ def __call__( 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.retail_v2beta.CompletionServiceClient.CompleteQuery", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "CompleteQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._CompleteQuery._get_response( self._host, @@ -414,7 +461,31 @@ def __call__( pb_resp = completion_service.CompleteQueryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = completion_service.CompleteQueryResponse.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.retail_v2beta.CompletionServiceClient.complete_query", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "CompleteQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportCompletionData( @@ -453,7 +524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import completion data method over HTTP. @@ -464,8 +535,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -478,6 +551,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseImportCompletionData._get_http_options() ) + request, metadata = self._interceptor.pre_import_completion_data( request, metadata ) @@ -494,6 +568,33 @@ def __call__( 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.retail_v2beta.CompletionServiceClient.ImportCompletionData", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "ImportCompletionData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CompletionServiceRestTransport._ImportCompletionData._get_response( @@ -515,7 +616,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_completion_data(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.retail_v2beta.CompletionServiceClient.import_completion_data", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "ImportCompletionData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -577,7 +700,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -587,8 +710,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -597,6 +722,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -607,6 +733,33 @@ def __call__( 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.retail_v2beta.CompletionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._GetOperation._get_response( self._host, @@ -626,6 +779,27 @@ def __call__( 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.retail_v2beta.CompletionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -667,7 +841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -677,8 +851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -687,6 +863,7 @@ def __call__( http_options = ( _BaseCompletionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCompletionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -697,6 +874,33 @@ def __call__( 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.retail_v2beta.CompletionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionServiceRestTransport._ListOperations._get_response( self._host, @@ -716,6 +920,27 @@ def __call__( 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.retail_v2beta.CompletionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.CompletionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/async_client.py index e40e87d8c61c..902f70128fcb 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .transports.grpc_asyncio import ControlServiceGrpcAsyncIOTransport +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 ControlServiceAsyncClient: """Service for modifying Control.""" @@ -263,6 +273,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.ControlServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "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.retail.v2beta.ControlService", + "credentialsType": None, + }, + ) + async def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -272,7 +304,7 @@ async def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -341,8 +373,10 @@ async def sample_create_control(): 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, 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: google.cloud.retail_v2beta.types.Control: @@ -409,7 +443,7 @@ async def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -453,8 +487,10 @@ async def sample_delete_control(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -507,7 +543,7 @@ async def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -570,8 +606,10 @@ async def sample_update_control(): 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, 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: google.cloud.retail_v2beta.types.Control: @@ -638,7 +676,7 @@ async def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -682,8 +720,10 @@ async def sample_get_control(): 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, 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: google.cloud.retail_v2beta.types.Control: @@ -746,7 +786,7 @@ async def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsAsyncPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. @@ -791,8 +831,10 @@ async def sample_list_controls(): 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, 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: google.cloud.retail_v2beta.services.control_service.pagers.ListControlsAsyncPager: @@ -866,7 +908,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -877,8 +919,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -919,7 +963,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -930,8 +974,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/client.py index 24ac5739c618..f773fe55cae3 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -609,6 +619,10 @@ def __init__( # 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( @@ -674,6 +688,29 @@ def __init__( 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.retail_v2beta.ControlServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "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.retail.v2beta.ControlService", + "credentialsType": None, + }, + ) + def create_control( self, request: Optional[Union[control_service.CreateControlRequest, dict]] = None, @@ -683,7 +720,7 @@ def create_control( control_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Creates a Control. @@ -752,8 +789,10 @@ def sample_create_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Control: @@ -817,7 +856,7 @@ def delete_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a Control. @@ -861,8 +900,10 @@ def sample_delete_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -912,7 +953,7 @@ def update_control( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Updates a Control. @@ -975,8 +1016,10 @@ def sample_update_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Control: @@ -1040,7 +1083,7 @@ def get_control( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Gets a Control. @@ -1084,8 +1127,10 @@ def sample_get_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Control: @@ -1145,7 +1190,7 @@ def list_controls( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListControlsPager: r"""Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. @@ -1190,8 +1235,10 @@ def sample_list_controls(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.services.control_service.pagers.ListControlsPager: @@ -1275,7 +1322,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1286,8 +1333,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1328,7 +1377,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1339,8 +1388,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/pagers.py index 9c15389d03bc..b89ffb047147 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = control_service.ListControlsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc.py index 13ca1550dd74..debcd8f243f2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import control from google.cloud.retail_v2beta.types import control as gcr_control @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport +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.retail.v2beta.ControlService", + "rpcName": 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.retail.v2beta.ControlService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcTransport(ControlServiceTransport): """gRPC backend transport for ControlService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -290,7 +376,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -321,7 +407,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -347,7 +433,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -376,7 +462,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -384,7 +470,7 @@ def list_controls( return self._stubs["list_controls"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -396,7 +482,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -415,7 +501,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc_asyncio.py index 2f21a3f8b36c..28dceec22000 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import control from google.cloud.retail_v2beta.types import control as gcr_control @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ControlServiceTransport from .grpc import ControlServiceGrpcTransport +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.retail.v2beta.ControlService", + "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.retail.v2beta.ControlService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ControlServiceGrpcAsyncIOTransport(ControlServiceTransport): """gRPC AsyncIO backend transport for ControlService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def create_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_control" not in self._stubs: - self._stubs["create_control"] = self.grpc_channel.unary_unary( + self._stubs["create_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/CreateControl", request_serializer=control_service.CreateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -300,7 +385,7 @@ def delete_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_control" not in self._stubs: - self._stubs["delete_control"] = self.grpc_channel.unary_unary( + self._stubs["delete_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/DeleteControl", request_serializer=control_service.DeleteControlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -333,7 +418,7 @@ def update_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_control" not in self._stubs: - self._stubs["update_control"] = self.grpc_channel.unary_unary( + self._stubs["update_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/UpdateControl", request_serializer=control_service.UpdateControlRequest.serialize, response_deserializer=gcr_control.Control.deserialize, @@ -359,7 +444,7 @@ def get_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_control" not in self._stubs: - self._stubs["get_control"] = self.grpc_channel.unary_unary( + self._stubs["get_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/GetControl", request_serializer=control_service.GetControlRequest.serialize, response_deserializer=control.Control.deserialize, @@ -389,7 +474,7 @@ def list_controls( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_controls" not in self._stubs: - self._stubs["list_controls"] = self.grpc_channel.unary_unary( + self._stubs["list_controls"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ControlService/ListControls", request_serializer=control_service.ListControlsRequest.serialize, response_deserializer=control_service.ListControlsResponse.deserialize, @@ -442,7 +527,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -458,7 +543,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -477,7 +562,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/rest.py index e7be2de69570..8a82c857a5ad 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/control_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -110,8 +118,10 @@ def post_update_control(self, response): def pre_create_control( self, request: control_service.CreateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.CreateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.CreateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_control Override in a subclass to manipulate the request or metadata @@ -131,8 +141,10 @@ def post_create_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_delete_control( self, request: control_service.DeleteControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.DeleteControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.DeleteControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_control Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def pre_delete_control( def pre_get_control( self, request: control_service.GetControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.GetControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.GetControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_control Override in a subclass to manipulate the request or metadata @@ -164,8 +178,10 @@ def post_get_control(self, response: control.Control) -> control.Control: def pre_list_controls( self, request: control_service.ListControlsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.ListControlsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.ListControlsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_controls Override in a subclass to manipulate the request or metadata @@ -187,8 +203,10 @@ def post_list_controls( def pre_update_control( self, request: control_service.UpdateControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[control_service.UpdateControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + control_service.UpdateControlRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_control Override in a subclass to manipulate the request or metadata @@ -208,8 +226,10 @@ def post_update_control(self, response: gcr_control.Control) -> gcr_control.Cont def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -231,8 +251,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -373,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the create control method over HTTP. @@ -383,8 +405,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -398,6 +422,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseCreateControl._get_http_options() ) + request, metadata = self._interceptor.pre_create_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseCreateControl._get_transcoded_request( http_options, request @@ -412,6 +437,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.CreateControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "CreateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._CreateControl._get_response( self._host, @@ -433,7 +485,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2beta.ControlServiceClient.create_control", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "CreateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteControl( @@ -470,7 +544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete control method over HTTP. @@ -480,13 +554,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseControlServiceRestTransport._BaseDeleteControl._get_http_options() ) + request, metadata = self._interceptor.pre_delete_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseDeleteControl._get_transcoded_request( http_options, request @@ -497,6 +574,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.DeleteControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "DeleteControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._DeleteControl._get_response( self._host, @@ -546,7 +650,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control.Control: r"""Call the get control method over HTTP. @@ -556,8 +660,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control.Control: @@ -571,6 +677,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetControl._get_http_options() ) + request, metadata = self._interceptor.pre_get_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetControl._get_transcoded_request( http_options, request @@ -583,6 +690,33 @@ def __call__( ) ) + 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.retail_v2beta.ControlServiceClient.GetControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "GetControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetControl._get_response( self._host, @@ -603,7 +737,29 @@ def __call__( pb_resp = control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control.Control.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.retail_v2beta.ControlServiceClient.get_control", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "GetControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListControls( @@ -640,7 +796,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> control_service.ListControlsResponse: r"""Call the list controls method over HTTP. @@ -650,8 +806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.control_service.ListControlsResponse: @@ -661,6 +819,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListControls._get_http_options() ) + request, metadata = self._interceptor.pre_list_controls(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListControls._get_transcoded_request( http_options, request @@ -671,6 +830,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.ListControls", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "ListControls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListControls._get_response( self._host, @@ -691,7 +877,31 @@ def __call__( pb_resp = control_service.ListControlsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_controls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = control_service.ListControlsResponse.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.retail_v2beta.ControlServiceClient.list_controls", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "ListControls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateControl( @@ -729,7 +939,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_control.Control: r"""Call the update control method over HTTP. @@ -739,8 +949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_control.Control: @@ -754,6 +966,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseUpdateControl._get_http_options() ) + request, metadata = self._interceptor.pre_update_control(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseUpdateControl._get_transcoded_request( http_options, request @@ -768,6 +981,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.UpdateControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "UpdateControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._UpdateControl._get_response( self._host, @@ -789,7 +1029,29 @@ def __call__( pb_resp = gcr_control.Control.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_control.Control.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.retail_v2beta.ControlServiceClient.update_control", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "UpdateControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -872,7 +1134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -882,8 +1144,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -892,6 +1156,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -902,6 +1167,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._GetOperation._get_response( self._host, @@ -921,6 +1213,27 @@ def __call__( 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.retail_v2beta.ControlServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -961,7 +1274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -971,8 +1284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -981,6 +1296,7 @@ def __call__( http_options = ( _BaseControlServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseControlServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -991,6 +1307,33 @@ def __call__( 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.retail_v2beta.ControlServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ControlServiceRestTransport._ListOperations._get_response( self._host, @@ -1010,6 +1353,27 @@ def __call__( 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.retail_v2beta.ControlServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ControlService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/async_client.py index 8dbdb4bb0955..c2bd914b556e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .transports.grpc_asyncio import GenerativeQuestionServiceGrpcAsyncIOTransport +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 GenerativeQuestionServiceAsyncClient: """Service for managing LLM generated questions in search @@ -276,6 +286,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.GenerativeQuestionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "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.retail.v2beta.GenerativeQuestionService", + "credentialsType": None, + }, + ) + async def update_generative_questions_feature_config( self, request: Optional[ @@ -291,7 +323,7 @@ async def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -349,8 +381,10 @@ async def sample_update_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig: @@ -432,7 +466,7 @@ async def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -479,8 +513,10 @@ async def sample_get_generative_questions_feature_config(): 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, 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: google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig: @@ -552,7 +588,7 @@ async def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -596,8 +632,10 @@ async def sample_list_generative_question_configs(): 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, 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: google.cloud.retail_v2beta.types.ListGenerativeQuestionConfigsResponse: @@ -667,7 +705,7 @@ async def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -725,8 +763,10 @@ async def sample_update_generative_question_config(): 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, 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: google.cloud.retail_v2beta.types.GenerativeQuestionConfig: @@ -810,7 +850,7 @@ async def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -867,8 +907,10 @@ async def sample_batch_update_generative_question_configs(): 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, 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: google.cloud.retail_v2beta.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -937,7 +979,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -948,8 +990,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -990,7 +1034,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1001,8 +1045,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/client.py index 17b7f7675915..70a438763916 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -594,6 +604,10 @@ def __init__( # 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( @@ -660,6 +674,29 @@ def __init__( 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.retail_v2beta.GenerativeQuestionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "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.retail.v2beta.GenerativeQuestionService", + "credentialsType": None, + }, + ) + def update_generative_questions_feature_config( self, request: Optional[ @@ -675,7 +712,7 @@ def update_generative_questions_feature_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -733,8 +770,10 @@ def sample_update_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig: @@ -815,7 +854,7 @@ def get_generative_questions_feature_config( catalog: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Manages overal generative question feature state -- enables toggling feature on and off. @@ -862,8 +901,10 @@ def sample_get_generative_questions_feature_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig: @@ -934,7 +975,7 @@ def list_generative_question_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Returns all questions for a given catalog. @@ -978,8 +1019,10 @@ def sample_list_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ListGenerativeQuestionConfigsResponse: @@ -1048,7 +1091,7 @@ def update_generative_question_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Allows management of individual questions. @@ -1106,8 +1149,10 @@ def sample_update_generative_question_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.GenerativeQuestionConfig: @@ -1190,7 +1235,7 @@ def batch_update_generative_question_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Allows management of multiple questions. @@ -1247,8 +1292,10 @@ def sample_batch_update_generative_question_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.BatchUpdateGenerativeQuestionConfigsResponse: @@ -1329,7 +1376,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1340,8 +1387,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1382,7 +1431,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1393,8 +1442,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc.py index 44cca87df83d..29a8b1a425a8 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import ( generative_question, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport +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.retail.v2beta.GenerativeQuestionService", + "rpcName": 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.retail.v2beta.GenerativeQuestionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcTransport(GenerativeQuestionServiceTransport): """gRPC backend transport for GenerativeQuestionService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -299,7 +385,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -331,7 +417,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -363,7 +449,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -395,7 +481,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -403,7 +489,7 @@ def batch_update_generative_question_configs( return self._stubs["batch_update_generative_question_configs"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -415,7 +501,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -434,7 +520,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc_asyncio.py index 6e291068347e..e2deffe4b2cb 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import ( generative_question, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, GenerativeQuestionServiceTransport from .grpc import GenerativeQuestionServiceGrpcTransport +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.retail.v2beta.GenerativeQuestionService", + "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.retail.v2beta.GenerativeQuestionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeQuestionServiceGrpcAsyncIOTransport(GenerativeQuestionServiceTransport): """gRPC AsyncIO backend transport for GenerativeQuestionService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def update_generative_questions_feature_config( if "update_generative_questions_feature_config" not in self._stubs: self._stubs[ "update_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/UpdateGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -307,7 +392,7 @@ def get_generative_questions_feature_config( if "get_generative_questions_feature_config" not in self._stubs: self._stubs[ "get_generative_questions_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/GetGenerativeQuestionsFeatureConfig", request_serializer=generative_question_service.GetGenerativeQuestionsFeatureConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionsFeatureConfig.deserialize, @@ -339,7 +424,7 @@ def list_generative_question_configs( if "list_generative_question_configs" not in self._stubs: self._stubs[ "list_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/ListGenerativeQuestionConfigs", request_serializer=generative_question_service.ListGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.ListGenerativeQuestionConfigsResponse.deserialize, @@ -371,7 +456,7 @@ def update_generative_question_config( if "update_generative_question_config" not in self._stubs: self._stubs[ "update_generative_question_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/UpdateGenerativeQuestionConfig", request_serializer=generative_question_service.UpdateGenerativeQuestionConfigRequest.serialize, response_deserializer=generative_question.GenerativeQuestionConfig.deserialize, @@ -405,7 +490,7 @@ def batch_update_generative_question_configs( if "batch_update_generative_question_configs" not in self._stubs: self._stubs[ "batch_update_generative_question_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.GenerativeQuestionService/BatchUpdateGenerativeQuestionConfigs", request_serializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest.serialize, response_deserializer=generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.deserialize, @@ -458,7 +543,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -474,7 +559,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -493,7 +578,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/rest.py index d6a8a184440d..878b621861d1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/generative_question_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -114,10 +122,10 @@ def post_update_generative_questions_feature_config(self, response): def pre_batch_update_generative_question_configs( self, request: generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.BatchUpdateGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_update_generative_question_configs @@ -141,10 +149,10 @@ def post_batch_update_generative_question_configs( def pre_get_generative_questions_feature_config( self, request: generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.GetGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_generative_questions_feature_config @@ -167,10 +175,10 @@ def post_get_generative_questions_feature_config( def pre_list_generative_question_configs( self, request: generative_question_service.ListGenerativeQuestionConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.ListGenerativeQuestionConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_generative_question_configs @@ -194,10 +202,10 @@ def post_list_generative_question_configs( def pre_update_generative_question_config( self, request: generative_question_service.UpdateGenerativeQuestionConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_question_config @@ -220,10 +228,10 @@ def post_update_generative_question_config( def pre_update_generative_questions_feature_config( self, request: generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ generative_question_service.UpdateGenerativeQuestionsFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_generative_questions_feature_config @@ -246,8 +254,10 @@ def post_update_generative_questions_feature_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -269,8 +279,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -417,7 +429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: r"""Call the batch update generative question configs method over HTTP. @@ -430,8 +442,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse: @@ -443,6 +457,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseBatchUpdateGenerativeQuestionConfigs._get_http_options() ) + ( request, metadata, @@ -462,6 +477,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.BatchUpdateGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._BatchUpdateGenerativeQuestionConfigs._get_response( self._host, @@ -487,7 +529,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.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.retail_v2beta.GenerativeQuestionServiceClient.batch_update_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "BatchUpdateGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGenerativeQuestionsFeatureConfig( @@ -527,7 +593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the get generative questions feature config method over HTTP. @@ -540,8 +606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -553,6 +621,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -568,6 +637,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.GetGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._GetGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -588,7 +684,33 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_generative_questions_feature_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2beta.GenerativeQuestionServiceClient.get_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "GetGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGenerativeQuestionConfigs( @@ -628,7 +750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question_service.ListGenerativeQuestionConfigsResponse: r"""Call the list generative question configs method over HTTP. @@ -639,8 +761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question_service.ListGenerativeQuestionConfigsResponse: @@ -650,6 +774,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListGenerativeQuestionConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_generative_question_configs( request, metadata ) @@ -662,6 +787,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.ListGenerativeQuestionConfigs", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._ListGenerativeQuestionConfigs._get_response( self._host, @@ -686,7 +838,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_generative_question_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_question_service.ListGenerativeQuestionConfigsResponse.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.retail_v2beta.GenerativeQuestionServiceClient.list_generative_question_configs", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "ListGenerativeQuestionConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionConfig( @@ -727,7 +903,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionConfig: r"""Call the update generative question config method over HTTP. @@ -739,8 +915,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionConfig: @@ -752,6 +930,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_generative_question_config( request, metadata ) @@ -768,6 +947,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.UpdateGenerativeQuestionConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionConfig._get_response( self._host, @@ -789,7 +995,31 @@ def __call__( pb_resp = generative_question.GenerativeQuestionConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_question_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionConfig.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.retail_v2beta.GenerativeQuestionServiceClient.update_generative_question_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerativeQuestionsFeatureConfig( @@ -830,7 +1060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_question.GenerativeQuestionsFeatureConfig: r"""Call the update generative questions feature config method over HTTP. @@ -843,8 +1073,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.generative_question.GenerativeQuestionsFeatureConfig: @@ -856,6 +1088,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseUpdateGenerativeQuestionsFeatureConfig._get_http_options() ) + ( request, metadata, @@ -875,6 +1108,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.UpdateGenerativeQuestionsFeatureConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeQuestionServiceRestTransport._UpdateGenerativeQuestionsFeatureConfig._get_response( self._host, @@ -896,9 +1156,35 @@ def __call__( pb_resp = generative_question.GenerativeQuestionsFeatureConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generative_questions_feature_config( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_question.GenerativeQuestionsFeatureConfig.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.retail_v2beta.GenerativeQuestionServiceClient.update_generative_questions_feature_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "UpdateGenerativeQuestionsFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -995,7 +1281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1005,8 +1291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1015,6 +1303,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1025,6 +1314,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._GetOperation._get_response( @@ -1046,6 +1362,27 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1087,7 +1424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1097,8 +1434,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1107,6 +1446,7 @@ def __call__( http_options = ( _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGenerativeQuestionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1117,6 +1457,33 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeQuestionServiceRestTransport._ListOperations._get_response( @@ -1138,6 +1505,27 @@ def __call__( 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.retail_v2beta.GenerativeQuestionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.GenerativeQuestionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/async_client.py index 9fca2c05572d..07d118f6bece 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +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 ModelServiceAsyncClient: """Service for performing CRUD operations on models. Recommendation @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "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.retail.v2beta.ModelService", + "credentialsType": None, + }, + ) + async def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -282,7 +314,7 @@ async def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new model. @@ -343,8 +375,10 @@ async def sample_create_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -421,7 +455,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -466,8 +500,10 @@ async def sample_get_model(): 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, 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: google.cloud.retail_v2beta.types.Model: @@ -532,7 +568,7 @@ async def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -576,8 +612,10 @@ async def sample_pause_model(): 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, 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: google.cloud.retail_v2beta.types.Model: @@ -642,7 +680,7 @@ async def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -686,8 +724,10 @@ async def sample_resume_model(): 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, 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: google.cloud.retail_v2beta.types.Model: @@ -752,7 +792,7 @@ async def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -794,8 +834,10 @@ async def sample_delete_model(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -847,7 +889,7 @@ async def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsAsyncPager: r"""Lists all the models linked to this event store. @@ -892,8 +934,10 @@ async def sample_list_models(): 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, 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: google.cloud.retail_v2beta.services.model_service.pagers.ListModelsAsyncPager: @@ -969,7 +1013,7 @@ async def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1028,8 +1072,10 @@ async def sample_update_model(): 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, 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: google.cloud.retail_v2beta.types.Model: @@ -1098,7 +1144,7 @@ async def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Tunes an existing model. @@ -1149,8 +1195,10 @@ async def sample_tune_model(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1221,7 +1269,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1232,8 +1280,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1274,7 +1324,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1285,8 +1335,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/client.py index 1d38631f8312..ecf7cc01c869 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -684,6 +698,29 @@ def __init__( 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.retail_v2beta.ModelServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "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.retail.v2beta.ModelService", + "credentialsType": None, + }, + ) + def create_model( self, request: Optional[Union[model_service.CreateModelRequest, dict]] = None, @@ -692,7 +729,7 @@ def create_model( model: Optional[gcr_model.Model] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new model. @@ -753,8 +790,10 @@ def sample_create_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -828,7 +867,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets a model. @@ -873,8 +912,10 @@ def sample_get_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2beta.types.Model: @@ -936,7 +977,7 @@ def pause_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Pauses the training of an existing model. @@ -980,8 +1021,10 @@ def sample_pause_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2beta.types.Model: @@ -1043,7 +1086,7 @@ def resume_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Resumes the training of an existing model. @@ -1087,8 +1130,10 @@ def sample_resume_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2beta.types.Model: @@ -1150,7 +1195,7 @@ def delete_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing model. @@ -1192,8 +1237,10 @@ def sample_delete_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1242,7 +1289,7 @@ def list_models( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListModelsPager: r"""Lists all the models linked to this event store. @@ -1287,8 +1334,10 @@ def sample_list_models(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2beta.services.model_service.pagers.ListModelsPager: @@ -1361,7 +1410,7 @@ def update_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Update of model metadata. Only fields that currently can be updated are: ``filtering_option`` and ``periodic_tuning_state``. @@ -1420,8 +1469,10 @@ def sample_update_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.retail_v2beta.types.Model: @@ -1487,7 +1538,7 @@ def tune_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Tunes an existing model. @@ -1538,8 +1589,10 @@ def sample_tune_model(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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: @@ -1620,7 +1673,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1631,8 +1684,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1673,7 +1728,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1684,8 +1739,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/pagers.py index 4fa1019a0a14..16a09fb25c74 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = model_service.ListModelsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc.py index 2863cf29082b..fab449a7304b 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import model from google.cloud.retail_v2beta.types import model as gcr_model @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +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.retail.v2beta.ModelService", + "rpcName": 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.retail.v2beta.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -196,7 +277,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -284,7 +372,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -308,7 +396,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -332,7 +420,7 @@ def pause_model(self) -> Callable[[model_service.PauseModelRequest], model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -356,7 +444,7 @@ def resume_model(self) -> Callable[[model_service.ResumeModelRequest], model.Mod # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -382,7 +470,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -408,7 +496,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -436,7 +524,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -462,7 +550,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -470,7 +558,7 @@ def tune_model( return self._stubs["tune_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -482,7 +570,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -501,7 +589,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc_asyncio.py index 4cc90cf97503..6b553ac222e5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import model from google.cloud.retail_v2beta.types import model as gcr_model @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +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.retail.v2beta.ModelService", + "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.retail.v2beta.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -243,10 +325,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -296,7 +381,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/CreateModel", request_serializer=model_service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -322,7 +407,7 @@ def get_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -348,7 +433,7 @@ def pause_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_model" not in self._stubs: - self._stubs["pause_model"] = self.grpc_channel.unary_unary( + self._stubs["pause_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/PauseModel", request_serializer=model_service.PauseModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -374,7 +459,7 @@ def resume_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_model" not in self._stubs: - self._stubs["resume_model"] = self.grpc_channel.unary_unary( + self._stubs["resume_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/ResumeModel", request_serializer=model_service.ResumeModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -400,7 +485,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -428,7 +513,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -456,7 +541,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/UpdateModel", request_serializer=model_service.UpdateModelRequest.serialize, response_deserializer=gcr_model.Model.deserialize, @@ -484,7 +569,7 @@ def tune_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tune_model" not in self._stubs: - self._stubs["tune_model"] = self.grpc_channel.unary_unary( + self._stubs["tune_model"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ModelService/TuneModel", request_serializer=model_service.TuneModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -552,7 +637,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -568,7 +653,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -587,7 +672,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/rest.py index 8e66fd7963f1..065b6dabc914 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/model_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -134,8 +142,10 @@ def post_update_model(self, response): def pre_create_model( self, request: model_service.CreateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.CreateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -157,8 +167,10 @@ def post_create_model( def pre_delete_model( self, request: model_service.DeleteModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.DeleteModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -169,8 +181,8 @@ def pre_delete_model( def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -213,8 +227,10 @@ def post_list_models( def pre_pause_model( self, request: model_service.PauseModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.PauseModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.PauseModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_model Override in a subclass to manipulate the request or metadata @@ -234,8 +250,10 @@ def post_pause_model(self, response: model.Model) -> model.Model: def pre_resume_model( self, request: model_service.ResumeModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ResumeModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ResumeModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_model Override in a subclass to manipulate the request or metadata @@ -255,8 +273,8 @@ def post_resume_model(self, response: model.Model) -> model.Model: def pre_tune_model( self, request: model_service.TuneModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.TuneModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for tune_model Override in a subclass to manipulate the request or metadata @@ -278,8 +296,10 @@ def post_tune_model( def pre_update_model( self, request: model_service.UpdateModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.UpdateModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.UpdateModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_model Override in a subclass to manipulate the request or metadata @@ -299,8 +319,10 @@ def post_update_model(self, response: gcr_model.Model) -> gcr_model.Model: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -322,8 +344,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -536,7 +560,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -546,8 +570,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -560,6 +586,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseCreateModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseCreateModel._get_transcoded_request( @@ -580,6 +607,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.CreateModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CreateModel._get_response( self._host, @@ -599,7 +653,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.retail_v2beta.ModelServiceClient.create_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteModel( @@ -636,7 +712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete model method over HTTP. @@ -646,13 +722,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseDeleteModel._get_transcoded_request( @@ -667,6 +746,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.DeleteModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._DeleteModel._get_response( self._host, @@ -714,7 +820,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -724,8 +830,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -742,6 +850,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -756,6 +865,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -776,7 +912,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2beta.ModelServiceClient.get_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -813,7 +971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -824,8 +982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model_service.ListModelsResponse: @@ -835,6 +995,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -849,6 +1010,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -869,7 +1057,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.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.retail_v2beta.ModelServiceClient.list_models", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseModel( @@ -907,7 +1119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the pause model method over HTTP. @@ -918,8 +1130,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -936,6 +1150,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BasePauseModel._get_http_options() ) + request, metadata = self._interceptor.pre_pause_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BasePauseModel._get_transcoded_request( @@ -956,6 +1171,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.PauseModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "PauseModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._PauseModel._get_response( self._host, @@ -977,7 +1219,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2beta.ModelServiceClient.pause_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "PauseModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeModel( @@ -1015,7 +1279,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the resume model method over HTTP. @@ -1026,8 +1290,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.model.Model: @@ -1044,6 +1310,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseResumeModel._get_http_options() ) + request, metadata = self._interceptor.pre_resume_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseResumeModel._get_transcoded_request( @@ -1064,6 +1331,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.ResumeModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ResumeModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ResumeModel._get_response( self._host, @@ -1085,7 +1379,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.retail_v2beta.ModelServiceClient.resume_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ResumeModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TuneModel( @@ -1123,7 +1439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the tune model method over HTTP. @@ -1136,8 +1452,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1150,6 +1468,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseTuneModel._get_http_options() ) + request, metadata = self._interceptor.pre_tune_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseTuneModel._get_transcoded_request( @@ -1168,6 +1487,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.TuneModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "TuneModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._TuneModel._get_response( self._host, @@ -1187,7 +1533,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tune_model(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.retail_v2beta.ModelServiceClient.tune_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "TuneModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateModel( @@ -1225,7 +1593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_model.Model: r"""Call the update model method over HTTP. @@ -1236,8 +1604,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_model.Model: @@ -1254,6 +1624,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_http_options() ) + request, metadata = self._interceptor.pre_update_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseUpdateModel._get_transcoded_request( @@ -1274,6 +1645,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.UpdateModel", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "UpdateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._UpdateModel._get_response( self._host, @@ -1295,7 +1693,29 @@ def __call__( pb_resp = gcr_model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_model.Model.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.retail_v2beta.ModelServiceClient.update_model", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "UpdateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1394,7 +1814,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1404,8 +1824,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1414,6 +1836,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1426,6 +1849,33 @@ def __call__( ) ) + 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.retail_v2beta.ModelServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetOperation._get_response( self._host, @@ -1445,6 +1895,27 @@ def __call__( 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.retail_v2beta.ModelServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1485,7 +1956,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1495,8 +1966,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1505,6 +1978,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1515,6 +1989,33 @@ def __call__( 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.retail_v2beta.ModelServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListOperations._get_response( self._host, @@ -1534,6 +2035,27 @@ def __call__( 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.retail_v2beta.ModelServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ModelService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/async_client.py index b72c49a335e3..6f905f0e9327 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """Service for making recommendation prediction.""" @@ -260,13 +270,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "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.retail.v2beta.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -307,8 +339,10 @@ async def sample_predict(): 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, 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: google.cloud.retail_v2beta.types.PredictResponse: @@ -352,7 +386,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -363,8 +397,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -405,7 +441,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -416,8 +452,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/client.py index 4078da4104c2..fcc284016dea 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -588,6 +598,10 @@ def __init__( # 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( @@ -654,13 +668,36 @@ def __init__( 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.retail_v2beta.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "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.retail.v2beta.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Makes a recommendation prediction. @@ -701,8 +738,10 @@ def sample_predict(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.PredictResponse: @@ -759,7 +798,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -770,8 +809,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -812,7 +853,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -823,8 +864,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc.py index e7bc23b7dfff..73ea3357ab3f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.retail.v2beta.PredictionService", + "rpcName": 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.retail.v2beta.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -265,7 +351,7 @@ def predict( return self._stubs["predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -277,7 +363,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -296,7 +382,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc_asyncio.py index 8843a32c7205..6545f3f85ee4 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.retail.v2beta.PredictionService", + "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.retail.v2beta.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -299,7 +384,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -315,7 +400,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -334,7 +419,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/rest.py index a600f436e279..b41e60438074 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/prediction_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -79,8 +87,10 @@ def post_predict(self, response): def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_predict( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -125,8 +137,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -277,8 +291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_service.PredictResponse: @@ -288,6 +304,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + 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.retail_v2beta.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.retail_v2beta.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -408,6 +479,33 @@ def __call__( 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.retail_v2beta.PredictionServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._GetOperation._get_response( self._host, @@ -427,6 +525,27 @@ def __call__( 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.retail_v2beta.PredictionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -468,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -478,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -488,6 +609,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -498,6 +620,33 @@ def __call__( 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.retail_v2beta.PredictionServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._ListOperations._get_response( self._host, @@ -517,6 +666,27 @@ def __call__( 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.retail_v2beta.PredictionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.PredictionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/async_client.py index dd1d99d714e1..178ef2fa01a7 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .transports.grpc_asyncio import ProductServiceGrpcAsyncIOTransport +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 ProductServiceAsyncClient: """Service for ingesting [Product][google.cloud.retail.v2beta.Product] @@ -270,6 +280,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.ProductServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "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.retail.v2beta.ProductService", + "credentialsType": None, + }, + ) + async def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -279,7 +311,7 @@ async def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2beta.Product]. @@ -360,8 +392,10 @@ async def sample_create_product(): 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, 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: google.cloud.retail_v2beta.types.Product: @@ -427,7 +461,7 @@ async def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2beta.Product]. @@ -482,8 +516,10 @@ async def sample_get_product(): 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, 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: google.cloud.retail_v2beta.types.Product: @@ -545,7 +581,7 @@ async def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsAsyncPager: r"""Gets a list of [Product][google.cloud.retail.v2beta.Product]s. @@ -598,8 +634,10 @@ async def sample_list_products(): 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, 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: google.cloud.retail_v2beta.services.product_service.pagers.ListProductsAsyncPager: @@ -676,7 +714,7 @@ async def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2beta.Product]. @@ -751,8 +789,10 @@ async def sample_update_product(): 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, 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: google.cloud.retail_v2beta.types.Product: @@ -818,7 +858,7 @@ async def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2beta.Product]. @@ -884,8 +924,10 @@ async def sample_delete_product(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -936,7 +978,7 @@ async def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2beta.Product]s under a branch. @@ -997,8 +1039,10 @@ async def sample_purge_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1055,7 +1099,7 @@ async def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. @@ -1107,8 +1151,10 @@ async def sample_import_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1168,7 +1214,7 @@ async def export_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports multiple [Product][google.cloud.retail.v2beta.Product]s. @@ -1213,8 +1259,10 @@ async def sample_export_products(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1274,7 +1322,7 @@ async def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting @@ -1454,8 +1502,10 @@ async def sample_set_inventory(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1534,7 +1584,7 @@ async def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] @@ -1622,8 +1672,10 @@ async def sample_add_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1698,7 +1750,7 @@ async def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] @@ -1786,8 +1838,10 @@ async def sample_remove_fulfillment_places(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1862,7 +1916,7 @@ async def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of @@ -1948,8 +2002,10 @@ async def sample_add_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2026,7 +2082,7 @@ async def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of @@ -2110,8 +2166,10 @@ async def sample_remove_local_inventories(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2185,7 +2243,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2196,8 +2254,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2238,7 +2298,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2249,8 +2309,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/client.py index cc1ce559937c..e4c3e6ec1277 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -620,6 +630,10 @@ def __init__( # 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( @@ -685,6 +699,29 @@ def __init__( 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.retail_v2beta.ProductServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "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.retail.v2beta.ProductService", + "credentialsType": None, + }, + ) + def create_product( self, request: Optional[Union[product_service.CreateProductRequest, dict]] = None, @@ -694,7 +731,7 @@ def create_product( product_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Creates a [Product][google.cloud.retail.v2beta.Product]. @@ -775,8 +812,10 @@ def sample_create_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Product: @@ -839,7 +878,7 @@ def get_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Gets a [Product][google.cloud.retail.v2beta.Product]. @@ -894,8 +933,10 @@ def sample_get_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Product: @@ -954,7 +995,7 @@ def list_products( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProductsPager: r"""Gets a list of [Product][google.cloud.retail.v2beta.Product]s. @@ -1007,8 +1048,10 @@ def sample_list_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.services.product_service.pagers.ListProductsPager: @@ -1082,7 +1125,7 @@ def update_product( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Updates a [Product][google.cloud.retail.v2beta.Product]. @@ -1157,8 +1200,10 @@ def sample_update_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.Product: @@ -1221,7 +1266,7 @@ def delete_product( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Product][google.cloud.retail.v2beta.Product]. @@ -1287,8 +1332,10 @@ def sample_delete_product(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1336,7 +1383,7 @@ def purge_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Permanently deletes all selected [Product][google.cloud.retail.v2beta.Product]s under a branch. @@ -1397,8 +1444,10 @@ def sample_purge_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1453,7 +1502,7 @@ def import_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. @@ -1505,8 +1554,10 @@ def sample_import_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1564,7 +1615,7 @@ def export_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports multiple [Product][google.cloud.retail.v2beta.Product]s. @@ -1609,8 +1660,10 @@ def sample_export_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1668,7 +1721,7 @@ def set_inventory( set_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting @@ -1848,8 +1901,10 @@ def sample_set_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1925,7 +1980,7 @@ def add_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] @@ -2013,8 +2068,10 @@ def sample_add_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2086,7 +2143,7 @@ def remove_fulfillment_places( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""We recommend that you use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] @@ -2174,8 +2231,10 @@ def sample_remove_fulfillment_places(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2249,7 +2308,7 @@ def add_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of @@ -2335,8 +2394,10 @@ def sample_add_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2410,7 +2471,7 @@ def remove_local_inventories( product: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of @@ -2494,8 +2555,10 @@ def sample_remove_local_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2579,7 +2642,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2590,8 +2653,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2632,7 +2697,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2643,8 +2708,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/pagers.py index 86930c1e693d..ecba02378d30 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = product_service.ListProductsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc.py index 18b23ec3c839..2e1b098ce1ea 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import export_config, import_config from google.cloud.retail_v2beta.types import product @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport +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.retail.v2beta.ProductService", + "rpcName": 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.retail.v2beta.ProductService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcTransport(ProductServiceTransport): """gRPC backend transport for ProductService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -301,7 +389,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -329,7 +417,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -355,7 +443,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -381,7 +469,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -426,7 +514,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +548,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -486,7 +574,7 @@ def export_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_products" not in self._stubs: - self._stubs["export_products"] = self.grpc_channel.unary_unary( + self._stubs["export_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ExportProducts", request_serializer=export_config.ExportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -564,7 +652,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -623,7 +711,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -682,7 +770,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +829,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -797,7 +885,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -805,7 +893,7 @@ def remove_local_inventories( return self._stubs["remove_local_inventories"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -817,7 +905,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -836,7 +924,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc_asyncio.py index 601f7966eb48..758abaa6b8d5 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import export_config, import_config from google.cloud.retail_v2beta.types import product @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ProductServiceTransport from .grpc import ProductServiceGrpcTransport +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.retail.v2beta.ProductService", + "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.retail.v2beta.ProductService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductServiceGrpcAsyncIOTransport(ProductServiceTransport): """gRPC AsyncIO backend transport for ProductService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_product" not in self._stubs: - self._stubs["create_product"] = self.grpc_channel.unary_unary( + self._stubs["create_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/CreateProduct", request_serializer=product_service.CreateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -313,7 +398,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/GetProduct", request_serializer=product_service.GetProductRequest.serialize, response_deserializer=product.Product.deserialize, @@ -342,7 +427,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ListProducts", request_serializer=product_service.ListProductsRequest.serialize, response_deserializer=product_service.ListProductsResponse.deserialize, @@ -370,7 +455,7 @@ def update_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_product" not in self._stubs: - self._stubs["update_product"] = self.grpc_channel.unary_unary( + self._stubs["update_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/UpdateProduct", request_serializer=product_service.UpdateProductRequest.serialize, response_deserializer=gcr_product.Product.deserialize, @@ -396,7 +481,7 @@ def delete_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product" not in self._stubs: - self._stubs["delete_product"] = self.grpc_channel.unary_unary( + self._stubs["delete_product"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/DeleteProduct", request_serializer=product_service.DeleteProductRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +528,7 @@ def purge_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_products" not in self._stubs: - self._stubs["purge_products"] = self.grpc_channel.unary_unary( + self._stubs["purge_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/PurgeProducts", request_serializer=purge_config.PurgeProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def import_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_products" not in self._stubs: - self._stubs["import_products"] = self.grpc_channel.unary_unary( + self._stubs["import_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ImportProducts", request_serializer=import_config.ImportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +592,7 @@ def export_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_products" not in self._stubs: - self._stubs["export_products"] = self.grpc_channel.unary_unary( + self._stubs["export_products"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/ExportProducts", request_serializer=export_config.ExportProductsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -587,7 +672,7 @@ def set_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_inventory" not in self._stubs: - self._stubs["set_inventory"] = self.grpc_channel.unary_unary( + self._stubs["set_inventory"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/SetInventory", request_serializer=product_service.SetInventoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -647,7 +732,7 @@ def add_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_fulfillment_places" not in self._stubs: - self._stubs["add_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["add_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/AddFulfillmentPlaces", request_serializer=product_service.AddFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +792,7 @@ def remove_fulfillment_places( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_fulfillment_places" not in self._stubs: - self._stubs["remove_fulfillment_places"] = self.grpc_channel.unary_unary( + self._stubs["remove_fulfillment_places"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/RemoveFulfillmentPlaces", request_serializer=product_service.RemoveFulfillmentPlacesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +852,7 @@ def add_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_local_inventories" not in self._stubs: - self._stubs["add_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["add_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/AddLocalInventories", request_serializer=product_service.AddLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -824,7 +909,7 @@ def remove_local_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_local_inventories" not in self._stubs: - self._stubs["remove_local_inventories"] = self.grpc_channel.unary_unary( + self._stubs["remove_local_inventories"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProductService/RemoveLocalInventories", request_serializer=product_service.RemoveLocalInventoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -927,7 +1012,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -943,7 +1028,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -962,7 +1047,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/rest.py index 806d7c76ea10..b925132e9dbd 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/product_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -175,8 +183,11 @@ def post_update_product(self, response): def pre_add_fulfillment_places( self, request: product_service.AddFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddFulfillmentPlacesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_fulfillment_places Override in a subclass to manipulate the request or metadata @@ -198,8 +209,11 @@ def post_add_fulfillment_places( def pre_add_local_inventories( self, request: product_service.AddLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.AddLocalInventoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.AddLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_local_inventories Override in a subclass to manipulate the request or metadata @@ -221,8 +235,10 @@ def post_add_local_inventories( def pre_create_product( self, request: product_service.CreateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.CreateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.CreateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_product Override in a subclass to manipulate the request or metadata @@ -242,8 +258,10 @@ def post_create_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_delete_product( self, request: product_service.DeleteProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.DeleteProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.DeleteProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_product Override in a subclass to manipulate the request or metadata @@ -254,8 +272,10 @@ def pre_delete_product( def pre_export_products( self, request: export_config.ExportProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_products Override in a subclass to manipulate the request or metadata @@ -277,8 +297,10 @@ def post_export_products( def pre_get_product( self, request: product_service.GetProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.GetProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.GetProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -298,8 +320,10 @@ def post_get_product(self, response: product.Product) -> product.Product: def pre_import_products( self, request: import_config.ImportProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_products Override in a subclass to manipulate the request or metadata @@ -321,8 +345,10 @@ def post_import_products( def pre_list_products( self, request: product_service.ListProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.ListProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.ListProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -344,8 +370,10 @@ def post_list_products( def pre_purge_products( self, request: purge_config.PurgeProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_products Override in a subclass to manipulate the request or metadata @@ -367,9 +395,10 @@ def post_purge_products( def pre_remove_fulfillment_places( self, request: product_service.RemoveFulfillmentPlacesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveFulfillmentPlacesRequest, Sequence[Tuple[str, str]] + product_service.RemoveFulfillmentPlacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_fulfillment_places @@ -392,9 +421,10 @@ def post_remove_fulfillment_places( def pre_remove_local_inventories( self, request: product_service.RemoveLocalInventoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - product_service.RemoveLocalInventoriesRequest, Sequence[Tuple[str, str]] + product_service.RemoveLocalInventoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_local_inventories @@ -417,8 +447,10 @@ def post_remove_local_inventories( def pre_set_inventory( self, request: product_service.SetInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.SetInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.SetInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_inventory Override in a subclass to manipulate the request or metadata @@ -440,8 +472,10 @@ def post_set_inventory( def pre_update_product( self, request: product_service.UpdateProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[product_service.UpdateProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + product_service.UpdateProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_product Override in a subclass to manipulate the request or metadata @@ -461,8 +495,10 @@ def post_update_product(self, response: gcr_product.Product) -> gcr_product.Prod def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -484,8 +520,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -689,7 +727,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add fulfillment places method over HTTP. @@ -701,8 +739,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -715,6 +755,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_add_fulfillment_places( request, metadata ) @@ -731,6 +772,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.AddFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "AddFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddFulfillmentPlaces._get_response( self._host, @@ -750,7 +818,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_fulfillment_places(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.retail_v2beta.ProductServiceClient.add_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "AddFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddLocalInventories( @@ -789,7 +879,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add local inventories method over HTTP. @@ -801,8 +891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -815,6 +907,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseAddLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_add_local_inventories( request, metadata ) @@ -831,6 +924,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.AddLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "AddLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._AddLocalInventories._get_response( self._host, @@ -850,7 +970,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_local_inventories(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.retail_v2beta.ProductServiceClient.add_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "AddLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProduct( @@ -888,7 +1030,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the create product method over HTTP. @@ -900,8 +1042,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -914,6 +1058,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseCreateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_create_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseCreateProduct._get_transcoded_request( http_options, request @@ -928,6 +1073,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.CreateProduct", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "CreateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._CreateProduct._get_response( self._host, @@ -949,7 +1121,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2beta.ProductServiceClient.create_product", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "CreateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProduct( @@ -986,7 +1180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete product method over HTTP. @@ -998,13 +1192,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseProductServiceRestTransport._BaseDeleteProduct._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseDeleteProduct._get_transcoded_request( http_options, request @@ -1015,6 +1212,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.DeleteProduct", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "DeleteProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._DeleteProduct._get_response( self._host, @@ -1065,7 +1289,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export products method over HTTP. @@ -1076,8 +1300,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1090,6 +1316,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseExportProducts._get_http_options() ) + request, metadata = self._interceptor.pre_export_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseExportProducts._get_transcoded_request( http_options, request @@ -1104,6 +1331,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.ExportProducts", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ExportProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ExportProducts._get_response( self._host, @@ -1123,7 +1377,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_products(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.retail_v2beta.ProductServiceClient.export_products", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ExportProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProduct( @@ -1160,7 +1436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product.Product: r"""Call the get product method over HTTP. @@ -1172,8 +1448,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product.Product: @@ -1186,6 +1464,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetProduct._get_transcoded_request( http_options, request @@ -1198,6 +1477,33 @@ def __call__( ) ) + 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.retail_v2beta.ProductServiceClient.GetProduct", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetProduct._get_response( self._host, @@ -1218,7 +1524,29 @@ def __call__( pb_resp = product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product.Product.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.retail_v2beta.ProductServiceClient.get_product", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportProducts( @@ -1256,7 +1584,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import products method over HTTP. @@ -1266,8 +1594,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1280,6 +1610,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseImportProducts._get_http_options() ) + request, metadata = self._interceptor.pre_import_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseImportProducts._get_transcoded_request( http_options, request @@ -1294,6 +1625,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.ImportProducts", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ImportProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ImportProducts._get_response( self._host, @@ -1313,7 +1671,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_products(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.retail_v2beta.ProductServiceClient.import_products", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ImportProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -1350,7 +1730,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> product_service.ListProductsResponse: r"""Call the list products method over HTTP. @@ -1362,8 +1742,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.product_service.ListProductsResponse: @@ -1376,6 +1758,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -1386,6 +1769,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.ListProducts", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListProducts._get_response( self._host, @@ -1406,7 +1816,31 @@ def __call__( pb_resp = product_service.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = product_service.ListProductsResponse.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.retail_v2beta.ProductServiceClient.list_products", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeProducts( @@ -1444,7 +1878,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge products method over HTTP. @@ -1455,8 +1889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1469,6 +1905,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BasePurgeProducts._get_http_options() ) + request, metadata = self._interceptor.pre_purge_products(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BasePurgeProducts._get_transcoded_request( http_options, request @@ -1483,6 +1920,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.PurgeProducts", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "PurgeProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._PurgeProducts._get_response( self._host, @@ -1502,7 +1966,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_products(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.retail_v2beta.ProductServiceClient.purge_products", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "PurgeProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveFulfillmentPlaces( @@ -1541,7 +2027,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove fulfillment places method over HTTP. @@ -1553,8 +2039,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1567,6 +2055,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveFulfillmentPlaces._get_http_options() ) + request, metadata = self._interceptor.pre_remove_fulfillment_places( request, metadata ) @@ -1583,6 +2072,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.RemoveFulfillmentPlaces", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveFulfillmentPlaces._get_response( @@ -1604,7 +2120,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_fulfillment_places(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.retail_v2beta.ProductServiceClient.remove_fulfillment_places", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "RemoveFulfillmentPlaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveLocalInventories( @@ -1643,7 +2181,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove local inventories method over HTTP. @@ -1655,8 +2193,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1669,6 +2209,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseRemoveLocalInventories._get_http_options() ) + request, metadata = self._interceptor.pre_remove_local_inventories( request, metadata ) @@ -1685,6 +2226,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.RemoveLocalInventories", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "RemoveLocalInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductServiceRestTransport._RemoveLocalInventories._get_response( @@ -1706,7 +2274,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_local_inventories(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.retail_v2beta.ProductServiceClient.remove_local_inventories", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "RemoveLocalInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetInventory( @@ -1744,7 +2334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the set inventory method over HTTP. @@ -1756,8 +2346,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1770,6 +2362,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseSetInventory._get_http_options() ) + request, metadata = self._interceptor.pre_set_inventory(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseSetInventory._get_transcoded_request( http_options, request @@ -1784,6 +2377,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.SetInventory", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "SetInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._SetInventory._get_response( self._host, @@ -1803,7 +2423,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_inventory(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.retail_v2beta.ProductServiceClient.set_inventory", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "SetInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProduct( @@ -1841,7 +2483,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_product.Product: r"""Call the update product method over HTTP. @@ -1853,8 +2495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_product.Product: @@ -1867,6 +2511,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseUpdateProduct._get_http_options() ) + request, metadata = self._interceptor.pre_update_product(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseUpdateProduct._get_transcoded_request( http_options, request @@ -1881,6 +2526,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.UpdateProduct", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "UpdateProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._UpdateProduct._get_response( self._host, @@ -1902,7 +2574,29 @@ def __call__( pb_resp = gcr_product.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_product.Product.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.retail_v2beta.ProductServiceClient.update_product", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "UpdateProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2057,7 +2751,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2067,8 +2761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2077,6 +2773,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2087,6 +2784,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._GetOperation._get_response( self._host, @@ -2106,6 +2830,27 @@ def __call__( 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.retail_v2beta.ProductServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2146,7 +2891,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2156,8 +2901,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2166,6 +2913,7 @@ def __call__( http_options = ( _BaseProductServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProductServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2176,6 +2924,33 @@ def __call__( 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.retail_v2beta.ProductServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductServiceRestTransport._ListOperations._get_response( self._host, @@ -2195,6 +2970,27 @@ def __call__( 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.retail_v2beta.ProductServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProductService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/async_client.py index b2b835e44270..3597840a86cf 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProjectServiceTransport from .transports.grpc_asyncio import ProjectServiceGrpcAsyncIOTransport +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 ProjectServiceAsyncClient: """Service for settings at Project level.""" @@ -257,6 +267,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.ProjectServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "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.retail.v2beta.ProjectService", + "credentialsType": None, + }, + ) + async def get_alert_config( self, request: Optional[Union[project_service.GetAlertConfigRequest, dict]] = None, @@ -264,7 +296,7 @@ async def get_alert_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Get the [AlertConfig][google.cloud.retail.v2beta.AlertConfig] of the requested project. @@ -310,8 +342,10 @@ async def sample_get_alert_config(): 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, 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: google.cloud.retail_v2beta.types.AlertConfig: @@ -371,7 +405,7 @@ async def update_alert_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Update the alert config of the requested project. @@ -436,8 +470,10 @@ async def sample_update_alert_config(): 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, 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: google.cloud.retail_v2beta.types.AlertConfig: @@ -499,7 +535,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -510,8 +546,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -552,7 +590,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -563,8 +601,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/client.py index bc5f1dbaf7be..3a6632933a62 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -574,6 +584,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.retail_v2beta.ProjectServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "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.retail.v2beta.ProjectService", + "credentialsType": None, + }, + ) + def get_alert_config( self, request: Optional[Union[project_service.GetAlertConfigRequest, dict]] = None, @@ -646,7 +683,7 @@ def get_alert_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Get the [AlertConfig][google.cloud.retail.v2beta.AlertConfig] of the requested project. @@ -692,8 +729,10 @@ def sample_get_alert_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AlertConfig: @@ -750,7 +789,7 @@ def update_alert_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Update the alert config of the requested project. @@ -815,8 +854,10 @@ def sample_update_alert_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.AlertConfig: @@ -888,7 +929,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -899,8 +940,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -941,7 +984,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -952,8 +995,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc.py index 5fb4dfbc60bd..8a24f0f02f2c 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import project, project_service from .base import DEFAULT_CLIENT_INFO, ProjectServiceTransport +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.retail.v2beta.ProjectService", + "rpcName": 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.retail.v2beta.ProjectService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectServiceGrpcTransport(ProjectServiceTransport): """gRPC backend transport for ProjectService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +342,7 @@ def get_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_alert_config" not in self._stubs: - self._stubs["get_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["get_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProjectService/GetAlertConfig", request_serializer=project_service.GetAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -282,7 +368,7 @@ def update_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_alert_config" not in self._stubs: - self._stubs["update_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["update_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProjectService/UpdateAlertConfig", request_serializer=project_service.UpdateAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -290,7 +376,7 @@ def update_alert_config( return self._stubs["update_alert_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -302,7 +388,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -321,7 +407,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc_asyncio.py index fb8c3c53c905..7311ea83d50f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import project, project_service from .base import DEFAULT_CLIENT_INFO, ProjectServiceTransport from .grpc import ProjectServiceGrpcTransport +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.retail.v2beta.ProjectService", + "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.retail.v2beta.ProjectService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectServiceGrpcAsyncIOTransport(ProjectServiceTransport): """gRPC AsyncIO backend transport for ProjectService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def get_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_alert_config" not in self._stubs: - self._stubs["get_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["get_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProjectService/GetAlertConfig", request_serializer=project_service.GetAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -294,7 +379,7 @@ def update_alert_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_alert_config" not in self._stubs: - self._stubs["update_alert_config"] = self.grpc_channel.unary_unary( + self._stubs["update_alert_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ProjectService/UpdateAlertConfig", request_serializer=project_service.UpdateAlertConfigRequest.serialize, response_deserializer=project.AlertConfig.deserialize, @@ -332,7 +417,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -348,7 +433,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -367,7 +452,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/rest.py index 7426e441820e..343e3e460ad0 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/project_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -87,8 +95,10 @@ def post_update_alert_config(self, response): def pre_get_alert_config( self, request: project_service.GetAlertConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.GetAlertConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.GetAlertConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_alert_config Override in a subclass to manipulate the request or metadata @@ -110,8 +120,11 @@ def post_get_alert_config( def pre_update_alert_config( self, request: project_service.UpdateAlertConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[project_service.UpdateAlertConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + project_service.UpdateAlertConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_alert_config Override in a subclass to manipulate the request or metadata @@ -133,8 +146,10 @@ def post_update_alert_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -156,8 +171,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -297,7 +314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Call the get alert config method over HTTP. @@ -309,8 +326,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.AlertConfig: @@ -320,6 +339,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetAlertConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_alert_config( request, metadata ) @@ -332,6 +352,33 @@ def __call__( 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.retail_v2beta.ProjectServiceClient.GetAlertConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "GetAlertConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetAlertConfig._get_response( self._host, @@ -352,7 +399,29 @@ def __call__( pb_resp = project.AlertConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_alert_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.AlertConfig.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.retail_v2beta.ProjectServiceClient.get_alert_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "GetAlertConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAlertConfig( @@ -390,7 +459,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> project.AlertConfig: r"""Call the update alert config method over HTTP. @@ -402,8 +471,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.project.AlertConfig: @@ -413,6 +484,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseUpdateAlertConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_alert_config( request, metadata ) @@ -429,6 +501,33 @@ def __call__( 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.retail_v2beta.ProjectServiceClient.UpdateAlertConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "UpdateAlertConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._UpdateAlertConfig._get_response( self._host, @@ -450,7 +549,29 @@ def __call__( pb_resp = project.AlertConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_alert_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = project.AlertConfig.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.retail_v2beta.ProjectServiceClient.update_alert_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "UpdateAlertConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -507,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -517,8 +638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -527,6 +650,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -537,6 +661,33 @@ def __call__( 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.retail_v2beta.ProjectServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._GetOperation._get_response( self._host, @@ -556,6 +707,27 @@ def __call__( 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.retail_v2beta.ProjectServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -596,7 +768,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -606,8 +778,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -616,6 +790,7 @@ def __call__( http_options = ( _BaseProjectServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProjectServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -626,6 +801,33 @@ def __call__( 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.retail_v2beta.ProjectServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectServiceRestTransport._ListOperations._get_response( self._host, @@ -645,6 +847,27 @@ def __call__( 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.retail_v2beta.ProjectServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ProjectService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/async_client.py index 1fdbb1b2c350..ea9669e8a4ca 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .transports.grpc_asyncio import SearchServiceGrpcAsyncIOTransport +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 SearchServiceAsyncClient: """Service for search. @@ -270,13 +280,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.SearchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "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.retail.v2beta.SearchService", + "credentialsType": None, + }, + ) + async def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAsyncPager: r"""Performs a search. @@ -320,8 +352,10 @@ async def sample_search(): 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, 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: google.cloud.retail_v2beta.services.search_service.pagers.SearchAsyncPager: @@ -382,7 +416,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -393,8 +427,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -435,7 +471,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -446,8 +482,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/client.py index 711329d7e27f..62061fae74aa 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -660,6 +670,10 @@ def __init__( # 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( @@ -725,13 +739,36 @@ def __init__( 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.retail_v2beta.SearchServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "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.retail.v2beta.SearchService", + "credentialsType": None, + }, + ) + def search( self, request: Optional[Union[search_service.SearchRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchPager: r"""Performs a search. @@ -775,8 +812,10 @@ def sample_search(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.services.search_service.pagers.SearchPager: @@ -850,7 +889,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -861,8 +900,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -903,7 +944,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -914,8 +955,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/pagers.py index 815ea82c8244..7ab6969e8356 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = search_service.SearchRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = search_service.SearchRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc.py index 840379ca5037..cddee24c736f 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport +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.retail.v2beta.SearchService", + "rpcName": 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.retail.v2beta.SearchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcTransport(SearchServiceTransport): """gRPC backend transport for SearchService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -271,7 +357,7 @@ def search( return self._stubs["search"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -283,7 +369,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -302,7 +388,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc_asyncio.py index 8d8e2ba26e76..9db1a13f9117 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import search_service from .base import DEFAULT_CLIENT_INFO, SearchServiceTransport from .grpc import SearchServiceGrpcTransport +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.retail.v2beta.SearchService", + "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.retail.v2beta.SearchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SearchServiceGrpcAsyncIOTransport(SearchServiceTransport): """gRPC AsyncIO backend transport for SearchService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +358,7 @@ def search( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search" not in self._stubs: - self._stubs["search"] = self.grpc_channel.unary_unary( + self._stubs["search"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.SearchService/Search", request_serializer=search_service.SearchRequest.serialize, response_deserializer=search_service.SearchResponse.deserialize, @@ -306,7 +391,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -322,7 +407,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -341,7 +426,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/rest.py index 27bddb1b4edd..df0ec4af6eb2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/search_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -77,8 +85,10 @@ def post_search(self, response): """ def pre_search( - self, request: search_service.SearchRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, str]]]: + self, + request: search_service.SearchRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[search_service.SearchRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search Override in a subclass to manipulate the request or metadata @@ -100,8 +110,10 @@ def post_search( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -123,8 +135,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -267,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> search_service.SearchResponse: r"""Call the search method over HTTP. @@ -279,8 +293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.search_service.SearchResponse: @@ -293,6 +309,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseSearch._get_http_options() ) + request, metadata = self._interceptor.pre_search(request, metadata) transcoded_request = ( _BaseSearchServiceRestTransport._BaseSearch._get_transcoded_request( @@ -311,6 +328,33 @@ def __call__( ) ) + 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.retail_v2beta.SearchServiceClient.Search", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "Search", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._Search._get_response( self._host, @@ -332,7 +376,29 @@ def __call__( pb_resp = search_service.SearchResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = search_service.SearchResponse.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.retail_v2beta.SearchServiceClient.search", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "Search", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -381,7 +447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -391,8 +457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -401,6 +469,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -411,6 +480,33 @@ def __call__( 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.retail_v2beta.SearchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._GetOperation._get_response( self._host, @@ -430,6 +526,27 @@ def __call__( 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.retail_v2beta.SearchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -470,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -480,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -490,6 +609,7 @@ def __call__( http_options = ( _BaseSearchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSearchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -500,6 +620,33 @@ def __call__( 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.retail_v2beta.SearchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SearchServiceRestTransport._ListOperations._get_response( self._host, @@ -519,6 +666,27 @@ def __call__( 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.retail_v2beta.SearchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.SearchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/async_client.py index df6da8aa0277..50947a4ae0c8 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .transports.grpc_asyncio import ServingConfigServiceGrpcAsyncIOTransport +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 ServingConfigServiceAsyncClient: """Service for modifying ServingConfig.""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.ServingConfigServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "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.retail.v2beta.ServingConfigService", + "credentialsType": None, + }, + ) + async def create_serving_config( self, request: Optional[ @@ -280,7 +312,7 @@ async def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -353,8 +385,10 @@ async def sample_create_serving_config(): 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, 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -423,7 +457,7 @@ async def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -468,8 +502,10 @@ async def sample_delete_serving_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -524,7 +560,7 @@ async def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -584,8 +620,10 @@ async def sample_update_serving_config(): 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, 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -654,7 +692,7 @@ async def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -701,8 +739,10 @@ async def sample_get_serving_config(): 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, 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -767,7 +807,7 @@ async def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsAsyncPager: r"""Lists all ServingConfigs linked to this catalog. @@ -812,8 +852,10 @@ async def sample_list_serving_configs(): 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, 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: google.cloud.retail_v2beta.services.serving_config_service.pagers.ListServingConfigsAsyncPager: @@ -888,7 +930,7 @@ async def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -939,8 +981,10 @@ async def sample_add_control(): 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, 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1007,7 +1051,7 @@ async def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1054,8 +1098,10 @@ async def sample_remove_control(): 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, 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1119,7 +1165,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1130,8 +1176,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1172,7 +1220,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1183,8 +1231,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/client.py index db63f511de3f..e43a252b88ef 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -613,6 +623,10 @@ def __init__( # 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( @@ -679,6 +693,29 @@ def __init__( 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.retail_v2beta.ServingConfigServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "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.retail.v2beta.ServingConfigService", + "credentialsType": None, + }, + ) + def create_serving_config( self, request: Optional[ @@ -690,7 +727,7 @@ def create_serving_config( serving_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Creates a ServingConfig. @@ -763,8 +800,10 @@ def sample_create_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -830,7 +869,7 @@ def delete_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ServingConfig. @@ -875,8 +914,10 @@ def sample_delete_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -928,7 +969,7 @@ def update_serving_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Updates a ServingConfig. @@ -988,8 +1029,10 @@ def sample_update_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1055,7 +1098,7 @@ def get_serving_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Gets a ServingConfig. @@ -1102,8 +1145,10 @@ def sample_get_serving_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1165,7 +1210,7 @@ def list_serving_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServingConfigsPager: r"""Lists all ServingConfigs linked to this catalog. @@ -1210,8 +1255,10 @@ def sample_list_serving_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.services.serving_config_service.pagers.ListServingConfigsPager: @@ -1283,7 +1330,7 @@ def add_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to @@ -1334,8 +1381,10 @@ def sample_add_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1399,7 +1448,7 @@ def remove_control( serving_config: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if @@ -1446,8 +1495,10 @@ def sample_remove_control(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.ServingConfig: @@ -1521,7 +1572,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1532,8 +1583,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1574,7 +1627,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1585,8 +1638,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/pagers.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/pagers.py index 6494e8dc22ad..a4382e6e75f7 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/pagers.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = serving_config_service.ListServingConfigsRequest(request) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc.py index 208066cc17c8..ca6d2da335c1 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import serving_config as gcr_serving_config from google.cloud.retail_v2beta.types import serving_config @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport +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.retail.v2beta.ServingConfigService", + "rpcName": 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.retail.v2beta.ServingConfigService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcTransport(ServingConfigServiceTransport): """gRPC backend transport for ServingConfigService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -295,7 +381,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -324,7 +410,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -355,7 +441,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -384,7 +470,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -418,7 +504,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -448,7 +534,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -456,7 +542,7 @@ def remove_control( return self._stubs["remove_control"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -468,7 +554,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -487,7 +573,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc_asyncio.py index 8a2ab4b03bc8..c3b480905bad 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import serving_config as gcr_serving_config from google.cloud.retail_v2beta.types import serving_config @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ServingConfigServiceTransport from .grpc import ServingConfigServiceGrpcTransport +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.retail.v2beta.ServingConfigService", + "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.retail.v2beta.ServingConfigService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServingConfigServiceGrpcAsyncIOTransport(ServingConfigServiceTransport): """gRPC AsyncIO backend transport for ServingConfigService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def create_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_serving_config" not in self._stubs: - self._stubs["create_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["create_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/CreateServingConfig", request_serializer=serving_config_service.CreateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -305,7 +390,7 @@ def delete_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_serving_config" not in self._stubs: - self._stubs["delete_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/DeleteServingConfig", request_serializer=serving_config_service.DeleteServingConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -334,7 +419,7 @@ def update_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_serving_config" not in self._stubs: - self._stubs["update_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["update_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/UpdateServingConfig", request_serializer=serving_config_service.UpdateServingConfigRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -366,7 +451,7 @@ def get_serving_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_serving_config" not in self._stubs: - self._stubs["get_serving_config"] = self.grpc_channel.unary_unary( + self._stubs["get_serving_config"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/GetServingConfig", request_serializer=serving_config_service.GetServingConfigRequest.serialize, response_deserializer=serving_config.ServingConfig.deserialize, @@ -395,7 +480,7 @@ def list_serving_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_serving_configs" not in self._stubs: - self._stubs["list_serving_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_serving_configs"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/ListServingConfigs", request_serializer=serving_config_service.ListServingConfigsRequest.serialize, response_deserializer=serving_config_service.ListServingConfigsResponse.deserialize, @@ -430,7 +515,7 @@ def add_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_control" not in self._stubs: - self._stubs["add_control"] = self.grpc_channel.unary_unary( + self._stubs["add_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/AddControl", request_serializer=serving_config_service.AddControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -461,7 +546,7 @@ def remove_control( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_control" not in self._stubs: - self._stubs["remove_control"] = self.grpc_channel.unary_unary( + self._stubs["remove_control"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.ServingConfigService/RemoveControl", request_serializer=serving_config_service.RemoveControlRequest.serialize, response_deserializer=gcr_serving_config.ServingConfig.deserialize, @@ -524,7 +609,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -540,7 +625,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -559,7 +644,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/rest.py index a0afbe610907..65e41bb6991e 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/serving_config_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -126,8 +134,11 @@ def post_update_serving_config(self, response): def pre_add_control( self, request: serving_config_service.AddControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.AddControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.AddControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_control Override in a subclass to manipulate the request or metadata @@ -149,9 +160,10 @@ def post_add_control( def pre_create_serving_config( self, request: serving_config_service.CreateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.CreateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.CreateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_serving_config @@ -174,9 +186,10 @@ def post_create_serving_config( def pre_delete_serving_config( self, request: serving_config_service.DeleteServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.DeleteServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.DeleteServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_serving_config @@ -188,9 +201,10 @@ def pre_delete_serving_config( def pre_get_serving_config( self, request: serving_config_service.GetServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.GetServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.GetServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_serving_config @@ -213,9 +227,10 @@ def post_get_serving_config( def pre_list_serving_configs( self, request: serving_config_service.ListServingConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.ListServingConfigsRequest, Sequence[Tuple[str, str]] + serving_config_service.ListServingConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_serving_configs @@ -238,8 +253,11 @@ def post_list_serving_configs( def pre_remove_control( self, request: serving_config_service.RemoveControlRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serving_config_service.RemoveControlRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serving_config_service.RemoveControlRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_control Override in a subclass to manipulate the request or metadata @@ -261,9 +279,10 @@ def post_remove_control( def pre_update_serving_config( self, request: serving_config_service.UpdateServingConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - serving_config_service.UpdateServingConfigRequest, Sequence[Tuple[str, str]] + serving_config_service.UpdateServingConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_serving_config @@ -286,8 +305,10 @@ def post_update_serving_config( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -309,8 +330,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -452,7 +475,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the add control method over HTTP. @@ -462,8 +485,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -477,6 +502,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseAddControl._get_http_options() ) + request, metadata = self._interceptor.pre_add_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseAddControl._get_transcoded_request( http_options, request @@ -491,6 +517,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.AddControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "AddControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._AddControl._get_response( self._host, @@ -512,7 +565,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2beta.ServingConfigServiceClient.add_control", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "AddControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServingConfig( @@ -551,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the create serving config method over HTTP. @@ -562,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -577,6 +656,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseCreateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_serving_config( request, metadata ) @@ -593,6 +673,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.CreateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "CreateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._CreateServingConfig._get_response( @@ -616,7 +723,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2beta.ServingConfigServiceClient.create_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "CreateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteServingConfig( @@ -654,7 +785,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete serving config method over HTTP. @@ -665,13 +796,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseServingConfigServiceRestTransport._BaseDeleteServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_serving_config( request, metadata ) @@ -684,6 +818,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.DeleteServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "DeleteServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._DeleteServingConfig._get_response( @@ -736,7 +897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config.ServingConfig: r"""Call the get serving config method over HTTP. @@ -746,8 +907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config.ServingConfig: @@ -761,6 +924,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_serving_config( request, metadata ) @@ -773,6 +937,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.GetServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "GetServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._GetServingConfig._get_response( @@ -795,7 +986,29 @@ def __call__( pb_resp = serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = serving_config.ServingConfig.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.retail_v2beta.ServingConfigServiceClient.get_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "GetServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServingConfigs( @@ -833,7 +1046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serving_config_service.ListServingConfigsResponse: r"""Call the list serving configs method over HTTP. @@ -844,8 +1057,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serving_config_service.ListServingConfigsResponse: @@ -857,6 +1072,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListServingConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_serving_configs( request, metadata ) @@ -869,6 +1085,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.ListServingConfigs", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "ListServingConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._ListServingConfigs._get_response( @@ -891,7 +1134,33 @@ def __call__( pb_resp = serving_config_service.ListServingConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_serving_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + serving_config_service.ListServingConfigsResponse.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.retail_v2beta.ServingConfigServiceClient.list_serving_configs", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "ListServingConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveControl( @@ -930,7 +1199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the remove control method over HTTP. @@ -940,8 +1209,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -955,6 +1226,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_http_options() ) + request, metadata = self._interceptor.pre_remove_control(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseRemoveControl._get_transcoded_request( http_options, request @@ -969,6 +1241,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.RemoveControl", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "RemoveControl", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._RemoveControl._get_response( self._host, @@ -990,7 +1289,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_control(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2beta.ServingConfigServiceClient.remove_control", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "RemoveControl", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateServingConfig( @@ -1029,7 +1352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_serving_config.ServingConfig: r"""Call the update serving config method over HTTP. @@ -1040,8 +1363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_serving_config.ServingConfig: @@ -1055,6 +1380,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseUpdateServingConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_serving_config( request, metadata ) @@ -1071,6 +1397,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.UpdateServingConfig", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "UpdateServingConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServingConfigServiceRestTransport._UpdateServingConfig._get_response( @@ -1094,7 +1447,31 @@ def __call__( pb_resp = gcr_serving_config.ServingConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_serving_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_serving_config.ServingConfig.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.retail_v2beta.ServingConfigServiceClient.update_serving_config", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "UpdateServingConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1207,7 +1584,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1217,8 +1594,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1227,6 +1606,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1237,6 +1617,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._GetOperation._get_response( self._host, @@ -1256,6 +1663,27 @@ def __call__( 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.retail_v2beta.ServingConfigServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1297,7 +1725,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1307,8 +1735,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1317,6 +1747,7 @@ def __call__( http_options = ( _BaseServingConfigServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseServingConfigServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1327,6 +1758,33 @@ def __call__( 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.retail_v2beta.ServingConfigServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServingConfigServiceRestTransport._ListOperations._get_response( self._host, @@ -1346,6 +1804,27 @@ def __call__( 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.retail_v2beta.ServingConfigServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.ServingConfigService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/async_client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/async_client.py index b85b0fb3a6d2..36011eca72cf 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/async_client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .transports.grpc_asyncio import UserEventServiceGrpcAsyncIOTransport +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 UserEventServiceAsyncClient: """Service for ingesting end user actions on the customer @@ -274,13 +284,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.retail_v2beta.UserEventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "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.retail.v2beta.UserEventService", + "credentialsType": None, + }, + ) + async def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -322,8 +354,10 @@ async def sample_write_user_event(): 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, 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: google.cloud.retail_v2beta.types.UserEvent: @@ -373,7 +407,7 @@ async def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -418,8 +452,10 @@ async def sample_collect_user_event(): 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, 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: google.api.httpbody_pb2.HttpBody: @@ -509,7 +545,7 @@ async def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -555,8 +591,10 @@ async def sample_purge_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -613,7 +651,7 @@ async def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -665,8 +703,10 @@ async def sample_import_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -725,7 +765,7 @@ async def export_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Exports user events. @@ -772,8 +812,10 @@ async def sample_export_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -834,7 +876,7 @@ async def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -885,8 +927,10 @@ async def sample_rejoin_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -943,7 +987,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -954,8 +998,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -996,7 +1042,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1007,8 +1053,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/client.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/client.py index f0a166867577..4fe0c29624ee 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/client.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import httpbody_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -688,13 +702,36 @@ def __init__( 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.retail_v2beta.UserEventServiceClient`.", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "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.retail.v2beta.UserEventService", + "credentialsType": None, + }, + ) + def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Writes a single user event. @@ -736,8 +773,10 @@ def sample_write_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.retail_v2beta.types.UserEvent: @@ -785,7 +824,7 @@ def collect_user_event( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -830,8 +869,10 @@ def sample_collect_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api.httpbody_pb2.HttpBody: @@ -919,7 +960,7 @@ def purge_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -965,8 +1006,10 @@ def sample_purge_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1021,7 +1064,7 @@ def import_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this @@ -1073,8 +1116,10 @@ def sample_import_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1131,7 +1176,7 @@ def export_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Exports user events. @@ -1178,8 +1223,10 @@ def sample_export_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1238,7 +1285,7 @@ def rejoin_user_events( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed @@ -1289,8 +1336,10 @@ def sample_rejoin_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1358,7 +1407,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1369,8 +1418,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1411,7 +1462,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1422,8 +1473,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc.py index b62f034833fd..7a61a3e9d715 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import ( export_config, @@ -35,6 +41,81 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport +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.retail.v2beta.UserEventService", + "rpcName": 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.retail.v2beta.UserEventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcTransport(UserEventServiceTransport): """gRPC backend transport for UserEventService. @@ -190,7 +271,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -310,7 +398,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -340,7 +428,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +460,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def export_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_user_events" not in self._stubs: - self._stubs["export_user_events"] = self.grpc_channel.unary_unary( + self._stubs["export_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/ExportUserEvents", request_serializer=export_config.ExportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +527,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +535,7 @@ def rejoin_user_events( return self._stubs["rejoin_user_events"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -459,7 +547,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -478,7 +566,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc_asyncio.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc_asyncio.py index ffabc7e14c7b..53c1d716c3c2 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.retail_v2beta.types import ( export_config, @@ -39,6 +45,82 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .grpc import UserEventServiceGrpcTransport +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.retail.v2beta.UserEventService", + "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.retail.v2beta.UserEventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcAsyncIOTransport(UserEventServiceTransport): """gRPC AsyncIO backend transport for UserEventService. @@ -237,10 +319,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -290,7 +375,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=user_event.UserEvent.deserialize, @@ -324,7 +409,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -356,7 +441,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/PurgeUserEvents", request_serializer=purge_config.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -390,7 +475,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/ImportUserEvents", request_serializer=import_config.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +506,7 @@ def export_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_user_events" not in self._stubs: - self._stubs["export_user_events"] = self.grpc_channel.unary_unary( + self._stubs["export_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/ExportUserEvents", request_serializer=export_config.ExportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +545,7 @@ def rejoin_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rejoin_user_events" not in self._stubs: - self._stubs["rejoin_user_events"] = self.grpc_channel.unary_unary( + self._stubs["rejoin_user_events"] = self._logged_channel.unary_unary( "/google.cloud.retail.v2beta.UserEventService/RejoinUserEvents", request_serializer=user_event_service.RejoinUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -538,7 +623,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -554,7 +639,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -573,7 +658,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/rest.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/rest.py index ba0ab9c96faa..2d4e90077575 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/rest.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/services/user_event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -46,6 +46,14 @@ 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, @@ -126,8 +134,11 @@ def post_write_user_event(self, response): def pre_collect_user_event( self, request: user_event_service.CollectUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.CollectUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.CollectUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for collect_user_event Override in a subclass to manipulate the request or metadata @@ -149,8 +160,10 @@ def post_collect_user_event( def pre_export_user_events( self, request: export_config.ExportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[export_config.ExportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + export_config.ExportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_user_events Override in a subclass to manipulate the request or metadata @@ -172,8 +185,10 @@ def post_export_user_events( def pre_import_user_events( self, request: import_config.ImportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_config.ImportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_config.ImportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_user_events Override in a subclass to manipulate the request or metadata @@ -195,8 +210,10 @@ def post_import_user_events( def pre_purge_user_events( self, request: purge_config.PurgeUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + purge_config.PurgeUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for purge_user_events Override in a subclass to manipulate the request or metadata @@ -218,8 +235,11 @@ def post_purge_user_events( def pre_rejoin_user_events( self, request: user_event_service.RejoinUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.RejoinUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.RejoinUserEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for rejoin_user_events Override in a subclass to manipulate the request or metadata @@ -241,8 +261,11 @@ def post_rejoin_user_events( def pre_write_user_event( self, request: user_event_service.WriteUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.WriteUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.WriteUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for write_user_event Override in a subclass to manipulate the request or metadata @@ -264,8 +287,10 @@ def post_write_user_event( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -287,8 +312,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -491,7 +518,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the collect user event method over HTTP. @@ -502,8 +529,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.httpbody_pb2.HttpBody: @@ -562,6 +591,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseCollectUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_collect_user_event( request, metadata ) @@ -574,6 +604,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.CollectUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "CollectUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._CollectUserEvent._get_response( self._host, @@ -594,7 +651,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_collect_user_event(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.retail_v2beta.UserEventServiceClient.collect_user_event", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "CollectUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportUserEvents( @@ -633,7 +712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export user events method over HTTP. @@ -643,8 +722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -657,6 +738,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseExportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_export_user_events( request, metadata ) @@ -673,6 +755,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.ExportUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ExportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ExportUserEvents._get_response( self._host, @@ -692,7 +801,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_user_events(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.retail_v2beta.UserEventServiceClient.export_user_events", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ExportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportUserEvents( @@ -731,7 +862,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import user events method over HTTP. @@ -742,8 +873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -756,6 +889,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseImportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_import_user_events( request, metadata ) @@ -772,6 +906,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.ImportUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ImportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ImportUserEvents._get_response( self._host, @@ -791,7 +952,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_user_events(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.retail_v2beta.UserEventServiceClient.import_user_events", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ImportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeUserEvents( @@ -830,7 +1013,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge user events method over HTTP. @@ -841,8 +1024,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -855,6 +1040,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BasePurgeUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_purge_user_events( request, metadata ) @@ -871,6 +1057,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.PurgeUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "PurgeUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._PurgeUserEvents._get_response( self._host, @@ -890,7 +1103,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_user_events(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.retail_v2beta.UserEventServiceClient.purge_user_events", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "PurgeUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RejoinUserEvents( @@ -929,7 +1164,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the rejoin user events method over HTTP. @@ -940,8 +1175,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -954,6 +1191,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseRejoinUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_rejoin_user_events( request, metadata ) @@ -970,6 +1208,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.RejoinUserEvents", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "RejoinUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._RejoinUserEvents._get_response( self._host, @@ -989,7 +1254,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rejoin_user_events(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.retail_v2beta.UserEventServiceClient.rejoin_user_events", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "RejoinUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _WriteUserEvent( @@ -1027,7 +1314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event.UserEvent: r"""Call the write user event method over HTTP. @@ -1038,8 +1325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.user_event.UserEvent: @@ -1053,6 +1342,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseWriteUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_write_user_event( request, metadata ) @@ -1069,6 +1359,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.WriteUserEvent", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "WriteUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._WriteUserEvent._get_response( self._host, @@ -1090,7 +1407,29 @@ def __call__( pb_resp = user_event.UserEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_write_user_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = user_event.UserEvent.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.retail_v2beta.UserEventServiceClient.write_user_event", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "WriteUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1181,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1191,8 +1530,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1201,6 +1542,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1211,6 +1553,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._GetOperation._get_response( self._host, @@ -1230,6 +1599,27 @@ def __call__( 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.retail_v2beta.UserEventServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1270,7 +1660,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1280,8 +1670,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1290,6 +1682,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseUserEventServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1300,6 +1693,33 @@ def __call__( 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.retail_v2beta.UserEventServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ListOperations._get_response( self._host, @@ -1319,6 +1739,27 @@ def __call__( 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.retail_v2beta.UserEventServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.retail.v2beta.UserEventService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json index bb86c627cb05..2551a0da71ff 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "1.23.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -353,7 +353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -433,7 +433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -514,7 +514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompletionConfig", @@ -594,7 +594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompletionConfig", @@ -675,7 +675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GetDefaultBranchResponse", @@ -755,7 +755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GetDefaultBranchResponse", @@ -836,7 +836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.catalog_service.pagers.ListCatalogsAsyncPager", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.catalog_service.pagers.ListCatalogsPager", @@ -993,7 +993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1146,7 +1146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1303,7 +1303,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1380,7 +1380,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1462,7 +1462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1546,7 +1546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.AttributesConfig", @@ -1631,7 +1631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Catalog", @@ -1715,7 +1715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Catalog", @@ -1800,7 +1800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompletionConfig", @@ -1884,7 +1884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompletionConfig", @@ -1961,7 +1961,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompleteQueryResponse", @@ -2037,7 +2037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.CompleteQueryResponse", @@ -2114,7 +2114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2190,7 +2190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2279,7 +2279,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -2448,7 +2448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -2525,7 +2525,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -2603,7 +2603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -2683,7 +2683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -2764,7 +2764,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.control_service.pagers.ListControlsAsyncPager", @@ -2844,7 +2844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.control_service.pagers.ListControlsPager", @@ -2929,7 +2929,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -3013,7 +3013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Control", @@ -3098,7 +3098,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3182,7 +3182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3263,7 +3263,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig", @@ -3343,7 +3343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig", @@ -3424,7 +3424,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ListGenerativeQuestionConfigsResponse", @@ -3504,7 +3504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ListGenerativeQuestionConfigsResponse", @@ -3589,7 +3589,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionConfig", @@ -3673,7 +3673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionConfig", @@ -3758,7 +3758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig", @@ -3842,7 +3842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.GenerativeQuestionsFeatureConfig", @@ -3927,7 +3927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4011,7 +4011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4092,7 +4092,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -4169,7 +4169,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -4247,7 +4247,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4327,7 +4327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4408,7 +4408,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.model_service.pagers.ListModelsAsyncPager", @@ -4488,7 +4488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.model_service.pagers.ListModelsPager", @@ -4569,7 +4569,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4649,7 +4649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4730,7 +4730,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4810,7 +4810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -4891,7 +4891,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4971,7 +4971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5056,7 +5056,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -5140,7 +5140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Model", @@ -5217,7 +5217,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.PredictResponse", @@ -5293,7 +5293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.PredictResponse", @@ -5374,7 +5374,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5454,7 +5454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5535,7 +5535,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5615,7 +5615,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5704,7 +5704,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -5792,7 +5792,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -5873,7 +5873,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -5950,7 +5950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -6028,7 +6028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -6108,7 +6108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -6185,7 +6185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6261,7 +6261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6342,7 +6342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.product_service.pagers.ListProductsAsyncPager", @@ -6422,7 +6422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.product_service.pagers.ListProductsPager", @@ -6499,7 +6499,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6575,7 +6575,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6656,7 +6656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6736,7 +6736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6817,7 +6817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6897,7 +6897,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6982,7 +6982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7066,7 +7066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7151,7 +7151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -7235,7 +7235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.Product", @@ -7312,7 +7312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.search_service.pagers.SearchAsyncPager", @@ -7388,7 +7388,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.search_service.pagers.SearchPager", @@ -7469,7 +7469,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -7549,7 +7549,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -7638,7 +7638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -7726,7 +7726,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -7807,7 +7807,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -7884,7 +7884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -7962,7 +7962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8042,7 +8042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8123,7 +8123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.serving_config_service.pagers.ListServingConfigsAsyncPager", @@ -8203,7 +8203,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.services.serving_config_service.pagers.ListServingConfigsPager", @@ -8284,7 +8284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8364,7 +8364,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8449,7 +8449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8533,7 +8533,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.ServingConfig", @@ -8610,7 +8610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -8686,7 +8686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -8763,7 +8763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8839,7 +8839,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8916,7 +8916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8992,7 +8992,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9069,7 +9069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9145,7 +9145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9222,7 +9222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.UserEvent", @@ -9298,7 +9298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2.types.UserEvent", diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json index a7ca27f94f21..b27771e5b373 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "1.23.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Branch", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Branch", @@ -361,7 +361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListBranchesResponse", @@ -441,7 +441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListBranchesResponse", @@ -518,7 +518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -594,7 +594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -671,7 +671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.BatchRemoveCatalogAttributesResponse", @@ -747,7 +747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.BatchRemoveCatalogAttributesResponse", @@ -828,7 +828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -908,7 +908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -989,7 +989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompletionConfig", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompletionConfig", @@ -1150,7 +1150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GetDefaultBranchResponse", @@ -1230,7 +1230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GetDefaultBranchResponse", @@ -1311,7 +1311,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.catalog_service.pagers.ListCatalogsAsyncPager", @@ -1391,7 +1391,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.catalog_service.pagers.ListCatalogsPager", @@ -1468,7 +1468,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -1621,7 +1621,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -1778,7 +1778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1855,7 +1855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1937,7 +1937,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -2021,7 +2021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AttributesConfig", @@ -2106,7 +2106,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Catalog", @@ -2190,7 +2190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Catalog", @@ -2275,7 +2275,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompletionConfig", @@ -2359,7 +2359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompletionConfig", @@ -2436,7 +2436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompleteQueryResponse", @@ -2512,7 +2512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.CompleteQueryResponse", @@ -2589,7 +2589,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2665,7 +2665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2754,7 +2754,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -2842,7 +2842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -2923,7 +2923,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -3000,7 +3000,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -3078,7 +3078,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -3158,7 +3158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -3239,7 +3239,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.control_service.pagers.ListControlsAsyncPager", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.control_service.pagers.ListControlsPager", @@ -3404,7 +3404,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -3488,7 +3488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Control", @@ -3573,7 +3573,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3657,7 +3657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3738,7 +3738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig", @@ -3818,7 +3818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig", @@ -3899,7 +3899,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListGenerativeQuestionConfigsResponse", @@ -3979,7 +3979,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListGenerativeQuestionConfigsResponse", @@ -4064,7 +4064,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionConfig", @@ -4148,7 +4148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionConfig", @@ -4233,7 +4233,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig", @@ -4317,7 +4317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.GenerativeQuestionsFeatureConfig", @@ -4402,7 +4402,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4486,7 +4486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4567,7 +4567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_merchant_center_account_link" @@ -4644,7 +4644,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_merchant_center_account_link" @@ -4722,7 +4722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListMerchantCenterAccountLinksResponse", @@ -4802,7 +4802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListMerchantCenterAccountLinksResponse", @@ -4887,7 +4887,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4971,7 +4971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5052,7 +5052,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -5129,7 +5129,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -5207,7 +5207,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5287,7 +5287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5368,7 +5368,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.model_service.pagers.ListModelsAsyncPager", @@ -5448,7 +5448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.model_service.pagers.ListModelsPager", @@ -5529,7 +5529,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5609,7 +5609,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5690,7 +5690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5770,7 +5770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -5851,7 +5851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5931,7 +5931,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6016,7 +6016,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -6100,7 +6100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Model", @@ -6177,7 +6177,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.PredictResponse", @@ -6253,7 +6253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.PredictResponse", @@ -6334,7 +6334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6495,7 +6495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6575,7 +6575,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6664,7 +6664,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -6752,7 +6752,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -6833,7 +6833,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -6910,7 +6910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -6984,7 +6984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7060,7 +7060,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7141,7 +7141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -7221,7 +7221,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -7298,7 +7298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7374,7 +7374,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7455,7 +7455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.product_service.pagers.ListProductsAsyncPager", @@ -7535,7 +7535,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.product_service.pagers.ListProductsPager", @@ -7612,7 +7612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7688,7 +7688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7769,7 +7769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7849,7 +7849,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7930,7 +7930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8010,7 +8010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8095,7 +8095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8179,7 +8179,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8264,7 +8264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -8348,7 +8348,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Product", @@ -8429,7 +8429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Project", @@ -8509,7 +8509,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Project", @@ -8586,7 +8586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8662,7 +8662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8743,7 +8743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AlertConfig", @@ -8823,7 +8823,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AlertConfig", @@ -8904,7 +8904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.LoggingConfig", @@ -8984,7 +8984,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.LoggingConfig", @@ -9065,7 +9065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Project", @@ -9145,7 +9145,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.Project", @@ -9226,7 +9226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListEnrolledSolutionsResponse", @@ -9306,7 +9306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ListEnrolledSolutionsResponse", @@ -9391,7 +9391,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AlertConfig", @@ -9475,7 +9475,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.AlertConfig", @@ -9560,7 +9560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.LoggingConfig", @@ -9644,7 +9644,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.LoggingConfig", @@ -9721,7 +9721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.search_service.pagers.SearchAsyncPager", @@ -9797,7 +9797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.search_service.pagers.SearchPager", @@ -9878,7 +9878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -9958,7 +9958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10047,7 +10047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10135,7 +10135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10216,7 +10216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -10293,7 +10293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -10371,7 +10371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10451,7 +10451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10532,7 +10532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.serving_config_service.pagers.ListServingConfigsAsyncPager", @@ -10612,7 +10612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.services.serving_config_service.pagers.ListServingConfigsPager", @@ -10693,7 +10693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10773,7 +10773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10858,7 +10858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -10942,7 +10942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.ServingConfig", @@ -11019,7 +11019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -11095,7 +11095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -11172,7 +11172,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11248,7 +11248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11325,7 +11325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11401,7 +11401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11478,7 +11478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11554,7 +11554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11631,7 +11631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11707,7 +11707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11784,7 +11784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.UserEvent", @@ -11860,7 +11860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2alpha.types.UserEvent", diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json index 9fb5ce0e6595..5b91d0f376d7 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "1.23.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.BatchRemoveCatalogAttributesResponse", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.BatchRemoveCatalogAttributesResponse", @@ -506,7 +506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -667,7 +667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompletionConfig", @@ -747,7 +747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompletionConfig", @@ -828,7 +828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GetDefaultBranchResponse", @@ -908,7 +908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GetDefaultBranchResponse", @@ -989,7 +989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.catalog_service.pagers.ListCatalogsAsyncPager", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.catalog_service.pagers.ListCatalogsPager", @@ -1146,7 +1146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1299,7 +1299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1375,7 +1375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1456,7 +1456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1533,7 +1533,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "set_default_branch" @@ -1615,7 +1615,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1699,7 +1699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AttributesConfig", @@ -1784,7 +1784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Catalog", @@ -1868,7 +1868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Catalog", @@ -1953,7 +1953,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompletionConfig", @@ -2037,7 +2037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompletionConfig", @@ -2114,7 +2114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompleteQueryResponse", @@ -2190,7 +2190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.CompleteQueryResponse", @@ -2267,7 +2267,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2343,7 +2343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2432,7 +2432,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -2520,7 +2520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -2601,7 +2601,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -2678,7 +2678,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_control" @@ -2756,7 +2756,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -2917,7 +2917,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.control_service.pagers.ListControlsAsyncPager", @@ -2997,7 +2997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.control_service.pagers.ListControlsPager", @@ -3082,7 +3082,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -3166,7 +3166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Control", @@ -3251,7 +3251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3335,7 +3335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.BatchUpdateGenerativeQuestionConfigsResponse", @@ -3416,7 +3416,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig", @@ -3496,7 +3496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig", @@ -3577,7 +3577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ListGenerativeQuestionConfigsResponse", @@ -3657,7 +3657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ListGenerativeQuestionConfigsResponse", @@ -3742,7 +3742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionConfig", @@ -3826,7 +3826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionConfig", @@ -3911,7 +3911,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig", @@ -3995,7 +3995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.GenerativeQuestionsFeatureConfig", @@ -4080,7 +4080,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4164,7 +4164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4245,7 +4245,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -4322,7 +4322,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_model" @@ -4400,7 +4400,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -4480,7 +4480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -4561,7 +4561,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.model_service.pagers.ListModelsAsyncPager", @@ -4641,7 +4641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.model_service.pagers.ListModelsPager", @@ -4722,7 +4722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -4802,7 +4802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -4883,7 +4883,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -4963,7 +4963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -5044,7 +5044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5124,7 +5124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5209,7 +5209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -5293,7 +5293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Model", @@ -5370,7 +5370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.PredictResponse", @@ -5446,7 +5446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.PredictResponse", @@ -5527,7 +5527,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5607,7 +5607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5688,7 +5688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5768,7 +5768,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5857,7 +5857,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -5945,7 +5945,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -6026,7 +6026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -6103,7 +6103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product" @@ -6177,7 +6177,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6253,7 +6253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6334,7 +6334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -6491,7 +6491,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6567,7 +6567,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6648,7 +6648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.product_service.pagers.ListProductsAsyncPager", @@ -6728,7 +6728,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.product_service.pagers.ListProductsPager", @@ -6805,7 +6805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6881,7 +6881,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6962,7 +6962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7042,7 +7042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7123,7 +7123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7203,7 +7203,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7288,7 +7288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7372,7 +7372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7457,7 +7457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -7541,7 +7541,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.Product", @@ -7622,7 +7622,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AlertConfig", @@ -7702,7 +7702,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AlertConfig", @@ -7787,7 +7787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AlertConfig", @@ -7871,7 +7871,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.AlertConfig", @@ -7948,7 +7948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.search_service.pagers.SearchAsyncPager", @@ -8024,7 +8024,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.search_service.pagers.SearchPager", @@ -8105,7 +8105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8185,7 +8185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8274,7 +8274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8362,7 +8362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8443,7 +8443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -8520,7 +8520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_serving_config" @@ -8598,7 +8598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8678,7 +8678,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -8759,7 +8759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.serving_config_service.pagers.ListServingConfigsAsyncPager", @@ -8839,7 +8839,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.services.serving_config_service.pagers.ListServingConfigsPager", @@ -8920,7 +8920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -9000,7 +9000,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -9085,7 +9085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -9169,7 +9169,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.ServingConfig", @@ -9246,7 +9246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -9322,7 +9322,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -9399,7 +9399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9475,7 +9475,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9552,7 +9552,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9628,7 +9628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9705,7 +9705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9781,7 +9781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9858,7 +9858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9934,7 +9934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10011,7 +10011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.UserEvent", @@ -10087,7 +10087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.retail_v2beta.types.UserEvent", diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_analytics_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_analytics_service.py index 011299a6f6a3..5baf13a7c3b6 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_analytics_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_analytics_service.py @@ -1472,6 +1472,7 @@ def test_export_analytics_metrics_rest_required_fields( response_value._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.export_analytics_metrics(request) @@ -1695,6 +1696,7 @@ def test_export_analytics_metrics_rest_bad_request( 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.export_analytics_metrics(request) @@ -1725,6 +1727,7 @@ def test_export_analytics_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_analytics_metrics(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_export_analytics_metrics_rest_interceptors(null_interceptor): 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 @@ -1812,6 +1816,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1842,6 +1847,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1872,6 +1878,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1902,6 +1909,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_catalog_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_catalog_service.py index 94225d65fb88..ae85f9bb43bd 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_catalog_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_catalog_service.py @@ -5003,6 +5003,7 @@ def test_list_catalogs_rest_required_fields( response_value._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_catalogs(request) @@ -5056,6 +5057,7 @@ def test_list_catalogs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalogs(**mock_args) @@ -5247,6 +5249,7 @@ def test_update_catalog_rest_required_fields( response_value._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_catalog(request) @@ -5295,6 +5298,7 @@ def test_update_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog(**mock_args) @@ -5393,6 +5397,7 @@ def test_set_default_branch_rest_flattened(): 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"} client.set_default_branch(**mock_args) @@ -5492,6 +5497,7 @@ def test_get_default_branch_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_default_branch(**mock_args) @@ -5628,6 +5634,7 @@ def test_get_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -5675,6 +5682,7 @@ def test_get_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -5809,6 +5817,7 @@ def test_update_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -5859,6 +5868,7 @@ def test_update_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -5996,6 +6006,7 @@ def test_get_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6043,6 +6054,7 @@ def test_get_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6177,6 +6189,7 @@ def test_update_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6227,6 +6240,7 @@ def test_update_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6365,6 +6379,7 @@ def test_add_catalog_attribute_rest_required_fields( response_value._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.add_catalog_attribute(request) @@ -6502,6 +6517,7 @@ def test_remove_catalog_attribute_rest_required_fields( response_value._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.remove_catalog_attribute(request) @@ -6635,6 +6651,7 @@ def test_replace_catalog_attribute_rest_required_fields( response_value._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.replace_catalog_attribute(request) @@ -7389,6 +7406,7 @@ def test_list_catalogs_rest_bad_request( 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_catalogs(request) @@ -7424,6 +7442,7 @@ def test_list_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalogs(request) # Establish that the response is the type that we expect. @@ -7464,6 +7483,7 @@ def test_list_catalogs_rest_interceptors(null_interceptor): 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 = catalog_service.ListCatalogsResponse.to_json( catalog_service.ListCatalogsResponse() ) @@ -7512,6 +7532,7 @@ def test_update_catalog_rest_bad_request( 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_catalog(request) @@ -7625,6 +7646,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog(request) # Establish that the response is the type that we expect. @@ -7666,6 +7688,7 @@ def test_update_catalog_rest_interceptors(null_interceptor): 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 = gcr_catalog.Catalog.to_json(gcr_catalog.Catalog()) req.return_value.content = return_value @@ -7710,6 +7733,7 @@ def test_set_default_branch_rest_bad_request( 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.set_default_branch(request) @@ -7740,6 +7764,7 @@ def test_set_default_branch_rest_call_success(request_type): 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.set_default_branch(request) # Establish that the response is the type that we expect. @@ -7776,6 +7801,7 @@ def test_set_default_branch_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = catalog_service.SetDefaultBranchRequest() metadata = [ @@ -7816,6 +7842,7 @@ def test_get_default_branch_rest_bad_request( 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_default_branch(request) @@ -7852,6 +7879,7 @@ def test_get_default_branch_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_default_branch(request) # Establish that the response is the type that we expect. @@ -7893,6 +7921,7 @@ def test_get_default_branch_rest_interceptors(null_interceptor): 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 = catalog_service.GetDefaultBranchResponse.to_json( catalog_service.GetDefaultBranchResponse() ) @@ -7941,6 +7970,7 @@ def test_get_completion_config_rest_bad_request( 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_completion_config(request) @@ -7985,6 +8015,7 @@ def test_get_completion_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8041,6 +8072,7 @@ def test_get_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8089,6 +8121,7 @@ def test_update_completion_config_rest_bad_request( 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_completion_config(request) @@ -8226,6 +8259,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8282,6 +8316,7 @@ def test_update_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8328,6 +8363,7 @@ def test_get_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -8366,6 +8402,7 @@ def test_get_attributes_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -8410,6 +8447,7 @@ def test_get_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8458,6 +8496,7 @@ def test_update_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -8572,6 +8611,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -8616,6 +8656,7 @@ def test_update_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8662,6 +8703,7 @@ def test_add_catalog_attribute_rest_bad_request( 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.add_catalog_attribute(request) @@ -8700,6 +8742,7 @@ def test_add_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -8744,6 +8787,7 @@ def test_add_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8790,6 +8834,7 @@ def test_remove_catalog_attribute_rest_bad_request( 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.remove_catalog_attribute(request) @@ -8828,6 +8873,7 @@ def test_remove_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -8872,6 +8918,7 @@ def test_remove_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8918,6 +8965,7 @@ def test_replace_catalog_attribute_rest_bad_request( 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.replace_catalog_attribute(request) @@ -8956,6 +9004,7 @@ def test_replace_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.replace_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9000,6 +9049,7 @@ def test_replace_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9046,6 +9096,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9076,6 +9127,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -9106,6 +9158,7 @@ def test_list_operations_rest_bad_request( 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) @@ -9136,6 +9189,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_completion_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_completion_service.py index 9ea0b7886525..21ef16f76391 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_completion_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_completion_service.py @@ -1746,6 +1746,7 @@ def test_complete_query_rest_required_fields( response_value._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.complete_query(request) @@ -1897,6 +1898,7 @@ def test_import_completion_data_rest_required_fields( response_value._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.import_completion_data(request) @@ -2168,6 +2170,7 @@ def test_complete_query_rest_bad_request( 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.complete_query(request) @@ -2203,6 +2206,7 @@ def test_complete_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.complete_query(request) # Establish that the response is the type that we expect. @@ -2243,6 +2247,7 @@ def test_complete_query_rest_interceptors(null_interceptor): 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 = completion_service.CompleteQueryResponse.to_json( completion_service.CompleteQueryResponse() ) @@ -2289,6 +2294,7 @@ def test_import_completion_data_rest_bad_request( 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.import_completion_data(request) @@ -2319,6 +2325,7 @@ def test_import_completion_data_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_completion_data(request) # Establish that the response is the type that we expect. @@ -2360,6 +2367,7 @@ def test_import_completion_data_rest_interceptors(null_interceptor): 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 @@ -2406,6 +2414,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2436,6 +2445,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2466,6 +2476,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2496,6 +2507,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_control_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_control_service.py index d84a2c6f788b..14df2d37a824 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_control_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_control_service.py @@ -3104,6 +3104,7 @@ def test_create_control_rest_required_fields( response_value._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_control(request) @@ -3170,6 +3171,7 @@ def test_create_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3302,6 +3304,7 @@ def test_delete_control_rest_required_fields( response_value._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_control(request) @@ -3347,6 +3350,7 @@ def test_delete_control_rest_flattened(): 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"} client.delete_control(**mock_args) @@ -3476,6 +3480,7 @@ def test_update_control_rest_required_fields( response_value._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_control(request) @@ -3528,6 +3533,7 @@ def test_update_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3662,6 +3668,7 @@ def test_get_control_rest_required_fields( response_value._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_control(request) @@ -3709,6 +3716,7 @@ def test_get_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3848,6 +3856,7 @@ def test_list_controls_rest_required_fields( response_value._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_controls(request) @@ -3904,6 +3913,7 @@ def test_list_controls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_controls(**mock_args) @@ -4400,6 +4410,7 @@ def test_create_control_rest_bad_request( 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_control(request) @@ -4565,6 +4576,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -4613,6 +4625,7 @@ def test_create_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -4659,6 +4672,7 @@ def test_delete_control_rest_bad_request( 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_control(request) @@ -4691,6 +4705,7 @@ def test_delete_control_rest_call_success(request_type): 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_control(request) # Establish that the response is the type that we expect. @@ -4727,6 +4742,7 @@ def test_delete_control_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = control_service.DeleteControlRequest() metadata = [ @@ -4771,6 +4787,7 @@ def test_update_control_rest_bad_request( 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_control(request) @@ -4940,6 +4957,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -4988,6 +5006,7 @@ def test_update_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -5032,6 +5051,7 @@ def test_get_control_rest_bad_request(request_type=control_service.GetControlReq 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_control(request) @@ -5075,6 +5095,7 @@ def test_get_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -5123,6 +5144,7 @@ def test_get_control_rest_interceptors(null_interceptor): 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 = control.Control.to_json(control.Control()) req.return_value.content = return_value @@ -5167,6 +5189,7 @@ def test_list_controls_rest_bad_request( 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_controls(request) @@ -5202,6 +5225,7 @@ def test_list_controls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_controls(request) # Establish that the response is the type that we expect. @@ -5242,6 +5266,7 @@ def test_list_controls_rest_interceptors(null_interceptor): 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 = control_service.ListControlsResponse.to_json( control_service.ListControlsResponse() ) @@ -5290,6 +5315,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5320,6 +5346,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5350,6 +5377,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5380,6 +5408,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_generative_question_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_generative_question_service.py index c8d21c06556b..2c36de851632 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_generative_question_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_generative_question_service.py @@ -3133,6 +3133,7 @@ def test_update_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3193,6 +3194,7 @@ def test_update_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3340,6 +3342,7 @@ def test_get_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3391,6 +3394,7 @@ def test_get_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3533,6 +3537,7 @@ def test_list_generative_question_configs_rest_required_fields( response_value._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_generative_question_configs(request) @@ -3588,6 +3593,7 @@ def test_list_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_configs(**mock_args) @@ -3722,6 +3728,7 @@ def test_update_generative_question_config_rest_required_fields( response_value._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_generative_question_config(request) @@ -3778,6 +3785,7 @@ def test_update_generative_question_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_config(**mock_args) @@ -3923,6 +3931,7 @@ def test_batch_update_generative_question_configs_rest_required_fields( response_value._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.batch_update_generative_question_configs(request) @@ -3987,6 +3996,7 @@ def test_batch_update_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_update_generative_question_configs(**mock_args) @@ -4463,6 +4473,7 @@ def test_update_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4586,6 +4597,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4630,6 +4642,7 @@ def test_update_generative_questions_feature_config_rest_interceptors(null_inter 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4678,6 +4691,7 @@ def test_get_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4717,6 +4731,7 @@ def test_get_generative_questions_feature_config_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4763,6 +4778,7 @@ def test_get_generative_questions_feature_config_rest_interceptors(null_intercep 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4811,6 +4827,7 @@ def test_list_generative_question_configs_rest_bad_request( 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_generative_question_configs(request) @@ -4850,6 +4867,7 @@ def test_list_generative_question_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -4895,6 +4913,7 @@ def test_list_generative_question_configs_rest_interceptors(null_interceptor): 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 = ( generative_question_service.ListGenerativeQuestionConfigsResponse.to_json( generative_question_service.ListGenerativeQuestionConfigsResponse() @@ -4949,6 +4968,7 @@ def test_update_generative_question_config_rest_bad_request( 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_generative_question_config(request) @@ -5078,6 +5098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_config(request) # Establish that the response is the type that we expect. @@ -5128,6 +5149,7 @@ def test_update_generative_question_config_rest_interceptors(null_interceptor): 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 = generative_question.GenerativeQuestionConfig.to_json( generative_question.GenerativeQuestionConfig() ) @@ -5174,6 +5196,7 @@ def test_batch_update_generative_question_configs_rest_bad_request( 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.batch_update_generative_question_configs(request) @@ -5213,6 +5236,7 @@ def test_batch_update_generative_question_configs_rest_call_success(request_type json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_update_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -5257,6 +5281,7 @@ def test_batch_update_generative_question_configs_rest_interceptors(null_interce 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 = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.to_json( generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse() ) @@ -5309,6 +5334,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5339,6 +5365,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5369,6 +5396,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5399,6 +5427,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_model_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_model_service.py index fdd639b5ecc6..34e497c9b496 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_model_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_model_service.py @@ -4123,6 +4123,7 @@ def test_create_model_rest_required_fields( response_value._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_model(request) @@ -4177,6 +4178,7 @@ def test_create_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4307,6 +4309,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._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_model(request) @@ -4354,6 +4357,7 @@ def test_get_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4484,6 +4488,7 @@ def test_pause_model_rest_required_fields(request_type=model_service.PauseModelR response_value._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.pause_model(request) @@ -4531,6 +4536,7 @@ def test_pause_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_model(**mock_args) @@ -4663,6 +4669,7 @@ def test_resume_model_rest_required_fields( response_value._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.resume_model(request) @@ -4710,6 +4717,7 @@ def test_resume_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_model(**mock_args) @@ -4838,6 +4846,7 @@ def test_delete_model_rest_required_fields( response_value._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_model(request) @@ -4883,6 +4892,7 @@ def test_delete_model_rest_flattened(): 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"} client.delete_model(**mock_args) @@ -5019,6 +5029,7 @@ def test_list_models_rest_required_fields(request_type=model_service.ListModelsR response_value._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_models(request) @@ -5074,6 +5085,7 @@ def test_list_models_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_models(**mock_args) @@ -5266,6 +5278,7 @@ def test_update_model_rest_required_fields( response_value._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_model(request) @@ -5316,6 +5329,7 @@ def test_update_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -5448,6 +5462,7 @@ def test_tune_model_rest_required_fields(request_type=model_service.TuneModelReq response_value._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.tune_model(request) @@ -5493,6 +5508,7 @@ def test_tune_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.tune_model(**mock_args) @@ -6080,6 +6096,7 @@ def test_create_model_rest_bad_request(request_type=model_service.CreateModelReq 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_model(request) @@ -6203,6 +6220,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6244,6 +6262,7 @@ def test_create_model_rest_interceptors(null_interceptor): 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 @@ -6288,6 +6307,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): 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_model(request) @@ -6334,6 +6354,7 @@ def test_get_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6387,6 +6408,7 @@ def test_get_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6431,6 +6453,7 @@ def test_pause_model_rest_bad_request(request_type=model_service.PauseModelReque 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.pause_model(request) @@ -6477,6 +6500,7 @@ def test_pause_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_model(request) # Establish that the response is the type that we expect. @@ -6532,6 +6556,7 @@ def test_pause_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6576,6 +6601,7 @@ def test_resume_model_rest_bad_request(request_type=model_service.ResumeModelReq 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.resume_model(request) @@ -6622,6 +6648,7 @@ def test_resume_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_model(request) # Establish that the response is the type that we expect. @@ -6677,6 +6704,7 @@ def test_resume_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6721,6 +6749,7 @@ def test_delete_model_rest_bad_request(request_type=model_service.DeleteModelReq 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_model(request) @@ -6753,6 +6782,7 @@ def test_delete_model_rest_call_success(request_type): 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_model(request) # Establish that the response is the type that we expect. @@ -6789,6 +6819,7 @@ def test_delete_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = model_service.DeleteModelRequest() metadata = [ @@ -6827,6 +6858,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque 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_models(request) @@ -6862,6 +6894,7 @@ def test_list_models_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_models(request) # Establish that the response is the type that we expect. @@ -6902,6 +6935,7 @@ def test_list_models_rest_interceptors(null_interceptor): 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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -6950,6 +6984,7 @@ def test_update_model_rest_bad_request(request_type=model_service.UpdateModelReq 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_model(request) @@ -7091,6 +7126,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -7146,6 +7182,7 @@ def test_update_model_rest_interceptors(null_interceptor): 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 = gcr_model.Model.to_json(gcr_model.Model()) req.return_value.content = return_value @@ -7190,6 +7227,7 @@ def test_tune_model_rest_bad_request(request_type=model_service.TuneModelRequest 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.tune_model(request) @@ -7222,6 +7260,7 @@ def test_tune_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.tune_model(request) # Establish that the response is the type that we expect. @@ -7261,6 +7300,7 @@ def test_tune_model_rest_interceptors(null_interceptor): 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 @@ -7307,6 +7347,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7337,6 +7378,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7367,6 +7409,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7397,6 +7440,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_prediction_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_prediction_service.py index dbeba4267722..99393c91045d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_prediction_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_prediction_service.py @@ -1462,6 +1462,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq response_value._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.predict(request) @@ -1685,6 +1686,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -1724,6 +1726,7 @@ def test_predict_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.predict(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_predict_rest_interceptors(null_interceptor): 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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -1814,6 +1818,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1844,6 +1849,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1874,6 +1880,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1904,6 +1911,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_product_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_product_service.py index 5021a9d4414e..d64df1b4ae2d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_product_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_product_service.py @@ -5449,6 +5449,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -5515,6 +5516,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -5650,6 +5652,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -5697,6 +5700,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -5837,6 +5841,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -5894,6 +5899,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -6093,6 +6099,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -6153,6 +6160,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -6284,6 +6292,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -6329,6 +6338,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -6466,6 +6476,7 @@ def test_purge_products_rest_required_fields( response_value._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.purge_products(request) @@ -6595,6 +6606,7 @@ def test_import_products_rest_required_fields( response_value._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.import_products(request) @@ -6719,6 +6731,7 @@ def test_set_inventory_rest_required_fields( response_value._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.set_inventory(request) @@ -6767,6 +6780,7 @@ def test_set_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_inventory(**mock_args) @@ -6914,6 +6928,7 @@ def test_add_fulfillment_places_rest_required_fields( response_value._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.add_fulfillment_places(request) @@ -6968,6 +6983,7 @@ def test_add_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_fulfillment_places(**mock_args) @@ -7114,6 +7130,7 @@ def test_remove_fulfillment_places_rest_required_fields( response_value._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.remove_fulfillment_places(request) @@ -7168,6 +7185,7 @@ def test_remove_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_fulfillment_places(**mock_args) @@ -7306,6 +7324,7 @@ def test_add_local_inventories_rest_required_fields( response_value._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.add_local_inventories(request) @@ -7359,6 +7378,7 @@ def test_add_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_local_inventories(**mock_args) @@ -7501,6 +7521,7 @@ def test_remove_local_inventories_rest_required_fields( response_value._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.remove_local_inventories(request) @@ -7554,6 +7575,7 @@ def test_remove_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_local_inventories(**mock_args) @@ -8358,6 +8380,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -8559,6 +8582,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -8616,6 +8640,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -8660,6 +8685,7 @@ def test_get_product_rest_bad_request(request_type=product_service.GetProductReq 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_product(request) @@ -8714,6 +8740,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -8771,6 +8798,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product.Product.to_json(product.Product()) req.return_value.content = return_value @@ -8817,6 +8845,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -8854,6 +8883,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -8894,6 +8924,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_service.ListProductsResponse.to_json( product_service.ListProductsResponse() ) @@ -8944,6 +8975,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -9147,6 +9179,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9204,6 +9237,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -9250,6 +9284,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -9282,6 +9317,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -9318,6 +9354,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_service.DeleteProductRequest() metadata = [ @@ -9360,6 +9397,7 @@ def test_purge_products_rest_bad_request( 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.purge_products(request) @@ -9392,6 +9430,7 @@ def test_purge_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_products(request) # Establish that the response is the type that we expect. @@ -9433,6 +9472,7 @@ def test_purge_products_rest_interceptors(null_interceptor): 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 @@ -9479,6 +9519,7 @@ def test_import_products_rest_bad_request( 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.import_products(request) @@ -9511,6 +9552,7 @@ def test_import_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_products(request) # Establish that the response is the type that we expect. @@ -9552,6 +9594,7 @@ def test_import_products_rest_interceptors(null_interceptor): 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 @@ -9600,6 +9643,7 @@ def test_set_inventory_rest_bad_request( 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.set_inventory(request) @@ -9634,6 +9678,7 @@ def test_set_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_inventory(request) # Establish that the response is the type that we expect. @@ -9675,6 +9720,7 @@ def test_set_inventory_rest_interceptors(null_interceptor): 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 @@ -9721,6 +9767,7 @@ def test_add_fulfillment_places_rest_bad_request( 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.add_fulfillment_places(request) @@ -9753,6 +9800,7 @@ def test_add_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -9794,6 +9842,7 @@ def test_add_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -9840,6 +9889,7 @@ def test_remove_fulfillment_places_rest_bad_request( 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.remove_fulfillment_places(request) @@ -9872,6 +9922,7 @@ def test_remove_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -9913,6 +9964,7 @@ def test_remove_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -9959,6 +10011,7 @@ def test_add_local_inventories_rest_bad_request( 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.add_local_inventories(request) @@ -9991,6 +10044,7 @@ def test_add_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_local_inventories(request) # Establish that the response is the type that we expect. @@ -10032,6 +10086,7 @@ def test_add_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10078,6 +10133,7 @@ def test_remove_local_inventories_rest_bad_request( 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.remove_local_inventories(request) @@ -10110,6 +10166,7 @@ def test_remove_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_local_inventories(request) # Establish that the response is the type that we expect. @@ -10151,6 +10208,7 @@ def test_remove_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10197,6 +10255,7 @@ def test_get_operation_rest_bad_request( 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) @@ -10227,6 +10286,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -10257,6 +10317,7 @@ def test_list_operations_rest_bad_request( 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) @@ -10287,6 +10348,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_search_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_search_service.py index 8eec7f026a0a..6dbdac7f41b5 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_search_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_search_service.py @@ -1634,6 +1634,7 @@ def test_search_rest_required_fields(request_type=search_service.SearchRequest): response_value._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.search(request) @@ -1925,6 +1926,7 @@ def test_search_rest_bad_request(request_type=search_service.SearchRequest): 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.search(request) @@ -1967,6 +1969,7 @@ def test_search_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search(request) # Establish that the response is the type that we expect. @@ -2010,6 +2013,7 @@ def test_search_rest_interceptors(null_interceptor): 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 = search_service.SearchResponse.to_json( search_service.SearchResponse() ) @@ -2058,6 +2062,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2088,6 +2093,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2118,6 +2124,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2148,6 +2155,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_serving_config_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_serving_config_service.py index cce7c11796c3..38e9868876b4 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_serving_config_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_serving_config_service.py @@ -4218,6 +4218,7 @@ def test_create_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4282,6 +4283,7 @@ def test_create_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4417,6 +4419,7 @@ def test_delete_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4462,6 +4465,7 @@ def test_delete_serving_config_rest_flattened(): 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"} client.delete_serving_config(**mock_args) @@ -4596,6 +4600,7 @@ def test_update_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4646,6 +4651,7 @@ def test_update_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4782,6 +4788,7 @@ def test_get_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4829,6 +4836,7 @@ def test_get_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4973,6 +4981,7 @@ def test_list_serving_configs_rest_required_fields( response_value._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_serving_configs(request) @@ -5030,6 +5039,7 @@ def test_list_serving_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_configs(**mock_args) @@ -5232,6 +5242,7 @@ def test_add_control_rest_required_fields( response_value._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.add_control(request) @@ -5287,6 +5298,7 @@ def test_add_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_control(**mock_args) @@ -5423,6 +5435,7 @@ def test_remove_control_rest_required_fields( response_value._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.remove_control(request) @@ -5478,6 +5491,7 @@ def test_remove_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_control(**mock_args) @@ -6092,6 +6106,7 @@ def test_create_serving_config_rest_bad_request( 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_serving_config(request) @@ -6256,6 +6271,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6318,6 +6334,7 @@ def test_create_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6366,6 +6383,7 @@ def test_delete_serving_config_rest_bad_request( 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_serving_config(request) @@ -6398,6 +6416,7 @@ def test_delete_serving_config_rest_call_success(request_type): 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_serving_config(request) # Establish that the response is the type that we expect. @@ -6434,6 +6453,7 @@ def test_delete_serving_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = serving_config_service.DeleteServingConfigRequest() metadata = [ @@ -6478,6 +6498,7 @@ def test_update_serving_config_rest_bad_request( 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_serving_config(request) @@ -6646,6 +6667,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6708,6 +6730,7 @@ def test_update_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6756,6 +6779,7 @@ def test_get_serving_config_rest_bad_request( 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_serving_config(request) @@ -6810,6 +6834,7 @@ def test_get_serving_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6872,6 +6897,7 @@ def test_get_serving_config_rest_interceptors(null_interceptor): 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 = serving_config.ServingConfig.to_json( serving_config.ServingConfig() ) @@ -6918,6 +6944,7 @@ def test_list_serving_configs_rest_bad_request( 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_serving_configs(request) @@ -6955,6 +6982,7 @@ def test_list_serving_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_configs(request) # Establish that the response is the type that we expect. @@ -6995,6 +7023,7 @@ def test_list_serving_configs_rest_interceptors(null_interceptor): 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 = serving_config_service.ListServingConfigsResponse.to_json( serving_config_service.ListServingConfigsResponse() ) @@ -7043,6 +7072,7 @@ def test_add_control_rest_bad_request( 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.add_control(request) @@ -7097,6 +7127,7 @@ def test_add_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_control(request) # Establish that the response is the type that we expect. @@ -7159,6 +7190,7 @@ def test_add_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7207,6 +7239,7 @@ def test_remove_control_rest_bad_request( 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.remove_control(request) @@ -7261,6 +7294,7 @@ def test_remove_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_control(request) # Establish that the response is the type that we expect. @@ -7323,6 +7357,7 @@ def test_remove_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7371,6 +7406,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7401,6 +7437,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7431,6 +7468,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7461,6 +7499,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_user_event_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_user_event_service.py index 64d97b5425d8..c3306aa0c3d1 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_user_event_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_user_event_service.py @@ -2568,6 +2568,7 @@ def test_write_user_event_rest_required_fields( response_value._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.write_user_event(request) @@ -2714,6 +2715,7 @@ def test_collect_user_event_rest_required_fields( response_value._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.collect_user_event(request) @@ -2863,6 +2865,7 @@ def test_purge_user_events_rest_required_fields( response_value._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.purge_user_events(request) @@ -2996,6 +2999,7 @@ def test_import_user_events_rest_required_fields( response_value._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.import_user_events(request) @@ -3129,6 +3133,7 @@ def test_rejoin_user_events_rest_required_fields( response_value._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.rejoin_user_events(request) @@ -3559,6 +3564,7 @@ def test_write_user_event_rest_bad_request( 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.write_user_event(request) @@ -3800,6 +3806,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.write_user_event(request) # Establish that the response is the type that we expect. @@ -3854,6 +3861,7 @@ def test_write_user_event_rest_interceptors(null_interceptor): 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 = user_event.UserEvent.to_json(user_event.UserEvent()) req.return_value.content = return_value @@ -3898,6 +3906,7 @@ def test_collect_user_event_rest_bad_request( 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.collect_user_event(request) @@ -3931,6 +3940,7 @@ def test_collect_user_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.collect_user_event(request) # Establish that the response is the type that we expect. @@ -3972,6 +3982,7 @@ def test_collect_user_event_rest_interceptors(null_interceptor): 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(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -4016,6 +4027,7 @@ def test_purge_user_events_rest_bad_request( 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.purge_user_events(request) @@ -4046,6 +4058,7 @@ def test_purge_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_user_events(request) # Establish that the response is the type that we expect. @@ -4087,6 +4100,7 @@ def test_purge_user_events_rest_interceptors(null_interceptor): 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 @@ -4131,6 +4145,7 @@ def test_import_user_events_rest_bad_request( 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.import_user_events(request) @@ -4161,6 +4176,7 @@ def test_import_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_user_events(request) # Establish that the response is the type that we expect. @@ -4202,6 +4218,7 @@ def test_import_user_events_rest_interceptors(null_interceptor): 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 @@ -4246,6 +4263,7 @@ def test_rejoin_user_events_rest_bad_request( 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.rejoin_user_events(request) @@ -4276,6 +4294,7 @@ def test_rejoin_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.rejoin_user_events(request) # Establish that the response is the type that we expect. @@ -4317,6 +4336,7 @@ def test_rejoin_user_events_rest_interceptors(null_interceptor): 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 @@ -4363,6 +4383,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4393,6 +4414,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4423,6 +4445,7 @@ def test_list_operations_rest_bad_request( 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) @@ -4453,6 +4476,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_analytics_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_analytics_service.py index ed406e3d4ee4..b0b35e9232c7 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_analytics_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_analytics_service.py @@ -1472,6 +1472,7 @@ def test_export_analytics_metrics_rest_required_fields( response_value._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.export_analytics_metrics(request) @@ -1695,6 +1696,7 @@ def test_export_analytics_metrics_rest_bad_request( 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.export_analytics_metrics(request) @@ -1725,6 +1727,7 @@ def test_export_analytics_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_analytics_metrics(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_export_analytics_metrics_rest_interceptors(null_interceptor): 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 @@ -1815,6 +1819,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1847,6 +1852,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1877,6 +1883,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1907,6 +1914,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_branch_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_branch_service.py index dee91bbccc7b..7358d01b0b01 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_branch_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_branch_service.py @@ -1804,6 +1804,7 @@ def test_list_branches_rest_required_fields( response_value._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_branches(request) @@ -1851,6 +1852,7 @@ def test_list_branches_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branches(**mock_args) @@ -1982,6 +1984,7 @@ def test_get_branch_rest_required_fields(request_type=branch_service.GetBranchRe response_value._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_branch(request) @@ -2029,6 +2032,7 @@ def test_get_branch_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch(**mock_args) @@ -2302,6 +2306,7 @@ def test_list_branches_rest_bad_request( 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_branches(request) @@ -2335,6 +2340,7 @@ def test_list_branches_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_branches(request) # Establish that the response is the type that we expect. @@ -2374,6 +2380,7 @@ def test_list_branches_rest_interceptors(null_interceptor): 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 = branch_service.ListBranchesResponse.to_json( branch_service.ListBranchesResponse() ) @@ -2420,6 +2427,7 @@ def test_get_branch_rest_bad_request(request_type=branch_service.GetBranchReques 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_branch(request) @@ -2459,6 +2467,7 @@ def test_get_branch_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch(request) # Establish that the response is the type that we expect. @@ -2501,6 +2510,7 @@ def test_get_branch_rest_interceptors(null_interceptor): 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 = branch.Branch.to_json(branch.Branch()) req.return_value.content = return_value @@ -2550,6 +2560,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2582,6 +2593,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2612,6 +2624,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2642,6 +2655,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_catalog_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_catalog_service.py index 30ffd3b87b33..25acb750463d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_catalog_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_catalog_service.py @@ -5264,6 +5264,7 @@ def test_list_catalogs_rest_required_fields( response_value._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_catalogs(request) @@ -5317,6 +5318,7 @@ def test_list_catalogs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalogs(**mock_args) @@ -5509,6 +5511,7 @@ def test_update_catalog_rest_required_fields( response_value._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_catalog(request) @@ -5557,6 +5560,7 @@ def test_update_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog(**mock_args) @@ -5655,6 +5659,7 @@ def test_set_default_branch_rest_flattened(): 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"} client.set_default_branch(**mock_args) @@ -5754,6 +5759,7 @@ def test_get_default_branch_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_default_branch(**mock_args) @@ -5890,6 +5896,7 @@ def test_get_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -5937,6 +5944,7 @@ def test_get_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -6071,6 +6079,7 @@ def test_update_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -6121,6 +6130,7 @@ def test_update_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -6258,6 +6268,7 @@ def test_get_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6305,6 +6316,7 @@ def test_get_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6439,6 +6451,7 @@ def test_update_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6489,6 +6502,7 @@ def test_update_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6627,6 +6641,7 @@ def test_add_catalog_attribute_rest_required_fields( response_value._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.add_catalog_attribute(request) @@ -6764,6 +6779,7 @@ def test_remove_catalog_attribute_rest_required_fields( response_value._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.remove_catalog_attribute(request) @@ -6903,6 +6919,7 @@ def test_batch_remove_catalog_attributes_rest_required_fields( response_value._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.batch_remove_catalog_attributes(request) @@ -7038,6 +7055,7 @@ def test_replace_catalog_attribute_rest_required_fields( response_value._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.replace_catalog_attribute(request) @@ -7845,6 +7863,7 @@ def test_list_catalogs_rest_bad_request( 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_catalogs(request) @@ -7880,6 +7899,7 @@ def test_list_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalogs(request) # Establish that the response is the type that we expect. @@ -7920,6 +7940,7 @@ def test_list_catalogs_rest_interceptors(null_interceptor): 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 = catalog_service.ListCatalogsResponse.to_json( catalog_service.ListCatalogsResponse() ) @@ -7968,6 +7989,7 @@ def test_update_catalog_rest_bad_request( 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_catalog(request) @@ -8098,6 +8120,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog(request) # Establish that the response is the type that we expect. @@ -8139,6 +8162,7 @@ def test_update_catalog_rest_interceptors(null_interceptor): 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 = gcr_catalog.Catalog.to_json(gcr_catalog.Catalog()) req.return_value.content = return_value @@ -8183,6 +8207,7 @@ def test_set_default_branch_rest_bad_request( 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.set_default_branch(request) @@ -8213,6 +8238,7 @@ def test_set_default_branch_rest_call_success(request_type): 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.set_default_branch(request) # Establish that the response is the type that we expect. @@ -8249,6 +8275,7 @@ def test_set_default_branch_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = catalog_service.SetDefaultBranchRequest() metadata = [ @@ -8289,6 +8316,7 @@ def test_get_default_branch_rest_bad_request( 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_default_branch(request) @@ -8325,6 +8353,7 @@ def test_get_default_branch_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_default_branch(request) # Establish that the response is the type that we expect. @@ -8366,6 +8395,7 @@ def test_get_default_branch_rest_interceptors(null_interceptor): 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 = catalog_service.GetDefaultBranchResponse.to_json( catalog_service.GetDefaultBranchResponse() ) @@ -8414,6 +8444,7 @@ def test_get_completion_config_rest_bad_request( 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_completion_config(request) @@ -8458,6 +8489,7 @@ def test_get_completion_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8514,6 +8546,7 @@ def test_get_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8562,6 +8595,7 @@ def test_update_completion_config_rest_bad_request( 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_completion_config(request) @@ -8699,6 +8733,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8755,6 +8790,7 @@ def test_update_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8801,6 +8837,7 @@ def test_get_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -8839,6 +8876,7 @@ def test_get_attributes_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -8883,6 +8921,7 @@ def test_get_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8931,6 +8970,7 @@ def test_update_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -9045,6 +9085,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -9089,6 +9130,7 @@ def test_update_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9135,6 +9177,7 @@ def test_add_catalog_attribute_rest_bad_request( 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.add_catalog_attribute(request) @@ -9173,6 +9216,7 @@ def test_add_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9217,6 +9261,7 @@ def test_add_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9263,6 +9308,7 @@ def test_remove_catalog_attribute_rest_bad_request( 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.remove_catalog_attribute(request) @@ -9301,6 +9347,7 @@ def test_remove_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9345,6 +9392,7 @@ def test_remove_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9391,6 +9439,7 @@ def test_batch_remove_catalog_attributes_rest_bad_request( 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.batch_remove_catalog_attributes(request) @@ -9431,6 +9480,7 @@ def test_batch_remove_catalog_attributes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_remove_catalog_attributes(request) # Establish that the response is the type that we expect. @@ -9472,6 +9522,7 @@ def test_batch_remove_catalog_attributes_rest_interceptors(null_interceptor): 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 = catalog_service.BatchRemoveCatalogAttributesResponse.to_json( catalog_service.BatchRemoveCatalogAttributesResponse() ) @@ -9520,6 +9571,7 @@ def test_replace_catalog_attribute_rest_bad_request( 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.replace_catalog_attribute(request) @@ -9558,6 +9610,7 @@ def test_replace_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.replace_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9602,6 +9655,7 @@ def test_replace_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9651,6 +9705,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9683,6 +9738,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -9713,6 +9769,7 @@ def test_list_operations_rest_bad_request( 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) @@ -9743,6 +9800,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_completion_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_completion_service.py index 762248d6b9d2..3a7ac5195d92 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_completion_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_completion_service.py @@ -1746,6 +1746,7 @@ def test_complete_query_rest_required_fields( response_value._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.complete_query(request) @@ -1897,6 +1898,7 @@ def test_import_completion_data_rest_required_fields( response_value._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.import_completion_data(request) @@ -2168,6 +2170,7 @@ def test_complete_query_rest_bad_request( 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.complete_query(request) @@ -2203,6 +2206,7 @@ def test_complete_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.complete_query(request) # Establish that the response is the type that we expect. @@ -2243,6 +2247,7 @@ def test_complete_query_rest_interceptors(null_interceptor): 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 = completion_service.CompleteQueryResponse.to_json( completion_service.CompleteQueryResponse() ) @@ -2289,6 +2294,7 @@ def test_import_completion_data_rest_bad_request( 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.import_completion_data(request) @@ -2319,6 +2325,7 @@ def test_import_completion_data_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_completion_data(request) # Establish that the response is the type that we expect. @@ -2360,6 +2367,7 @@ def test_import_completion_data_rest_interceptors(null_interceptor): 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 @@ -2409,6 +2417,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2441,6 +2450,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2471,6 +2481,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2501,6 +2512,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_control_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_control_service.py index dd4108a3016b..4e38d91a9315 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_control_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_control_service.py @@ -3152,6 +3152,7 @@ def test_create_control_rest_required_fields( response_value._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_control(request) @@ -3222,6 +3223,7 @@ def test_create_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3358,6 +3360,7 @@ def test_delete_control_rest_required_fields( response_value._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_control(request) @@ -3403,6 +3406,7 @@ def test_delete_control_rest_flattened(): 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"} client.delete_control(**mock_args) @@ -3532,6 +3536,7 @@ def test_update_control_rest_required_fields( response_value._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_control(request) @@ -3588,6 +3593,7 @@ def test_update_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3726,6 +3732,7 @@ def test_get_control_rest_required_fields( response_value._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_control(request) @@ -3773,6 +3780,7 @@ def test_get_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3912,6 +3920,7 @@ def test_list_controls_rest_required_fields( response_value._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_controls(request) @@ -3968,6 +3977,7 @@ def test_list_controls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_controls(**mock_args) @@ -4464,6 +4474,7 @@ def test_create_control_rest_bad_request( 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_control(request) @@ -4658,6 +4669,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -4706,6 +4718,7 @@ def test_create_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -4752,6 +4765,7 @@ def test_delete_control_rest_bad_request( 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_control(request) @@ -4784,6 +4798,7 @@ def test_delete_control_rest_call_success(request_type): 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_control(request) # Establish that the response is the type that we expect. @@ -4820,6 +4835,7 @@ def test_delete_control_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = control_service.DeleteControlRequest() metadata = [ @@ -4864,6 +4880,7 @@ def test_update_control_rest_bad_request( 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_control(request) @@ -5062,6 +5079,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -5110,6 +5128,7 @@ def test_update_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -5154,6 +5173,7 @@ def test_get_control_rest_bad_request(request_type=control_service.GetControlReq 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_control(request) @@ -5197,6 +5217,7 @@ def test_get_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -5245,6 +5266,7 @@ def test_get_control_rest_interceptors(null_interceptor): 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 = control.Control.to_json(control.Control()) req.return_value.content = return_value @@ -5289,6 +5311,7 @@ def test_list_controls_rest_bad_request( 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_controls(request) @@ -5324,6 +5347,7 @@ def test_list_controls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_controls(request) # Establish that the response is the type that we expect. @@ -5364,6 +5388,7 @@ def test_list_controls_rest_interceptors(null_interceptor): 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 = control_service.ListControlsResponse.to_json( control_service.ListControlsResponse() ) @@ -5415,6 +5440,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5447,6 +5473,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5477,6 +5504,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5507,6 +5535,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_generative_question_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_generative_question_service.py index 3edcf0ce9a06..ccfb419462f6 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_generative_question_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_generative_question_service.py @@ -3133,6 +3133,7 @@ def test_update_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3193,6 +3194,7 @@ def test_update_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3340,6 +3342,7 @@ def test_get_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3391,6 +3394,7 @@ def test_get_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3533,6 +3537,7 @@ def test_list_generative_question_configs_rest_required_fields( response_value._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_generative_question_configs(request) @@ -3588,6 +3593,7 @@ def test_list_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_configs(**mock_args) @@ -3722,6 +3728,7 @@ def test_update_generative_question_config_rest_required_fields( response_value._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_generative_question_config(request) @@ -3778,6 +3785,7 @@ def test_update_generative_question_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_config(**mock_args) @@ -3923,6 +3931,7 @@ def test_batch_update_generative_question_configs_rest_required_fields( response_value._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.batch_update_generative_question_configs(request) @@ -3987,6 +3996,7 @@ def test_batch_update_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_update_generative_question_configs(**mock_args) @@ -4463,6 +4473,7 @@ def test_update_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4586,6 +4597,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4630,6 +4642,7 @@ def test_update_generative_questions_feature_config_rest_interceptors(null_inter 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4678,6 +4691,7 @@ def test_get_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4717,6 +4731,7 @@ def test_get_generative_questions_feature_config_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4763,6 +4778,7 @@ def test_get_generative_questions_feature_config_rest_interceptors(null_intercep 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4811,6 +4827,7 @@ def test_list_generative_question_configs_rest_bad_request( 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_generative_question_configs(request) @@ -4850,6 +4867,7 @@ def test_list_generative_question_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -4895,6 +4913,7 @@ def test_list_generative_question_configs_rest_interceptors(null_interceptor): 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 = ( generative_question_service.ListGenerativeQuestionConfigsResponse.to_json( generative_question_service.ListGenerativeQuestionConfigsResponse() @@ -4949,6 +4968,7 @@ def test_update_generative_question_config_rest_bad_request( 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_generative_question_config(request) @@ -5078,6 +5098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_config(request) # Establish that the response is the type that we expect. @@ -5128,6 +5149,7 @@ def test_update_generative_question_config_rest_interceptors(null_interceptor): 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 = generative_question.GenerativeQuestionConfig.to_json( generative_question.GenerativeQuestionConfig() ) @@ -5174,6 +5196,7 @@ def test_batch_update_generative_question_configs_rest_bad_request( 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.batch_update_generative_question_configs(request) @@ -5213,6 +5236,7 @@ def test_batch_update_generative_question_configs_rest_call_success(request_type json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_update_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -5257,6 +5281,7 @@ def test_batch_update_generative_question_configs_rest_interceptors(null_interce 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 = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.to_json( generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse() ) @@ -5312,6 +5337,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5344,6 +5370,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5374,6 +5401,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5404,6 +5432,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_merchant_center_account_link_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_merchant_center_account_link_service.py index cc95bf2acb3a..51543b6cd09d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_merchant_center_account_link_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_merchant_center_account_link_service.py @@ -2374,6 +2374,7 @@ def test_list_merchant_center_account_links_rest_required_fields( response_value._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_merchant_center_account_links(request) @@ -2427,6 +2428,7 @@ def test_list_merchant_center_account_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_merchant_center_account_links(**mock_args) @@ -2567,6 +2569,7 @@ def test_create_merchant_center_account_link_rest_required_fields( response_value._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_merchant_center_account_link(request) @@ -2625,6 +2628,7 @@ def test_create_merchant_center_account_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_merchant_center_account_link(**mock_args) @@ -2763,6 +2767,7 @@ def test_delete_merchant_center_account_link_rest_required_fields( response_value._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_merchant_center_account_link(request) @@ -2810,6 +2815,7 @@ def test_delete_merchant_center_account_link_rest_flattened(): 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"} client.delete_merchant_center_account_link(**mock_args) @@ -3151,6 +3157,7 @@ def test_list_merchant_center_account_links_rest_bad_request( 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_merchant_center_account_links(request) @@ -3188,6 +3195,7 @@ def test_list_merchant_center_account_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_merchant_center_account_links(request) # Establish that the response is the type that we expect. @@ -3232,6 +3240,7 @@ def test_list_merchant_center_account_links_rest_interceptors(null_interceptor): 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 = merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse.to_json( merchant_center_account_link_service.ListMerchantCenterAccountLinksResponse() ) @@ -3282,6 +3291,7 @@ def test_create_merchant_center_account_link_rest_bad_request( 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_merchant_center_account_link(request) @@ -3399,6 +3409,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_merchant_center_account_link(request) # Establish that the response is the type that we expect. @@ -3442,6 +3453,7 @@ def test_create_merchant_center_account_link_rest_interceptors(null_interceptor) 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 @@ -3490,6 +3502,7 @@ def test_delete_merchant_center_account_link_rest_bad_request( 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_merchant_center_account_link(request) @@ -3522,6 +3535,7 @@ def test_delete_merchant_center_account_link_rest_call_success(request_type): 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_merchant_center_account_link(request) # Establish that the response is the type that we expect. @@ -3559,6 +3573,7 @@ def test_delete_merchant_center_account_link_rest_interceptors(null_interceptor) req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( merchant_center_account_link_service.DeleteMerchantCenterAccountLinkRequest() @@ -3606,6 +3621,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3638,6 +3654,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -3668,6 +3685,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3698,6 +3716,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_model_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_model_service.py index 40743b057001..71bf19a1a07d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_model_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_model_service.py @@ -4171,6 +4171,7 @@ def test_create_model_rest_required_fields( response_value._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_model(request) @@ -4229,6 +4230,7 @@ def test_create_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4363,6 +4365,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._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_model(request) @@ -4410,6 +4413,7 @@ def test_get_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4540,6 +4544,7 @@ def test_pause_model_rest_required_fields(request_type=model_service.PauseModelR response_value._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.pause_model(request) @@ -4587,6 +4592,7 @@ def test_pause_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_model(**mock_args) @@ -4719,6 +4725,7 @@ def test_resume_model_rest_required_fields( response_value._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.resume_model(request) @@ -4766,6 +4773,7 @@ def test_resume_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_model(**mock_args) @@ -4894,6 +4902,7 @@ def test_delete_model_rest_required_fields( response_value._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_model(request) @@ -4939,6 +4948,7 @@ def test_delete_model_rest_flattened(): 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"} client.delete_model(**mock_args) @@ -5075,6 +5085,7 @@ def test_list_models_rest_required_fields(request_type=model_service.ListModelsR response_value._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_models(request) @@ -5130,6 +5141,7 @@ def test_list_models_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_models(**mock_args) @@ -5322,6 +5334,7 @@ def test_update_model_rest_required_fields( response_value._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_model(request) @@ -5376,6 +5389,7 @@ def test_update_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -5512,6 +5526,7 @@ def test_tune_model_rest_required_fields(request_type=model_service.TuneModelReq response_value._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.tune_model(request) @@ -5557,6 +5572,7 @@ def test_tune_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.tune_model(**mock_args) @@ -6144,6 +6160,7 @@ def test_create_model_rest_bad_request(request_type=model_service.CreateModelReq 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_model(request) @@ -6281,6 +6298,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6322,6 +6340,7 @@ def test_create_model_rest_interceptors(null_interceptor): 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 @@ -6366,6 +6385,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): 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_model(request) @@ -6412,6 +6432,7 @@ def test_get_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6465,6 +6486,7 @@ def test_get_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6509,6 +6531,7 @@ def test_pause_model_rest_bad_request(request_type=model_service.PauseModelReque 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.pause_model(request) @@ -6555,6 +6578,7 @@ def test_pause_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_model(request) # Establish that the response is the type that we expect. @@ -6610,6 +6634,7 @@ def test_pause_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6654,6 +6679,7 @@ def test_resume_model_rest_bad_request(request_type=model_service.ResumeModelReq 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.resume_model(request) @@ -6700,6 +6726,7 @@ def test_resume_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_model(request) # Establish that the response is the type that we expect. @@ -6755,6 +6782,7 @@ def test_resume_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6799,6 +6827,7 @@ def test_delete_model_rest_bad_request(request_type=model_service.DeleteModelReq 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_model(request) @@ -6831,6 +6860,7 @@ def test_delete_model_rest_call_success(request_type): 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_model(request) # Establish that the response is the type that we expect. @@ -6867,6 +6897,7 @@ def test_delete_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = model_service.DeleteModelRequest() metadata = [ @@ -6905,6 +6936,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque 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_models(request) @@ -6940,6 +6972,7 @@ def test_list_models_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_models(request) # Establish that the response is the type that we expect. @@ -6980,6 +7013,7 @@ def test_list_models_rest_interceptors(null_interceptor): 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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -7028,6 +7062,7 @@ def test_update_model_rest_bad_request(request_type=model_service.UpdateModelReq 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_model(request) @@ -7183,6 +7218,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -7238,6 +7274,7 @@ def test_update_model_rest_interceptors(null_interceptor): 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 = gcr_model.Model.to_json(gcr_model.Model()) req.return_value.content = return_value @@ -7282,6 +7319,7 @@ def test_tune_model_rest_bad_request(request_type=model_service.TuneModelRequest 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.tune_model(request) @@ -7314,6 +7352,7 @@ def test_tune_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.tune_model(request) # Establish that the response is the type that we expect. @@ -7353,6 +7392,7 @@ def test_tune_model_rest_interceptors(null_interceptor): 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 @@ -7402,6 +7442,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7434,6 +7475,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7464,6 +7506,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7494,6 +7537,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_prediction_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_prediction_service.py index 0b69cc6de2f2..29a412631659 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_prediction_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_prediction_service.py @@ -1462,6 +1462,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq response_value._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.predict(request) @@ -1685,6 +1686,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -1724,6 +1726,7 @@ def test_predict_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.predict(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_predict_rest_interceptors(null_interceptor): 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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -1817,6 +1821,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1849,6 +1854,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1879,6 +1885,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1909,6 +1916,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_product_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_product_service.py index cec9dbd1a65a..61d1a8ff3a0b 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_product_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_product_service.py @@ -5700,6 +5700,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -5766,6 +5767,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -5901,6 +5903,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -5948,6 +5951,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -6089,6 +6093,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -6147,6 +6152,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -6346,6 +6352,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -6406,6 +6413,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -6539,6 +6547,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -6584,6 +6593,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -6721,6 +6731,7 @@ def test_purge_products_rest_required_fields( response_value._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.purge_products(request) @@ -6850,6 +6861,7 @@ def test_import_products_rest_required_fields( response_value._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.import_products(request) @@ -6979,6 +6991,7 @@ def test_export_products_rest_required_fields( response_value._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.export_products(request) @@ -7103,6 +7116,7 @@ def test_set_inventory_rest_required_fields( response_value._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.set_inventory(request) @@ -7151,6 +7165,7 @@ def test_set_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_inventory(**mock_args) @@ -7298,6 +7313,7 @@ def test_add_fulfillment_places_rest_required_fields( response_value._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.add_fulfillment_places(request) @@ -7352,6 +7368,7 @@ def test_add_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_fulfillment_places(**mock_args) @@ -7498,6 +7515,7 @@ def test_remove_fulfillment_places_rest_required_fields( response_value._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.remove_fulfillment_places(request) @@ -7552,6 +7570,7 @@ def test_remove_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_fulfillment_places(**mock_args) @@ -7690,6 +7709,7 @@ def test_add_local_inventories_rest_required_fields( response_value._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.add_local_inventories(request) @@ -7743,6 +7763,7 @@ def test_add_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_local_inventories(**mock_args) @@ -7885,6 +7906,7 @@ def test_remove_local_inventories_rest_required_fields( response_value._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.remove_local_inventories(request) @@ -7938,6 +7960,7 @@ def test_remove_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_local_inventories(**mock_args) @@ -8789,6 +8812,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -8990,6 +9014,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9047,6 +9072,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -9091,6 +9117,7 @@ def test_get_product_rest_bad_request(request_type=product_service.GetProductReq 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_product(request) @@ -9145,6 +9172,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9202,6 +9230,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product.Product.to_json(product.Product()) req.return_value.content = return_value @@ -9248,6 +9277,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -9286,6 +9316,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -9327,6 +9358,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_service.ListProductsResponse.to_json( product_service.ListProductsResponse() ) @@ -9377,6 +9409,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -9580,6 +9613,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9637,6 +9671,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -9683,6 +9718,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -9715,6 +9751,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -9751,6 +9788,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_service.DeleteProductRequest() metadata = [ @@ -9793,6 +9831,7 @@ def test_purge_products_rest_bad_request( 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.purge_products(request) @@ -9825,6 +9864,7 @@ def test_purge_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_products(request) # Establish that the response is the type that we expect. @@ -9866,6 +9906,7 @@ def test_purge_products_rest_interceptors(null_interceptor): 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 @@ -9912,6 +9953,7 @@ def test_import_products_rest_bad_request( 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.import_products(request) @@ -9944,6 +9986,7 @@ def test_import_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_products(request) # Establish that the response is the type that we expect. @@ -9985,6 +10028,7 @@ def test_import_products_rest_interceptors(null_interceptor): 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 @@ -10031,6 +10075,7 @@ def test_export_products_rest_bad_request( 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.export_products(request) @@ -10063,6 +10108,7 @@ def test_export_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_products(request) # Establish that the response is the type that we expect. @@ -10104,6 +10150,7 @@ def test_export_products_rest_interceptors(null_interceptor): 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 @@ -10152,6 +10199,7 @@ def test_set_inventory_rest_bad_request( 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.set_inventory(request) @@ -10186,6 +10234,7 @@ def test_set_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_inventory(request) # Establish that the response is the type that we expect. @@ -10227,6 +10276,7 @@ def test_set_inventory_rest_interceptors(null_interceptor): 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 @@ -10273,6 +10323,7 @@ def test_add_fulfillment_places_rest_bad_request( 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.add_fulfillment_places(request) @@ -10305,6 +10356,7 @@ def test_add_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -10346,6 +10398,7 @@ def test_add_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -10392,6 +10445,7 @@ def test_remove_fulfillment_places_rest_bad_request( 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.remove_fulfillment_places(request) @@ -10424,6 +10478,7 @@ def test_remove_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -10465,6 +10520,7 @@ def test_remove_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -10511,6 +10567,7 @@ def test_add_local_inventories_rest_bad_request( 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.add_local_inventories(request) @@ -10543,6 +10600,7 @@ def test_add_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_local_inventories(request) # Establish that the response is the type that we expect. @@ -10584,6 +10642,7 @@ def test_add_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10630,6 +10689,7 @@ def test_remove_local_inventories_rest_bad_request( 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.remove_local_inventories(request) @@ -10662,6 +10722,7 @@ def test_remove_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_local_inventories(request) # Establish that the response is the type that we expect. @@ -10703,6 +10764,7 @@ def test_remove_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10752,6 +10814,7 @@ def test_get_operation_rest_bad_request( 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) @@ -10784,6 +10847,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -10814,6 +10878,7 @@ def test_list_operations_rest_bad_request( 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) @@ -10844,6 +10909,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_project_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_project_service.py index 5c7526fa4a22..d0d185518a0d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_project_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_project_service.py @@ -3778,6 +3778,7 @@ def test_get_project_rest_required_fields( response_value._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_project(request) @@ -3823,6 +3824,7 @@ def test_get_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_project(**mock_args) @@ -3954,6 +3956,7 @@ def test_accept_terms_rest_required_fields( response_value._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.accept_terms(request) @@ -3999,6 +4002,7 @@ def test_accept_terms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.accept_terms(**mock_args) @@ -4132,6 +4136,7 @@ def test_enroll_solution_rest_required_fields( response_value._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.enroll_solution(request) @@ -4266,6 +4271,7 @@ def test_list_enrolled_solutions_rest_required_fields( response_value._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_enrolled_solutions(request) @@ -4311,6 +4317,7 @@ def test_list_enrolled_solutions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_enrolled_solutions(**mock_args) @@ -4445,6 +4452,7 @@ def test_get_logging_config_rest_required_fields( response_value._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_logging_config(request) @@ -4490,6 +4498,7 @@ def test_get_logging_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_config(**mock_args) @@ -4623,6 +4632,7 @@ def test_update_logging_config_rest_required_fields( response_value._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_logging_config(request) @@ -4669,6 +4679,7 @@ def test_update_logging_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_logging_config(**mock_args) @@ -4803,6 +4814,7 @@ def test_get_alert_config_rest_required_fields( response_value._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_alert_config(request) @@ -4848,6 +4860,7 @@ def test_get_alert_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_alert_config(**mock_args) @@ -4979,6 +4992,7 @@ def test_update_alert_config_rest_required_fields( response_value._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_alert_config(request) @@ -5025,6 +5039,7 @@ def test_update_alert_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_alert_config(**mock_args) @@ -5601,6 +5616,7 @@ def test_get_project_rest_bad_request(request_type=project_service.GetProjectReq 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_project(request) @@ -5637,6 +5653,7 @@ def test_get_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_project(request) # Establish that the response is the type that we expect. @@ -5680,6 +5697,7 @@ def test_get_project_rest_interceptors(null_interceptor): 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 = project.Project.to_json(project.Project()) req.return_value.content = return_value @@ -5722,6 +5740,7 @@ def test_accept_terms_rest_bad_request(request_type=project_service.AcceptTermsR 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.accept_terms(request) @@ -5758,6 +5777,7 @@ def test_accept_terms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.accept_terms(request) # Establish that the response is the type that we expect. @@ -5801,6 +5821,7 @@ def test_accept_terms_rest_interceptors(null_interceptor): 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 = gcr_project.Project.to_json(gcr_project.Project()) req.return_value.content = return_value @@ -5845,6 +5866,7 @@ def test_enroll_solution_rest_bad_request( 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.enroll_solution(request) @@ -5875,6 +5897,7 @@ def test_enroll_solution_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enroll_solution(request) # Establish that the response is the type that we expect. @@ -5916,6 +5939,7 @@ def test_enroll_solution_rest_interceptors(null_interceptor): 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 @@ -5960,6 +5984,7 @@ def test_list_enrolled_solutions_rest_bad_request( 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_enrolled_solutions(request) @@ -5995,6 +6020,7 @@ def test_list_enrolled_solutions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_enrolled_solutions(request) # Establish that the response is the type that we expect. @@ -6037,6 +6063,7 @@ def test_list_enrolled_solutions_rest_interceptors(null_interceptor): 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 = project_service.ListEnrolledSolutionsResponse.to_json( project_service.ListEnrolledSolutionsResponse() ) @@ -6083,6 +6110,7 @@ def test_get_logging_config_rest_bad_request( 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_logging_config(request) @@ -6118,6 +6146,7 @@ def test_get_logging_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_config(request) # Establish that the response is the type that we expect. @@ -6158,6 +6187,7 @@ def test_get_logging_config_rest_interceptors(null_interceptor): 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 = project.LoggingConfig.to_json(project.LoggingConfig()) req.return_value.content = return_value @@ -6202,6 +6232,7 @@ def test_update_logging_config_rest_bad_request( 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_logging_config(request) @@ -6316,6 +6347,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_logging_config(request) # Establish that the response is the type that we expect. @@ -6356,6 +6388,7 @@ def test_update_logging_config_rest_interceptors(null_interceptor): 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 = project.LoggingConfig.to_json(project.LoggingConfig()) req.return_value.content = return_value @@ -6400,6 +6433,7 @@ def test_get_alert_config_rest_bad_request( 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_alert_config(request) @@ -6435,6 +6469,7 @@ def test_get_alert_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_alert_config(request) # Establish that the response is the type that we expect. @@ -6475,6 +6510,7 @@ def test_get_alert_config_rest_interceptors(null_interceptor): 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 = project.AlertConfig.to_json(project.AlertConfig()) req.return_value.content = return_value @@ -6519,6 +6555,7 @@ def test_update_alert_config_rest_bad_request( 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_alert_config(request) @@ -6631,6 +6668,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_alert_config(request) # Establish that the response is the type that we expect. @@ -6671,6 +6709,7 @@ def test_update_alert_config_rest_interceptors(null_interceptor): 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 = project.AlertConfig.to_json(project.AlertConfig()) req.return_value.content = return_value @@ -6720,6 +6759,7 @@ def test_get_operation_rest_bad_request( 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) @@ -6752,6 +6792,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -6782,6 +6823,7 @@ def test_list_operations_rest_bad_request( 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) @@ -6812,6 +6854,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_search_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_search_service.py index 9c94fec0c8f7..391881054acf 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_search_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_search_service.py @@ -1634,6 +1634,7 @@ def test_search_rest_required_fields(request_type=search_service.SearchRequest): response_value._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.search(request) @@ -1925,6 +1926,7 @@ def test_search_rest_bad_request(request_type=search_service.SearchRequest): 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.search(request) @@ -1967,6 +1969,7 @@ def test_search_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search(request) # Establish that the response is the type that we expect. @@ -2010,6 +2013,7 @@ def test_search_rest_interceptors(null_interceptor): 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 = search_service.SearchResponse.to_json( search_service.SearchResponse() ) @@ -2061,6 +2065,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2093,6 +2098,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2123,6 +2129,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2153,6 +2160,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_serving_config_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_serving_config_service.py index 3a7ad145dc38..cd9b8d978c02 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_serving_config_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_serving_config_service.py @@ -4218,6 +4218,7 @@ def test_create_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4282,6 +4283,7 @@ def test_create_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4417,6 +4419,7 @@ def test_delete_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4462,6 +4465,7 @@ def test_delete_serving_config_rest_flattened(): 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"} client.delete_serving_config(**mock_args) @@ -4596,6 +4600,7 @@ def test_update_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4646,6 +4651,7 @@ def test_update_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4782,6 +4788,7 @@ def test_get_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4829,6 +4836,7 @@ def test_get_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4973,6 +4981,7 @@ def test_list_serving_configs_rest_required_fields( response_value._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_serving_configs(request) @@ -5030,6 +5039,7 @@ def test_list_serving_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_configs(**mock_args) @@ -5232,6 +5242,7 @@ def test_add_control_rest_required_fields( response_value._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.add_control(request) @@ -5287,6 +5298,7 @@ def test_add_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_control(**mock_args) @@ -5423,6 +5435,7 @@ def test_remove_control_rest_required_fields( response_value._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.remove_control(request) @@ -5478,6 +5491,7 @@ def test_remove_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_control(**mock_args) @@ -6092,6 +6106,7 @@ def test_create_serving_config_rest_bad_request( 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_serving_config(request) @@ -6256,6 +6271,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6318,6 +6334,7 @@ def test_create_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6366,6 +6383,7 @@ def test_delete_serving_config_rest_bad_request( 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_serving_config(request) @@ -6398,6 +6416,7 @@ def test_delete_serving_config_rest_call_success(request_type): 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_serving_config(request) # Establish that the response is the type that we expect. @@ -6434,6 +6453,7 @@ def test_delete_serving_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = serving_config_service.DeleteServingConfigRequest() metadata = [ @@ -6478,6 +6498,7 @@ def test_update_serving_config_rest_bad_request( 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_serving_config(request) @@ -6646,6 +6667,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6708,6 +6730,7 @@ def test_update_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6756,6 +6779,7 @@ def test_get_serving_config_rest_bad_request( 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_serving_config(request) @@ -6810,6 +6834,7 @@ def test_get_serving_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6872,6 +6897,7 @@ def test_get_serving_config_rest_interceptors(null_interceptor): 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 = serving_config.ServingConfig.to_json( serving_config.ServingConfig() ) @@ -6918,6 +6944,7 @@ def test_list_serving_configs_rest_bad_request( 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_serving_configs(request) @@ -6955,6 +6982,7 @@ def test_list_serving_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_configs(request) # Establish that the response is the type that we expect. @@ -6995,6 +7023,7 @@ def test_list_serving_configs_rest_interceptors(null_interceptor): 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 = serving_config_service.ListServingConfigsResponse.to_json( serving_config_service.ListServingConfigsResponse() ) @@ -7043,6 +7072,7 @@ def test_add_control_rest_bad_request( 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.add_control(request) @@ -7097,6 +7127,7 @@ def test_add_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_control(request) # Establish that the response is the type that we expect. @@ -7159,6 +7190,7 @@ def test_add_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7207,6 +7239,7 @@ def test_remove_control_rest_bad_request( 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.remove_control(request) @@ -7261,6 +7294,7 @@ def test_remove_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_control(request) # Establish that the response is the type that we expect. @@ -7323,6 +7357,7 @@ def test_remove_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7374,6 +7409,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7406,6 +7442,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7436,6 +7473,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7466,6 +7504,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_user_event_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_user_event_service.py index b30ca8f0136d..2e7ec0b0fa0a 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_user_event_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_user_event_service.py @@ -2830,6 +2830,7 @@ def test_write_user_event_rest_required_fields( response_value._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.write_user_event(request) @@ -2976,6 +2977,7 @@ def test_collect_user_event_rest_required_fields( response_value._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.collect_user_event(request) @@ -3125,6 +3127,7 @@ def test_purge_user_events_rest_required_fields( response_value._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.purge_user_events(request) @@ -3258,6 +3261,7 @@ def test_import_user_events_rest_required_fields( response_value._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.import_user_events(request) @@ -3391,6 +3395,7 @@ def test_export_user_events_rest_required_fields( response_value._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.export_user_events(request) @@ -3524,6 +3529,7 @@ def test_rejoin_user_events_rest_required_fields( response_value._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.rejoin_user_events(request) @@ -4004,6 +4010,7 @@ def test_write_user_event_rest_bad_request( 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.write_user_event(request) @@ -4245,6 +4252,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.write_user_event(request) # Establish that the response is the type that we expect. @@ -4299,6 +4307,7 @@ def test_write_user_event_rest_interceptors(null_interceptor): 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 = user_event.UserEvent.to_json(user_event.UserEvent()) req.return_value.content = return_value @@ -4343,6 +4352,7 @@ def test_collect_user_event_rest_bad_request( 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.collect_user_event(request) @@ -4376,6 +4386,7 @@ def test_collect_user_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.collect_user_event(request) # Establish that the response is the type that we expect. @@ -4417,6 +4428,7 @@ def test_collect_user_event_rest_interceptors(null_interceptor): 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(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -4461,6 +4473,7 @@ def test_purge_user_events_rest_bad_request( 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.purge_user_events(request) @@ -4491,6 +4504,7 @@ def test_purge_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_user_events(request) # Establish that the response is the type that we expect. @@ -4532,6 +4546,7 @@ def test_purge_user_events_rest_interceptors(null_interceptor): 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 @@ -4576,6 +4591,7 @@ def test_import_user_events_rest_bad_request( 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.import_user_events(request) @@ -4606,6 +4622,7 @@ def test_import_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_user_events(request) # Establish that the response is the type that we expect. @@ -4647,6 +4664,7 @@ def test_import_user_events_rest_interceptors(null_interceptor): 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 @@ -4691,6 +4709,7 @@ def test_export_user_events_rest_bad_request( 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.export_user_events(request) @@ -4721,6 +4740,7 @@ def test_export_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_user_events(request) # Establish that the response is the type that we expect. @@ -4762,6 +4782,7 @@ def test_export_user_events_rest_interceptors(null_interceptor): 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 @@ -4806,6 +4827,7 @@ def test_rejoin_user_events_rest_bad_request( 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.rejoin_user_events(request) @@ -4836,6 +4858,7 @@ def test_rejoin_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.rejoin_user_events(request) # Establish that the response is the type that we expect. @@ -4877,6 +4900,7 @@ def test_rejoin_user_events_rest_interceptors(null_interceptor): 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 @@ -4926,6 +4950,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4958,6 +4983,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4988,6 +5014,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5018,6 +5045,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_analytics_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_analytics_service.py index cdfb0b195234..39041b69dcd9 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_analytics_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_analytics_service.py @@ -1472,6 +1472,7 @@ def test_export_analytics_metrics_rest_required_fields( response_value._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.export_analytics_metrics(request) @@ -1695,6 +1696,7 @@ def test_export_analytics_metrics_rest_bad_request( 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.export_analytics_metrics(request) @@ -1725,6 +1727,7 @@ def test_export_analytics_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_analytics_metrics(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_export_analytics_metrics_rest_interceptors(null_interceptor): 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 @@ -1815,6 +1819,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1847,6 +1852,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1877,6 +1883,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1907,6 +1914,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_catalog_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_catalog_service.py index fbec37c9da02..c4ae0b1dec4d 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_catalog_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_catalog_service.py @@ -5264,6 +5264,7 @@ def test_list_catalogs_rest_required_fields( response_value._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_catalogs(request) @@ -5317,6 +5318,7 @@ def test_list_catalogs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalogs(**mock_args) @@ -5509,6 +5511,7 @@ def test_update_catalog_rest_required_fields( response_value._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_catalog(request) @@ -5557,6 +5560,7 @@ def test_update_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog(**mock_args) @@ -5655,6 +5659,7 @@ def test_set_default_branch_rest_flattened(): 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"} client.set_default_branch(**mock_args) @@ -5754,6 +5759,7 @@ def test_get_default_branch_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_default_branch(**mock_args) @@ -5890,6 +5896,7 @@ def test_get_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -5937,6 +5944,7 @@ def test_get_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -6071,6 +6079,7 @@ def test_update_completion_config_rest_required_fields( response_value._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_completion_config(request) @@ -6121,6 +6130,7 @@ def test_update_completion_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_completion_config(**mock_args) @@ -6258,6 +6268,7 @@ def test_get_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6305,6 +6316,7 @@ def test_get_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6439,6 +6451,7 @@ def test_update_attributes_config_rest_required_fields( response_value._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_attributes_config(request) @@ -6489,6 +6502,7 @@ def test_update_attributes_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attributes_config(**mock_args) @@ -6627,6 +6641,7 @@ def test_add_catalog_attribute_rest_required_fields( response_value._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.add_catalog_attribute(request) @@ -6764,6 +6779,7 @@ def test_remove_catalog_attribute_rest_required_fields( response_value._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.remove_catalog_attribute(request) @@ -6903,6 +6919,7 @@ def test_batch_remove_catalog_attributes_rest_required_fields( response_value._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.batch_remove_catalog_attributes(request) @@ -7038,6 +7055,7 @@ def test_replace_catalog_attribute_rest_required_fields( response_value._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.replace_catalog_attribute(request) @@ -7845,6 +7863,7 @@ def test_list_catalogs_rest_bad_request( 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_catalogs(request) @@ -7880,6 +7899,7 @@ def test_list_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalogs(request) # Establish that the response is the type that we expect. @@ -7920,6 +7940,7 @@ def test_list_catalogs_rest_interceptors(null_interceptor): 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 = catalog_service.ListCatalogsResponse.to_json( catalog_service.ListCatalogsResponse() ) @@ -7968,6 +7989,7 @@ def test_update_catalog_rest_bad_request( 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_catalog(request) @@ -8098,6 +8120,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog(request) # Establish that the response is the type that we expect. @@ -8139,6 +8162,7 @@ def test_update_catalog_rest_interceptors(null_interceptor): 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 = gcr_catalog.Catalog.to_json(gcr_catalog.Catalog()) req.return_value.content = return_value @@ -8183,6 +8207,7 @@ def test_set_default_branch_rest_bad_request( 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.set_default_branch(request) @@ -8213,6 +8238,7 @@ def test_set_default_branch_rest_call_success(request_type): 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.set_default_branch(request) # Establish that the response is the type that we expect. @@ -8249,6 +8275,7 @@ def test_set_default_branch_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = catalog_service.SetDefaultBranchRequest() metadata = [ @@ -8289,6 +8316,7 @@ def test_get_default_branch_rest_bad_request( 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_default_branch(request) @@ -8325,6 +8353,7 @@ def test_get_default_branch_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_default_branch(request) # Establish that the response is the type that we expect. @@ -8366,6 +8395,7 @@ def test_get_default_branch_rest_interceptors(null_interceptor): 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 = catalog_service.GetDefaultBranchResponse.to_json( catalog_service.GetDefaultBranchResponse() ) @@ -8414,6 +8444,7 @@ def test_get_completion_config_rest_bad_request( 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_completion_config(request) @@ -8458,6 +8489,7 @@ def test_get_completion_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8514,6 +8546,7 @@ def test_get_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8562,6 +8595,7 @@ def test_update_completion_config_rest_bad_request( 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_completion_config(request) @@ -8699,6 +8733,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_completion_config(request) # Establish that the response is the type that we expect. @@ -8755,6 +8790,7 @@ def test_update_completion_config_rest_interceptors(null_interceptor): 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 = catalog.CompletionConfig.to_json(catalog.CompletionConfig()) req.return_value.content = return_value @@ -8801,6 +8837,7 @@ def test_get_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -8839,6 +8876,7 @@ def test_get_attributes_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -8883,6 +8921,7 @@ def test_get_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -8931,6 +8970,7 @@ def test_update_attributes_config_rest_bad_request( 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_attributes_config(request) @@ -9045,6 +9085,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_attributes_config(request) # Establish that the response is the type that we expect. @@ -9089,6 +9130,7 @@ def test_update_attributes_config_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9135,6 +9177,7 @@ def test_add_catalog_attribute_rest_bad_request( 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.add_catalog_attribute(request) @@ -9173,6 +9216,7 @@ def test_add_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9217,6 +9261,7 @@ def test_add_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9263,6 +9308,7 @@ def test_remove_catalog_attribute_rest_bad_request( 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.remove_catalog_attribute(request) @@ -9301,6 +9347,7 @@ def test_remove_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9345,6 +9392,7 @@ def test_remove_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9391,6 +9439,7 @@ def test_batch_remove_catalog_attributes_rest_bad_request( 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.batch_remove_catalog_attributes(request) @@ -9431,6 +9480,7 @@ def test_batch_remove_catalog_attributes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_remove_catalog_attributes(request) # Establish that the response is the type that we expect. @@ -9472,6 +9522,7 @@ def test_batch_remove_catalog_attributes_rest_interceptors(null_interceptor): 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 = catalog_service.BatchRemoveCatalogAttributesResponse.to_json( catalog_service.BatchRemoveCatalogAttributesResponse() ) @@ -9520,6 +9571,7 @@ def test_replace_catalog_attribute_rest_bad_request( 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.replace_catalog_attribute(request) @@ -9558,6 +9610,7 @@ def test_replace_catalog_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.replace_catalog_attribute(request) # Establish that the response is the type that we expect. @@ -9602,6 +9655,7 @@ def test_replace_catalog_attribute_rest_interceptors(null_interceptor): 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 = catalog.AttributesConfig.to_json(catalog.AttributesConfig()) req.return_value.content = return_value @@ -9651,6 +9705,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9683,6 +9738,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -9713,6 +9769,7 @@ def test_list_operations_rest_bad_request( 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) @@ -9743,6 +9800,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_completion_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_completion_service.py index dd04b1a63bd9..36306639e32a 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_completion_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_completion_service.py @@ -1746,6 +1746,7 @@ def test_complete_query_rest_required_fields( response_value._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.complete_query(request) @@ -1897,6 +1898,7 @@ def test_import_completion_data_rest_required_fields( response_value._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.import_completion_data(request) @@ -2168,6 +2170,7 @@ def test_complete_query_rest_bad_request( 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.complete_query(request) @@ -2203,6 +2206,7 @@ def test_complete_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.complete_query(request) # Establish that the response is the type that we expect. @@ -2243,6 +2247,7 @@ def test_complete_query_rest_interceptors(null_interceptor): 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 = completion_service.CompleteQueryResponse.to_json( completion_service.CompleteQueryResponse() ) @@ -2289,6 +2294,7 @@ def test_import_completion_data_rest_bad_request( 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.import_completion_data(request) @@ -2319,6 +2325,7 @@ def test_import_completion_data_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_completion_data(request) # Establish that the response is the type that we expect. @@ -2360,6 +2367,7 @@ def test_import_completion_data_rest_interceptors(null_interceptor): 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 @@ -2409,6 +2417,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2441,6 +2450,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2471,6 +2481,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2501,6 +2512,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_control_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_control_service.py index 3407af74c41b..f38696bd2f89 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_control_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_control_service.py @@ -3152,6 +3152,7 @@ def test_create_control_rest_required_fields( response_value._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_control(request) @@ -3222,6 +3223,7 @@ def test_create_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3358,6 +3360,7 @@ def test_delete_control_rest_required_fields( response_value._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_control(request) @@ -3403,6 +3406,7 @@ def test_delete_control_rest_flattened(): 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"} client.delete_control(**mock_args) @@ -3532,6 +3536,7 @@ def test_update_control_rest_required_fields( response_value._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_control(request) @@ -3588,6 +3593,7 @@ def test_update_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3726,6 +3732,7 @@ def test_get_control_rest_required_fields( response_value._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_control(request) @@ -3773,6 +3780,7 @@ def test_get_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_control(**mock_args) @@ -3912,6 +3920,7 @@ def test_list_controls_rest_required_fields( response_value._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_controls(request) @@ -3968,6 +3977,7 @@ def test_list_controls_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_controls(**mock_args) @@ -4464,6 +4474,7 @@ def test_create_control_rest_bad_request( 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_control(request) @@ -4658,6 +4669,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -4706,6 +4718,7 @@ def test_create_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -4752,6 +4765,7 @@ def test_delete_control_rest_bad_request( 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_control(request) @@ -4784,6 +4798,7 @@ def test_delete_control_rest_call_success(request_type): 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_control(request) # Establish that the response is the type that we expect. @@ -4820,6 +4835,7 @@ def test_delete_control_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = control_service.DeleteControlRequest() metadata = [ @@ -4864,6 +4880,7 @@ def test_update_control_rest_bad_request( 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_control(request) @@ -5062,6 +5079,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -5110,6 +5128,7 @@ def test_update_control_rest_interceptors(null_interceptor): 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 = gcr_control.Control.to_json(gcr_control.Control()) req.return_value.content = return_value @@ -5154,6 +5173,7 @@ def test_get_control_rest_bad_request(request_type=control_service.GetControlReq 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_control(request) @@ -5197,6 +5217,7 @@ def test_get_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_control(request) # Establish that the response is the type that we expect. @@ -5245,6 +5266,7 @@ def test_get_control_rest_interceptors(null_interceptor): 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 = control.Control.to_json(control.Control()) req.return_value.content = return_value @@ -5289,6 +5311,7 @@ def test_list_controls_rest_bad_request( 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_controls(request) @@ -5324,6 +5347,7 @@ def test_list_controls_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_controls(request) # Establish that the response is the type that we expect. @@ -5364,6 +5388,7 @@ def test_list_controls_rest_interceptors(null_interceptor): 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 = control_service.ListControlsResponse.to_json( control_service.ListControlsResponse() ) @@ -5415,6 +5440,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5447,6 +5473,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5477,6 +5504,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5507,6 +5535,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_generative_question_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_generative_question_service.py index 1a10f16a463c..e691152ffbf3 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_generative_question_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_generative_question_service.py @@ -3133,6 +3133,7 @@ def test_update_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3193,6 +3194,7 @@ def test_update_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3340,6 +3342,7 @@ def test_get_generative_questions_feature_config_rest_required_fields( response_value._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_generative_questions_feature_config(request) @@ -3391,6 +3394,7 @@ def test_get_generative_questions_feature_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_questions_feature_config(**mock_args) @@ -3533,6 +3537,7 @@ def test_list_generative_question_configs_rest_required_fields( response_value._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_generative_question_configs(request) @@ -3588,6 +3593,7 @@ def test_list_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_configs(**mock_args) @@ -3722,6 +3728,7 @@ def test_update_generative_question_config_rest_required_fields( response_value._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_generative_question_config(request) @@ -3778,6 +3785,7 @@ def test_update_generative_question_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_generative_question_config(**mock_args) @@ -3923,6 +3931,7 @@ def test_batch_update_generative_question_configs_rest_required_fields( response_value._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.batch_update_generative_question_configs(request) @@ -3987,6 +3996,7 @@ def test_batch_update_generative_question_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_update_generative_question_configs(**mock_args) @@ -4463,6 +4473,7 @@ def test_update_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4586,6 +4597,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4630,6 +4642,7 @@ def test_update_generative_questions_feature_config_rest_interceptors(null_inter 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4678,6 +4691,7 @@ def test_get_generative_questions_feature_config_rest_bad_request( 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_generative_questions_feature_config(request) @@ -4717,6 +4731,7 @@ def test_get_generative_questions_feature_config_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_questions_feature_config(request) # Establish that the response is the type that we expect. @@ -4763,6 +4778,7 @@ def test_get_generative_questions_feature_config_rest_interceptors(null_intercep 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 = generative_question.GenerativeQuestionsFeatureConfig.to_json( generative_question.GenerativeQuestionsFeatureConfig() ) @@ -4811,6 +4827,7 @@ def test_list_generative_question_configs_rest_bad_request( 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_generative_question_configs(request) @@ -4850,6 +4867,7 @@ def test_list_generative_question_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -4895,6 +4913,7 @@ def test_list_generative_question_configs_rest_interceptors(null_interceptor): 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 = ( generative_question_service.ListGenerativeQuestionConfigsResponse.to_json( generative_question_service.ListGenerativeQuestionConfigsResponse() @@ -4949,6 +4968,7 @@ def test_update_generative_question_config_rest_bad_request( 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_generative_question_config(request) @@ -5078,6 +5098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_generative_question_config(request) # Establish that the response is the type that we expect. @@ -5128,6 +5149,7 @@ def test_update_generative_question_config_rest_interceptors(null_interceptor): 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 = generative_question.GenerativeQuestionConfig.to_json( generative_question.GenerativeQuestionConfig() ) @@ -5174,6 +5196,7 @@ def test_batch_update_generative_question_configs_rest_bad_request( 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.batch_update_generative_question_configs(request) @@ -5213,6 +5236,7 @@ def test_batch_update_generative_question_configs_rest_call_success(request_type json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_update_generative_question_configs(request) # Establish that the response is the type that we expect. @@ -5257,6 +5281,7 @@ def test_batch_update_generative_question_configs_rest_interceptors(null_interce 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 = generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse.to_json( generative_question_service.BatchUpdateGenerativeQuestionConfigsResponse() ) @@ -5312,6 +5337,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5344,6 +5370,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -5374,6 +5401,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5404,6 +5432,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_model_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_model_service.py index 49c592a7b7ec..9fa9f853036a 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_model_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_model_service.py @@ -4123,6 +4123,7 @@ def test_create_model_rest_required_fields( response_value._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_model(request) @@ -4177,6 +4178,7 @@ def test_create_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4307,6 +4309,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._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_model(request) @@ -4354,6 +4357,7 @@ def test_get_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -4484,6 +4488,7 @@ def test_pause_model_rest_required_fields(request_type=model_service.PauseModelR response_value._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.pause_model(request) @@ -4531,6 +4536,7 @@ def test_pause_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_model(**mock_args) @@ -4663,6 +4669,7 @@ def test_resume_model_rest_required_fields( response_value._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.resume_model(request) @@ -4710,6 +4717,7 @@ def test_resume_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_model(**mock_args) @@ -4838,6 +4846,7 @@ def test_delete_model_rest_required_fields( response_value._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_model(request) @@ -4883,6 +4892,7 @@ def test_delete_model_rest_flattened(): 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"} client.delete_model(**mock_args) @@ -5019,6 +5029,7 @@ def test_list_models_rest_required_fields(request_type=model_service.ListModelsR response_value._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_models(request) @@ -5074,6 +5085,7 @@ def test_list_models_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_models(**mock_args) @@ -5266,6 +5278,7 @@ def test_update_model_rest_required_fields( response_value._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_model(request) @@ -5316,6 +5329,7 @@ def test_update_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_model(**mock_args) @@ -5448,6 +5462,7 @@ def test_tune_model_rest_required_fields(request_type=model_service.TuneModelReq response_value._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.tune_model(request) @@ -5493,6 +5508,7 @@ def test_tune_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.tune_model(**mock_args) @@ -6080,6 +6096,7 @@ def test_create_model_rest_bad_request(request_type=model_service.CreateModelReq 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_model(request) @@ -6203,6 +6220,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6244,6 +6262,7 @@ def test_create_model_rest_interceptors(null_interceptor): 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 @@ -6288,6 +6307,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): 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_model(request) @@ -6334,6 +6354,7 @@ def test_get_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -6387,6 +6408,7 @@ def test_get_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6431,6 +6453,7 @@ def test_pause_model_rest_bad_request(request_type=model_service.PauseModelReque 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.pause_model(request) @@ -6477,6 +6500,7 @@ def test_pause_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_model(request) # Establish that the response is the type that we expect. @@ -6532,6 +6556,7 @@ def test_pause_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6576,6 +6601,7 @@ def test_resume_model_rest_bad_request(request_type=model_service.ResumeModelReq 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.resume_model(request) @@ -6622,6 +6648,7 @@ def test_resume_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_model(request) # Establish that the response is the type that we expect. @@ -6677,6 +6704,7 @@ def test_resume_model_rest_interceptors(null_interceptor): 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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -6721,6 +6749,7 @@ def test_delete_model_rest_bad_request(request_type=model_service.DeleteModelReq 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_model(request) @@ -6753,6 +6782,7 @@ def test_delete_model_rest_call_success(request_type): 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_model(request) # Establish that the response is the type that we expect. @@ -6789,6 +6819,7 @@ def test_delete_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = model_service.DeleteModelRequest() metadata = [ @@ -6827,6 +6858,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque 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_models(request) @@ -6862,6 +6894,7 @@ def test_list_models_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_models(request) # Establish that the response is the type that we expect. @@ -6902,6 +6935,7 @@ def test_list_models_rest_interceptors(null_interceptor): 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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -6950,6 +6984,7 @@ def test_update_model_rest_bad_request(request_type=model_service.UpdateModelReq 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_model(request) @@ -7091,6 +7126,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_model(request) # Establish that the response is the type that we expect. @@ -7146,6 +7182,7 @@ def test_update_model_rest_interceptors(null_interceptor): 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 = gcr_model.Model.to_json(gcr_model.Model()) req.return_value.content = return_value @@ -7190,6 +7227,7 @@ def test_tune_model_rest_bad_request(request_type=model_service.TuneModelRequest 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.tune_model(request) @@ -7222,6 +7260,7 @@ def test_tune_model_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.tune_model(request) # Establish that the response is the type that we expect. @@ -7261,6 +7300,7 @@ def test_tune_model_rest_interceptors(null_interceptor): 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 @@ -7310,6 +7350,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7342,6 +7383,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7372,6 +7414,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7402,6 +7445,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_prediction_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_prediction_service.py index e56d964435df..ade44114cd6a 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_prediction_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_prediction_service.py @@ -1462,6 +1462,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq response_value._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.predict(request) @@ -1685,6 +1686,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -1724,6 +1726,7 @@ def test_predict_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.predict(request) # Establish that the response is the type that we expect. @@ -1766,6 +1769,7 @@ def test_predict_rest_interceptors(null_interceptor): 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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -1817,6 +1821,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1849,6 +1854,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1879,6 +1885,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1909,6 +1916,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_product_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_product_service.py index ed4e1fdc8286..ff8091532968 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_product_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_product_service.py @@ -5696,6 +5696,7 @@ def test_create_product_rest_required_fields( response_value._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_product(request) @@ -5762,6 +5763,7 @@ def test_create_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -5897,6 +5899,7 @@ def test_get_product_rest_required_fields( response_value._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_product(request) @@ -5944,6 +5947,7 @@ def test_get_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -6084,6 +6088,7 @@ def test_list_products_rest_required_fields( response_value._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_products(request) @@ -6141,6 +6146,7 @@ def test_list_products_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_products(**mock_args) @@ -6340,6 +6346,7 @@ def test_update_product_rest_required_fields( response_value._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_product(request) @@ -6400,6 +6407,7 @@ def test_update_product_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_product(**mock_args) @@ -6531,6 +6539,7 @@ def test_delete_product_rest_required_fields( response_value._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_product(request) @@ -6576,6 +6585,7 @@ def test_delete_product_rest_flattened(): 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"} client.delete_product(**mock_args) @@ -6713,6 +6723,7 @@ def test_purge_products_rest_required_fields( response_value._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.purge_products(request) @@ -6842,6 +6853,7 @@ def test_import_products_rest_required_fields( response_value._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.import_products(request) @@ -6971,6 +6983,7 @@ def test_export_products_rest_required_fields( response_value._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.export_products(request) @@ -7095,6 +7108,7 @@ def test_set_inventory_rest_required_fields( response_value._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.set_inventory(request) @@ -7143,6 +7157,7 @@ def test_set_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_inventory(**mock_args) @@ -7290,6 +7305,7 @@ def test_add_fulfillment_places_rest_required_fields( response_value._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.add_fulfillment_places(request) @@ -7344,6 +7360,7 @@ def test_add_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_fulfillment_places(**mock_args) @@ -7490,6 +7507,7 @@ def test_remove_fulfillment_places_rest_required_fields( response_value._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.remove_fulfillment_places(request) @@ -7544,6 +7562,7 @@ def test_remove_fulfillment_places_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_fulfillment_places(**mock_args) @@ -7682,6 +7701,7 @@ def test_add_local_inventories_rest_required_fields( response_value._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.add_local_inventories(request) @@ -7735,6 +7755,7 @@ def test_add_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_local_inventories(**mock_args) @@ -7877,6 +7898,7 @@ def test_remove_local_inventories_rest_required_fields( response_value._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.remove_local_inventories(request) @@ -7930,6 +7952,7 @@ def test_remove_local_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_local_inventories(**mock_args) @@ -8780,6 +8803,7 @@ def test_create_product_rest_bad_request( 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_product(request) @@ -8981,6 +9005,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9038,6 +9063,7 @@ def test_create_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -9082,6 +9108,7 @@ def test_get_product_rest_bad_request(request_type=product_service.GetProductReq 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_product(request) @@ -9136,6 +9163,7 @@ def test_get_product_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9193,6 +9221,7 @@ def test_get_product_rest_interceptors(null_interceptor): 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 = product.Product.to_json(product.Product()) req.return_value.content = return_value @@ -9239,6 +9268,7 @@ def test_list_products_rest_bad_request( 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_products(request) @@ -9276,6 +9306,7 @@ def test_list_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_products(request) # Establish that the response is the type that we expect. @@ -9316,6 +9347,7 @@ def test_list_products_rest_interceptors(null_interceptor): 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 = product_service.ListProductsResponse.to_json( product_service.ListProductsResponse() ) @@ -9366,6 +9398,7 @@ def test_update_product_rest_bad_request( 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_product(request) @@ -9569,6 +9602,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_product(request) # Establish that the response is the type that we expect. @@ -9626,6 +9660,7 @@ def test_update_product_rest_interceptors(null_interceptor): 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 = gcr_product.Product.to_json(gcr_product.Product()) req.return_value.content = return_value @@ -9672,6 +9707,7 @@ def test_delete_product_rest_bad_request( 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_product(request) @@ -9704,6 +9740,7 @@ def test_delete_product_rest_call_success(request_type): 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_product(request) # Establish that the response is the type that we expect. @@ -9740,6 +9777,7 @@ def test_delete_product_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = product_service.DeleteProductRequest() metadata = [ @@ -9782,6 +9820,7 @@ def test_purge_products_rest_bad_request( 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.purge_products(request) @@ -9814,6 +9853,7 @@ def test_purge_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_products(request) # Establish that the response is the type that we expect. @@ -9855,6 +9895,7 @@ def test_purge_products_rest_interceptors(null_interceptor): 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 @@ -9901,6 +9942,7 @@ def test_import_products_rest_bad_request( 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.import_products(request) @@ -9933,6 +9975,7 @@ def test_import_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_products(request) # Establish that the response is the type that we expect. @@ -9974,6 +10017,7 @@ def test_import_products_rest_interceptors(null_interceptor): 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 @@ -10020,6 +10064,7 @@ def test_export_products_rest_bad_request( 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.export_products(request) @@ -10052,6 +10097,7 @@ def test_export_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_products(request) # Establish that the response is the type that we expect. @@ -10093,6 +10139,7 @@ def test_export_products_rest_interceptors(null_interceptor): 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 @@ -10141,6 +10188,7 @@ def test_set_inventory_rest_bad_request( 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.set_inventory(request) @@ -10175,6 +10223,7 @@ def test_set_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_inventory(request) # Establish that the response is the type that we expect. @@ -10216,6 +10265,7 @@ def test_set_inventory_rest_interceptors(null_interceptor): 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 @@ -10262,6 +10312,7 @@ def test_add_fulfillment_places_rest_bad_request( 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.add_fulfillment_places(request) @@ -10294,6 +10345,7 @@ def test_add_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -10335,6 +10387,7 @@ def test_add_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -10381,6 +10434,7 @@ def test_remove_fulfillment_places_rest_bad_request( 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.remove_fulfillment_places(request) @@ -10413,6 +10467,7 @@ def test_remove_fulfillment_places_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_fulfillment_places(request) # Establish that the response is the type that we expect. @@ -10454,6 +10509,7 @@ def test_remove_fulfillment_places_rest_interceptors(null_interceptor): 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 @@ -10500,6 +10556,7 @@ def test_add_local_inventories_rest_bad_request( 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.add_local_inventories(request) @@ -10532,6 +10589,7 @@ def test_add_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_local_inventories(request) # Establish that the response is the type that we expect. @@ -10573,6 +10631,7 @@ def test_add_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10619,6 +10678,7 @@ def test_remove_local_inventories_rest_bad_request( 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.remove_local_inventories(request) @@ -10651,6 +10711,7 @@ def test_remove_local_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_local_inventories(request) # Establish that the response is the type that we expect. @@ -10692,6 +10753,7 @@ def test_remove_local_inventories_rest_interceptors(null_interceptor): 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 @@ -10741,6 +10803,7 @@ def test_get_operation_rest_bad_request( 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) @@ -10773,6 +10836,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -10803,6 +10867,7 @@ def test_list_operations_rest_bad_request( 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) @@ -10833,6 +10898,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_project_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_project_service.py index 1e2aafca4eca..5193d6609cc5 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_project_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_project_service.py @@ -1831,6 +1831,7 @@ def test_get_alert_config_rest_required_fields( response_value._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_alert_config(request) @@ -1876,6 +1877,7 @@ def test_get_alert_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_alert_config(**mock_args) @@ -2007,6 +2009,7 @@ def test_update_alert_config_rest_required_fields( response_value._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_alert_config(request) @@ -2053,6 +2056,7 @@ def test_update_alert_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_alert_config(**mock_args) @@ -2331,6 +2335,7 @@ def test_get_alert_config_rest_bad_request( 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_alert_config(request) @@ -2366,6 +2371,7 @@ def test_get_alert_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_alert_config(request) # Establish that the response is the type that we expect. @@ -2406,6 +2412,7 @@ def test_get_alert_config_rest_interceptors(null_interceptor): 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 = project.AlertConfig.to_json(project.AlertConfig()) req.return_value.content = return_value @@ -2450,6 +2457,7 @@ def test_update_alert_config_rest_bad_request( 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_alert_config(request) @@ -2562,6 +2570,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_alert_config(request) # Establish that the response is the type that we expect. @@ -2602,6 +2611,7 @@ def test_update_alert_config_rest_interceptors(null_interceptor): 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 = project.AlertConfig.to_json(project.AlertConfig()) req.return_value.content = return_value @@ -2651,6 +2661,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2683,6 +2694,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2713,6 +2725,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2743,6 +2756,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_search_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_search_service.py index bd201e06725b..71ef3e5141bd 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_search_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_search_service.py @@ -1634,6 +1634,7 @@ def test_search_rest_required_fields(request_type=search_service.SearchRequest): response_value._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.search(request) @@ -1925,6 +1926,7 @@ def test_search_rest_bad_request(request_type=search_service.SearchRequest): 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.search(request) @@ -1967,6 +1969,7 @@ def test_search_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search(request) # Establish that the response is the type that we expect. @@ -2010,6 +2013,7 @@ def test_search_rest_interceptors(null_interceptor): 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 = search_service.SearchResponse.to_json( search_service.SearchResponse() ) @@ -2061,6 +2065,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2093,6 +2098,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2123,6 +2129,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2153,6 +2160,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_serving_config_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_serving_config_service.py index 441ed4a767a3..109369ff5750 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_serving_config_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_serving_config_service.py @@ -4218,6 +4218,7 @@ def test_create_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4282,6 +4283,7 @@ def test_create_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4417,6 +4419,7 @@ def test_delete_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4462,6 +4465,7 @@ def test_delete_serving_config_rest_flattened(): 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"} client.delete_serving_config(**mock_args) @@ -4596,6 +4600,7 @@ def test_update_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4646,6 +4651,7 @@ def test_update_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4782,6 +4788,7 @@ def test_get_serving_config_rest_required_fields( response_value._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_serving_config(request) @@ -4829,6 +4836,7 @@ def test_get_serving_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_config(**mock_args) @@ -4973,6 +4981,7 @@ def test_list_serving_configs_rest_required_fields( response_value._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_serving_configs(request) @@ -5030,6 +5039,7 @@ def test_list_serving_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_serving_configs(**mock_args) @@ -5232,6 +5242,7 @@ def test_add_control_rest_required_fields( response_value._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.add_control(request) @@ -5287,6 +5298,7 @@ def test_add_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_control(**mock_args) @@ -5423,6 +5435,7 @@ def test_remove_control_rest_required_fields( response_value._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.remove_control(request) @@ -5478,6 +5491,7 @@ def test_remove_control_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.remove_control(**mock_args) @@ -6092,6 +6106,7 @@ def test_create_serving_config_rest_bad_request( 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_serving_config(request) @@ -6256,6 +6271,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6318,6 +6334,7 @@ def test_create_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6366,6 +6383,7 @@ def test_delete_serving_config_rest_bad_request( 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_serving_config(request) @@ -6398,6 +6416,7 @@ def test_delete_serving_config_rest_call_success(request_type): 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_serving_config(request) # Establish that the response is the type that we expect. @@ -6434,6 +6453,7 @@ def test_delete_serving_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = serving_config_service.DeleteServingConfigRequest() metadata = [ @@ -6478,6 +6498,7 @@ def test_update_serving_config_rest_bad_request( 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_serving_config(request) @@ -6646,6 +6667,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6708,6 +6730,7 @@ def test_update_serving_config_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -6756,6 +6779,7 @@ def test_get_serving_config_rest_bad_request( 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_serving_config(request) @@ -6810,6 +6834,7 @@ def test_get_serving_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_config(request) # Establish that the response is the type that we expect. @@ -6872,6 +6897,7 @@ def test_get_serving_config_rest_interceptors(null_interceptor): 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 = serving_config.ServingConfig.to_json( serving_config.ServingConfig() ) @@ -6918,6 +6944,7 @@ def test_list_serving_configs_rest_bad_request( 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_serving_configs(request) @@ -6955,6 +6982,7 @@ def test_list_serving_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_serving_configs(request) # Establish that the response is the type that we expect. @@ -6995,6 +7023,7 @@ def test_list_serving_configs_rest_interceptors(null_interceptor): 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 = serving_config_service.ListServingConfigsResponse.to_json( serving_config_service.ListServingConfigsResponse() ) @@ -7043,6 +7072,7 @@ def test_add_control_rest_bad_request( 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.add_control(request) @@ -7097,6 +7127,7 @@ def test_add_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_control(request) # Establish that the response is the type that we expect. @@ -7159,6 +7190,7 @@ def test_add_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7207,6 +7239,7 @@ def test_remove_control_rest_bad_request( 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.remove_control(request) @@ -7261,6 +7294,7 @@ def test_remove_control_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_control(request) # Establish that the response is the type that we expect. @@ -7323,6 +7357,7 @@ def test_remove_control_rest_interceptors(null_interceptor): 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 = gcr_serving_config.ServingConfig.to_json( gcr_serving_config.ServingConfig() ) @@ -7374,6 +7409,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7406,6 +7442,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7436,6 +7473,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7466,6 +7504,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_user_event_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_user_event_service.py index 55a3c980e49b..238d613d31b9 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_user_event_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2beta/test_user_event_service.py @@ -2830,6 +2830,7 @@ def test_write_user_event_rest_required_fields( response_value._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.write_user_event(request) @@ -2976,6 +2977,7 @@ def test_collect_user_event_rest_required_fields( response_value._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.collect_user_event(request) @@ -3125,6 +3127,7 @@ def test_purge_user_events_rest_required_fields( response_value._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.purge_user_events(request) @@ -3258,6 +3261,7 @@ def test_import_user_events_rest_required_fields( response_value._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.import_user_events(request) @@ -3391,6 +3395,7 @@ def test_export_user_events_rest_required_fields( response_value._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.export_user_events(request) @@ -3524,6 +3529,7 @@ def test_rejoin_user_events_rest_required_fields( response_value._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.rejoin_user_events(request) @@ -4004,6 +4010,7 @@ def test_write_user_event_rest_bad_request( 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.write_user_event(request) @@ -4245,6 +4252,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.write_user_event(request) # Establish that the response is the type that we expect. @@ -4299,6 +4307,7 @@ def test_write_user_event_rest_interceptors(null_interceptor): 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 = user_event.UserEvent.to_json(user_event.UserEvent()) req.return_value.content = return_value @@ -4343,6 +4352,7 @@ def test_collect_user_event_rest_bad_request( 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.collect_user_event(request) @@ -4376,6 +4386,7 @@ def test_collect_user_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.collect_user_event(request) # Establish that the response is the type that we expect. @@ -4417,6 +4428,7 @@ def test_collect_user_event_rest_interceptors(null_interceptor): 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(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -4461,6 +4473,7 @@ def test_purge_user_events_rest_bad_request( 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.purge_user_events(request) @@ -4491,6 +4504,7 @@ def test_purge_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_user_events(request) # Establish that the response is the type that we expect. @@ -4532,6 +4546,7 @@ def test_purge_user_events_rest_interceptors(null_interceptor): 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 @@ -4576,6 +4591,7 @@ def test_import_user_events_rest_bad_request( 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.import_user_events(request) @@ -4606,6 +4622,7 @@ def test_import_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_user_events(request) # Establish that the response is the type that we expect. @@ -4647,6 +4664,7 @@ def test_import_user_events_rest_interceptors(null_interceptor): 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 @@ -4691,6 +4709,7 @@ def test_export_user_events_rest_bad_request( 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.export_user_events(request) @@ -4721,6 +4740,7 @@ def test_export_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_user_events(request) # Establish that the response is the type that we expect. @@ -4762,6 +4782,7 @@ def test_export_user_events_rest_interceptors(null_interceptor): 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 @@ -4806,6 +4827,7 @@ def test_rejoin_user_events_rest_bad_request( 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.rejoin_user_events(request) @@ -4836,6 +4858,7 @@ def test_rejoin_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.rejoin_user_events(request) # Establish that the response is the type that we expect. @@ -4877,6 +4900,7 @@ def test_rejoin_user_events_rest_interceptors(null_interceptor): 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 @@ -4926,6 +4950,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4958,6 +4983,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4988,6 +5014,7 @@ def test_list_operations_rest_bad_request( 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) @@ -5018,6 +5045,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-run/google/cloud/run/gapic_version.py b/packages/google-cloud-run/google/cloud/run/gapic_version.py index 3de369591024..558c8aab67c5 100644 --- a/packages/google-cloud-run/google/cloud/run/gapic_version.py +++ b/packages/google-cloud-run/google/cloud/run/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-run/google/cloud/run_v2/gapic_version.py b/packages/google-cloud-run/google/cloud/run_v2/gapic_version.py index 3de369591024..558c8aab67c5 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/gapic_version.py +++ b/packages/google-cloud-run/google/cloud/run_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/builds/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/builds/async_client.py index b8aad7365599..824fc8728ebe 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/builds/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/builds/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, BuildsTransport from .transports.grpc_asyncio import BuildsGrpcAsyncIOTransport +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 BuildsAsyncClient: """Cloud Run Build Control Plane API""" @@ -246,13 +256,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.BuildsAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "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.run.v2.Builds", + "credentialsType": None, + }, + ) + async def submit_build( self, request: Optional[Union[build.SubmitBuildRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> build.SubmitBuildResponse: r"""Submits a build in a given project. @@ -295,8 +327,10 @@ async def sample_submit_build(): 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, 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: google.cloud.run_v2.types.SubmitBuildResponse: @@ -342,7 +376,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -353,8 +387,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -395,7 +431,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -406,8 +442,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -448,7 +486,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -464,8 +502,10 @@ async def delete_operation( 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, 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: None """ @@ -502,7 +542,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -519,8 +559,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/builds/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/builds/client.py index a3f05182bc63..47e5e299b780 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/builds/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/builds/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -580,6 +590,10 @@ def __init__( # 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( @@ -642,13 +656,36 @@ def __init__( 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.run_v2.BuildsClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "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.run.v2.Builds", + "credentialsType": None, + }, + ) + def submit_build( self, request: Optional[Union[build.SubmitBuildRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> build.SubmitBuildResponse: r"""Submits a build in a given project. @@ -691,8 +728,10 @@ def sample_submit_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.SubmitBuildResponse: @@ -749,7 +788,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -760,8 +799,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -802,7 +843,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -813,8 +854,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -855,7 +898,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -871,8 +914,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -909,7 +954,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -926,8 +971,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc.py index 80dd8298cff3..c888cfddff0a 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import build from .base import DEFAULT_CLIENT_INFO, BuildsTransport +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.run.v2.Builds", + "rpcName": 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.run.v2.Builds", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BuildsGrpcTransport(BuildsTransport): """gRPC backend transport for Builds. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +341,7 @@ def submit_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_build" not in self._stubs: - self._stubs["submit_build"] = self.grpc_channel.unary_unary( + self._stubs["submit_build"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Builds/SubmitBuild", request_serializer=build.SubmitBuildRequest.serialize, response_deserializer=build.SubmitBuildResponse.deserialize, @@ -263,7 +349,7 @@ def submit_build( return self._stubs["submit_build"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -275,7 +361,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -292,7 +378,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -309,7 +395,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -328,7 +414,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc_asyncio.py index 8641cc12b296..f639bdf24e1b 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import build from .base import DEFAULT_CLIENT_INFO, BuildsTransport from .grpc import BuildsGrpcTransport +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.run.v2.Builds", + "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.run.v2.Builds", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BuildsGrpcAsyncIOTransport(BuildsTransport): """gRPC AsyncIO backend transport for Builds. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def submit_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_build" not in self._stubs: - self._stubs["submit_build"] = self.grpc_channel.unary_unary( + self._stubs["submit_build"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Builds/SubmitBuild", request_serializer=build.SubmitBuildRequest.serialize, response_deserializer=build.SubmitBuildResponse.deserialize, @@ -306,7 +391,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -322,7 +407,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -339,7 +424,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -356,7 +441,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -375,7 +460,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/rest.py index 4b16d08247e1..e9a5167a9fb8 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/builds/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -77,8 +85,10 @@ def post_submit_build(self, response): """ def pre_submit_build( - self, request: build.SubmitBuildRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[build.SubmitBuildRequest, Sequence[Tuple[str, str]]]: + self, + request: build.SubmitBuildRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[build.SubmitBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for submit_build Override in a subclass to manipulate the request or metadata @@ -100,8 +110,10 @@ def post_submit_build( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -121,8 +133,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -144,8 +158,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -167,8 +183,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -307,7 +325,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> build.SubmitBuildResponse: r"""Call the submit build method over HTTP. @@ -318,8 +336,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.build.SubmitBuildResponse: @@ -329,6 +349,7 @@ def __call__( """ http_options = _BaseBuildsRestTransport._BaseSubmitBuild._get_http_options() + request, metadata = self._interceptor.pre_submit_build(request, metadata) transcoded_request = ( _BaseBuildsRestTransport._BaseSubmitBuild._get_transcoded_request( @@ -347,6 +368,33 @@ def __call__( ) ) + 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.run_v2.BuildsClient.SubmitBuild", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "SubmitBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BuildsRestTransport._SubmitBuild._get_response( self._host, @@ -368,7 +416,29 @@ def __call__( pb_resp = build.SubmitBuildResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_submit_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = build.SubmitBuildResponse.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.run_v2.BuildsClient.submit_build", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "SubmitBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -417,7 +487,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -427,13 +497,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseBuildsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -450,6 +523,33 @@ def __call__( ) ) + 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.run_v2.BuildsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BuildsRestTransport._DeleteOperation._get_response( self._host, @@ -503,7 +603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -513,8 +613,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -523,6 +625,7 @@ def __call__( http_options = ( _BaseBuildsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseBuildsRestTransport._BaseGetOperation._get_transcoded_request( @@ -537,6 +640,33 @@ def __call__( ) ) + 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.run_v2.BuildsClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BuildsRestTransport._GetOperation._get_response( self._host, @@ -556,6 +686,27 @@ def __call__( 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.run_v2.BuildsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -594,7 +745,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -604,8 +755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -614,6 +767,7 @@ def __call__( http_options = ( _BaseBuildsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseBuildsRestTransport._BaseListOperations._get_transcoded_request( @@ -628,6 +782,33 @@ def __call__( ) ) + 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.run_v2.BuildsClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BuildsRestTransport._ListOperations._get_response( self._host, @@ -647,6 +828,27 @@ def __call__( 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.run_v2.BuildsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -686,7 +888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -696,8 +898,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -706,6 +910,7 @@ def __call__( http_options = ( _BaseBuildsRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseBuildsRestTransport._BaseWaitOperation._get_transcoded_request( @@ -724,6 +929,33 @@ def __call__( ) ) + 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.run_v2.BuildsClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BuildsRestTransport._WaitOperation._get_response( self._host, @@ -744,6 +976,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.BuildsAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Builds", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/async_client.py index fe756fc51179..1270906228a7 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .transports.grpc_asyncio import ExecutionsGrpcAsyncIOTransport +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 ExecutionsAsyncClient: """Cloud Run Execution Control Plane API.""" @@ -265,6 +275,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.ExecutionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "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.run.v2.Executions", + "credentialsType": None, + }, + ) + async def get_execution( self, request: Optional[Union[execution.GetExecutionRequest, dict]] = None, @@ -272,7 +304,7 @@ async def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> execution.Execution: r"""Gets information about an Execution. @@ -317,8 +349,10 @@ async def sample_get_execution(): 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, 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: google.cloud.run_v2.types.Execution: @@ -382,7 +416,7 @@ async def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsAsyncPager: r"""Lists Executions from a Job. Results are sorted by creation time, descending. @@ -431,8 +465,10 @@ async def sample_list_executions(): 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, 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: google.cloud.run_v2.services.executions.pagers.ListExecutionsAsyncPager: @@ -507,7 +543,7 @@ async def delete_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes an Execution. @@ -556,8 +592,10 @@ async def sample_delete_execution(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -629,7 +667,7 @@ async def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Cancels an Execution. @@ -678,8 +716,10 @@ async def sample_cancel_execution(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -750,7 +790,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -761,8 +801,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -803,7 +845,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -814,8 +856,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -856,7 +900,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -872,8 +916,10 @@ async def delete_operation( 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, 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: None """ @@ -910,7 +956,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -927,8 +973,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/client.py index 5c907a766720..007f5993e76d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import launch_stage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -692,6 +702,10 @@ def __init__( # 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( @@ -754,6 +768,29 @@ def __init__( 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.run_v2.ExecutionsClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "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.run.v2.Executions", + "credentialsType": None, + }, + ) + def get_execution( self, request: Optional[Union[execution.GetExecutionRequest, dict]] = None, @@ -761,7 +798,7 @@ def get_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> execution.Execution: r"""Gets information about an Execution. @@ -806,8 +843,10 @@ def sample_get_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.Execution: @@ -868,7 +907,7 @@ def list_executions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExecutionsPager: r"""Lists Executions from a Job. Results are sorted by creation time, descending. @@ -917,8 +956,10 @@ def sample_list_executions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.services.executions.pagers.ListExecutionsPager: @@ -990,7 +1031,7 @@ def delete_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes an Execution. @@ -1039,8 +1080,10 @@ def sample_delete_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1109,7 +1152,7 @@ def cancel_execution( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Cancels an Execution. @@ -1158,8 +1201,10 @@ def sample_cancel_execution(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1240,7 +1285,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1251,8 +1296,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1293,7 +1340,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1304,8 +1351,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1346,7 +1395,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1362,8 +1411,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1400,7 +1451,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1417,8 +1468,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/pagers.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/pagers.py index c1f80a533331..50c11e0b46c6 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/pagers.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = execution.ListExecutionsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = execution.ListExecutionsRequest(request) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc.py index d0492b5a4129..5bdb60a7c763 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import execution from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport +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.run.v2.Executions", + "rpcName": 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.run.v2.Executions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcTransport(ExecutionsTransport): """gRPC backend transport for Executions. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/GetExecution", request_serializer=execution.GetExecutionRequest.serialize, response_deserializer=execution.Execution.deserialize, @@ -297,7 +385,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/ListExecutions", request_serializer=execution.ListExecutionsRequest.serialize, response_deserializer=execution.ListExecutionsResponse.deserialize, @@ -323,7 +411,7 @@ def delete_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_execution" not in self._stubs: - self._stubs["delete_execution"] = self.grpc_channel.unary_unary( + self._stubs["delete_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/DeleteExecution", request_serializer=execution.DeleteExecutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -349,7 +437,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/CancelExecution", request_serializer=execution.CancelExecutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -357,7 +445,7 @@ def cancel_execution( return self._stubs["cancel_execution"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -369,7 +457,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -386,7 +474,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -403,7 +491,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -422,7 +510,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc_asyncio.py index df1b30c72680..348d7175981d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import execution from .base import DEFAULT_CLIENT_INFO, ExecutionsTransport from .grpc import ExecutionsGrpcTransport +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.run.v2.Executions", + "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.run.v2.Executions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ExecutionsGrpcAsyncIOTransport(ExecutionsTransport): """gRPC AsyncIO backend transport for Executions. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -280,7 +365,7 @@ def get_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_execution" not in self._stubs: - self._stubs["get_execution"] = self.grpc_channel.unary_unary( + self._stubs["get_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/GetExecution", request_serializer=execution.GetExecutionRequest.serialize, response_deserializer=execution.Execution.deserialize, @@ -309,7 +394,7 @@ def list_executions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_executions" not in self._stubs: - self._stubs["list_executions"] = self.grpc_channel.unary_unary( + self._stubs["list_executions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/ListExecutions", request_serializer=execution.ListExecutionsRequest.serialize, response_deserializer=execution.ListExecutionsResponse.deserialize, @@ -337,7 +422,7 @@ def delete_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_execution" not in self._stubs: - self._stubs["delete_execution"] = self.grpc_channel.unary_unary( + self._stubs["delete_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/DeleteExecution", request_serializer=execution.DeleteExecutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +450,7 @@ def cancel_execution( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_execution" not in self._stubs: - self._stubs["cancel_execution"] = self.grpc_channel.unary_unary( + self._stubs["cancel_execution"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Executions/CancelExecution", request_serializer=execution.CancelExecutionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -439,7 +524,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -456,7 +541,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -473,7 +558,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -492,7 +577,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/rest.py index 1c2b42f2bc42..4213d313e57d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/executions/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -103,8 +111,10 @@ def post_list_executions(self, response): def pre_cancel_execution( self, request: execution.CancelExecutionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[execution.CancelExecutionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + execution.CancelExecutionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_execution Override in a subclass to manipulate the request or metadata @@ -126,8 +136,10 @@ def post_cancel_execution( def pre_delete_execution( self, request: execution.DeleteExecutionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[execution.DeleteExecutionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + execution.DeleteExecutionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_execution Override in a subclass to manipulate the request or metadata @@ -149,8 +161,8 @@ def post_delete_execution( def pre_get_execution( self, request: execution.GetExecutionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[execution.GetExecutionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[execution.GetExecutionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_execution Override in a subclass to manipulate the request or metadata @@ -170,8 +182,10 @@ def post_get_execution(self, response: execution.Execution) -> execution.Executi def pre_list_executions( self, request: execution.ListExecutionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[execution.ListExecutionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + execution.ListExecutionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_executions Override in a subclass to manipulate the request or metadata @@ -193,8 +207,10 @@ def post_list_executions( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -214,8 +230,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -237,8 +255,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -260,8 +280,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -456,7 +478,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the cancel execution method over HTTP. @@ -467,8 +489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -481,6 +505,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseCancelExecution._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_execution( request, metadata ) @@ -497,6 +522,33 @@ def __call__( 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.run_v2.ExecutionsClient.CancelExecution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "CancelExecution", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._CancelExecution._get_response( self._host, @@ -516,7 +568,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_execution(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.run_v2.ExecutionsClient.cancel_execution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "CancelExecution", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteExecution( @@ -553,7 +627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete execution method over HTTP. @@ -564,8 +638,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -578,6 +654,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseDeleteExecution._get_http_options() ) + request, metadata = self._interceptor.pre_delete_execution( request, metadata ) @@ -590,6 +667,33 @@ def __call__( 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.run_v2.ExecutionsClient.DeleteExecution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "DeleteExecution", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._DeleteExecution._get_response( self._host, @@ -608,7 +712,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_execution(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.run_v2.ExecutionsClient.delete_execution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "DeleteExecution", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExecution( @@ -645,7 +771,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> execution.Execution: r"""Call the get execution method over HTTP. @@ -656,8 +782,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.execution.Execution: @@ -672,6 +800,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseGetExecution._get_http_options() ) + request, metadata = self._interceptor.pre_get_execution(request, metadata) transcoded_request = ( _BaseExecutionsRestTransport._BaseGetExecution._get_transcoded_request( @@ -686,6 +815,33 @@ def __call__( ) ) + 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.run_v2.ExecutionsClient.GetExecution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "GetExecution", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._GetExecution._get_response( self._host, @@ -706,7 +862,29 @@ def __call__( pb_resp = execution.Execution.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_execution(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = execution.Execution.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.run_v2.ExecutionsClient.get_execution", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "GetExecution", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExecutions( @@ -743,7 +921,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> execution.ListExecutionsResponse: r"""Call the list executions method over HTTP. @@ -754,8 +932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.execution.ListExecutionsResponse: @@ -767,6 +947,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseListExecutions._get_http_options() ) + request, metadata = self._interceptor.pre_list_executions(request, metadata) transcoded_request = _BaseExecutionsRestTransport._BaseListExecutions._get_transcoded_request( http_options, request @@ -779,6 +960,33 @@ def __call__( ) ) + 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.run_v2.ExecutionsClient.ListExecutions", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "ListExecutions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._ListExecutions._get_response( self._host, @@ -799,7 +1007,31 @@ def __call__( pb_resp = execution.ListExecutionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_executions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = execution.ListExecutionsResponse.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.run_v2.ExecutionsClient.list_executions", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "ListExecutions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -872,7 +1104,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -882,13 +1114,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseExecutionsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -901,6 +1136,33 @@ def __call__( 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.run_v2.ExecutionsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._DeleteOperation._get_response( self._host, @@ -956,7 +1218,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -966,8 +1228,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -976,6 +1240,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseExecutionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -990,6 +1255,33 @@ def __call__( ) ) + 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.run_v2.ExecutionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._GetOperation._get_response( self._host, @@ -1009,6 +1301,27 @@ def __call__( 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.run_v2.ExecutionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1049,7 +1362,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1059,8 +1372,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1069,6 +1384,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseExecutionsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1081,6 +1397,33 @@ def __call__( ) ) + 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.run_v2.ExecutionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._ListOperations._get_response( self._host, @@ -1100,6 +1443,27 @@ def __call__( 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.run_v2.ExecutionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1141,7 +1505,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -1151,8 +1515,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -1161,6 +1527,7 @@ def __call__( http_options = ( _BaseExecutionsRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseExecutionsRestTransport._BaseWaitOperation._get_transcoded_request( @@ -1181,6 +1548,33 @@ def __call__( ) ) + 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.run_v2.ExecutionsClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExecutionsRestTransport._WaitOperation._get_response( self._host, @@ -1201,6 +1595,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.ExecutionsAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Executions", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/async_client.py index babaec5a8ff1..a7a3d41d7ebb 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, JobsTransport from .transports.grpc_asyncio import JobsGrpcAsyncIOTransport +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 JobsAsyncClient: """Cloud Run Job Control Plane API.""" @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.JobsAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "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.run.v2.Jobs", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[gcr_job.CreateJobRequest, dict]] = None, @@ -277,7 +309,7 @@ async def create_job( job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Job. @@ -346,8 +378,10 @@ async def sample_create_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -430,7 +464,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets information about a Job. @@ -477,8 +511,10 @@ async def sample_get_job(): 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, 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: google.cloud.run_v2.types.Job: @@ -546,7 +582,7 @@ async def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists Jobs. Results are sorted by creation time, descending. @@ -595,8 +631,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.run_v2.services.jobs.pagers.ListJobsAsyncPager: @@ -679,7 +717,7 @@ async def update_job( job: Optional[gcr_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a Job. @@ -728,8 +766,10 @@ async def sample_update_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -808,7 +848,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Job. @@ -859,8 +899,10 @@ async def sample_delete_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -939,7 +981,7 @@ async def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Triggers creation of a new Execution of this Job. @@ -990,8 +1032,10 @@ async def sample_run_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1068,7 +1112,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Access Control policy currently in effect for the given Job. This result does not include @@ -1107,8 +1151,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1184,7 +1230,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Access control policy for the specified Job. Overwrites any existing policy. @@ -1222,8 +1268,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1299,7 +1347,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified Project. @@ -1340,8 +1388,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1387,7 +1437,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1398,8 +1448,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1440,7 +1492,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1451,8 +1503,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1493,7 +1547,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1509,8 +1563,10 @@ async def delete_operation( 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, 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: None """ @@ -1547,7 +1603,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1564,8 +1620,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/client.py index ddc1c1fa25a5..ccddaeaa15e3 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import launch_stage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -712,6 +722,10 @@ def __init__( # 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( @@ -772,6 +786,29 @@ def __init__( 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.run_v2.JobsClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "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.run.v2.Jobs", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[gcr_job.CreateJobRequest, dict]] = None, @@ -781,7 +818,7 @@ def create_job( job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Job. @@ -850,8 +887,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -931,7 +970,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets information about a Job. @@ -978,8 +1017,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.Job: @@ -1046,7 +1087,7 @@ def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists Jobs. Results are sorted by creation time, descending. @@ -1095,8 +1136,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.services.jobs.pagers.ListJobsPager: @@ -1176,7 +1219,7 @@ def update_job( job: Optional[gcr_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a Job. @@ -1225,8 +1268,10 @@ def sample_update_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1302,7 +1347,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Job. @@ -1353,8 +1398,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1430,7 +1477,7 @@ def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Triggers creation of a new Execution of this Job. @@ -1481,8 +1528,10 @@ def sample_run_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1558,7 +1607,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Access Control policy currently in effect for the given Job. This result does not include @@ -1597,8 +1646,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1673,7 +1724,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Access control policy for the specified Job. Overwrites any existing policy. @@ -1711,8 +1762,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1787,7 +1840,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified Project. @@ -1828,8 +1881,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1887,7 +1942,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1898,8 +1953,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1940,7 +1997,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1951,8 +2008,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1993,7 +2052,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2009,8 +2068,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2047,7 +2108,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -2064,8 +2125,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/pagers.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/pagers.py index 62ceddce5ced..95949da44f3d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/pagers.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = job.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = job.ListJobsRequest(request) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc.py index 9493b0cc95fa..794f00d04a4b 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,13 +27,91 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import job from google.cloud.run_v2.types import job as gcr_job from .base import DEFAULT_CLIENT_INFO, JobsTransport +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.run.v2.Jobs", + "rpcName": 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.run.v2.Jobs", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobsGrpcTransport(JobsTransport): """gRPC backend transport for Jobs. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/CreateJob", request_serializer=gcr_job.CreateJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -297,7 +385,7 @@ def get_job(self) -> Callable[[job.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/GetJob", request_serializer=job.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -322,7 +410,7 @@ def list_jobs(self) -> Callable[[job.ListJobsRequest], job.ListJobsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/ListJobs", request_serializer=job.ListJobsRequest.serialize, response_deserializer=job.ListJobsResponse.deserialize, @@ -348,7 +436,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/UpdateJob", request_serializer=gcr_job.UpdateJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +460,7 @@ def delete_job(self) -> Callable[[job.DeleteJobRequest], operations_pb2.Operatio # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/DeleteJob", request_serializer=job.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -396,7 +484,7 @@ def run_job(self) -> Callable[[job.RunJobRequest], operations_pb2.Operation]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/RunJob", request_serializer=job.RunJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -424,7 +512,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -451,7 +539,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -483,7 +571,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -491,7 +579,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -503,7 +591,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -520,7 +608,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -537,7 +625,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -556,7 +644,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc_asyncio.py index 219ca188ebdf..2f44292270dd 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import job from google.cloud.run_v2.types import job as gcr_job @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, JobsTransport from .grpc import JobsGrpcTransport +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.run.v2.Jobs", + "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.run.v2.Jobs", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobsGrpcAsyncIOTransport(JobsTransport): """gRPC AsyncIO backend transport for Jobs. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/CreateJob", request_serializer=gcr_job.CreateJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -307,7 +392,7 @@ def get_job(self) -> Callable[[job.GetJobRequest], Awaitable[job.Job]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/GetJob", request_serializer=job.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -334,7 +419,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/ListJobs", request_serializer=job.ListJobsRequest.serialize, response_deserializer=job.ListJobsResponse.deserialize, @@ -360,7 +445,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/UpdateJob", request_serializer=gcr_job.UpdateJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/DeleteJob", request_serializer=job.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -412,7 +497,7 @@ def run_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/RunJob", request_serializer=job.RunJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -440,7 +525,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -467,7 +552,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -499,7 +584,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Jobs/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -582,7 +667,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -598,7 +683,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -615,7 +700,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -632,7 +717,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -651,7 +736,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/rest.py index 9239c89dbe44..0a21d7c42d0d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/jobs/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -144,8 +152,10 @@ def post_update_job(self, response): """ def pre_create_job( - self, request: gcr_job.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gcr_job.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: gcr_job.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcr_job.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -165,8 +175,10 @@ def post_create_job( return response def pre_delete_job( - self, request: job.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -188,8 +200,10 @@ def post_delete_job( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -207,8 +221,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_job( - self, request: job.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -226,8 +242,10 @@ def post_get_job(self, response: job.Job) -> job.Job: return response def pre_list_jobs( - self, request: job.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: job.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -245,8 +263,10 @@ def post_list_jobs(self, response: job.ListJobsResponse) -> job.ListJobsResponse return response def pre_run_job( - self, request: job.RunJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job.RunJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job.RunJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job.RunJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_job Override in a subclass to manipulate the request or metadata @@ -268,8 +288,10 @@ def post_run_job( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -289,8 +311,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -310,8 +335,10 @@ def post_test_iam_permissions( return response def pre_update_job( - self, request: gcr_job.UpdateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gcr_job.UpdateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: gcr_job.UpdateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcr_job.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -333,8 +360,10 @@ def post_update_job( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -354,8 +383,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -377,8 +408,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -400,8 +433,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -594,7 +629,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create job method over HTTP. @@ -604,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -616,6 +653,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseCreateJob._get_http_options() + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseCreateJob._get_transcoded_request( @@ -632,6 +670,33 @@ def __call__( 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.run_v2.JobsClient.CreateJob", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._CreateJob._get_response( self._host, @@ -651,7 +716,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(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.run_v2.JobsClient.create_job", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob(_BaseJobsRestTransport._BaseDeleteJob, JobsRestStub): @@ -686,7 +773,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete job method over HTTP. @@ -697,8 +784,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -709,6 +798,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseDeleteJob._get_http_options() + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseDeleteJob._get_transcoded_request( @@ -721,6 +811,33 @@ def __call__( 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.run_v2.JobsClient.DeleteJob", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._DeleteJob._get_response( self._host, @@ -739,7 +856,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_job(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.run_v2.JobsClient.delete_job", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "DeleteJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseJobsRestTransport._BaseGetIamPolicy, JobsRestStub): @@ -774,7 +913,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -784,8 +923,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -868,6 +1009,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseGetIamPolicy._get_http_options() + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -882,6 +1024,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._GetIamPolicy._get_response( self._host, @@ -902,7 +1071,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.run_v2.JobsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetJob(_BaseJobsRestTransport._BaseGetJob, JobsRestStub): @@ -937,7 +1128,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -948,8 +1139,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -960,6 +1153,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseGetJob._get_http_options() + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseGetJob._get_transcoded_request( @@ -972,6 +1166,33 @@ def __call__( 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.run_v2.JobsClient.GetJob", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._GetJob._get_response( self._host, @@ -992,7 +1213,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.run_v2.JobsClient.get_job", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs(_BaseJobsRestTransport._BaseListJobs, JobsRestStub): @@ -1027,7 +1270,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -1038,8 +1281,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.ListJobsResponse: @@ -1049,6 +1294,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseListJobs._get_http_options() + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseListJobs._get_transcoded_request( @@ -1061,6 +1307,33 @@ def __call__( 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.run_v2.JobsClient.ListJobs", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._ListJobs._get_response( self._host, @@ -1081,7 +1354,29 @@ def __call__( pb_resp = job.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.ListJobsResponse.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.run_v2.JobsClient.list_jobs", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunJob(_BaseJobsRestTransport._BaseRunJob, JobsRestStub): @@ -1117,7 +1412,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run job method over HTTP. @@ -1128,8 +1423,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1140,6 +1437,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseRunJob._get_http_options() + request, metadata = self._interceptor.pre_run_job(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseRunJob._get_transcoded_request( @@ -1156,6 +1454,33 @@ def __call__( 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.run_v2.JobsClient.RunJob", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "RunJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._RunJob._get_response( self._host, @@ -1175,7 +1500,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_job(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.run_v2.JobsClient.run_job", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "RunJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseJobsRestTransport._BaseSetIamPolicy, JobsRestStub): @@ -1211,7 +1558,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1221,8 +1568,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1305,6 +1654,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseSetIamPolicy._get_http_options() + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1323,6 +1673,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._SetIamPolicy._get_response( self._host, @@ -1344,7 +1721,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.run_v2.JobsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1382,7 +1781,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1392,8 +1791,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1403,6 +1804,7 @@ def __call__( http_options = ( _BaseJobsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1425,6 +1827,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._TestIamPermissions._get_response( self._host, @@ -1446,7 +1875,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.run_v2.JobsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob(_BaseJobsRestTransport._BaseUpdateJob, JobsRestStub): @@ -1482,7 +1933,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update job method over HTTP. @@ -1492,8 +1943,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1504,6 +1957,7 @@ def __call__( """ http_options = _BaseJobsRestTransport._BaseUpdateJob._get_http_options() + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1520,6 +1974,33 @@ def __call__( 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.run_v2.JobsClient.UpdateJob", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._UpdateJob._get_response( self._host, @@ -1539,7 +2020,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(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.run_v2.JobsClient.update_job", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1645,7 +2148,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1655,13 +2158,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseJobsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1678,6 +2184,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._DeleteOperation._get_response( self._host, @@ -1731,7 +2264,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1741,14 +2274,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. """ http_options = _BaseJobsRestTransport._BaseGetOperation._get_http_options() + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1763,6 +2299,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._GetOperation._get_response( self._host, @@ -1782,6 +2345,27 @@ def __call__( 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.run_v2.JobsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1820,7 +2404,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1830,8 +2414,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1840,6 +2426,7 @@ def __call__( http_options = ( _BaseJobsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseListOperations._get_transcoded_request( @@ -1854,6 +2441,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._ListOperations._get_response( self._host, @@ -1873,6 +2487,27 @@ def __call__( 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.run_v2.JobsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1912,7 +2547,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -1922,14 +2557,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. """ http_options = _BaseJobsRestTransport._BaseWaitOperation._get_http_options() + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseJobsRestTransport._BaseWaitOperation._get_transcoded_request( @@ -1948,6 +2586,33 @@ def __call__( ) ) + 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.run_v2.JobsClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobsRestTransport._WaitOperation._get_response( self._host, @@ -1968,6 +2633,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.JobsAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Jobs", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py index e5917935da4d..7899cfeb45f6 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RevisionsTransport from .transports.grpc_asyncio import RevisionsGrpcAsyncIOTransport +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 RevisionsAsyncClient: """Cloud Run Revision Control Plane API.""" @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.RevisionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "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.run.v2.Revisions", + "credentialsType": None, + }, + ) + async def get_revision( self, request: Optional[Union[revision.GetRevisionRequest, dict]] = None, @@ -281,7 +313,7 @@ async def get_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> revision.Revision: r"""Gets information about a Revision. @@ -327,8 +359,10 @@ async def sample_get_revision(): 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, 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: google.cloud.run_v2.types.Revision: @@ -400,7 +434,7 @@ async def list_revisions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRevisionsAsyncPager: r"""Lists Revisions from a given Service, or from a given location. Results are sorted by creation time, @@ -451,8 +485,10 @@ async def sample_list_revisions(): 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, 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: google.cloud.run_v2.services.revisions.pagers.ListRevisionsAsyncPager: @@ -535,7 +571,7 @@ async def delete_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Revision. @@ -588,8 +624,10 @@ async def sample_delete_revision(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -668,7 +706,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -679,8 +717,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -721,7 +761,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -732,8 +772,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -774,7 +816,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -790,8 +832,10 @@ async def delete_operation( 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, 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: None """ @@ -828,7 +872,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -845,8 +889,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/client.py index 899b33ceee23..6ce987982ea2 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import launch_stage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -721,6 +731,10 @@ def __init__( # 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( @@ -783,6 +797,29 @@ def __init__( 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.run_v2.RevisionsClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "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.run.v2.Revisions", + "credentialsType": None, + }, + ) + def get_revision( self, request: Optional[Union[revision.GetRevisionRequest, dict]] = None, @@ -790,7 +827,7 @@ def get_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> revision.Revision: r"""Gets information about a Revision. @@ -836,8 +873,10 @@ def sample_get_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.Revision: @@ -906,7 +945,7 @@ def list_revisions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRevisionsPager: r"""Lists Revisions from a given Service, or from a given location. Results are sorted by creation time, @@ -957,8 +996,10 @@ def sample_list_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.services.revisions.pagers.ListRevisionsPager: @@ -1038,7 +1079,7 @@ def delete_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Revision. @@ -1091,8 +1132,10 @@ def sample_delete_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1181,7 +1224,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1192,8 +1235,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1234,7 +1279,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1245,8 +1290,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1287,7 +1334,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1303,8 +1350,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1341,7 +1390,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1358,8 +1407,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/pagers.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/pagers.py index 7b0965cfbaed..5fc3eaacf58e 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/pagers.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = revision.ListRevisionsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = revision.ListRevisionsRequest(request) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc.py index 53051de73f83..1c6c51d17240 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import revision from .base import DEFAULT_CLIENT_INFO, RevisionsTransport +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.run.v2.Revisions", + "rpcName": 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.run.v2.Revisions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RevisionsGrpcTransport(RevisionsTransport): """gRPC backend transport for Revisions. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def get_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_revision" not in self._stubs: - self._stubs["get_revision"] = self.grpc_channel.unary_unary( + self._stubs["get_revision"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/GetRevision", request_serializer=revision.GetRevisionRequest.serialize, response_deserializer=revision.Revision.deserialize, @@ -298,7 +386,7 @@ def list_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_revisions" not in self._stubs: - self._stubs["list_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_revisions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/ListRevisions", request_serializer=revision.ListRevisionsRequest.serialize, response_deserializer=revision.ListRevisionsResponse.deserialize, @@ -324,7 +412,7 @@ def delete_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_revision" not in self._stubs: - self._stubs["delete_revision"] = self.grpc_channel.unary_unary( + self._stubs["delete_revision"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/DeleteRevision", request_serializer=revision.DeleteRevisionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +420,7 @@ def delete_revision( return self._stubs["delete_revision"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -344,7 +432,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -361,7 +449,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -378,7 +466,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -397,7 +485,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc_asyncio.py index 374c7fd2f355..b37d88b9d1b6 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import revision from .base import DEFAULT_CLIENT_INFO, RevisionsTransport from .grpc import RevisionsGrpcTransport +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.run.v2.Revisions", + "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.run.v2.Revisions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RevisionsGrpcAsyncIOTransport(RevisionsTransport): """gRPC AsyncIO backend transport for Revisions. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -280,7 +365,7 @@ def get_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_revision" not in self._stubs: - self._stubs["get_revision"] = self.grpc_channel.unary_unary( + self._stubs["get_revision"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/GetRevision", request_serializer=revision.GetRevisionRequest.serialize, response_deserializer=revision.Revision.deserialize, @@ -310,7 +395,7 @@ def list_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_revisions" not in self._stubs: - self._stubs["list_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_revisions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/ListRevisions", request_serializer=revision.ListRevisionsRequest.serialize, response_deserializer=revision.ListRevisionsResponse.deserialize, @@ -338,7 +423,7 @@ def delete_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_revision" not in self._stubs: - self._stubs["delete_revision"] = self.grpc_channel.unary_unary( + self._stubs["delete_revision"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Revisions/DeleteRevision", request_serializer=revision.DeleteRevisionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +476,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -407,7 +492,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -424,7 +509,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -441,7 +526,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -460,7 +545,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/rest.py index 5e2ca971a478..f26557dbfe37 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -95,8 +103,8 @@ def post_list_revisions(self, response): def pre_delete_revision( self, request: revision.DeleteRevisionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[revision.DeleteRevisionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[revision.DeleteRevisionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_revision Override in a subclass to manipulate the request or metadata @@ -116,8 +124,10 @@ def post_delete_revision( return response def pre_get_revision( - self, request: revision.GetRevisionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[revision.GetRevisionRequest, Sequence[Tuple[str, str]]]: + self, + request: revision.GetRevisionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[revision.GetRevisionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_revision Override in a subclass to manipulate the request or metadata @@ -137,8 +147,8 @@ def post_get_revision(self, response: revision.Revision) -> revision.Revision: def pre_list_revisions( self, request: revision.ListRevisionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[revision.ListRevisionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[revision.ListRevisionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_revisions Override in a subclass to manipulate the request or metadata @@ -160,8 +170,10 @@ def post_list_revisions( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -181,8 +193,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -204,8 +218,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -227,8 +243,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -422,7 +440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete revision method over HTTP. @@ -436,8 +454,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -450,6 +470,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseDeleteRevision._get_http_options() ) + request, metadata = self._interceptor.pre_delete_revision(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseDeleteRevision._get_transcoded_request( @@ -464,6 +485,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.DeleteRevision", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "DeleteRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._DeleteRevision._get_response( self._host, @@ -482,7 +530,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_revision(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.run_v2.RevisionsClient.delete_revision", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "DeleteRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRevision(_BaseRevisionsRestTransport._BaseGetRevision, RevisionsRestStub): @@ -517,7 +587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> revision.Revision: r"""Call the get revision method over HTTP. @@ -528,8 +598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.revision.Revision: @@ -544,6 +616,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseGetRevision._get_http_options() ) + request, metadata = self._interceptor.pre_get_revision(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseGetRevision._get_transcoded_request( @@ -558,6 +631,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.GetRevision", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "GetRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._GetRevision._get_response( self._host, @@ -578,7 +678,29 @@ def __call__( pb_resp = revision.Revision.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = revision.Revision.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.run_v2.RevisionsClient.get_revision", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "GetRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRevisions( @@ -615,7 +737,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> revision.ListRevisionsResponse: r"""Call the list revisions method over HTTP. @@ -626,8 +748,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.revision.ListRevisionsResponse: @@ -639,6 +763,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseListRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_revisions(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseListRevisions._get_transcoded_request( @@ -653,6 +778,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.ListRevisions", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "ListRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._ListRevisions._get_response( self._host, @@ -673,7 +825,29 @@ def __call__( pb_resp = revision.ListRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = revision.ListRevisionsResponse.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.run_v2.RevisionsClient.list_revisions", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "ListRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -738,7 +912,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -748,13 +922,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRevisionsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -769,6 +946,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._DeleteOperation._get_response( self._host, @@ -824,7 +1028,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -834,8 +1038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -844,6 +1050,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -858,6 +1065,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._GetOperation._get_response( self._host, @@ -877,6 +1111,27 @@ def __call__( 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.run_v2.RevisionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -917,7 +1172,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -927,8 +1182,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -937,6 +1194,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseListOperations._get_transcoded_request( @@ -951,6 +1209,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._ListOperations._get_response( self._host, @@ -970,6 +1255,27 @@ def __call__( 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.run_v2.RevisionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1011,7 +1317,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -1021,8 +1327,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -1031,6 +1339,7 @@ def __call__( http_options = ( _BaseRevisionsRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseRevisionsRestTransport._BaseWaitOperation._get_transcoded_request( @@ -1051,6 +1360,33 @@ def __call__( ) ) + 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.run_v2.RevisionsClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RevisionsRestTransport._WaitOperation._get_response( self._host, @@ -1071,6 +1407,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.RevisionsAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Revisions", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py index b84c67188765..7324282668df 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -62,6 +63,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServicesTransport from .transports.grpc_asyncio import ServicesGrpcAsyncIOTransport +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 ServicesAsyncClient: """Cloud Run Service Control Plane API""" @@ -273,6 +283,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.ServicesAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "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.run.v2.Services", + "credentialsType": None, + }, + ) + async def create_service( self, request: Optional[Union[gcr_service.CreateServiceRequest, dict]] = None, @@ -282,7 +314,7 @@ async def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Service in a given project and location. @@ -353,8 +385,10 @@ async def sample_create_service(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -442,7 +476,7 @@ async def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets information about a Service. @@ -489,8 +523,10 @@ async def sample_get_service(): 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, 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: google.cloud.run_v2.types.Service: @@ -566,7 +602,7 @@ async def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists Services. Results are sorted by creation time, descending. @@ -617,8 +653,10 @@ async def sample_list_services(): 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, 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: google.cloud.run_v2.services.services.pagers.ListServicesAsyncPager: @@ -702,7 +740,7 @@ async def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a Service. @@ -754,8 +792,10 @@ async def sample_update_service(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -841,7 +881,7 @@ async def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Service. This will cause the Service to stop serving traffic and @@ -894,8 +934,10 @@ async def sample_delete_service(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -978,7 +1020,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does @@ -1017,8 +1059,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1094,7 +1138,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Access control policy for the specified Service. Overwrites any existing policy. @@ -1132,8 +1176,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1209,7 +1255,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified Project. @@ -1250,8 +1296,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1297,7 +1345,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1308,8 +1356,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1350,7 +1400,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1361,8 +1411,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1403,7 +1455,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1419,8 +1471,10 @@ async def delete_operation( 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, 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: None """ @@ -1457,7 +1511,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1474,8 +1528,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/client.py index 6177216a8d8a..623fe745cf11 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import launch_stage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -735,6 +745,10 @@ def __init__( # 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( @@ -797,6 +811,29 @@ def __init__( 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.run_v2.ServicesClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "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.run.v2.Services", + "credentialsType": None, + }, + ) + def create_service( self, request: Optional[Union[gcr_service.CreateServiceRequest, dict]] = None, @@ -806,7 +843,7 @@ def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Service in a given project and location. @@ -877,8 +914,10 @@ def sample_create_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -963,7 +1002,7 @@ def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets information about a Service. @@ -1010,8 +1049,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.Service: @@ -1084,7 +1125,7 @@ def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesPager: r"""Lists Services. Results are sorted by creation time, descending. @@ -1135,8 +1176,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.services.services.pagers.ListServicesPager: @@ -1217,7 +1260,7 @@ def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a Service. @@ -1269,8 +1312,10 @@ def sample_update_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1353,7 +1398,7 @@ def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Service. This will cause the Service to stop serving traffic and @@ -1406,8 +1451,10 @@ def sample_delete_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1487,7 +1534,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does @@ -1526,8 +1573,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1602,7 +1651,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Access control policy for the specified Service. Overwrites any existing policy. @@ -1640,8 +1689,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1716,7 +1767,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified Project. @@ -1757,8 +1808,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1816,7 +1869,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1827,8 +1880,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1869,7 +1924,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1880,8 +1935,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1922,7 +1979,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1938,8 +1995,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1976,7 +2035,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1993,8 +2052,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/pagers.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/pagers.py index 62d2db47cc36..041b8314d205 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/pagers.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListServicesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListServicesRequest(request) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc.py index 9ea21b579f53..ee4d518e3b27 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,13 +27,91 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import service from google.cloud.run_v2.types import service as gcr_service from .base import DEFAULT_CLIENT_INFO, ServicesTransport +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.run.v2.Services", + "rpcName": 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.run.v2.Services", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServicesGrpcTransport(ServicesTransport): """gRPC backend transport for Services. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/CreateService", request_serializer=gcr_service.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -298,7 +386,7 @@ def get_service(self) -> Callable[[service.GetServiceRequest], service.Service]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/GetService", request_serializer=service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -325,7 +413,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/ListServices", request_serializer=service.ListServicesRequest.serialize, response_deserializer=service.ListServicesResponse.deserialize, @@ -351,7 +439,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/UpdateService", request_serializer=gcr_service.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/DeleteService", request_serializer=service.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -407,7 +495,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -434,7 +522,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -466,7 +554,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -474,7 +562,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -486,7 +574,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -503,7 +591,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -520,7 +608,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -539,7 +627,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc_asyncio.py index 3cfe78a8bcfe..cc58662f677a 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import service from google.cloud.run_v2.types import service as gcr_service @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ServicesTransport from .grpc import ServicesGrpcTransport +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.run.v2.Services", + "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.run.v2.Services", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServicesGrpcAsyncIOTransport(ServicesTransport): """gRPC AsyncIO backend transport for Services. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/CreateService", request_serializer=gcr_service.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +397,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/GetService", request_serializer=service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -341,7 +426,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/ListServices", request_serializer=service.ListServicesRequest.serialize, response_deserializer=service.ListServicesResponse.deserialize, @@ -369,7 +454,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/UpdateService", request_serializer=gcr_service.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/DeleteService", request_serializer=service.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -425,7 +510,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -452,7 +537,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -484,7 +569,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Services/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -580,7 +665,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -596,7 +681,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -613,7 +698,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -630,7 +715,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -649,7 +734,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/rest.py index e6435ca85464..f30d09acd756 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -138,8 +146,10 @@ def post_update_service(self, response): def pre_create_service( self, request: gcr_service.CreateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcr_service.CreateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcr_service.CreateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_service Override in a subclass to manipulate the request or metadata @@ -159,8 +169,10 @@ def post_create_service( return response def pre_delete_service( - self, request: service.DeleteServiceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteServiceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -182,8 +194,10 @@ def post_delete_service( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -201,8 +215,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_service( - self, request: service.GetServiceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetServiceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetServiceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -220,8 +236,10 @@ def post_get_service(self, response: service.Service) -> service.Service: return response def pre_list_services( - self, request: service.ListServicesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListServicesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListServicesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -243,8 +261,10 @@ def post_list_services( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -264,8 +284,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -287,8 +310,10 @@ def post_test_iam_permissions( def pre_update_service( self, request: gcr_service.UpdateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcr_service.UpdateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcr_service.UpdateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_service Override in a subclass to manipulate the request or metadata @@ -310,8 +335,10 @@ def post_update_service( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -331,8 +358,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -354,8 +383,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -377,8 +408,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -573,7 +606,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create service method over HTTP. @@ -584,8 +617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -598,6 +633,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseCreateService._get_http_options() ) + request, metadata = self._interceptor.pre_create_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseCreateService._get_transcoded_request( @@ -616,6 +652,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.CreateService", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "CreateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._CreateService._get_response( self._host, @@ -635,7 +698,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service(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.run_v2.ServicesClient.create_service", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "CreateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteService( @@ -672,7 +757,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete service method over HTTP. @@ -683,8 +768,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -697,6 +784,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseDeleteService._get_transcoded_request( @@ -711,6 +799,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.DeleteService", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._DeleteService._get_response( self._host, @@ -729,7 +844,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_service(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.run_v2.ServicesClient.delete_service", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "DeleteService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseServicesRestTransport._BaseGetIamPolicy, ServicesRestStub): @@ -764,7 +901,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -774,8 +911,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -860,6 +999,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -874,6 +1014,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._GetIamPolicy._get_response( self._host, @@ -894,7 +1061,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.run_v2.ServicesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService(_BaseServicesRestTransport._BaseGetService, ServicesRestStub): @@ -929,7 +1118,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Call the get service method over HTTP. @@ -940,8 +1129,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.Service: @@ -960,6 +1151,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseGetService._get_transcoded_request( @@ -974,6 +1166,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.GetService", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._GetService._get_response( self._host, @@ -994,7 +1213,29 @@ def __call__( pb_resp = service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Service.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.run_v2.ServicesClient.get_service", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices(_BaseServicesRestTransport._BaseListServices, ServicesRestStub): @@ -1029,7 +1270,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListServicesResponse: r"""Call the list services method over HTTP. @@ -1040,8 +1281,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListServicesResponse: @@ -1053,6 +1296,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseListServices._get_transcoded_request( @@ -1067,6 +1311,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.ListServices", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._ListServices._get_response( self._host, @@ -1087,7 +1358,29 @@ def __call__( pb_resp = service.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListServicesResponse.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.run_v2.ServicesClient.list_services", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseServicesRestTransport._BaseSetIamPolicy, ServicesRestStub): @@ -1123,7 +1416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1133,8 +1426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1219,6 +1514,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1237,6 +1533,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._SetIamPolicy._get_response( self._host, @@ -1258,7 +1581,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.run_v2.ServicesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1296,7 +1641,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1306,8 +1651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1317,6 +1664,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1333,6 +1681,33 @@ def __call__( 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.run_v2.ServicesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._TestIamPermissions._get_response( self._host, @@ -1354,7 +1729,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.run_v2.ServicesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateService( @@ -1392,7 +1789,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update service method over HTTP. @@ -1403,8 +1800,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1417,6 +1816,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseUpdateService._get_http_options() ) + request, metadata = self._interceptor.pre_update_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseUpdateService._get_transcoded_request( @@ -1435,6 +1835,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.UpdateService", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "UpdateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._UpdateService._get_response( self._host, @@ -1454,7 +1881,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_service(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.run_v2.ServicesClient.update_service", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "UpdateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1560,7 +2009,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1570,13 +2019,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseServicesRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1593,6 +2045,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._DeleteOperation._get_response( self._host, @@ -1646,7 +2125,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1656,8 +2135,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1666,6 +2147,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseGetOperation._get_transcoded_request( @@ -1680,6 +2162,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._GetOperation._get_response( self._host, @@ -1699,6 +2208,27 @@ def __call__( 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.run_v2.ServicesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1739,7 +2269,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1749,8 +2279,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1759,6 +2291,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseListOperations._get_transcoded_request( @@ -1773,6 +2306,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._ListOperations._get_response( self._host, @@ -1792,6 +2352,27 @@ def __call__( 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.run_v2.ServicesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1833,7 +2414,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -1843,8 +2424,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -1853,6 +2436,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseWaitOperation._get_transcoded_request( @@ -1871,6 +2455,33 @@ def __call__( ) ) + 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.run_v2.ServicesClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._WaitOperation._get_response( self._host, @@ -1891,6 +2502,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.ServicesAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Services", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/async_client.py index 90a4d16db39e..963d864b927d 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TasksTransport from .transports.grpc_asyncio import TasksGrpcAsyncIOTransport +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 TasksAsyncClient: """Cloud Run Task Control Plane API.""" @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.run_v2.TasksAsyncClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "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.run.v2.Tasks", + "credentialsType": None, + }, + ) + async def get_task( self, request: Optional[Union[task.GetTaskRequest, dict]] = None, @@ -268,7 +300,7 @@ async def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets information about a Task. @@ -314,8 +346,10 @@ async def sample_get_task(): 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, 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: google.cloud.run_v2.types.Task: @@ -374,7 +408,7 @@ async def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksAsyncPager: r"""Lists Tasks from an Execution of a Job. @@ -425,8 +459,10 @@ async def sample_list_tasks(): 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, 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: google.cloud.run_v2.services.tasks.pagers.ListTasksAsyncPager: @@ -500,7 +536,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -511,8 +547,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -553,7 +591,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -564,8 +602,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -606,7 +646,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -622,8 +662,10 @@ async def delete_operation( 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, 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: None """ @@ -660,7 +702,7 @@ async def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -677,8 +719,10 @@ async def wait_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/client.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/client.py index cef504d17b17..4d21d4a562f7 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore @@ -716,6 +726,10 @@ def __init__( # 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( @@ -778,6 +792,29 @@ def __init__( 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.run_v2.TasksClient`.", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "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.run.v2.Tasks", + "credentialsType": None, + }, + ) + def get_task( self, request: Optional[Union[task.GetTaskRequest, dict]] = None, @@ -785,7 +822,7 @@ def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets information about a Task. @@ -831,8 +868,10 @@ def sample_get_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.types.Task: @@ -890,7 +929,7 @@ def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksPager: r"""Lists Tasks from an Execution of a Job. @@ -941,8 +980,10 @@ def sample_list_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.run_v2.services.tasks.pagers.ListTasksPager: @@ -1026,7 +1067,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1037,8 +1078,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1079,7 +1122,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1090,8 +1133,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1132,7 +1177,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1148,8 +1193,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1186,7 +1233,7 @@ def wait_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. @@ -1203,8 +1250,10 @@ def wait_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/pagers.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/pagers.py index c872d33379f5..05d0075590cd 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/pagers.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = task.ListTasksRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = task.ListTasksRequest(request) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc.py index b61173ea3cd5..15e17a4d2d11 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import task from .base import DEFAULT_CLIENT_INFO, TasksTransport +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.run.v2.Tasks", + "rpcName": 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.run.v2.Tasks", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TasksGrpcTransport(TasksTransport): """gRPC backend transport for Tasks. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -253,7 +339,7 @@ def get_task(self) -> Callable[[task.GetTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Tasks/GetTask", request_serializer=task.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -277,7 +363,7 @@ def list_tasks(self) -> Callable[[task.ListTasksRequest], task.ListTasksResponse # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Tasks/ListTasks", request_serializer=task.ListTasksRequest.serialize, response_deserializer=task.ListTasksResponse.deserialize, @@ -285,7 +371,7 @@ def list_tasks(self) -> Callable[[task.ListTasksRequest], task.ListTasksResponse return self._stubs["list_tasks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -297,7 +383,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -314,7 +400,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -331,7 +417,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -350,7 +436,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc_asyncio.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc_asyncio.py index a8e1530d7302..7d859d499c20 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc_asyncio.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.run_v2.types import task from .base import DEFAULT_CLIENT_INFO, TasksTransport from .grpc import TasksGrpcTransport +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.run.v2.Tasks", + "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.run.v2.Tasks", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TasksGrpcAsyncIOTransport(TasksTransport): """gRPC AsyncIO backend transport for Tasks. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def get_task(self) -> Callable[[task.GetTaskRequest], Awaitable[task.Task]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Tasks/GetTask", request_serializer=task.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -287,7 +372,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.run.v2.Tasks/ListTasks", request_serializer=task.ListTasksRequest.serialize, response_deserializer=task.ListTasksResponse.deserialize, @@ -335,7 +420,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -351,7 +436,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -368,7 +453,7 @@ def wait_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "wait_operation" not in self._stubs: - self._stubs["wait_operation"] = self.grpc_channel.unary_unary( + self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, @@ -385,7 +470,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -404,7 +489,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/rest.py b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/rest.py index a9d22e2ac428..632beacefcf3 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/rest.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/tasks/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -85,8 +93,10 @@ def post_list_tasks(self, response): """ def pre_get_task( - self, request: task.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[task.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: task.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[task.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -104,8 +114,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_list_tasks( - self, request: task.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[task.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: task.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[task.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -127,8 +139,10 @@ def post_list_tasks( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -148,8 +162,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -171,8 +187,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -194,8 +212,10 @@ def post_list_operations( def pre_wait_operation( self, request: operations_pb2.WaitOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.WaitOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.WaitOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait_operation Override in a subclass to manipulate the request or metadata @@ -333,7 +353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the get task method over HTTP. @@ -344,8 +364,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.task.Task: @@ -355,6 +377,7 @@ def __call__( """ http_options = _BaseTasksRestTransport._BaseGetTask._get_http_options() + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseTasksRestTransport._BaseGetTask._get_transcoded_request( @@ -367,6 +390,33 @@ def __call__( 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.run_v2.TasksClient.GetTask", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._GetTask._get_response( self._host, @@ -387,7 +437,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.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.run_v2.TasksClient.get_task", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks(_BaseTasksRestTransport._BaseListTasks, TasksRestStub): @@ -422,7 +494,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -433,8 +505,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.task.ListTasksResponse: @@ -444,6 +518,7 @@ def __call__( """ http_options = _BaseTasksRestTransport._BaseListTasks._get_http_options() + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseTasksRestTransport._BaseListTasks._get_transcoded_request( @@ -458,6 +533,33 @@ def __call__( ) ) + 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.run_v2.TasksClient.ListTasks", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._ListTasks._get_response( self._host, @@ -478,7 +580,29 @@ def __call__( pb_resp = task.ListTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.ListTasksResponse.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.run_v2.TasksClient.list_tasks", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -529,7 +653,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -539,13 +663,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTasksRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -562,6 +689,33 @@ def __call__( ) ) + 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.run_v2.TasksClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._DeleteOperation._get_response( self._host, @@ -615,7 +769,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -625,14 +779,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. """ http_options = _BaseTasksRestTransport._BaseGetOperation._get_http_options() + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTasksRestTransport._BaseGetOperation._get_transcoded_request( @@ -647,6 +804,33 @@ def __call__( ) ) + 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.run_v2.TasksClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._GetOperation._get_response( self._host, @@ -666,6 +850,27 @@ def __call__( 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.run_v2.TasksAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -704,7 +909,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -714,8 +919,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -724,6 +931,7 @@ def __call__( http_options = ( _BaseTasksRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseTasksRestTransport._BaseListOperations._get_transcoded_request( @@ -738,6 +946,33 @@ def __call__( ) ) + 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.run_v2.TasksClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._ListOperations._get_response( self._host, @@ -757,6 +992,27 @@ def __call__( 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.run_v2.TasksAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -796,7 +1052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the wait operation method over HTTP. @@ -806,8 +1062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from WaitOperation method. @@ -816,6 +1074,7 @@ def __call__( http_options = ( _BaseTasksRestTransport._BaseWaitOperation._get_http_options() ) + request, metadata = self._interceptor.pre_wait_operation(request, metadata) transcoded_request = ( _BaseTasksRestTransport._BaseWaitOperation._get_transcoded_request( @@ -834,6 +1093,33 @@ def __call__( ) ) + 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.run_v2.TasksClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "WaitOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TasksRestTransport._WaitOperation._get_response( self._host, @@ -854,6 +1140,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_wait_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.run_v2.TasksAsyncClient.WaitOperation", + extra={ + "serviceName": "google.cloud.run.v2.Tasks", + "rpcName": "WaitOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-run/samples/generated_samples/snippet_metadata_google.cloud.run.v2.json b/packages/google-cloud-run/samples/generated_samples/snippet_metadata_google.cloud.run.v2.json index 87298dfd4206..91a10655bff1 100644 --- a/packages/google-cloud-run/samples/generated_samples/snippet_metadata_google.cloud.run.v2.json +++ b/packages/google-cloud-run/samples/generated_samples/snippet_metadata_google.cloud.run.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-run", - "version": "0.10.13" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.SubmitBuildResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.SubmitBuildResponse", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -361,7 +361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -441,7 +441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -522,7 +522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Execution", @@ -602,7 +602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Execution", @@ -683,7 +683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.executions.pagers.ListExecutionsAsyncPager", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.executions.pagers.ListExecutionsPager", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1021,7 +1021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1101,7 +1101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1335,7 +1335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Job", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Job", @@ -1496,7 +1496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.jobs.pagers.ListJobsAsyncPager", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.jobs.pagers.ListJobsPager", @@ -1657,7 +1657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1737,7 +1737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1814,7 +1814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1890,7 +1890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1967,7 +1967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2043,7 +2043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2124,7 +2124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2204,7 +2204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2285,7 +2285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2365,7 +2365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2446,7 +2446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Revision", @@ -2526,7 +2526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Revision", @@ -2607,7 +2607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.revisions.pagers.ListRevisionsAsyncPager", @@ -2687,7 +2687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.revisions.pagers.ListRevisionsPager", @@ -2776,7 +2776,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2864,7 +2864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2945,7 +2945,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3025,7 +3025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3102,7 +3102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3178,7 +3178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3259,7 +3259,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Service", @@ -3339,7 +3339,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Service", @@ -3420,7 +3420,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.services.pagers.ListServicesAsyncPager", @@ -3500,7 +3500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.services.pagers.ListServicesPager", @@ -3577,7 +3577,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3653,7 +3653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3730,7 +3730,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3806,7 +3806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3891,7 +3891,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3975,7 +3975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4056,7 +4056,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Task", @@ -4136,7 +4136,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.types.Task", @@ -4217,7 +4217,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.tasks.pagers.ListTasksAsyncPager", @@ -4297,7 +4297,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.run_v2.services.tasks.pagers.ListTasksPager", diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_builds.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_builds.py index ccc77b890696..6e6e2815b349 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_builds.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_builds.py @@ -1349,6 +1349,7 @@ def test_submit_build_rest_required_fields(request_type=build.SubmitBuildRequest response_value._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.submit_build(request) @@ -1570,6 +1571,7 @@ def test_submit_build_rest_bad_request(request_type=build.SubmitBuildRequest): 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.submit_build(request) @@ -1606,6 +1608,7 @@ def test_submit_build_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.submit_build(request) # Establish that the response is the type that we expect. @@ -1643,6 +1646,7 @@ def test_submit_build_rest_interceptors(null_interceptor): 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 = build.SubmitBuildResponse.to_json(build.SubmitBuildResponse()) req.return_value.content = return_value @@ -1689,6 +1693,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -1719,6 +1724,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -1749,6 +1755,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1779,6 +1786,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1809,6 +1817,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1839,6 +1848,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -1869,6 +1879,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -1899,6 +1910,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_executions.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_executions.py index 7326953e1e8d..e364f0db9d8d 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_executions.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_executions.py @@ -2696,6 +2696,7 @@ def test_get_execution_rest_required_fields(request_type=execution.GetExecutionR response_value._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_execution(request) @@ -2743,6 +2744,7 @@ def test_get_execution_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_execution(**mock_args) @@ -2882,6 +2884,7 @@ def test_list_executions_rest_required_fields( response_value._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_executions(request) @@ -2936,6 +2939,7 @@ def test_list_executions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_executions(**mock_args) @@ -3138,6 +3142,7 @@ def test_delete_execution_rest_required_fields( response_value._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_execution(request) @@ -3191,6 +3196,7 @@ def test_delete_execution_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_execution(**mock_args) @@ -3326,6 +3332,7 @@ def test_cancel_execution_rest_required_fields( response_value._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_execution(request) @@ -3371,6 +3378,7 @@ def test_cancel_execution_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.cancel_execution(**mock_args) @@ -3752,6 +3760,7 @@ def test_get_execution_rest_bad_request(request_type=execution.GetExecutionReque 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_execution(request) @@ -3805,6 +3814,7 @@ def test_get_execution_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_execution(request) # Establish that the response is the type that we expect. @@ -3859,6 +3869,7 @@ def test_get_execution_rest_interceptors(null_interceptor): 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 = execution.Execution.to_json(execution.Execution()) req.return_value.content = return_value @@ -3901,6 +3912,7 @@ def test_list_executions_rest_bad_request(request_type=execution.ListExecutionsR 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_executions(request) @@ -3936,6 +3948,7 @@ def test_list_executions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_executions(request) # Establish that the response is the type that we expect. @@ -3976,6 +3989,7 @@ def test_list_executions_rest_interceptors(null_interceptor): 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 = execution.ListExecutionsResponse.to_json( execution.ListExecutionsResponse() ) @@ -4024,6 +4038,7 @@ def test_delete_execution_rest_bad_request( 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_execution(request) @@ -4056,6 +4071,7 @@ def test_delete_execution_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_execution(request) # Establish that the response is the type that we expect. @@ -4097,6 +4113,7 @@ def test_delete_execution_rest_interceptors(null_interceptor): 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 @@ -4143,6 +4160,7 @@ def test_cancel_execution_rest_bad_request( 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.cancel_execution(request) @@ -4175,6 +4193,7 @@ def test_cancel_execution_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_execution(request) # Establish that the response is the type that we expect. @@ -4216,6 +4235,7 @@ def test_cancel_execution_rest_interceptors(null_interceptor): 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 @@ -4262,6 +4282,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -4292,6 +4313,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -4322,6 +4344,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4352,6 +4375,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4382,6 +4406,7 @@ def test_list_operations_rest_bad_request( 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) @@ -4412,6 +4437,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -4442,6 +4468,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -4472,6 +4499,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_jobs.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_jobs.py index e9dc19f8fd0f..129832f97c3a 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_jobs.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_jobs.py @@ -3745,6 +3745,7 @@ def test_create_job_rest_required_fields(request_type=gcr_job.CreateJobRequest): response_value._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_job(request) @@ -3810,6 +3811,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -3940,6 +3942,7 @@ def test_get_job_rest_required_fields(request_type=job.GetJobRequest): response_value._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_job(request) @@ -3985,6 +3988,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4121,6 +4125,7 @@ def test_list_jobs_rest_required_fields(request_type=job.ListJobsRequest): response_value._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_jobs(request) @@ -4175,6 +4180,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -4368,6 +4374,7 @@ def test_update_job_rest_required_fields(request_type=gcr_job.UpdateJobRequest): response_value._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_job(request) @@ -4421,6 +4428,7 @@ def test_update_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4557,6 +4565,7 @@ def test_delete_job_rest_required_fields(request_type=job.DeleteJobRequest): response_value._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_job(request) @@ -4608,6 +4617,7 @@ def test_delete_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4738,6 +4748,7 @@ def test_run_job_rest_required_fields(request_type=job.RunJobRequest): response_value._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.run_job(request) @@ -4781,6 +4792,7 @@ def test_run_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_job(**mock_args) @@ -4911,6 +4923,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -5029,6 +5042,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -5163,6 +5177,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -6142,6 +6157,7 @@ def test_create_job_rest_bad_request(request_type=gcr_job.CreateJobRequest): 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_job(request) @@ -6389,6 +6405,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6426,6 +6443,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 @@ -6468,6 +6486,7 @@ def test_get_job_rest_bad_request(request_type=job.GetJobRequest): 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_job(request) @@ -6516,6 +6535,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6564,6 +6584,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -6606,6 +6627,7 @@ def test_list_jobs_rest_bad_request(request_type=job.ListJobsRequest): 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_jobs(request) @@ -6641,6 +6663,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -6677,6 +6700,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = job.ListJobsResponse.to_json(job.ListJobsResponse()) req.return_value.content = return_value @@ -6719,6 +6743,7 @@ def test_update_job_rest_bad_request(request_type=gcr_job.UpdateJobRequest): 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_job(request) @@ -6966,6 +6991,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7003,6 +7029,7 @@ def test_update_job_rest_interceptors(null_interceptor): 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 @@ -7045,6 +7072,7 @@ def test_delete_job_rest_bad_request(request_type=job.DeleteJobRequest): 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_job(request) @@ -7075,6 +7103,7 @@ def test_delete_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7112,6 +7141,7 @@ def test_delete_job_rest_interceptors(null_interceptor): 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 @@ -7154,6 +7184,7 @@ def test_run_job_rest_bad_request(request_type=job.RunJobRequest): 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.run_job(request) @@ -7184,6 +7215,7 @@ def test_run_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_job(request) # Establish that the response is the type that we expect. @@ -7221,6 +7253,7 @@ def test_run_job_rest_interceptors(null_interceptor): 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 @@ -7265,6 +7298,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -7298,6 +7332,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -7335,6 +7370,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7379,6 +7415,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -7412,6 +7449,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -7449,6 +7487,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7493,6 +7532,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -7525,6 +7565,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7561,6 +7602,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -7609,6 +7651,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -7639,6 +7682,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -7669,6 +7713,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7699,6 +7744,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7729,6 +7775,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7759,6 +7806,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -7789,6 +7837,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -7819,6 +7868,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py index 8eb171dba392..01b9629ea918 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py @@ -2190,6 +2190,7 @@ def test_get_revision_rest_required_fields(request_type=revision.GetRevisionRequ response_value._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_revision(request) @@ -2237,6 +2238,7 @@ def test_get_revision_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_revision(**mock_args) @@ -2376,6 +2378,7 @@ def test_list_revisions_rest_required_fields( response_value._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_revisions(request) @@ -2432,6 +2435,7 @@ def test_list_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_revisions(**mock_args) @@ -2634,6 +2638,7 @@ def test_delete_revision_rest_required_fields( response_value._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_revision(request) @@ -2687,6 +2692,7 @@ def test_delete_revision_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_revision(**mock_args) @@ -3220,6 +3226,7 @@ def test_get_revision_rest_bad_request(request_type=revision.GetRevisionRequest) 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_revision(request) @@ -3272,6 +3279,7 @@ def test_get_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_revision(request) # Establish that the response is the type that we expect. @@ -3329,6 +3337,7 @@ def test_get_revision_rest_interceptors(null_interceptor): 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 = revision.Revision.to_json(revision.Revision()) req.return_value.content = return_value @@ -3371,6 +3380,7 @@ def test_list_revisions_rest_bad_request(request_type=revision.ListRevisionsRequ 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_revisions(request) @@ -3406,6 +3416,7 @@ def test_list_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_revisions(request) # Establish that the response is the type that we expect. @@ -3442,6 +3453,7 @@ def test_list_revisions_rest_interceptors(null_interceptor): 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 = revision.ListRevisionsResponse.to_json( revision.ListRevisionsResponse() ) @@ -3488,6 +3500,7 @@ def test_delete_revision_rest_bad_request(request_type=revision.DeleteRevisionRe 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_revision(request) @@ -3520,6 +3533,7 @@ def test_delete_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_revision(request) # Establish that the response is the type that we expect. @@ -3557,6 +3571,7 @@ def test_delete_revision_rest_interceptors(null_interceptor): 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 @@ -3603,6 +3618,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -3633,6 +3649,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -3663,6 +3680,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3693,6 +3711,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -3723,6 +3742,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3753,6 +3773,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -3783,6 +3804,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -3813,6 +3835,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py index 7308504b2943..b1f21feabfca 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py @@ -3563,6 +3563,7 @@ def test_create_service_rest_required_fields( response_value._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_service(request) @@ -3628,6 +3629,7 @@ def test_create_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -3758,6 +3760,7 @@ def test_get_service_rest_required_fields(request_type=service.GetServiceRequest response_value._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_service(request) @@ -3803,6 +3806,7 @@ def test_get_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -3939,6 +3943,7 @@ def test_list_services_rest_required_fields(request_type=service.ListServicesReq response_value._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_services(request) @@ -3993,6 +3998,7 @@ def test_list_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_services(**mock_args) @@ -4189,6 +4195,7 @@ def test_update_service_rest_required_fields( response_value._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_service(request) @@ -4244,6 +4251,7 @@ def test_update_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -4382,6 +4390,7 @@ def test_delete_service_rest_required_fields(request_type=service.DeleteServiceR response_value._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_service(request) @@ -4433,6 +4442,7 @@ def test_delete_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -4563,6 +4573,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -4681,6 +4692,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -4815,6 +4827,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -5710,6 +5723,7 @@ def test_create_service_rest_bad_request(request_type=gcr_service.CreateServiceR 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_service(request) @@ -5982,6 +5996,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -6021,6 +6036,7 @@ def test_create_service_rest_interceptors(null_interceptor): 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 @@ -6063,6 +6079,7 @@ def test_get_service_rest_bad_request(request_type=service.GetServiceRequest): 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_service(request) @@ -6118,6 +6135,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -6174,6 +6192,7 @@ def test_get_service_rest_interceptors(null_interceptor): 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 = service.Service.to_json(service.Service()) req.return_value.content = return_value @@ -6216,6 +6235,7 @@ def test_list_services_rest_bad_request(request_type=service.ListServicesRequest 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_services(request) @@ -6251,6 +6271,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_services(request) # Establish that the response is the type that we expect. @@ -6287,6 +6308,7 @@ def test_list_services_rest_interceptors(null_interceptor): 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 = service.ListServicesResponse.to_json( service.ListServicesResponse() ) @@ -6333,6 +6355,7 @@ def test_update_service_rest_bad_request(request_type=gcr_service.UpdateServiceR 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_service(request) @@ -6607,6 +6630,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -6646,6 +6670,7 @@ def test_update_service_rest_interceptors(null_interceptor): 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 @@ -6688,6 +6713,7 @@ def test_delete_service_rest_bad_request(request_type=service.DeleteServiceReque 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_service(request) @@ -6718,6 +6744,7 @@ def test_delete_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -6755,6 +6782,7 @@ def test_delete_service_rest_interceptors(null_interceptor): 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 @@ -6799,6 +6827,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -6832,6 +6861,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -6869,6 +6899,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -6913,6 +6944,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -6946,6 +6978,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -6983,6 +7016,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7027,6 +7061,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -7059,6 +7094,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7095,6 +7131,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -7143,6 +7180,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -7173,6 +7211,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -7203,6 +7242,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7233,6 +7273,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7263,6 +7304,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7293,6 +7335,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -7323,6 +7366,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -7353,6 +7397,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_tasks.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_tasks.py index b21e975b58a3..6f0b260c4343 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_tasks.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_tasks.py @@ -1992,6 +1992,7 @@ def test_get_task_rest_required_fields(request_type=task.GetTaskRequest): response_value._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_task(request) @@ -2039,6 +2040,7 @@ def test_get_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_task(**mock_args) @@ -2176,6 +2178,7 @@ def test_list_tasks_rest_required_fields(request_type=task.ListTasksRequest): response_value._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_tasks(request) @@ -2232,6 +2235,7 @@ def test_list_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tasks(**mock_args) @@ -2583,6 +2587,7 @@ def test_get_task_rest_bad_request(request_type=task.GetTaskRequest): 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_task(request) @@ -2635,6 +2640,7 @@ def test_get_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_task(request) # Establish that the response is the type that we expect. @@ -2689,6 +2695,7 @@ def test_get_task_rest_interceptors(null_interceptor): 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 = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -2733,6 +2740,7 @@ def test_list_tasks_rest_bad_request(request_type=task.ListTasksRequest): 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_tasks(request) @@ -2770,6 +2778,7 @@ def test_list_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tasks(request) # Establish that the response is the type that we expect. @@ -2806,6 +2815,7 @@ def test_list_tasks_rest_interceptors(null_interceptor): 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 = task.ListTasksResponse.to_json(task.ListTasksResponse()) req.return_value.content = return_value @@ -2852,6 +2862,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -2882,6 +2893,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -2912,6 +2924,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2942,6 +2955,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2972,6 +2986,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3002,6 +3017,7 @@ def test_list_operations_rest(request_type): response_value.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) @@ -3032,6 +3048,7 @@ def test_wait_operation_rest_bad_request( 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.wait_operation(request) @@ -3062,6 +3079,7 @@ def test_wait_operation_rest(request_type): response_value.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.wait_operation(request) diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler/gapic_version.py b/packages/google-cloud-scheduler/google/cloud/scheduler/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler/gapic_version.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/gapic_version.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/gapic_version.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/async_client.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/async_client.py index af0460efea05..48fcfd2fd594 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/async_client.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport from .transports.grpc_asyncio import CloudSchedulerGrpcAsyncIOTransport +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 CloudSchedulerAsyncClient: """The Cloud Scheduler API allows external entities to reliably @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.scheduler_v1.CloudSchedulerAsyncClient`.", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "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.scheduler.v1.CloudScheduler", + "credentialsType": None, + }, + ) + async def list_jobs( self, request: Optional[Union[cloudscheduler.ListJobsRequest, dict]] = None, @@ -274,7 +306,7 @@ async def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs. @@ -319,8 +351,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsAsyncPager: @@ -395,7 +429,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets a job. @@ -439,8 +473,10 @@ async def sample_get_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -501,7 +537,7 @@ async def create_job( job: Optional[gcs_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Creates a job. @@ -558,8 +594,10 @@ async def sample_create_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -624,7 +662,7 @@ async def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Updates a job. @@ -690,8 +728,10 @@ async def sample_update_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -755,7 +795,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -796,8 +836,10 @@ async def sample_delete_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -849,7 +891,7 @@ async def pause_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Pauses a job. @@ -904,8 +946,10 @@ async def sample_pause_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -967,7 +1011,7 @@ async def resume_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Resume a job. @@ -1021,8 +1065,10 @@ async def sample_resume_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -1084,7 +1130,7 @@ async def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Forces a job to run now. @@ -1131,8 +1177,10 @@ async def sample_run_job(): 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, 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: google.cloud.scheduler_v1.types.Job: @@ -1191,7 +1239,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1202,8 +1250,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1244,7 +1294,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1255,8 +1305,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/client.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/client.py index 4e63df0a1e5d..5e299d9fc7b4 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/client.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -606,6 +616,10 @@ def __init__( # 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( @@ -671,6 +685,29 @@ def __init__( 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.scheduler_v1.CloudSchedulerClient`.", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "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.scheduler.v1.CloudScheduler", + "credentialsType": None, + }, + ) + def list_jobs( self, request: Optional[Union[cloudscheduler.ListJobsRequest, dict]] = None, @@ -678,7 +715,7 @@ def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists jobs. @@ -723,8 +760,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsPager: @@ -796,7 +835,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets a job. @@ -840,8 +879,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -901,7 +942,7 @@ def create_job( job: Optional[gcs_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Creates a job. @@ -958,8 +999,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -1021,7 +1064,7 @@ def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Updates a job. @@ -1087,8 +1130,10 @@ def sample_update_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -1149,7 +1194,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -1190,8 +1235,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1240,7 +1287,7 @@ def pause_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Pauses a job. @@ -1295,8 +1342,10 @@ def sample_pause_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -1355,7 +1404,7 @@ def resume_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Resume a job. @@ -1409,8 +1458,10 @@ def sample_resume_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -1469,7 +1520,7 @@ def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Forces a job to run now. @@ -1516,8 +1567,10 @@ def sample_run_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1.types.Job: @@ -1588,7 +1641,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1599,8 +1652,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1641,7 +1696,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1652,8 +1707,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/pagers.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/pagers.py index dd6b41cbd5ac..ab4423e5bad0 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/pagers.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloudscheduler.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloudscheduler.ListJobsRequest(request) diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc.py index d806bae15ed3..c5cb21774f33 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.scheduler_v1.types import cloudscheduler from google.cloud.scheduler_v1.types import job @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport +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.scheduler.v1.CloudScheduler", + "rpcName": 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.scheduler.v1.CloudScheduler", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudSchedulerGrpcTransport(CloudSchedulerTransport): """gRPC backend transport for CloudScheduler. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/ListJobs", request_serializer=cloudscheduler.ListJobsRequest.serialize, response_deserializer=cloudscheduler.ListJobsResponse.deserialize, @@ -282,7 +368,7 @@ def get_job(self) -> Callable[[cloudscheduler.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/GetJob", request_serializer=cloudscheduler.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -306,7 +392,7 @@ def create_job(self) -> Callable[[cloudscheduler.CreateJobRequest], gcs_job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/CreateJob", request_serializer=cloudscheduler.CreateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -341,7 +427,7 @@ def update_job(self) -> Callable[[cloudscheduler.UpdateJobRequest], gcs_job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/UpdateJob", request_serializer=cloudscheduler.UpdateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -367,7 +453,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/DeleteJob", request_serializer=cloudscheduler.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -402,7 +488,7 @@ def pause_job(self) -> Callable[[cloudscheduler.PauseJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_job" not in self._stubs: - self._stubs["pause_job"] = self.grpc_channel.unary_unary( + self._stubs["pause_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/PauseJob", request_serializer=cloudscheduler.PauseJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -436,7 +522,7 @@ def resume_job(self) -> Callable[[cloudscheduler.ResumeJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_job" not in self._stubs: - self._stubs["resume_job"] = self.grpc_channel.unary_unary( + self._stubs["resume_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/ResumeJob", request_serializer=cloudscheduler.ResumeJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -463,7 +549,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/RunJob", request_serializer=cloudscheduler.RunJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -471,7 +557,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], job.Job]: return self._stubs["run_job"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -485,7 +571,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -502,7 +588,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc_asyncio.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc_asyncio.py index 6a82b75ae527..90a7ac3929c3 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc_asyncio.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.scheduler_v1.types import cloudscheduler from google.cloud.scheduler_v1.types import job @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport from .grpc import CloudSchedulerGrpcTransport +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.scheduler.v1.CloudScheduler", + "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.scheduler.v1.CloudScheduler", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudSchedulerGrpcAsyncIOTransport(CloudSchedulerTransport): """gRPC AsyncIO backend transport for CloudScheduler. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/ListJobs", request_serializer=cloudscheduler.ListJobsRequest.serialize, response_deserializer=cloudscheduler.ListJobsResponse.deserialize, @@ -292,7 +377,7 @@ def get_job(self) -> Callable[[cloudscheduler.GetJobRequest], Awaitable[job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/GetJob", request_serializer=cloudscheduler.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -318,7 +403,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/CreateJob", request_serializer=cloudscheduler.CreateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -355,7 +440,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/UpdateJob", request_serializer=cloudscheduler.UpdateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -381,7 +466,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/DeleteJob", request_serializer=cloudscheduler.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -418,7 +503,7 @@ def pause_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_job" not in self._stubs: - self._stubs["pause_job"] = self.grpc_channel.unary_unary( + self._stubs["pause_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/PauseJob", request_serializer=cloudscheduler.PauseJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -454,7 +539,7 @@ def resume_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_job" not in self._stubs: - self._stubs["resume_job"] = self.grpc_channel.unary_unary( + self._stubs["resume_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/ResumeJob", request_serializer=cloudscheduler.ResumeJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -481,7 +566,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], Awaitable[job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1.CloudScheduler/RunJob", request_serializer=cloudscheduler.RunJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -579,7 +664,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -597,7 +682,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -614,7 +699,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/rest.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/rest.py index 244503b3c2fa..69606bce4804 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/rest.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1/services/cloud_scheduler/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -133,8 +141,10 @@ def post_update_job(self, response): def pre_create_job( self, request: cloudscheduler.CreateJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.CreateJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -154,8 +164,10 @@ def post_create_job(self, response: gcs_job.Job) -> gcs_job.Job: def pre_delete_job( self, request: cloudscheduler.DeleteJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.DeleteJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -164,8 +176,10 @@ def pre_delete_job( return request, metadata def pre_get_job( - self, request: cloudscheduler.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudscheduler.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudscheduler.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -185,8 +199,8 @@ def post_get_job(self, response: job.Job) -> job.Job: def pre_list_jobs( self, request: cloudscheduler.ListJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.ListJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -208,8 +222,8 @@ def post_list_jobs( def pre_pause_job( self, request: cloudscheduler.PauseJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.PauseJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.PauseJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for pause_job Override in a subclass to manipulate the request or metadata @@ -229,8 +243,10 @@ def post_pause_job(self, response: job.Job) -> job.Job: def pre_resume_job( self, request: cloudscheduler.ResumeJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.ResumeJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.ResumeJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_job Override in a subclass to manipulate the request or metadata @@ -248,8 +264,10 @@ def post_resume_job(self, response: job.Job) -> job.Job: return response def pre_run_job( - self, request: cloudscheduler.RunJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudscheduler.RunJobRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudscheduler.RunJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.RunJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_job Override in a subclass to manipulate the request or metadata @@ -269,8 +287,10 @@ def post_run_job(self, response: job.Job) -> job.Job: def pre_update_job( self, request: cloudscheduler.UpdateJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.UpdateJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -290,8 +310,10 @@ def post_update_job(self, response: gcs_job.Job) -> gcs_job.Job: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -313,8 +335,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -456,7 +480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Call the create job method over HTTP. @@ -467,8 +491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_job.Job: @@ -481,6 +507,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseCreateJob._get_transcoded_request( @@ -501,6 +528,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.CreateJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._CreateJob._get_response( self._host, @@ -522,7 +576,29 @@ def __call__( pb_resp = gcs_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_job.Job.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.scheduler_v1.CloudSchedulerClient.create_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -559,7 +635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job method over HTTP. @@ -570,13 +646,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudSchedulerRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseDeleteJob._get_transcoded_request( @@ -591,6 +670,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.DeleteJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._DeleteJob._get_response( self._host, @@ -638,7 +744,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -649,8 +755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -663,6 +771,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseGetJob._get_transcoded_request( @@ -677,6 +786,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.GetJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._GetJob._get_response( self._host, @@ -697,7 +833,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1.CloudSchedulerClient.get_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs( @@ -734,7 +892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudscheduler.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -745,8 +903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloudscheduler.ListJobsResponse: @@ -758,6 +918,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseListJobs._get_transcoded_request( @@ -772,6 +933,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.ListJobs", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ListJobs._get_response( self._host, @@ -792,7 +980,29 @@ def __call__( pb_resp = cloudscheduler.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudscheduler.ListJobsResponse.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.scheduler_v1.CloudSchedulerClient.list_jobs", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseJob( @@ -830,7 +1040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the pause job method over HTTP. @@ -841,8 +1051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -855,6 +1067,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BasePauseJob._get_http_options() ) + request, metadata = self._interceptor.pre_pause_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BasePauseJob._get_transcoded_request( @@ -875,6 +1088,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.PauseJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "PauseJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._PauseJob._get_response( self._host, @@ -896,7 +1136,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1.CloudSchedulerClient.pause_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "PauseJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeJob( @@ -934,7 +1196,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the resume job method over HTTP. @@ -945,8 +1207,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -959,6 +1223,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseResumeJob._get_http_options() ) + request, metadata = self._interceptor.pre_resume_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseResumeJob._get_transcoded_request( @@ -979,6 +1244,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.ResumeJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ResumeJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ResumeJob._get_response( self._host, @@ -1000,7 +1292,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1.CloudSchedulerClient.resume_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ResumeJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunJob(_BaseCloudSchedulerRestTransport._BaseRunJob, CloudSchedulerRestStub): @@ -1036,7 +1350,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the run job method over HTTP. @@ -1047,8 +1361,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -1061,6 +1377,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseRunJob._get_http_options() ) + request, metadata = self._interceptor.pre_run_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseRunJob._get_transcoded_request( @@ -1079,6 +1396,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.RunJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "RunJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._RunJob._get_response( self._host, @@ -1100,7 +1444,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1.CloudSchedulerClient.run_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "RunJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob( @@ -1138,7 +1504,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Call the update job method over HTTP. @@ -1149,8 +1515,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_job.Job: @@ -1163,6 +1531,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseUpdateJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1183,6 +1552,33 @@ def __call__( ) ) + 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.scheduler_v1.CloudSchedulerClient.UpdateJob", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._UpdateJob._get_response( self._host, @@ -1204,7 +1600,29 @@ def __call__( pb_resp = gcs_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_job.Job.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.scheduler_v1.CloudSchedulerClient.update_job", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1297,7 +1715,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1307,8 +1725,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1317,6 +1737,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCloudSchedulerRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1327,6 +1748,33 @@ def __call__( 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.scheduler_v1.CloudSchedulerClient.GetLocation", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._GetLocation._get_response( self._host, @@ -1346,6 +1794,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.scheduler_v1.CloudSchedulerAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1386,7 +1855,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1396,8 +1865,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1406,6 +1877,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCloudSchedulerRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1416,6 +1888,33 @@ def __call__( 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.scheduler_v1.CloudSchedulerClient.ListLocations", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ListLocations._get_response( self._host, @@ -1435,6 +1934,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.scheduler_v1.CloudSchedulerAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.scheduler.v1.CloudScheduler", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/gapic_version.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/gapic_version.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/async_client.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/async_client.py index fa333b6faf4e..4f5c390fb599 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/async_client.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport from .transports.grpc_asyncio import CloudSchedulerGrpcAsyncIOTransport +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 CloudSchedulerAsyncClient: """The Cloud Scheduler API allows external entities to reliably @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.scheduler_v1beta1.CloudSchedulerAsyncClient`.", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "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.scheduler.v1beta1.CloudScheduler", + "credentialsType": None, + }, + ) + async def list_jobs( self, request: Optional[Union[cloudscheduler.ListJobsRequest, dict]] = None, @@ -274,7 +306,7 @@ async def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs. @@ -319,8 +351,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.scheduler_v1beta1.services.cloud_scheduler.pagers.ListJobsAsyncPager: @@ -395,7 +429,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets a job. @@ -439,8 +473,10 @@ async def sample_get_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -501,7 +537,7 @@ async def create_job( job: Optional[gcs_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Creates a job. @@ -559,8 +595,10 @@ async def sample_create_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -625,7 +663,7 @@ async def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Updates a job. @@ -691,8 +729,10 @@ async def sample_update_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -756,7 +796,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -797,8 +837,10 @@ async def sample_delete_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -850,7 +892,7 @@ async def pause_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Pauses a job. @@ -905,8 +947,10 @@ async def sample_pause_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -968,7 +1012,7 @@ async def resume_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Resume a job. @@ -1022,8 +1066,10 @@ async def sample_resume_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1085,7 +1131,7 @@ async def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Forces a job to run now. @@ -1132,8 +1178,10 @@ async def sample_run_job(): 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, 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1192,7 +1240,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1203,8 +1251,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1245,7 +1295,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1256,8 +1306,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/client.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/client.py index 3cf9ca3bf6f0..2c83170454b9 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/client.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -606,6 +616,10 @@ def __init__( # 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( @@ -671,6 +685,29 @@ def __init__( 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.scheduler_v1beta1.CloudSchedulerClient`.", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "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.scheduler.v1beta1.CloudScheduler", + "credentialsType": None, + }, + ) + def list_jobs( self, request: Optional[Union[cloudscheduler.ListJobsRequest, dict]] = None, @@ -678,7 +715,7 @@ def list_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists jobs. @@ -723,8 +760,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.services.cloud_scheduler.pagers.ListJobsPager: @@ -796,7 +835,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Gets a job. @@ -840,8 +879,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -901,7 +942,7 @@ def create_job( job: Optional[gcs_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Creates a job. @@ -959,8 +1000,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1022,7 +1065,7 @@ def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Updates a job. @@ -1088,8 +1131,10 @@ def sample_update_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1150,7 +1195,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a job. @@ -1191,8 +1236,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1241,7 +1288,7 @@ def pause_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Pauses a job. @@ -1296,8 +1343,10 @@ def sample_pause_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1356,7 +1405,7 @@ def resume_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Resume a job. @@ -1410,8 +1459,10 @@ def sample_resume_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1470,7 +1521,7 @@ def run_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Forces a job to run now. @@ -1517,8 +1568,10 @@ def sample_run_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.scheduler_v1beta1.types.Job: @@ -1589,7 +1642,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1600,8 +1653,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1642,7 +1697,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1653,8 +1708,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/pagers.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/pagers.py index 8fd1700fdede..4d9339ca5ec3 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/pagers.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloudscheduler.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloudscheduler.ListJobsRequest(request) diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc.py index 2886b7802c1b..3e0e343b64c9 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.scheduler_v1beta1.types import cloudscheduler from google.cloud.scheduler_v1beta1.types import job @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport +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.scheduler.v1beta1.CloudScheduler", + "rpcName": 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.scheduler.v1beta1.CloudScheduler", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudSchedulerGrpcTransport(CloudSchedulerTransport): """gRPC backend transport for CloudScheduler. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/ListJobs", request_serializer=cloudscheduler.ListJobsRequest.serialize, response_deserializer=cloudscheduler.ListJobsResponse.deserialize, @@ -282,7 +368,7 @@ def get_job(self) -> Callable[[cloudscheduler.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/GetJob", request_serializer=cloudscheduler.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -306,7 +392,7 @@ def create_job(self) -> Callable[[cloudscheduler.CreateJobRequest], gcs_job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/CreateJob", request_serializer=cloudscheduler.CreateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -341,7 +427,7 @@ def update_job(self) -> Callable[[cloudscheduler.UpdateJobRequest], gcs_job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/UpdateJob", request_serializer=cloudscheduler.UpdateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -367,7 +453,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/DeleteJob", request_serializer=cloudscheduler.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -402,7 +488,7 @@ def pause_job(self) -> Callable[[cloudscheduler.PauseJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_job" not in self._stubs: - self._stubs["pause_job"] = self.grpc_channel.unary_unary( + self._stubs["pause_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/PauseJob", request_serializer=cloudscheduler.PauseJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -436,7 +522,7 @@ def resume_job(self) -> Callable[[cloudscheduler.ResumeJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_job" not in self._stubs: - self._stubs["resume_job"] = self.grpc_channel.unary_unary( + self._stubs["resume_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/ResumeJob", request_serializer=cloudscheduler.ResumeJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -463,7 +549,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/RunJob", request_serializer=cloudscheduler.RunJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -471,7 +557,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], job.Job]: return self._stubs["run_job"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -485,7 +571,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -502,7 +588,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc_asyncio.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc_asyncio.py index 524f37ae65e4..e13e731f3217 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc_asyncio.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.scheduler_v1beta1.types import cloudscheduler from google.cloud.scheduler_v1beta1.types import job @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, CloudSchedulerTransport from .grpc import CloudSchedulerGrpcTransport +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.scheduler.v1beta1.CloudScheduler", + "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.scheduler.v1beta1.CloudScheduler", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudSchedulerGrpcAsyncIOTransport(CloudSchedulerTransport): """gRPC AsyncIO backend transport for CloudScheduler. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/ListJobs", request_serializer=cloudscheduler.ListJobsRequest.serialize, response_deserializer=cloudscheduler.ListJobsResponse.deserialize, @@ -292,7 +377,7 @@ def get_job(self) -> Callable[[cloudscheduler.GetJobRequest], Awaitable[job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/GetJob", request_serializer=cloudscheduler.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -318,7 +403,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/CreateJob", request_serializer=cloudscheduler.CreateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -355,7 +440,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/UpdateJob", request_serializer=cloudscheduler.UpdateJobRequest.serialize, response_deserializer=gcs_job.Job.deserialize, @@ -381,7 +466,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/DeleteJob", request_serializer=cloudscheduler.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -418,7 +503,7 @@ def pause_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_job" not in self._stubs: - self._stubs["pause_job"] = self.grpc_channel.unary_unary( + self._stubs["pause_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/PauseJob", request_serializer=cloudscheduler.PauseJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -454,7 +539,7 @@ def resume_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_job" not in self._stubs: - self._stubs["resume_job"] = self.grpc_channel.unary_unary( + self._stubs["resume_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/ResumeJob", request_serializer=cloudscheduler.ResumeJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -481,7 +566,7 @@ def run_job(self) -> Callable[[cloudscheduler.RunJobRequest], Awaitable[job.Job] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_job" not in self._stubs: - self._stubs["run_job"] = self.grpc_channel.unary_unary( + self._stubs["run_job"] = self._logged_channel.unary_unary( "/google.cloud.scheduler.v1beta1.CloudScheduler/RunJob", request_serializer=cloudscheduler.RunJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -599,7 +684,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -617,7 +702,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -634,7 +719,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/rest.py b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/rest.py index 2b7a72b5cb54..197c0e5f2d3e 100644 --- a/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/rest.py +++ b/packages/google-cloud-scheduler/google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -133,8 +141,10 @@ def post_update_job(self, response): def pre_create_job( self, request: cloudscheduler.CreateJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.CreateJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -154,8 +164,10 @@ def post_create_job(self, response: gcs_job.Job) -> gcs_job.Job: def pre_delete_job( self, request: cloudscheduler.DeleteJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.DeleteJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -164,8 +176,10 @@ def pre_delete_job( return request, metadata def pre_get_job( - self, request: cloudscheduler.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudscheduler.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudscheduler.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -185,8 +199,8 @@ def post_get_job(self, response: job.Job) -> job.Job: def pre_list_jobs( self, request: cloudscheduler.ListJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.ListJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -208,8 +222,8 @@ def post_list_jobs( def pre_pause_job( self, request: cloudscheduler.PauseJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.PauseJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.PauseJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for pause_job Override in a subclass to manipulate the request or metadata @@ -229,8 +243,10 @@ def post_pause_job(self, response: job.Job) -> job.Job: def pre_resume_job( self, request: cloudscheduler.ResumeJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.ResumeJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.ResumeJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_job Override in a subclass to manipulate the request or metadata @@ -248,8 +264,10 @@ def post_resume_job(self, response: job.Job) -> job.Job: return response def pre_run_job( - self, request: cloudscheduler.RunJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudscheduler.RunJobRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudscheduler.RunJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudscheduler.RunJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_job Override in a subclass to manipulate the request or metadata @@ -269,8 +287,10 @@ def post_run_job(self, response: job.Job) -> job.Job: def pre_update_job( self, request: cloudscheduler.UpdateJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudscheduler.UpdateJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudscheduler.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -290,8 +310,10 @@ def post_update_job(self, response: gcs_job.Job) -> gcs_job.Job: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -313,8 +335,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -456,7 +480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Call the create job method over HTTP. @@ -467,8 +491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_job.Job: @@ -481,6 +507,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseCreateJob._get_transcoded_request( @@ -501,6 +528,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.CreateJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._CreateJob._get_response( self._host, @@ -522,7 +576,29 @@ def __call__( pb_resp = gcs_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_job.Job.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.scheduler_v1beta1.CloudSchedulerClient.create_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -559,7 +635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job method over HTTP. @@ -570,13 +646,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudSchedulerRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseDeleteJob._get_transcoded_request( @@ -591,6 +670,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.DeleteJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._DeleteJob._get_response( self._host, @@ -638,7 +744,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -649,8 +755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -663,6 +771,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseGetJob._get_transcoded_request( @@ -677,6 +786,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.GetJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._GetJob._get_response( self._host, @@ -697,7 +833,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1beta1.CloudSchedulerClient.get_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs( @@ -734,7 +892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudscheduler.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -745,8 +903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloudscheduler.ListJobsResponse: @@ -758,6 +918,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseListJobs._get_transcoded_request( @@ -772,6 +933,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.ListJobs", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ListJobs._get_response( self._host, @@ -792,7 +980,29 @@ def __call__( pb_resp = cloudscheduler.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudscheduler.ListJobsResponse.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.scheduler_v1beta1.CloudSchedulerClient.list_jobs", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseJob( @@ -830,7 +1040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the pause job method over HTTP. @@ -841,8 +1051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -855,6 +1067,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BasePauseJob._get_http_options() ) + request, metadata = self._interceptor.pre_pause_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BasePauseJob._get_transcoded_request( @@ -875,6 +1088,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.PauseJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "PauseJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._PauseJob._get_response( self._host, @@ -896,7 +1136,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1beta1.CloudSchedulerClient.pause_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "PauseJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeJob( @@ -934,7 +1196,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the resume job method over HTTP. @@ -945,8 +1207,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -959,6 +1223,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseResumeJob._get_http_options() ) + request, metadata = self._interceptor.pre_resume_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseResumeJob._get_transcoded_request( @@ -979,6 +1244,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.ResumeJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ResumeJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ResumeJob._get_response( self._host, @@ -1000,7 +1292,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1beta1.CloudSchedulerClient.resume_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ResumeJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunJob(_BaseCloudSchedulerRestTransport._BaseRunJob, CloudSchedulerRestStub): @@ -1036,7 +1350,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the run job method over HTTP. @@ -1047,8 +1361,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -1061,6 +1377,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseRunJob._get_http_options() ) + request, metadata = self._interceptor.pre_run_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseRunJob._get_transcoded_request( @@ -1079,6 +1396,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.RunJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "RunJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._RunJob._get_response( self._host, @@ -1100,7 +1444,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.scheduler_v1beta1.CloudSchedulerClient.run_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "RunJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob( @@ -1138,7 +1504,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_job.Job: r"""Call the update job method over HTTP. @@ -1149,8 +1515,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_job.Job: @@ -1163,6 +1531,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseUpdateJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseCloudSchedulerRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1183,6 +1552,33 @@ def __call__( ) ) + 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.scheduler_v1beta1.CloudSchedulerClient.UpdateJob", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._UpdateJob._get_response( self._host, @@ -1204,7 +1600,29 @@ def __call__( pb_resp = gcs_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_job.Job.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.scheduler_v1beta1.CloudSchedulerClient.update_job", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1297,7 +1715,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1307,8 +1725,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1317,6 +1737,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCloudSchedulerRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1327,6 +1748,33 @@ def __call__( 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.scheduler_v1beta1.CloudSchedulerClient.GetLocation", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._GetLocation._get_response( self._host, @@ -1346,6 +1794,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.scheduler_v1beta1.CloudSchedulerAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1386,7 +1855,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1396,8 +1865,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1406,6 +1877,7 @@ def __call__( http_options = ( _BaseCloudSchedulerRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCloudSchedulerRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1416,6 +1888,33 @@ def __call__( 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.scheduler_v1beta1.CloudSchedulerClient.ListLocations", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudSchedulerRestTransport._ListLocations._get_response( self._host, @@ -1435,6 +1934,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.scheduler_v1beta1.CloudSchedulerAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.scheduler.v1beta1.CloudScheduler", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1.json b/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1.json index 11f7d97ae79a..150f660ac6a2 100644 --- a/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1.json +++ b/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-scheduler", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsPager", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1.types.Job", diff --git a/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1beta1.json b/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1beta1.json index 8ec70ad7ec44..579bee0411e1 100644 --- a/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1beta1.json +++ b/packages/google-cloud-scheduler/samples/generated_samples/snippet_metadata_google.cloud.scheduler.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-scheduler", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.services.cloud_scheduler.pagers.ListJobsAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.services.cloud_scheduler.pagers.ListJobsPager", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.scheduler_v1beta1.types.Job", diff --git a/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py b/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py index 5cadbd06cb96..d3ba6b692818 100644 --- a/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py +++ b/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py @@ -4016,6 +4016,7 @@ def test_list_jobs_rest_required_fields(request_type=cloudscheduler.ListJobsRequ response_value._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_jobs(request) @@ -4069,6 +4070,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -4258,6 +4260,7 @@ def test_get_job_rest_required_fields(request_type=cloudscheduler.GetJobRequest) response_value._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_job(request) @@ -4303,6 +4306,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4432,6 +4436,7 @@ def test_create_job_rest_required_fields(request_type=cloudscheduler.CreateJobRe response_value._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_job(request) @@ -4486,6 +4491,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4613,6 +4619,7 @@ def test_update_job_rest_required_fields(request_type=cloudscheduler.UpdateJobRe response_value._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_job(request) @@ -4661,6 +4668,7 @@ def test_update_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4787,6 +4795,7 @@ def test_delete_job_rest_required_fields(request_type=cloudscheduler.DeleteJobRe response_value._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_job(request) @@ -4830,6 +4839,7 @@ def test_delete_job_rest_flattened(): 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"} client.delete_job(**mock_args) @@ -4959,6 +4969,7 @@ def test_pause_job_rest_required_fields(request_type=cloudscheduler.PauseJobRequ response_value._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.pause_job(request) @@ -5004,6 +5015,7 @@ def test_pause_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_job(**mock_args) @@ -5133,6 +5145,7 @@ def test_resume_job_rest_required_fields(request_type=cloudscheduler.ResumeJobRe response_value._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.resume_job(request) @@ -5178,6 +5191,7 @@ def test_resume_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_job(**mock_args) @@ -5308,6 +5322,7 @@ def test_run_job_rest_required_fields(request_type=cloudscheduler.RunJobRequest) response_value._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.run_job(request) @@ -5353,6 +5368,7 @@ def test_run_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_job(**mock_args) @@ -5931,6 +5947,7 @@ def test_list_jobs_rest_bad_request(request_type=cloudscheduler.ListJobsRequest) 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_jobs(request) @@ -5966,6 +5983,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -6004,6 +6022,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = cloudscheduler.ListJobsResponse.to_json( cloudscheduler.ListJobsResponse() ) @@ -6048,6 +6067,7 @@ def test_get_job_rest_bad_request(request_type=cloudscheduler.GetJobRequest): 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_job(request) @@ -6087,6 +6107,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6129,6 +6150,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -6171,6 +6193,7 @@ def test_create_job_rest_bad_request(request_type=cloudscheduler.CreateJobReques 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_job(request) @@ -6336,6 +6359,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6380,6 +6404,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 = gcs_job.Job.to_json(gcs_job.Job()) req.return_value.content = return_value @@ -6422,6 +6447,7 @@ def test_update_job_rest_bad_request(request_type=cloudscheduler.UpdateJobReques 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_job(request) @@ -6587,6 +6613,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6631,6 +6658,7 @@ def test_update_job_rest_interceptors(null_interceptor): 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 = gcs_job.Job.to_json(gcs_job.Job()) req.return_value.content = return_value @@ -6673,6 +6701,7 @@ def test_delete_job_rest_bad_request(request_type=cloudscheduler.DeleteJobReques 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_job(request) @@ -6703,6 +6732,7 @@ def test_delete_job_rest_call_success(request_type): 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_job(request) # Establish that the response is the type that we expect. @@ -6739,6 +6769,7 @@ def test_delete_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudscheduler.DeleteJobRequest() metadata = [ @@ -6777,6 +6808,7 @@ def test_pause_job_rest_bad_request(request_type=cloudscheduler.PauseJobRequest) 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.pause_job(request) @@ -6816,6 +6848,7 @@ def test_pause_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_job(request) # Establish that the response is the type that we expect. @@ -6858,6 +6891,7 @@ def test_pause_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -6900,6 +6934,7 @@ def test_resume_job_rest_bad_request(request_type=cloudscheduler.ResumeJobReques 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.resume_job(request) @@ -6939,6 +6974,7 @@ def test_resume_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_job(request) # Establish that the response is the type that we expect. @@ -6983,6 +7019,7 @@ def test_resume_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -7025,6 +7062,7 @@ def test_run_job_rest_bad_request(request_type=cloudscheduler.RunJobRequest): 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.run_job(request) @@ -7064,6 +7102,7 @@ def test_run_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_job(request) # Establish that the response is the type that we expect. @@ -7106,6 +7145,7 @@ def test_run_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -7150,6 +7190,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -7180,6 +7221,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -7208,6 +7250,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -7238,6 +7281,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py b/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py index 87ff72d780ea..d7837853eb7c 100644 --- a/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py +++ b/packages/google-cloud-scheduler/tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py @@ -4044,6 +4044,7 @@ def test_list_jobs_rest_required_fields(request_type=cloudscheduler.ListJobsRequ response_value._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_jobs(request) @@ -4099,6 +4100,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -4288,6 +4290,7 @@ def test_get_job_rest_required_fields(request_type=cloudscheduler.GetJobRequest) response_value._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_job(request) @@ -4333,6 +4336,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4462,6 +4466,7 @@ def test_create_job_rest_required_fields(request_type=cloudscheduler.CreateJobRe response_value._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_job(request) @@ -4516,6 +4521,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4643,6 +4649,7 @@ def test_update_job_rest_required_fields(request_type=cloudscheduler.UpdateJobRe response_value._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_job(request) @@ -4691,6 +4698,7 @@ def test_update_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4820,6 +4828,7 @@ def test_delete_job_rest_required_fields(request_type=cloudscheduler.DeleteJobRe response_value._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_job(request) @@ -4863,6 +4872,7 @@ def test_delete_job_rest_flattened(): 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"} client.delete_job(**mock_args) @@ -4992,6 +5002,7 @@ def test_pause_job_rest_required_fields(request_type=cloudscheduler.PauseJobRequ response_value._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.pause_job(request) @@ -5037,6 +5048,7 @@ def test_pause_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_job(**mock_args) @@ -5167,6 +5179,7 @@ def test_resume_job_rest_required_fields(request_type=cloudscheduler.ResumeJobRe response_value._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.resume_job(request) @@ -5212,6 +5225,7 @@ def test_resume_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_job(**mock_args) @@ -5342,6 +5356,7 @@ def test_run_job_rest_required_fields(request_type=cloudscheduler.RunJobRequest) response_value._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.run_job(request) @@ -5387,6 +5402,7 @@ def test_run_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_job(**mock_args) @@ -5972,6 +5988,7 @@ def test_list_jobs_rest_bad_request(request_type=cloudscheduler.ListJobsRequest) 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_jobs(request) @@ -6007,6 +6024,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -6045,6 +6063,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = cloudscheduler.ListJobsResponse.to_json( cloudscheduler.ListJobsResponse() ) @@ -6089,6 +6108,7 @@ def test_get_job_rest_bad_request(request_type=cloudscheduler.GetJobRequest): 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_job(request) @@ -6129,6 +6149,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6172,6 +6193,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -6214,6 +6236,7 @@ def test_create_job_rest_bad_request(request_type=cloudscheduler.CreateJobReques 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_job(request) @@ -6381,6 +6404,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6426,6 +6450,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 = gcs_job.Job.to_json(gcs_job.Job()) req.return_value.content = return_value @@ -6468,6 +6493,7 @@ def test_update_job_rest_bad_request(request_type=cloudscheduler.UpdateJobReques 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_job(request) @@ -6635,6 +6661,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -6680,6 +6707,7 @@ def test_update_job_rest_interceptors(null_interceptor): 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 = gcs_job.Job.to_json(gcs_job.Job()) req.return_value.content = return_value @@ -6722,6 +6750,7 @@ def test_delete_job_rest_bad_request(request_type=cloudscheduler.DeleteJobReques 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_job(request) @@ -6752,6 +6781,7 @@ def test_delete_job_rest_call_success(request_type): 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_job(request) # Establish that the response is the type that we expect. @@ -6788,6 +6818,7 @@ def test_delete_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudscheduler.DeleteJobRequest() metadata = [ @@ -6826,6 +6857,7 @@ def test_pause_job_rest_bad_request(request_type=cloudscheduler.PauseJobRequest) 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.pause_job(request) @@ -6866,6 +6898,7 @@ def test_pause_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_job(request) # Establish that the response is the type that we expect. @@ -6909,6 +6942,7 @@ def test_pause_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -6951,6 +6985,7 @@ def test_resume_job_rest_bad_request(request_type=cloudscheduler.ResumeJobReques 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.resume_job(request) @@ -6991,6 +7026,7 @@ def test_resume_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_job(request) # Establish that the response is the type that we expect. @@ -7036,6 +7072,7 @@ def test_resume_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -7078,6 +7115,7 @@ def test_run_job_rest_bad_request(request_type=cloudscheduler.RunJobRequest): 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.run_job(request) @@ -7118,6 +7156,7 @@ def test_run_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_job(request) # Establish that the response is the type that we expect. @@ -7161,6 +7200,7 @@ def test_run_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -7205,6 +7245,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -7235,6 +7276,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -7263,6 +7305,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -7293,6 +7336,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager/gapic_version.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager/gapic_version.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/gapic_version.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/gapic_version.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py index ed1fc15fc70a..575a885113d0 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .transports.grpc_asyncio import SecretManagerServiceGrpcAsyncIOTransport +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 SecretManagerServiceAsyncClient: """Secret Manager Service @@ -278,6 +288,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.secretmanager_v1.SecretManagerServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "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.secretmanager.v1.SecretManagerService", + "credentialsType": None, + }, + ) + async def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -285,7 +317,7 @@ async def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsAsyncPager: r"""Lists [Secrets][google.cloud.secretmanager.v1.Secret]. @@ -332,8 +364,10 @@ async def sample_list_secrets(): 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, 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: google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretsAsyncPager: @@ -410,7 +444,7 @@ async def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no @@ -478,8 +512,10 @@ async def sample_create_secret(): 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, 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: google.cloud.secretmanager_v1.types.Secret: @@ -550,7 +586,7 @@ async def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] @@ -608,8 +644,10 @@ async def sample_add_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -672,7 +710,7 @@ async def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. @@ -719,8 +757,10 @@ async def sample_get_secret(): 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, 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: google.cloud.secretmanager_v1.types.Secret: @@ -787,7 +827,7 @@ async def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. @@ -838,8 +878,10 @@ async def sample_update_secret(): 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, 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: google.cloud.secretmanager_v1.types.Secret: @@ -909,7 +951,7 @@ async def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. @@ -951,8 +993,10 @@ async def sample_delete_secret(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1004,7 +1048,7 @@ async def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsAsyncPager: r"""Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. @@ -1055,8 +1099,10 @@ async def sample_list_secret_versions(): 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, 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: google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager: @@ -1131,7 +1177,7 @@ async def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1187,8 +1233,10 @@ async def sample_get_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1249,7 +1297,7 @@ async def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1306,8 +1354,10 @@ async def sample_access_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.AccessSecretVersionResponse: @@ -1368,7 +1418,7 @@ async def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1422,8 +1472,10 @@ async def sample_disable_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1484,7 +1536,7 @@ async def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1538,8 +1590,10 @@ async def sample_enable_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1600,7 +1654,7 @@ async def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1655,8 +1709,10 @@ async def sample_destroy_secret_version(): 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, 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1716,7 +1772,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -1759,8 +1815,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1836,7 +1894,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -1875,8 +1933,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1952,7 +2012,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -1997,8 +2057,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2044,7 +2106,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2055,8 +2117,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2097,7 +2161,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2108,8 +2172,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py index 6e677792bf85..ff51c2e75ee8 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -630,6 +640,10 @@ def __init__( # 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( @@ -696,6 +710,29 @@ def __init__( 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.secretmanager_v1.SecretManagerServiceClient`.", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "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.secretmanager.v1.SecretManagerService", + "credentialsType": None, + }, + ) + def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -703,7 +740,7 @@ def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsPager: r"""Lists [Secrets][google.cloud.secretmanager.v1.Secret]. @@ -750,8 +787,10 @@ def sample_list_secrets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretsPager: @@ -825,7 +864,7 @@ def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no @@ -893,8 +932,10 @@ def sample_create_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.Secret: @@ -962,7 +1003,7 @@ def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] @@ -1020,8 +1061,10 @@ def sample_add_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1081,7 +1124,7 @@ def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. @@ -1128,8 +1171,10 @@ def sample_get_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.Secret: @@ -1193,7 +1238,7 @@ def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. @@ -1244,8 +1289,10 @@ def sample_update_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.Secret: @@ -1312,7 +1359,7 @@ def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. @@ -1354,8 +1401,10 @@ def sample_delete_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1404,7 +1453,7 @@ def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsPager: r"""Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. @@ -1455,8 +1504,10 @@ def sample_list_secret_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretVersionsPager: @@ -1528,7 +1579,7 @@ def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1584,8 +1635,10 @@ def sample_get_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1643,7 +1696,7 @@ def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1700,8 +1753,10 @@ def sample_access_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.AccessSecretVersionResponse: @@ -1759,7 +1814,7 @@ def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1813,8 +1868,10 @@ def sample_disable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1872,7 +1929,7 @@ def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -1926,8 +1983,10 @@ def sample_enable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -1985,7 +2044,7 @@ def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -2040,8 +2099,10 @@ def sample_destroy_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1.types.SecretVersion: @@ -2098,7 +2159,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -2141,8 +2202,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2217,7 +2280,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -2256,8 +2319,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2332,7 +2397,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -2377,8 +2442,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2436,7 +2503,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2447,8 +2514,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2489,7 +2558,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2500,8 +2569,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/pagers.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/pagers.py index 7c016caca6f4..7662748b8140 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/pagers.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py index 49a23de022d2..39417529a2bc 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport +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.secretmanager.v1.SecretManagerService", + "rpcName": 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.secretmanager.v1.SecretManagerService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcTransport(SecretManagerServiceTransport): """gRPC backend transport for SecretManagerService. @@ -189,7 +270,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -291,7 +377,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -320,7 +406,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -345,7 +431,7 @@ def get_secret(self) -> Callable[[service.GetSecretRequest], resources.Secret]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -372,7 +458,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -396,7 +482,7 @@ def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty_pb2.Emp # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -426,7 +512,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -457,7 +543,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -491,7 +577,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -524,7 +610,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -557,7 +643,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -591,7 +677,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -623,7 +709,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -651,7 +737,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -687,7 +773,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -695,7 +781,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -709,7 +795,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -726,7 +812,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py index d6482dc5153c..c06c292e9a15 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .grpc import SecretManagerServiceGrpcTransport +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.secretmanager.v1.SecretManagerService", + "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.secretmanager.v1.SecretManagerService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcAsyncIOTransport(SecretManagerServiceTransport): """gRPC AsyncIO backend transport for SecretManagerService. @@ -236,10 +318,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -299,7 +384,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -330,7 +415,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -357,7 +442,7 @@ def get_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -384,7 +469,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -410,7 +495,7 @@ def delete_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -441,7 +526,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -474,7 +559,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -509,7 +594,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -544,7 +629,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -579,7 +664,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -615,7 +700,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -647,7 +732,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -675,7 +760,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -711,7 +796,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -824,7 +909,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -842,7 +927,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -859,7 +944,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/rest.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/rest.py index 879d137cfc54..ecb623152afa 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/rest.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -189,8 +197,10 @@ def post_update_secret(self, response): def pre_access_secret_version( self, request: service.AccessSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AccessSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AccessSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for access_secret_version Override in a subclass to manipulate the request or metadata @@ -212,8 +222,10 @@ def post_access_secret_version( def pre_add_secret_version( self, request: service.AddSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AddSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AddSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_secret_version Override in a subclass to manipulate the request or metadata @@ -233,8 +245,10 @@ def post_add_secret_version( return response def pre_create_secret( - self, request: service.CreateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_secret Override in a subclass to manipulate the request or metadata @@ -252,8 +266,10 @@ def post_create_secret(self, response: resources.Secret) -> resources.Secret: return response def pre_delete_secret( - self, request: service.DeleteSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_secret Override in a subclass to manipulate the request or metadata @@ -264,8 +280,10 @@ def pre_delete_secret( def pre_destroy_secret_version( self, request: service.DestroySecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DestroySecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DestroySecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for destroy_secret_version Override in a subclass to manipulate the request or metadata @@ -287,8 +305,10 @@ def post_destroy_secret_version( def pre_disable_secret_version( self, request: service.DisableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DisableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DisableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_secret_version Override in a subclass to manipulate the request or metadata @@ -310,8 +330,10 @@ def post_disable_secret_version( def pre_enable_secret_version( self, request: service.EnableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EnableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EnableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_secret_version Override in a subclass to manipulate the request or metadata @@ -333,8 +355,10 @@ def post_enable_secret_version( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -352,8 +376,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_secret( - self, request: service.GetSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_secret Override in a subclass to manipulate the request or metadata @@ -373,8 +399,10 @@ def post_get_secret(self, response: resources.Secret) -> resources.Secret: def pre_get_secret_version( self, request: service.GetSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_secret_version Override in a subclass to manipulate the request or metadata @@ -394,8 +422,10 @@ def post_get_secret_version( return response def pre_list_secrets( - self, request: service.ListSecretsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListSecretsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_secrets Override in a subclass to manipulate the request or metadata @@ -417,8 +447,10 @@ def post_list_secrets( def pre_list_secret_versions( self, request: service.ListSecretVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSecretVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSecretVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_secret_versions Override in a subclass to manipulate the request or metadata @@ -440,8 +472,10 @@ def post_list_secret_versions( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -461,8 +495,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -482,8 +519,10 @@ def post_test_iam_permissions( return response def pre_update_secret( - self, request: service.UpdateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_secret Override in a subclass to manipulate the request or metadata @@ -503,8 +542,10 @@ def post_update_secret(self, response: resources.Secret) -> resources.Secret: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -526,8 +567,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -674,7 +717,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Call the access secret version method over HTTP. @@ -685,8 +728,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.AccessSecretVersionResponse: @@ -698,6 +743,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAccessSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_access_secret_version( request, metadata ) @@ -710,6 +756,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.AccessSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "AccessSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AccessSecretVersion._get_response( @@ -732,7 +805,31 @@ def __call__( pb_resp = service.AccessSecretVersionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_access_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.AccessSecretVersionResponse.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.secretmanager_v1.SecretManagerServiceClient.access_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "AccessSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddSecretVersion( @@ -771,7 +868,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the add secret version method over HTTP. @@ -782,8 +879,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -795,6 +894,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAddSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_add_secret_version( request, metadata ) @@ -811,6 +911,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.AddSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "AddSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AddSecretVersion._get_response( @@ -834,7 +961,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1.SecretManagerServiceClient.add_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "AddSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecret( @@ -873,7 +1022,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the create secret method over HTTP. @@ -884,8 +1033,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -902,6 +1053,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_create_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_transcoded_request( http_options, request @@ -916,6 +1068,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.CreateSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "CreateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._CreateSecret._get_response( self._host, @@ -937,7 +1116,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1.SecretManagerServiceClient.create_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "CreateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSecret( @@ -975,7 +1176,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete secret method over HTTP. @@ -986,13 +1187,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_http_options() ) + request, metadata = self._interceptor.pre_delete_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_transcoded_request( http_options, request @@ -1003,6 +1207,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.DeleteSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "DeleteSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._DeleteSecret._get_response( self._host, @@ -1054,7 +1285,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the destroy secret version method over HTTP. @@ -1065,8 +1296,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1078,6 +1311,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDestroySecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_destroy_secret_version( request, metadata ) @@ -1094,6 +1328,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.DestroySecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "DestroySecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DestroySecretVersion._get_response( @@ -1117,7 +1378,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_destroy_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1.SecretManagerServiceClient.destroy_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "DestroySecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableSecretVersion( @@ -1156,7 +1439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the disable secret version method over HTTP. @@ -1167,8 +1450,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1180,6 +1465,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDisableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_disable_secret_version( request, metadata ) @@ -1196,6 +1482,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.DisableSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "DisableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DisableSecretVersion._get_response( @@ -1219,7 +1532,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1.SecretManagerServiceClient.disable_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "DisableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableSecretVersion( @@ -1258,7 +1593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the enable secret version method over HTTP. @@ -1269,8 +1604,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1282,6 +1619,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseEnableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_enable_secret_version( request, metadata ) @@ -1298,6 +1636,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.EnableSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "EnableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._EnableSecretVersion._get_response( @@ -1321,7 +1686,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1.SecretManagerServiceClient.enable_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "EnableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1359,7 +1746,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1369,8 +1756,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1455,6 +1844,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1465,6 +1855,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1485,7 +1902,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.secretmanager_v1.SecretManagerServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecret( @@ -1523,7 +1962,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the get secret method over HTTP. @@ -1534,8 +1973,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -1552,6 +1993,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_transcoded_request( http_options, request @@ -1562,6 +2004,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.GetSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetSecret._get_response( self._host, @@ -1582,7 +2051,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1.SecretManagerServiceClient.get_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecretVersion( @@ -1620,7 +2111,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the get secret version method over HTTP. @@ -1631,8 +2122,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1644,6 +2137,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret_version( request, metadata ) @@ -1656,6 +2150,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.GetSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._GetSecretVersion._get_response( @@ -1678,7 +2199,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1.SecretManagerServiceClient.get_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecrets( @@ -1716,7 +2259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretsResponse: r"""Call the list secrets method over HTTP. @@ -1727,8 +2270,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretsResponse: @@ -1740,6 +2285,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_secrets(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_transcoded_request( http_options, request @@ -1750,6 +2296,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.ListSecrets", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._ListSecrets._get_response( self._host, @@ -1770,7 +2343,29 @@ def __call__( pb_resp = service.ListSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretsResponse.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.secretmanager_v1.SecretManagerServiceClient.list_secrets", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecretVersions( @@ -1808,7 +2403,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretVersionsResponse: r"""Call the list secret versions method over HTTP. @@ -1819,8 +2414,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretVersionsResponse: @@ -1832,6 +2429,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecretVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_secret_versions( request, metadata ) @@ -1844,6 +2442,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.ListSecretVersions", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListSecretVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._ListSecretVersions._get_response( @@ -1866,7 +2491,31 @@ def __call__( pb_resp = service.ListSecretVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secret_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretVersionsResponse.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.secretmanager_v1.SecretManagerServiceClient.list_secret_versions", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListSecretVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1905,7 +2554,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1915,8 +2564,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2001,6 +2652,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2015,6 +2667,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -2036,7 +2715,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.secretmanager_v1.SecretManagerServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2075,7 +2776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2085,8 +2786,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2096,6 +2799,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2112,6 +2816,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._TestIamPermissions._get_response( @@ -2135,7 +2866,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.secretmanager_v1.SecretManagerServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecret( @@ -2174,7 +2927,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the update secret method over HTTP. @@ -2185,8 +2938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -2203,6 +2958,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_update_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_transcoded_request( http_options, request @@ -2217,6 +2973,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.UpdateSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "UpdateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._UpdateSecret._get_response( self._host, @@ -2238,7 +3021,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1.SecretManagerServiceClient.update_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "UpdateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2403,7 +3208,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2413,8 +3218,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2423,6 +3230,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2433,6 +3241,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetLocation._get_response( self._host, @@ -2452,6 +3287,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.secretmanager_v1.SecretManagerServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2493,7 +3349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2503,8 +3359,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2513,6 +3371,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2523,6 +3382,33 @@ def __call__( 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.secretmanager_v1.SecretManagerServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._ListLocations._get_response( self._host, @@ -2542,6 +3428,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.secretmanager_v1.SecretManagerServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.secretmanager.v1.SecretManagerService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/gapic_version.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/gapic_version.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py index 395a32437652..c442a84f7783 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .transports.grpc_asyncio import SecretManagerServiceGrpcAsyncIOTransport +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 SecretManagerServiceAsyncClient: """Secret Manager Service @@ -274,6 +284,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.secrets_v1beta1.SecretManagerServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "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.secrets.v1beta1.SecretManagerService", + "credentialsType": None, + }, + ) + async def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -281,7 +313,7 @@ async def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsAsyncPager: r"""Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. @@ -327,8 +359,10 @@ async def sample_list_secrets(): 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, 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: google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsAsyncPager: @@ -405,7 +439,7 @@ async def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no @@ -472,8 +506,10 @@ async def sample_create_secret(): 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, 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -544,7 +580,7 @@ async def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] @@ -601,8 +637,10 @@ async def sample_add_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -665,7 +703,7 @@ async def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -711,8 +749,10 @@ async def sample_get_secret(): 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, 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -779,7 +819,7 @@ async def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -830,8 +870,10 @@ async def sample_update_secret(): 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, 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -901,7 +943,7 @@ async def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -943,8 +985,10 @@ async def sample_delete_secret(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -996,7 +1040,7 @@ async def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsAsyncPager: r"""Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1046,8 +1090,10 @@ async def sample_list_secret_versions(): 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, 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: google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager: @@ -1122,7 +1168,7 @@ async def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1175,8 +1221,10 @@ async def sample_get_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1237,7 +1285,7 @@ async def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1288,8 +1336,10 @@ async def sample_access_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse: @@ -1350,7 +1400,7 @@ async def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1402,8 +1452,10 @@ async def sample_disable_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1464,7 +1516,7 @@ async def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1516,8 +1568,10 @@ async def sample_enable_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1578,7 +1632,7 @@ async def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1631,8 +1685,10 @@ async def sample_destroy_secret_version(): 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, 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1692,7 +1748,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -1735,8 +1791,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1812,7 +1870,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -1851,8 +1909,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1928,7 +1988,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -1973,8 +2033,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py index 62afa3538900..11733fa5dc99 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -611,6 +621,10 @@ def __init__( # 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( @@ -677,6 +691,29 @@ def __init__( 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.secrets_v1beta1.SecretManagerServiceClient`.", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "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.secrets.v1beta1.SecretManagerService", + "credentialsType": None, + }, + ) + def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -684,7 +721,7 @@ def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsPager: r"""Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. @@ -730,8 +767,10 @@ def sample_list_secrets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsPager: @@ -805,7 +844,7 @@ def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no @@ -872,8 +911,10 @@ def sample_create_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -941,7 +982,7 @@ def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] @@ -998,8 +1039,10 @@ def sample_add_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1059,7 +1102,7 @@ def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -1105,8 +1148,10 @@ def sample_get_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -1170,7 +1215,7 @@ def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -1221,8 +1266,10 @@ def sample_update_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.Secret: @@ -1289,7 +1336,7 @@ def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. @@ -1331,8 +1378,10 @@ def sample_delete_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1381,7 +1430,7 @@ def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsPager: r"""Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1431,8 +1480,10 @@ def sample_list_secret_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsPager: @@ -1504,7 +1555,7 @@ def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1557,8 +1608,10 @@ def sample_get_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1616,7 +1669,7 @@ def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1667,8 +1720,10 @@ def sample_access_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse: @@ -1726,7 +1781,7 @@ def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1778,8 +1833,10 @@ def sample_disable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1837,7 +1894,7 @@ def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -1889,8 +1946,10 @@ def sample_enable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -1948,7 +2007,7 @@ def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. @@ -2001,8 +2060,10 @@ def sample_destroy_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta1.types.SecretVersion: @@ -2059,7 +2120,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -2102,8 +2163,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2178,7 +2241,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -2217,8 +2280,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2293,7 +2358,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -2338,8 +2403,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py index 651df6de622a..16a0f04fae83 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py index 5db59fda5a19..76772c84884a 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport +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.secrets.v1beta1.SecretManagerService", + "rpcName": 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.secrets.v1beta1.SecretManagerService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcTransport(SecretManagerServiceTransport): """gRPC backend transport for SecretManagerService. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -262,7 +348,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -290,7 +376,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -319,7 +405,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -344,7 +430,7 @@ def get_secret(self) -> Callable[[service.GetSecretRequest], resources.Secret]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -371,7 +457,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -395,7 +481,7 @@ def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty_pb2.Emp # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -425,7 +511,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -456,7 +542,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -490,7 +576,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -522,7 +608,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -554,7 +640,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -587,7 +673,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -619,7 +705,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -647,7 +733,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -683,7 +769,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -691,7 +777,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py index 08c6352119ff..30701d8866d3 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .grpc import SecretManagerServiceGrpcTransport +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.secrets.v1beta1.SecretManagerService", + "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.secrets.v1beta1.SecretManagerService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcAsyncIOTransport(SecretManagerServiceTransport): """gRPC AsyncIO backend transport for SecretManagerService. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -298,7 +383,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -329,7 +414,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -356,7 +441,7 @@ def get_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -383,7 +468,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -409,7 +494,7 @@ def delete_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -440,7 +525,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -473,7 +558,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -508,7 +593,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -542,7 +627,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -576,7 +661,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -611,7 +696,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -643,7 +728,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -671,7 +756,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -707,7 +792,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secrets.v1beta1.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -810,7 +895,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/rest.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/rest.py index d92d239f16ca..48ccca6d5bc6 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/rest.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -188,8 +196,10 @@ def post_update_secret(self, response): def pre_access_secret_version( self, request: service.AccessSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AccessSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AccessSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for access_secret_version Override in a subclass to manipulate the request or metadata @@ -211,8 +221,10 @@ def post_access_secret_version( def pre_add_secret_version( self, request: service.AddSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AddSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AddSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_secret_version Override in a subclass to manipulate the request or metadata @@ -232,8 +244,10 @@ def post_add_secret_version( return response def pre_create_secret( - self, request: service.CreateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_secret Override in a subclass to manipulate the request or metadata @@ -251,8 +265,10 @@ def post_create_secret(self, response: resources.Secret) -> resources.Secret: return response def pre_delete_secret( - self, request: service.DeleteSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_secret Override in a subclass to manipulate the request or metadata @@ -263,8 +279,10 @@ def pre_delete_secret( def pre_destroy_secret_version( self, request: service.DestroySecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DestroySecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DestroySecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for destroy_secret_version Override in a subclass to manipulate the request or metadata @@ -286,8 +304,10 @@ def post_destroy_secret_version( def pre_disable_secret_version( self, request: service.DisableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DisableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DisableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_secret_version Override in a subclass to manipulate the request or metadata @@ -309,8 +329,10 @@ def post_disable_secret_version( def pre_enable_secret_version( self, request: service.EnableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EnableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EnableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_secret_version Override in a subclass to manipulate the request or metadata @@ -332,8 +354,10 @@ def post_enable_secret_version( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -351,8 +375,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_secret( - self, request: service.GetSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_secret Override in a subclass to manipulate the request or metadata @@ -372,8 +398,10 @@ def post_get_secret(self, response: resources.Secret) -> resources.Secret: def pre_get_secret_version( self, request: service.GetSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_secret_version Override in a subclass to manipulate the request or metadata @@ -393,8 +421,10 @@ def post_get_secret_version( return response def pre_list_secrets( - self, request: service.ListSecretsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListSecretsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_secrets Override in a subclass to manipulate the request or metadata @@ -416,8 +446,10 @@ def post_list_secrets( def pre_list_secret_versions( self, request: service.ListSecretVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSecretVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSecretVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_secret_versions Override in a subclass to manipulate the request or metadata @@ -439,8 +471,10 @@ def post_list_secret_versions( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -460,8 +494,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -481,8 +518,10 @@ def post_test_iam_permissions( return response def pre_update_secret( - self, request: service.UpdateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_secret Override in a subclass to manipulate the request or metadata @@ -627,7 +666,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Call the access secret version method over HTTP. @@ -638,8 +677,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.AccessSecretVersionResponse: @@ -651,6 +692,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAccessSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_access_secret_version( request, metadata ) @@ -663,6 +705,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.AccessSecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "AccessSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AccessSecretVersion._get_response( @@ -685,7 +754,31 @@ def __call__( pb_resp = service.AccessSecretVersionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_access_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.AccessSecretVersionResponse.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.secrets_v1beta1.SecretManagerServiceClient.access_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "AccessSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddSecretVersion( @@ -724,7 +817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the add secret version method over HTTP. @@ -735,8 +828,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -748,6 +843,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAddSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_add_secret_version( request, metadata ) @@ -764,6 +860,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.AddSecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "AddSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AddSecretVersion._get_response( @@ -787,7 +910,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secrets_v1beta1.SecretManagerServiceClient.add_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "AddSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecret( @@ -826,7 +971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the create secret method over HTTP. @@ -837,8 +982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -855,6 +1002,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_create_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_transcoded_request( http_options, request @@ -869,6 +1017,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.CreateSecret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "CreateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._CreateSecret._get_response( self._host, @@ -890,7 +1065,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secrets_v1beta1.SecretManagerServiceClient.create_secret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "CreateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSecret( @@ -928,7 +1125,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete secret method over HTTP. @@ -939,13 +1136,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_http_options() ) + request, metadata = self._interceptor.pre_delete_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_transcoded_request( http_options, request @@ -956,6 +1156,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.DeleteSecret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "DeleteSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._DeleteSecret._get_response( self._host, @@ -1007,7 +1234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the destroy secret version method over HTTP. @@ -1018,8 +1245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1031,6 +1260,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDestroySecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_destroy_secret_version( request, metadata ) @@ -1047,6 +1277,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.DestroySecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "DestroySecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DestroySecretVersion._get_response( @@ -1070,7 +1327,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_destroy_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secrets_v1beta1.SecretManagerServiceClient.destroy_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "DestroySecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableSecretVersion( @@ -1109,7 +1388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the disable secret version method over HTTP. @@ -1120,8 +1399,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1133,6 +1414,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDisableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_disable_secret_version( request, metadata ) @@ -1149,6 +1431,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.DisableSecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "DisableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DisableSecretVersion._get_response( @@ -1172,7 +1481,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secrets_v1beta1.SecretManagerServiceClient.disable_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "DisableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableSecretVersion( @@ -1211,7 +1542,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the enable secret version method over HTTP. @@ -1222,8 +1553,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1235,6 +1568,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseEnableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_enable_secret_version( request, metadata ) @@ -1251,6 +1585,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.EnableSecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "EnableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._EnableSecretVersion._get_response( @@ -1274,7 +1635,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secrets_v1beta1.SecretManagerServiceClient.enable_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "EnableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1312,7 +1695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1322,8 +1705,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1408,6 +1793,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1418,6 +1804,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1438,7 +1851,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.secrets_v1beta1.SecretManagerServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecret( @@ -1476,7 +1911,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the get secret method over HTTP. @@ -1487,8 +1922,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -1505,6 +1942,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_transcoded_request( http_options, request @@ -1515,6 +1953,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.GetSecret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetSecret._get_response( self._host, @@ -1535,7 +2000,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secrets_v1beta1.SecretManagerServiceClient.get_secret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecretVersion( @@ -1573,7 +2060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the get secret version method over HTTP. @@ -1584,8 +2071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1597,6 +2086,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret_version( request, metadata ) @@ -1609,6 +2099,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.GetSecretVersion", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._GetSecretVersion._get_response( @@ -1631,7 +2148,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secrets_v1beta1.SecretManagerServiceClient.get_secret_version", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "GetSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecrets( @@ -1669,7 +2208,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretsResponse: r"""Call the list secrets method over HTTP. @@ -1680,8 +2219,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretsResponse: @@ -1693,6 +2234,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_secrets(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_transcoded_request( http_options, request @@ -1703,6 +2245,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.ListSecrets", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "ListSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._ListSecrets._get_response( self._host, @@ -1723,7 +2292,29 @@ def __call__( pb_resp = service.ListSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretsResponse.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.secrets_v1beta1.SecretManagerServiceClient.list_secrets", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "ListSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecretVersions( @@ -1761,7 +2352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretVersionsResponse: r"""Call the list secret versions method over HTTP. @@ -1772,8 +2363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretVersionsResponse: @@ -1785,6 +2378,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecretVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_secret_versions( request, metadata ) @@ -1797,6 +2391,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.ListSecretVersions", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "ListSecretVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._ListSecretVersions._get_response( @@ -1819,7 +2440,31 @@ def __call__( pb_resp = service.ListSecretVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secret_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretVersionsResponse.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.secrets_v1beta1.SecretManagerServiceClient.list_secret_versions", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "ListSecretVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1858,7 +2503,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1868,8 +2513,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1954,6 +2601,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1968,6 +2616,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1989,7 +2664,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.secrets_v1beta1.SecretManagerServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2028,7 +2725,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2038,8 +2735,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2049,6 +2748,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2065,6 +2765,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._TestIamPermissions._get_response( @@ -2088,7 +2815,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.secrets_v1beta1.SecretManagerServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecret( @@ -2127,7 +2876,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the update secret method over HTTP. @@ -2138,8 +2887,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -2156,6 +2907,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_update_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_transcoded_request( http_options, request @@ -2170,6 +2922,33 @@ def __call__( 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.secrets_v1beta1.SecretManagerServiceClient.UpdateSecret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "UpdateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._UpdateSecret._get_response( self._host, @@ -2191,7 +2970,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secrets_v1beta1.SecretManagerServiceClient.update_secret", + extra={ + "serviceName": "google.cloud.secrets.v1beta1.SecretManagerService", + "rpcName": "UpdateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/gapic_version.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/gapic_version.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/async_client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/async_client.py index 4536895c68ef..dc7fa4621bce 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/async_client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .transports.grpc_asyncio import SecretManagerServiceGrpcAsyncIOTransport +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 SecretManagerServiceAsyncClient: """Secret Manager Service @@ -278,6 +288,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.secretmanager_v1beta2.SecretManagerServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "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.secretmanager.v1beta2.SecretManagerService", + "credentialsType": None, + }, + ) + async def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -285,7 +317,7 @@ async def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsAsyncPager: r"""Lists [Secrets][google.cloud.secretmanager.v1beta2.Secret]. @@ -332,8 +364,10 @@ async def sample_list_secrets(): 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, 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: google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretsAsyncPager: @@ -410,7 +444,7 @@ async def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing @@ -479,8 +513,10 @@ async def sample_create_secret(): 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, 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -551,7 +587,7 @@ async def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] @@ -609,8 +645,10 @@ async def sample_add_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -673,7 +711,7 @@ async def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -720,8 +758,10 @@ async def sample_get_secret(): 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, 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -788,7 +828,7 @@ async def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -840,8 +880,10 @@ async def sample_update_secret(): 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, 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -911,7 +953,7 @@ async def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -953,8 +995,10 @@ async def sample_delete_secret(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1006,7 +1050,7 @@ async def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsAsyncPager: r"""Lists [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1057,8 +1101,10 @@ async def sample_list_secret_versions(): 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, 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: google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager: @@ -1133,7 +1179,7 @@ async def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1189,8 +1235,10 @@ async def sample_get_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1251,7 +1299,7 @@ async def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1308,8 +1356,10 @@ async def sample_access_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.AccessSecretVersionResponse: @@ -1370,7 +1420,7 @@ async def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1425,8 +1475,10 @@ async def sample_disable_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1487,7 +1539,7 @@ async def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1542,8 +1594,10 @@ async def sample_enable_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1604,7 +1658,7 @@ async def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1660,8 +1714,10 @@ async def sample_destroy_secret_version(): 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, 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1721,7 +1777,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -1764,8 +1820,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1841,7 +1899,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -1880,8 +1938,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1957,7 +2017,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -2002,8 +2062,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2049,7 +2111,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2060,8 +2122,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2102,7 +2166,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2113,8 +2177,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/client.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/client.py index d18e16f49c42..e9f110b0863b 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/client.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -630,6 +640,10 @@ def __init__( # 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( @@ -696,6 +710,29 @@ def __init__( 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.secretmanager_v1beta2.SecretManagerServiceClient`.", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "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.secretmanager.v1beta2.SecretManagerService", + "credentialsType": None, + }, + ) + def list_secrets( self, request: Optional[Union[service.ListSecretsRequest, dict]] = None, @@ -703,7 +740,7 @@ def list_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretsPager: r"""Lists [Secrets][google.cloud.secretmanager.v1beta2.Secret]. @@ -750,8 +787,10 @@ def sample_list_secrets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretsPager: @@ -825,7 +864,7 @@ def create_secret( secret: Optional[resources.Secret] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing @@ -894,8 +933,10 @@ def sample_create_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -963,7 +1004,7 @@ def add_secret_version( payload: Optional[resources.SecretPayload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] @@ -1021,8 +1062,10 @@ def sample_add_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1082,7 +1125,7 @@ def get_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -1129,8 +1172,10 @@ def sample_get_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -1194,7 +1239,7 @@ def update_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -1246,8 +1291,10 @@ def sample_update_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.Secret: @@ -1314,7 +1361,7 @@ def delete_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a [Secret][google.cloud.secretmanager.v1beta2.Secret]. @@ -1356,8 +1403,10 @@ def sample_delete_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1406,7 +1455,7 @@ def list_secret_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecretVersionsPager: r"""Lists [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1457,8 +1506,10 @@ def sample_list_secret_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretVersionsPager: @@ -1530,7 +1581,7 @@ def get_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1586,8 +1637,10 @@ def sample_get_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1645,7 +1698,7 @@ def access_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1702,8 +1755,10 @@ def sample_access_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.AccessSecretVersionResponse: @@ -1761,7 +1816,7 @@ def disable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1816,8 +1871,10 @@ def sample_disable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1875,7 +1932,7 @@ def enable_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -1930,8 +1987,10 @@ def sample_enable_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -1989,7 +2048,7 @@ def destroy_secret_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. @@ -2045,8 +2104,10 @@ def sample_destroy_secret_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.secretmanager_v1beta2.types.SecretVersion: @@ -2103,7 +2164,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified secret. Replaces any existing policy. @@ -2146,8 +2207,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2222,7 +2285,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a secret. Returns empty policy if the secret exists and does not @@ -2261,8 +2324,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2337,7 +2402,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of @@ -2382,8 +2447,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2441,7 +2508,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2452,8 +2519,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2494,7 +2563,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2505,8 +2574,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/pagers.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/pagers.py index 4c0f854e8b79..51e2cad65aca 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/pagers.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListSecretVersionsRequest(request) diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc.py index 978c1e3669bd..399e62cc21cf 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1beta2.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport +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.secretmanager.v1beta2.SecretManagerService", + "rpcName": 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.secretmanager.v1beta2.SecretManagerService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcTransport(SecretManagerServiceTransport): """gRPC backend transport for SecretManagerService. @@ -189,7 +270,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -292,7 +378,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -321,7 +407,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -346,7 +432,7 @@ def get_secret(self) -> Callable[[service.GetSecretRequest], resources.Secret]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -373,7 +459,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -397,7 +483,7 @@ def delete_secret(self) -> Callable[[service.DeleteSecretRequest], empty_pb2.Emp # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -427,7 +513,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -458,7 +544,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -492,7 +578,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -526,7 +612,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -560,7 +646,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -595,7 +681,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -627,7 +713,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -655,7 +741,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -691,7 +777,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -699,7 +785,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -713,7 +799,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -730,7 +816,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc_asyncio.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc_asyncio.py index 659ba813e5d7..2acdd875d9bc 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.secretmanager_v1beta2.types import resources, service from .base import DEFAULT_CLIENT_INFO, SecretManagerServiceTransport from .grpc import SecretManagerServiceGrpcTransport +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.secretmanager.v1beta2.SecretManagerService", + "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.secretmanager.v1beta2.SecretManagerService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecretManagerServiceGrpcAsyncIOTransport(SecretManagerServiceTransport): """gRPC AsyncIO backend transport for SecretManagerService. @@ -236,10 +318,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -271,7 +356,7 @@ def list_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secrets" not in self._stubs: - self._stubs["list_secrets"] = self.grpc_channel.unary_unary( + self._stubs["list_secrets"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/ListSecrets", request_serializer=service.ListSecretsRequest.serialize, response_deserializer=service.ListSecretsResponse.deserialize, @@ -300,7 +385,7 @@ def create_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secret" not in self._stubs: - self._stubs["create_secret"] = self.grpc_channel.unary_unary( + self._stubs["create_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/CreateSecret", request_serializer=service.CreateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -331,7 +416,7 @@ def add_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_secret_version" not in self._stubs: - self._stubs["add_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["add_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/AddSecretVersion", request_serializer=service.AddSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -358,7 +443,7 @@ def get_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret" not in self._stubs: - self._stubs["get_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetSecret", request_serializer=service.GetSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -385,7 +470,7 @@ def update_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_secret" not in self._stubs: - self._stubs["update_secret"] = self.grpc_channel.unary_unary( + self._stubs["update_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/UpdateSecret", request_serializer=service.UpdateSecretRequest.serialize, response_deserializer=resources.Secret.deserialize, @@ -411,7 +496,7 @@ def delete_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_secret" not in self._stubs: - self._stubs["delete_secret"] = self.grpc_channel.unary_unary( + self._stubs["delete_secret"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DeleteSecret", request_serializer=service.DeleteSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -442,7 +527,7 @@ def list_secret_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_secret_versions" not in self._stubs: - self._stubs["list_secret_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_secret_versions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/ListSecretVersions", request_serializer=service.ListSecretVersionsRequest.serialize, response_deserializer=service.ListSecretVersionsResponse.deserialize, @@ -475,7 +560,7 @@ def get_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_secret_version" not in self._stubs: - self._stubs["get_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["get_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetSecretVersion", request_serializer=service.GetSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -510,7 +595,7 @@ def access_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "access_secret_version" not in self._stubs: - self._stubs["access_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["access_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/AccessSecretVersion", request_serializer=service.AccessSecretVersionRequest.serialize, response_deserializer=service.AccessSecretVersionResponse.deserialize, @@ -546,7 +631,7 @@ def disable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_secret_version" not in self._stubs: - self._stubs["disable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["disable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DisableSecretVersion", request_serializer=service.DisableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -582,7 +667,7 @@ def enable_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_secret_version" not in self._stubs: - self._stubs["enable_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["enable_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/EnableSecretVersion", request_serializer=service.EnableSecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -619,7 +704,7 @@ def destroy_secret_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "destroy_secret_version" not in self._stubs: - self._stubs["destroy_secret_version"] = self.grpc_channel.unary_unary( + self._stubs["destroy_secret_version"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/DestroySecretVersion", request_serializer=service.DestroySecretVersionRequest.serialize, response_deserializer=resources.SecretVersion.deserialize, @@ -651,7 +736,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -679,7 +764,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -715,7 +800,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.secretmanager.v1beta2.SecretManagerService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -828,7 +913,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -846,7 +931,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -863,7 +948,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/rest.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/rest.py index edec8f2908c2..73f02bbe4da0 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/rest.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1beta2/services/secret_manager_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -189,8 +197,10 @@ def post_update_secret(self, response): def pre_access_secret_version( self, request: service.AccessSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AccessSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AccessSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for access_secret_version Override in a subclass to manipulate the request or metadata @@ -212,8 +222,10 @@ def post_access_secret_version( def pre_add_secret_version( self, request: service.AddSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.AddSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.AddSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_secret_version Override in a subclass to manipulate the request or metadata @@ -233,8 +245,10 @@ def post_add_secret_version( return response def pre_create_secret( - self, request: service.CreateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_secret Override in a subclass to manipulate the request or metadata @@ -252,8 +266,10 @@ def post_create_secret(self, response: resources.Secret) -> resources.Secret: return response def pre_delete_secret( - self, request: service.DeleteSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_secret Override in a subclass to manipulate the request or metadata @@ -264,8 +280,10 @@ def pre_delete_secret( def pre_destroy_secret_version( self, request: service.DestroySecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DestroySecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DestroySecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for destroy_secret_version Override in a subclass to manipulate the request or metadata @@ -287,8 +305,10 @@ def post_destroy_secret_version( def pre_disable_secret_version( self, request: service.DisableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DisableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DisableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_secret_version Override in a subclass to manipulate the request or metadata @@ -310,8 +330,10 @@ def post_disable_secret_version( def pre_enable_secret_version( self, request: service.EnableSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EnableSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EnableSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_secret_version Override in a subclass to manipulate the request or metadata @@ -333,8 +355,10 @@ def post_enable_secret_version( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -352,8 +376,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_secret( - self, request: service.GetSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_secret Override in a subclass to manipulate the request or metadata @@ -373,8 +399,10 @@ def post_get_secret(self, response: resources.Secret) -> resources.Secret: def pre_get_secret_version( self, request: service.GetSecretVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetSecretVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetSecretVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_secret_version Override in a subclass to manipulate the request or metadata @@ -394,8 +422,10 @@ def post_get_secret_version( return response def pre_list_secrets( - self, request: service.ListSecretsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListSecretsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListSecretsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_secrets Override in a subclass to manipulate the request or metadata @@ -417,8 +447,10 @@ def post_list_secrets( def pre_list_secret_versions( self, request: service.ListSecretVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSecretVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSecretVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_secret_versions Override in a subclass to manipulate the request or metadata @@ -440,8 +472,10 @@ def post_list_secret_versions( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -461,8 +495,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -482,8 +519,10 @@ def post_test_iam_permissions( return response def pre_update_secret( - self, request: service.UpdateSecretRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateSecretRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSecretRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_secret Override in a subclass to manipulate the request or metadata @@ -503,8 +542,10 @@ def post_update_secret(self, response: resources.Secret) -> resources.Secret: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -526,8 +567,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -674,7 +717,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.AccessSecretVersionResponse: r"""Call the access secret version method over HTTP. @@ -685,8 +728,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.AccessSecretVersionResponse: @@ -698,6 +743,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAccessSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_access_secret_version( request, metadata ) @@ -710,6 +756,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.AccessSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "AccessSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AccessSecretVersion._get_response( @@ -732,7 +805,31 @@ def __call__( pb_resp = service.AccessSecretVersionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_access_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.AccessSecretVersionResponse.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.secretmanager_v1beta2.SecretManagerServiceClient.access_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "AccessSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddSecretVersion( @@ -771,7 +868,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the add secret version method over HTTP. @@ -782,8 +879,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -795,6 +894,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseAddSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_add_secret_version( request, metadata ) @@ -811,6 +911,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.AddSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "AddSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._AddSecretVersion._get_response( @@ -834,7 +961,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1beta2.SecretManagerServiceClient.add_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "AddSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecret( @@ -873,7 +1022,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the create secret method over HTTP. @@ -884,8 +1033,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -903,6 +1054,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_create_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseCreateSecret._get_transcoded_request( http_options, request @@ -917,6 +1069,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.CreateSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "CreateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._CreateSecret._get_response( self._host, @@ -938,7 +1117,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1beta2.SecretManagerServiceClient.create_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "CreateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSecret( @@ -976,7 +1177,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete secret method over HTTP. @@ -987,13 +1188,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_http_options() ) + request, metadata = self._interceptor.pre_delete_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseDeleteSecret._get_transcoded_request( http_options, request @@ -1004,6 +1208,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.DeleteSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "DeleteSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._DeleteSecret._get_response( self._host, @@ -1055,7 +1286,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the destroy secret version method over HTTP. @@ -1066,8 +1297,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1079,6 +1312,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDestroySecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_destroy_secret_version( request, metadata ) @@ -1095,6 +1329,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.DestroySecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "DestroySecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DestroySecretVersion._get_response( @@ -1118,7 +1379,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_destroy_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1beta2.SecretManagerServiceClient.destroy_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "DestroySecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableSecretVersion( @@ -1157,7 +1440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the disable secret version method over HTTP. @@ -1168,8 +1451,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1181,6 +1466,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseDisableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_disable_secret_version( request, metadata ) @@ -1197,6 +1483,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.DisableSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "DisableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._DisableSecretVersion._get_response( @@ -1220,7 +1533,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1beta2.SecretManagerServiceClient.disable_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "DisableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableSecretVersion( @@ -1259,7 +1594,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the enable secret version method over HTTP. @@ -1270,8 +1605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1283,6 +1620,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseEnableSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_enable_secret_version( request, metadata ) @@ -1299,6 +1637,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.EnableSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "EnableSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._EnableSecretVersion._get_response( @@ -1322,7 +1687,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1beta2.SecretManagerServiceClient.enable_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "EnableSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1360,7 +1747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1370,8 +1757,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1456,6 +1845,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1466,6 +1856,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1486,7 +1903,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.secretmanager_v1beta2.SecretManagerServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecret( @@ -1524,7 +1963,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the get secret method over HTTP. @@ -1535,8 +1974,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -1554,6 +1995,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetSecret._get_transcoded_request( http_options, request @@ -1564,6 +2006,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.GetSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetSecret._get_response( self._host, @@ -1584,7 +2053,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1beta2.SecretManagerServiceClient.get_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecretVersion( @@ -1622,7 +2113,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SecretVersion: r"""Call the get secret version method over HTTP. @@ -1633,8 +2124,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.SecretVersion: @@ -1646,6 +2139,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetSecretVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_secret_version( request, metadata ) @@ -1658,6 +2152,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.GetSecretVersion", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetSecretVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._GetSecretVersion._get_response( @@ -1680,7 +2201,29 @@ def __call__( pb_resp = resources.SecretVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_secret_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SecretVersion.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.secretmanager_v1beta2.SecretManagerServiceClient.get_secret_version", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetSecretVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecrets( @@ -1718,7 +2261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretsResponse: r"""Call the list secrets method over HTTP. @@ -1729,8 +2272,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretsResponse: @@ -1742,6 +2287,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_secrets(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseListSecrets._get_transcoded_request( http_options, request @@ -1752,6 +2298,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.ListSecrets", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._ListSecrets._get_response( self._host, @@ -1772,7 +2345,29 @@ def __call__( pb_resp = service.ListSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretsResponse.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.secretmanager_v1beta2.SecretManagerServiceClient.list_secrets", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecretVersions( @@ -1810,7 +2405,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSecretVersionsResponse: r"""Call the list secret versions method over HTTP. @@ -1821,8 +2416,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListSecretVersionsResponse: @@ -1834,6 +2431,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListSecretVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_secret_versions( request, metadata ) @@ -1846,6 +2444,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.ListSecretVersions", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListSecretVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._ListSecretVersions._get_response( @@ -1868,7 +2493,31 @@ def __call__( pb_resp = service.ListSecretVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_secret_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListSecretVersionsResponse.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.secretmanager_v1beta2.SecretManagerServiceClient.list_secret_versions", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListSecretVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1907,7 +2556,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1917,8 +2566,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2003,6 +2654,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2017,6 +2669,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -2038,7 +2717,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.secretmanager_v1beta2.SecretManagerServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2077,7 +2778,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2087,8 +2788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2098,6 +2801,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2114,6 +2818,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecretManagerServiceRestTransport._TestIamPermissions._get_response( @@ -2137,7 +2868,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.secretmanager_v1beta2.SecretManagerServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecret( @@ -2176,7 +2929,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Secret: r"""Call the update secret method over HTTP. @@ -2187,8 +2940,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Secret: @@ -2206,6 +2961,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_http_options() ) + request, metadata = self._interceptor.pre_update_secret(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseUpdateSecret._get_transcoded_request( http_options, request @@ -2220,6 +2976,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.UpdateSecret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "UpdateSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._UpdateSecret._get_response( self._host, @@ -2241,7 +3024,29 @@ def __call__( pb_resp = resources.Secret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Secret.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.secretmanager_v1beta2.SecretManagerServiceClient.update_secret", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "UpdateSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2406,7 +3211,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2416,8 +3221,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2426,6 +3233,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2436,6 +3244,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._GetLocation._get_response( self._host, @@ -2455,6 +3290,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.secretmanager_v1beta2.SecretManagerServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2496,7 +3352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2506,8 +3362,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2516,6 +3374,7 @@ def __call__( http_options = ( _BaseSecretManagerServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSecretManagerServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2526,6 +3385,33 @@ def __call__( 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.secretmanager_v1beta2.SecretManagerServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecretManagerServiceRestTransport._ListLocations._get_response( self._host, @@ -2545,6 +3431,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.secretmanager_v1beta2.SecretManagerServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.secretmanager.v1beta2.SecretManagerService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1.json b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1.json index 3c7dd652e551..e75ffe273c93 100644 --- a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1.json +++ b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-secret-manager", - "version": "2.21.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.AccessSecretVersionResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.AccessSecretVersionResponse", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -631,7 +631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -709,7 +709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -789,7 +789,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -950,7 +950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -1111,7 +1111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -1188,7 +1188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.SecretVersion", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretVersionsPager", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretsAsyncPager", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.services.secret_manager_service.pagers.ListSecretsPager", @@ -1985,7 +1985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2061,7 +2061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2138,7 +2138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2299,7 +2299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", @@ -2383,7 +2383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1.types.Secret", diff --git a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1beta2.json b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1beta2.json index 8ef408731b94..f2d2a2eaea8e 100644 --- a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1beta2.json +++ b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secretmanager.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-secretmanager", - "version": "2.21.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.AccessSecretVersionResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.AccessSecretVersionResponse", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -631,7 +631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -709,7 +709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -789,7 +789,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -950,7 +950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -1111,7 +1111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -1188,7 +1188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.SecretVersion", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretVersionsPager", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretsAsyncPager", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.services.secret_manager_service.pagers.ListSecretsPager", @@ -1985,7 +1985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2061,7 +2061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2138,7 +2138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2299,7 +2299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", @@ -2383,7 +2383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta2.types.Secret", diff --git a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json index 5aa8d84e30ea..cdba6a34a0ba 100644 --- a/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json +++ b/packages/google-cloud-secret-manager/samples/generated_samples/snippet_metadata_google.cloud.secrets.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-secretmanager", - "version": "2.21.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.AccessSecretVersionResponse", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -631,7 +631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_secret" @@ -709,7 +709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -789,7 +789,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -870,7 +870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -950,7 +950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -1031,7 +1031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -1111,7 +1111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -1188,7 +1188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -1425,7 +1425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.SecretVersion", @@ -1506,7 +1506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", @@ -1586,7 +1586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", @@ -1667,7 +1667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsAsyncPager", @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretVersionsPager", @@ -1828,7 +1828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsAsyncPager", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.services.secret_manager_service.pagers.ListSecretsPager", @@ -1985,7 +1985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2061,7 +2061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2138,7 +2138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2299,7 +2299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", @@ -2383,7 +2383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.secretmanager_v1beta1.types.Secret", diff --git a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py index 15722f0db8a4..1bf71bf19b09 100644 --- a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py +++ b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py @@ -6542,6 +6542,7 @@ def test_list_secrets_rest_required_fields(request_type=service.ListSecretsReque response_value._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_secrets(request) @@ -6596,6 +6597,7 @@ def test_list_secrets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secrets(**mock_args) @@ -6794,6 +6796,7 @@ def test_create_secret_rest_required_fields(request_type=service.CreateSecretReq response_value._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_secret(request) @@ -6856,6 +6859,7 @@ def test_create_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -6992,6 +6996,7 @@ def test_add_secret_version_rest_required_fields( response_value._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.add_secret_version(request) @@ -7046,6 +7051,7 @@ def test_add_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_secret_version(**mock_args) @@ -7175,6 +7181,7 @@ def test_get_secret_rest_required_fields(request_type=service.GetSecretRequest): response_value._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_secret(request) @@ -7220,6 +7227,7 @@ def test_get_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7345,6 +7353,7 @@ def test_update_secret_rest_required_fields(request_type=service.UpdateSecretReq response_value._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_secret(request) @@ -7399,6 +7408,7 @@ def test_update_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7526,6 +7536,7 @@ def test_delete_secret_rest_required_fields(request_type=service.DeleteSecretReq response_value._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_secret(request) @@ -7569,6 +7580,7 @@ def test_delete_secret_rest_flattened(): 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"} client.delete_secret(**mock_args) @@ -7710,6 +7722,7 @@ def test_list_secret_versions_rest_required_fields( response_value._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_secret_versions(request) @@ -7764,6 +7777,7 @@ def test_list_secret_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_versions(**mock_args) @@ -7961,6 +7975,7 @@ def test_get_secret_version_rest_required_fields( response_value._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_secret_version(request) @@ -8006,6 +8021,7 @@ def test_get_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_version(**mock_args) @@ -8141,6 +8157,7 @@ def test_access_secret_version_rest_required_fields( response_value._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.access_secret_version(request) @@ -8186,6 +8203,7 @@ def test_access_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.access_secret_version(**mock_args) @@ -8323,6 +8341,7 @@ def test_disable_secret_version_rest_required_fields( response_value._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.disable_secret_version(request) @@ -8368,6 +8387,7 @@ def test_disable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.disable_secret_version(**mock_args) @@ -8505,6 +8525,7 @@ def test_enable_secret_version_rest_required_fields( response_value._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.enable_secret_version(request) @@ -8550,6 +8571,7 @@ def test_enable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.enable_secret_version(**mock_args) @@ -8687,6 +8709,7 @@ def test_destroy_secret_version_rest_required_fields( response_value._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.destroy_secret_version(request) @@ -8732,6 +8755,7 @@ def test_destroy_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.destroy_secret_version(**mock_args) @@ -8862,6 +8886,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -8989,6 +9014,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -9115,6 +9141,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -10056,6 +10083,7 @@ def test_list_secrets_rest_bad_request(request_type=service.ListSecretsRequest): 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_secrets(request) @@ -10092,6 +10120,7 @@ def test_list_secrets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secrets(request) # Establish that the response is the type that we expect. @@ -10131,6 +10160,7 @@ def test_list_secrets_rest_interceptors(null_interceptor): 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 = service.ListSecretsResponse.to_json( service.ListSecretsResponse() ) @@ -10175,6 +10205,7 @@ def test_create_secret_rest_bad_request(request_type=service.CreateSecretRequest 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_secret(request) @@ -10302,6 +10333,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10341,6 +10373,7 @@ def test_create_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10385,6 +10418,7 @@ def test_add_secret_version_rest_bad_request( 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.add_secret_version(request) @@ -10423,6 +10457,7 @@ def test_add_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_secret_version(request) # Establish that the response is the type that we expect. @@ -10466,6 +10501,7 @@ def test_add_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -10508,6 +10544,7 @@ def test_get_secret_rest_bad_request(request_type=service.GetSecretRequest): 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_secret(request) @@ -10544,6 +10581,7 @@ def test_get_secret_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10583,6 +10621,7 @@ def test_get_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10625,6 +10664,7 @@ def test_update_secret_rest_bad_request(request_type=service.UpdateSecretRequest 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_secret(request) @@ -10752,6 +10792,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10791,6 +10832,7 @@ def test_update_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10833,6 +10875,7 @@ def test_delete_secret_rest_bad_request(request_type=service.DeleteSecretRequest 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_secret(request) @@ -10863,6 +10906,7 @@ def test_delete_secret_rest_call_success(request_type): 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_secret(request) # Establish that the response is the type that we expect. @@ -10897,6 +10941,7 @@ def test_delete_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = service.DeleteSecretRequest() metadata = [ @@ -10937,6 +10982,7 @@ def test_list_secret_versions_rest_bad_request( 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_secret_versions(request) @@ -10973,6 +11019,7 @@ def test_list_secret_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_versions(request) # Establish that the response is the type that we expect. @@ -11014,6 +11061,7 @@ def test_list_secret_versions_rest_interceptors(null_interceptor): 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 = service.ListSecretVersionsResponse.to_json( service.ListSecretVersionsResponse() ) @@ -11060,6 +11108,7 @@ def test_get_secret_version_rest_bad_request( 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_secret_version(request) @@ -11098,6 +11147,7 @@ def test_get_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_version(request) # Establish that the response is the type that we expect. @@ -11141,6 +11191,7 @@ def test_get_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11185,6 +11236,7 @@ def test_access_secret_version_rest_bad_request( 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.access_secret_version(request) @@ -11220,6 +11272,7 @@ def test_access_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.access_secret_version(request) # Establish that the response is the type that we expect. @@ -11260,6 +11313,7 @@ def test_access_secret_version_rest_interceptors(null_interceptor): 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 = service.AccessSecretVersionResponse.to_json( service.AccessSecretVersionResponse() ) @@ -11306,6 +11360,7 @@ def test_disable_secret_version_rest_bad_request( 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.disable_secret_version(request) @@ -11344,6 +11399,7 @@ def test_disable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_secret_version(request) # Establish that the response is the type that we expect. @@ -11387,6 +11443,7 @@ def test_disable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11431,6 +11488,7 @@ def test_enable_secret_version_rest_bad_request( 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.enable_secret_version(request) @@ -11469,6 +11527,7 @@ def test_enable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_secret_version(request) # Establish that the response is the type that we expect. @@ -11512,6 +11571,7 @@ def test_enable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11556,6 +11616,7 @@ def test_destroy_secret_version_rest_bad_request( 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.destroy_secret_version(request) @@ -11594,6 +11655,7 @@ def test_destroy_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.destroy_secret_version(request) # Establish that the response is the type that we expect. @@ -11637,6 +11699,7 @@ def test_destroy_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11681,6 +11744,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -11714,6 +11778,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -11753,6 +11818,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11797,6 +11863,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -11830,6 +11897,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -11869,6 +11937,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11913,6 +11982,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -11945,6 +12015,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -11983,6 +12054,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -12029,6 +12101,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -12059,6 +12132,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -12087,6 +12161,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -12117,6 +12192,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py index 5accf17f8980..7cbe393d7e22 100644 --- a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py +++ b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py @@ -6475,6 +6475,7 @@ def test_list_secrets_rest_required_fields(request_type=service.ListSecretsReque response_value._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_secrets(request) @@ -6528,6 +6529,7 @@ def test_list_secrets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secrets(**mock_args) @@ -6726,6 +6728,7 @@ def test_create_secret_rest_required_fields(request_type=service.CreateSecretReq response_value._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_secret(request) @@ -6788,6 +6791,7 @@ def test_create_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -6924,6 +6928,7 @@ def test_add_secret_version_rest_required_fields( response_value._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.add_secret_version(request) @@ -6978,6 +6983,7 @@ def test_add_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_secret_version(**mock_args) @@ -7108,6 +7114,7 @@ def test_get_secret_rest_required_fields(request_type=service.GetSecretRequest): response_value._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_secret(request) @@ -7153,6 +7160,7 @@ def test_get_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7278,6 +7286,7 @@ def test_update_secret_rest_required_fields(request_type=service.UpdateSecretReq response_value._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_secret(request) @@ -7332,6 +7341,7 @@ def test_update_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7458,6 +7468,7 @@ def test_delete_secret_rest_required_fields(request_type=service.DeleteSecretReq response_value._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_secret(request) @@ -7501,6 +7512,7 @@ def test_delete_secret_rest_flattened(): 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"} client.delete_secret(**mock_args) @@ -7641,6 +7653,7 @@ def test_list_secret_versions_rest_required_fields( response_value._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_secret_versions(request) @@ -7694,6 +7707,7 @@ def test_list_secret_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_versions(**mock_args) @@ -7892,6 +7906,7 @@ def test_get_secret_version_rest_required_fields( response_value._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_secret_version(request) @@ -7937,6 +7952,7 @@ def test_get_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_version(**mock_args) @@ -8073,6 +8089,7 @@ def test_access_secret_version_rest_required_fields( response_value._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.access_secret_version(request) @@ -8118,6 +8135,7 @@ def test_access_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.access_secret_version(**mock_args) @@ -8255,6 +8273,7 @@ def test_disable_secret_version_rest_required_fields( response_value._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.disable_secret_version(request) @@ -8300,6 +8319,7 @@ def test_disable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.disable_secret_version(**mock_args) @@ -8437,6 +8457,7 @@ def test_enable_secret_version_rest_required_fields( response_value._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.enable_secret_version(request) @@ -8482,6 +8503,7 @@ def test_enable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.enable_secret_version(**mock_args) @@ -8619,6 +8641,7 @@ def test_destroy_secret_version_rest_required_fields( response_value._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.destroy_secret_version(request) @@ -8664,6 +8687,7 @@ def test_destroy_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.destroy_secret_version(**mock_args) @@ -8794,6 +8818,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -8921,6 +8946,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -9047,6 +9073,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -9975,6 +10002,7 @@ def test_list_secrets_rest_bad_request(request_type=service.ListSecretsRequest): 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_secrets(request) @@ -10011,6 +10039,7 @@ def test_list_secrets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secrets(request) # Establish that the response is the type that we expect. @@ -10050,6 +10079,7 @@ def test_list_secrets_rest_interceptors(null_interceptor): 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 = service.ListSecretsResponse.to_json( service.ListSecretsResponse() ) @@ -10094,6 +10124,7 @@ def test_create_secret_rest_bad_request(request_type=service.CreateSecretRequest 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_secret(request) @@ -10205,6 +10236,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10243,6 +10275,7 @@ def test_create_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10287,6 +10320,7 @@ def test_add_secret_version_rest_bad_request( 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.add_secret_version(request) @@ -10323,6 +10357,7 @@ def test_add_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_secret_version(request) # Establish that the response is the type that we expect. @@ -10364,6 +10399,7 @@ def test_add_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -10406,6 +10442,7 @@ def test_get_secret_rest_bad_request(request_type=service.GetSecretRequest): 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_secret(request) @@ -10441,6 +10478,7 @@ def test_get_secret_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10479,6 +10517,7 @@ def test_get_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10521,6 +10560,7 @@ def test_update_secret_rest_bad_request(request_type=service.UpdateSecretRequest 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_secret(request) @@ -10632,6 +10672,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10670,6 +10711,7 @@ def test_update_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10712,6 +10754,7 @@ def test_delete_secret_rest_bad_request(request_type=service.DeleteSecretRequest 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_secret(request) @@ -10742,6 +10785,7 @@ def test_delete_secret_rest_call_success(request_type): 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_secret(request) # Establish that the response is the type that we expect. @@ -10776,6 +10820,7 @@ def test_delete_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = service.DeleteSecretRequest() metadata = [ @@ -10816,6 +10861,7 @@ def test_list_secret_versions_rest_bad_request( 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_secret_versions(request) @@ -10852,6 +10898,7 @@ def test_list_secret_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_versions(request) # Establish that the response is the type that we expect. @@ -10893,6 +10940,7 @@ def test_list_secret_versions_rest_interceptors(null_interceptor): 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 = service.ListSecretVersionsResponse.to_json( service.ListSecretVersionsResponse() ) @@ -10939,6 +10987,7 @@ def test_get_secret_version_rest_bad_request( 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_secret_version(request) @@ -10975,6 +11024,7 @@ def test_get_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_version(request) # Establish that the response is the type that we expect. @@ -11016,6 +11066,7 @@ def test_get_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11060,6 +11111,7 @@ def test_access_secret_version_rest_bad_request( 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.access_secret_version(request) @@ -11095,6 +11147,7 @@ def test_access_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.access_secret_version(request) # Establish that the response is the type that we expect. @@ -11135,6 +11188,7 @@ def test_access_secret_version_rest_interceptors(null_interceptor): 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 = service.AccessSecretVersionResponse.to_json( service.AccessSecretVersionResponse() ) @@ -11181,6 +11235,7 @@ def test_disable_secret_version_rest_bad_request( 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.disable_secret_version(request) @@ -11217,6 +11272,7 @@ def test_disable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_secret_version(request) # Establish that the response is the type that we expect. @@ -11258,6 +11314,7 @@ def test_disable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11302,6 +11359,7 @@ def test_enable_secret_version_rest_bad_request( 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.enable_secret_version(request) @@ -11338,6 +11396,7 @@ def test_enable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_secret_version(request) # Establish that the response is the type that we expect. @@ -11379,6 +11438,7 @@ def test_enable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11423,6 +11483,7 @@ def test_destroy_secret_version_rest_bad_request( 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.destroy_secret_version(request) @@ -11459,6 +11520,7 @@ def test_destroy_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.destroy_secret_version(request) # Establish that the response is the type that we expect. @@ -11500,6 +11562,7 @@ def test_destroy_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11544,6 +11607,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -11577,6 +11641,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -11616,6 +11681,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11660,6 +11726,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -11693,6 +11760,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -11732,6 +11800,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11776,6 +11845,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -11808,6 +11878,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -11846,6 +11917,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) diff --git a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta2/test_secret_manager_service.py b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta2/test_secret_manager_service.py index 6088b48646ef..e34d9873676d 100644 --- a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta2/test_secret_manager_service.py +++ b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1beta2/test_secret_manager_service.py @@ -6542,6 +6542,7 @@ def test_list_secrets_rest_required_fields(request_type=service.ListSecretsReque response_value._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_secrets(request) @@ -6596,6 +6597,7 @@ def test_list_secrets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secrets(**mock_args) @@ -6794,6 +6796,7 @@ def test_create_secret_rest_required_fields(request_type=service.CreateSecretReq response_value._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_secret(request) @@ -6856,6 +6859,7 @@ def test_create_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -6992,6 +6996,7 @@ def test_add_secret_version_rest_required_fields( response_value._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.add_secret_version(request) @@ -7046,6 +7051,7 @@ def test_add_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.add_secret_version(**mock_args) @@ -7176,6 +7182,7 @@ def test_get_secret_rest_required_fields(request_type=service.GetSecretRequest): response_value._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_secret(request) @@ -7221,6 +7228,7 @@ def test_get_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7346,6 +7354,7 @@ def test_update_secret_rest_required_fields(request_type=service.UpdateSecretReq response_value._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_secret(request) @@ -7400,6 +7409,7 @@ def test_update_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret(**mock_args) @@ -7528,6 +7538,7 @@ def test_delete_secret_rest_required_fields(request_type=service.DeleteSecretReq response_value._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_secret(request) @@ -7571,6 +7582,7 @@ def test_delete_secret_rest_flattened(): 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"} client.delete_secret(**mock_args) @@ -7712,6 +7724,7 @@ def test_list_secret_versions_rest_required_fields( response_value._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_secret_versions(request) @@ -7766,6 +7779,7 @@ def test_list_secret_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_versions(**mock_args) @@ -7964,6 +7978,7 @@ def test_get_secret_version_rest_required_fields( response_value._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_secret_version(request) @@ -8009,6 +8024,7 @@ def test_get_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_secret_version(**mock_args) @@ -8145,6 +8161,7 @@ def test_access_secret_version_rest_required_fields( response_value._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.access_secret_version(request) @@ -8190,6 +8207,7 @@ def test_access_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.access_secret_version(**mock_args) @@ -8327,6 +8345,7 @@ def test_disable_secret_version_rest_required_fields( response_value._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.disable_secret_version(request) @@ -8372,6 +8391,7 @@ def test_disable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.disable_secret_version(**mock_args) @@ -8509,6 +8529,7 @@ def test_enable_secret_version_rest_required_fields( response_value._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.enable_secret_version(request) @@ -8554,6 +8575,7 @@ def test_enable_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.enable_secret_version(**mock_args) @@ -8691,6 +8713,7 @@ def test_destroy_secret_version_rest_required_fields( response_value._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.destroy_secret_version(request) @@ -8736,6 +8759,7 @@ def test_destroy_secret_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.destroy_secret_version(**mock_args) @@ -8866,6 +8890,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -8993,6 +9018,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -9119,6 +9145,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -10060,6 +10087,7 @@ def test_list_secrets_rest_bad_request(request_type=service.ListSecretsRequest): 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_secrets(request) @@ -10096,6 +10124,7 @@ def test_list_secrets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secrets(request) # Establish that the response is the type that we expect. @@ -10135,6 +10164,7 @@ def test_list_secrets_rest_interceptors(null_interceptor): 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 = service.ListSecretsResponse.to_json( service.ListSecretsResponse() ) @@ -10179,6 +10209,7 @@ def test_create_secret_rest_bad_request(request_type=service.CreateSecretRequest 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_secret(request) @@ -10306,6 +10337,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10345,6 +10377,7 @@ def test_create_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10389,6 +10422,7 @@ def test_add_secret_version_rest_bad_request( 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.add_secret_version(request) @@ -10427,6 +10461,7 @@ def test_add_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_secret_version(request) # Establish that the response is the type that we expect. @@ -10470,6 +10505,7 @@ def test_add_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -10512,6 +10548,7 @@ def test_get_secret_rest_bad_request(request_type=service.GetSecretRequest): 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_secret(request) @@ -10548,6 +10585,7 @@ def test_get_secret_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10587,6 +10625,7 @@ def test_get_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10629,6 +10668,7 @@ def test_update_secret_rest_bad_request(request_type=service.UpdateSecretRequest 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_secret(request) @@ -10756,6 +10796,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret(request) # Establish that the response is the type that we expect. @@ -10795,6 +10836,7 @@ def test_update_secret_rest_interceptors(null_interceptor): 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 = resources.Secret.to_json(resources.Secret()) req.return_value.content = return_value @@ -10837,6 +10879,7 @@ def test_delete_secret_rest_bad_request(request_type=service.DeleteSecretRequest 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_secret(request) @@ -10867,6 +10910,7 @@ def test_delete_secret_rest_call_success(request_type): 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_secret(request) # Establish that the response is the type that we expect. @@ -10901,6 +10945,7 @@ def test_delete_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = service.DeleteSecretRequest() metadata = [ @@ -10941,6 +10986,7 @@ def test_list_secret_versions_rest_bad_request( 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_secret_versions(request) @@ -10977,6 +11023,7 @@ def test_list_secret_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_versions(request) # Establish that the response is the type that we expect. @@ -11018,6 +11065,7 @@ def test_list_secret_versions_rest_interceptors(null_interceptor): 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 = service.ListSecretVersionsResponse.to_json( service.ListSecretVersionsResponse() ) @@ -11064,6 +11112,7 @@ def test_get_secret_version_rest_bad_request( 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_secret_version(request) @@ -11102,6 +11151,7 @@ def test_get_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_secret_version(request) # Establish that the response is the type that we expect. @@ -11145,6 +11195,7 @@ def test_get_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11189,6 +11240,7 @@ def test_access_secret_version_rest_bad_request( 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.access_secret_version(request) @@ -11224,6 +11276,7 @@ def test_access_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.access_secret_version(request) # Establish that the response is the type that we expect. @@ -11264,6 +11317,7 @@ def test_access_secret_version_rest_interceptors(null_interceptor): 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 = service.AccessSecretVersionResponse.to_json( service.AccessSecretVersionResponse() ) @@ -11310,6 +11364,7 @@ def test_disable_secret_version_rest_bad_request( 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.disable_secret_version(request) @@ -11348,6 +11403,7 @@ def test_disable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_secret_version(request) # Establish that the response is the type that we expect. @@ -11391,6 +11447,7 @@ def test_disable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11435,6 +11492,7 @@ def test_enable_secret_version_rest_bad_request( 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.enable_secret_version(request) @@ -11473,6 +11531,7 @@ def test_enable_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_secret_version(request) # Establish that the response is the type that we expect. @@ -11516,6 +11575,7 @@ def test_enable_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11560,6 +11620,7 @@ def test_destroy_secret_version_rest_bad_request( 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.destroy_secret_version(request) @@ -11598,6 +11659,7 @@ def test_destroy_secret_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.destroy_secret_version(request) # Establish that the response is the type that we expect. @@ -11641,6 +11703,7 @@ def test_destroy_secret_version_rest_interceptors(null_interceptor): 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 = resources.SecretVersion.to_json(resources.SecretVersion()) req.return_value.content = return_value @@ -11685,6 +11748,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -11718,6 +11782,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -11757,6 +11822,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11801,6 +11867,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -11834,6 +11901,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -11873,6 +11941,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -11917,6 +11986,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -11949,6 +12019,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -11987,6 +12058,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -12033,6 +12105,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -12063,6 +12136,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -12091,6 +12165,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -12121,6 +12196,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/gapic_version.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/gapic_version.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_version.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_version.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py index d80cedadad59..93c28ad18580 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecureSourceManagerTransport from .transports.grpc_asyncio import SecureSourceManagerGrpcAsyncIOTransport +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 SecureSourceManagerAsyncClient: """Secure Source Manager API @@ -313,6 +323,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient`.", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "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.securesourcemanager.v1.SecureSourceManager", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[ @@ -322,7 +354,7 @@ async def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists Instances in a given project and location. @@ -367,8 +399,10 @@ async def sample_list_instances(): 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, 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesAsyncPager: @@ -441,7 +475,7 @@ async def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Instance: r"""Gets details of a single instance. @@ -483,8 +517,10 @@ async def sample_get_instance(): 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, 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: google.cloud.securesourcemanager_v1.types.Instance: @@ -549,7 +585,7 @@ async def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new instance in a given project and location. @@ -609,8 +645,10 @@ async def sample_create_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -689,7 +727,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single instance. @@ -735,8 +773,10 @@ async def sample_delete_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -817,7 +857,7 @@ async def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesAsyncPager: r"""Lists Repositories in a given project and location. @@ -864,8 +904,10 @@ async def sample_list_repositories(): 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, 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesAsyncPager: @@ -940,7 +982,7 @@ async def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Repository: r"""Gets metadata of a repository. @@ -987,8 +1029,10 @@ async def sample_get_repository(): 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, 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: google.cloud.securesourcemanager_v1.types.Repository: @@ -1053,7 +1097,7 @@ async def create_repository( repository_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new repository in a given project and location. @@ -1119,8 +1163,10 @@ async def sample_create_repository(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1198,7 +1244,7 @@ async def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Repository. @@ -1249,8 +1295,10 @@ async def sample_delete_repository(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1329,7 +1377,7 @@ async def get_iam_policy_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Get IAM policy for a repository. @@ -1375,8 +1423,10 @@ async def sample_get_iam_policy_repo(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1462,7 +1512,7 @@ async def set_iam_policy_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Set IAM policy on a repository. @@ -1508,8 +1558,10 @@ async def sample_set_iam_policy_repo(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1595,7 +1647,7 @@ async def test_iam_permissions_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Test IAM permissions on a repository. IAM permission checks are not required on this method. @@ -1643,8 +1695,10 @@ async def sample_test_iam_permissions_repo(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1704,7 +1758,7 @@ async def create_branch_rule( branch_rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""CreateBranchRule creates a branch rule in a given repository. @@ -1762,8 +1816,10 @@ async def sample_create_branch_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1841,7 +1897,7 @@ async def list_branch_rules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBranchRulesAsyncPager: r"""ListBranchRules lists branch rules in a given repository. @@ -1885,8 +1941,10 @@ async def sample_list_branch_rules(): 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, 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager: @@ -1963,7 +2021,7 @@ async def get_branch_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.BranchRule: r"""GetBranchRule gets a branch rule. @@ -2008,8 +2066,10 @@ async def sample_get_branch_rule(): 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, 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: google.cloud.securesourcemanager_v1.types.BranchRule: @@ -2075,7 +2135,7 @@ async def update_branch_rule( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""UpdateBranchRule updates a branch rule. @@ -2131,8 +2191,10 @@ async def sample_update_branch_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2210,7 +2272,7 @@ async def delete_branch_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""DeleteBranchRule deletes a branch rule. @@ -2256,8 +2318,10 @@ async def sample_delete_branch_rule(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2335,7 +2399,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2346,8 +2410,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2388,7 +2454,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2399,8 +2465,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2441,7 +2509,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2457,8 +2525,10 @@ async def delete_operation( 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, 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: None """ @@ -2495,7 +2565,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2510,8 +2580,10 @@ async def cancel_operation( 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, 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: None """ @@ -2548,7 +2620,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -2561,8 +2633,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2667,7 +2741,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -2681,8 +2755,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2787,7 +2863,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -2802,8 +2878,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -2847,7 +2925,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2858,8 +2936,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2900,7 +2980,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2911,8 +2991,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py index 4c1f75effaf0..d3e271c23b75 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -733,6 +743,10 @@ def __init__( # 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( @@ -799,6 +813,29 @@ def __init__( 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.securesourcemanager_v1.SecureSourceManagerClient`.", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "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.securesourcemanager.v1.SecureSourceManager", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[ @@ -808,7 +845,7 @@ def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesPager: r"""Lists Instances in a given project and location. @@ -853,8 +890,10 @@ def sample_list_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesPager: @@ -924,7 +963,7 @@ def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Instance: r"""Gets details of a single instance. @@ -966,8 +1005,10 @@ def sample_get_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.types.Instance: @@ -1029,7 +1070,7 @@ def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new instance in a given project and location. @@ -1089,8 +1130,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1166,7 +1209,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single instance. @@ -1212,8 +1255,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1291,7 +1336,7 @@ def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesPager: r"""Lists Repositories in a given project and location. @@ -1338,8 +1383,10 @@ def sample_list_repositories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesPager: @@ -1411,7 +1458,7 @@ def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Repository: r"""Gets metadata of a repository. @@ -1458,8 +1505,10 @@ def sample_get_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.types.Repository: @@ -1521,7 +1570,7 @@ def create_repository( repository_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new repository in a given project and location. @@ -1587,8 +1636,10 @@ def sample_create_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1663,7 +1714,7 @@ def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Repository. @@ -1714,8 +1765,10 @@ def sample_delete_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1791,7 +1844,7 @@ def get_iam_policy_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Get IAM policy for a repository. @@ -1837,8 +1890,10 @@ def sample_get_iam_policy_repo(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1925,7 +1980,7 @@ def set_iam_policy_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Set IAM policy on a repository. @@ -1971,8 +2026,10 @@ def sample_set_iam_policy_repo(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2059,7 +2116,7 @@ def test_iam_permissions_repo( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Test IAM permissions on a repository. IAM permission checks are not required on this method. @@ -2107,8 +2164,10 @@ def sample_test_iam_permissions_repo(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2171,7 +2230,7 @@ def create_branch_rule( branch_rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""CreateBranchRule creates a branch rule in a given repository. @@ -2229,8 +2288,10 @@ def sample_create_branch_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2305,7 +2366,7 @@ def list_branch_rules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBranchRulesPager: r"""ListBranchRules lists branch rules in a given repository. @@ -2349,8 +2410,10 @@ def sample_list_branch_rules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager: @@ -2424,7 +2487,7 @@ def get_branch_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.BranchRule: r"""GetBranchRule gets a branch rule. @@ -2469,8 +2532,10 @@ def sample_get_branch_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securesourcemanager_v1.types.BranchRule: @@ -2533,7 +2598,7 @@ def update_branch_rule( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""UpdateBranchRule updates a branch rule. @@ -2589,8 +2654,10 @@ def sample_update_branch_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2665,7 +2732,7 @@ def delete_branch_rule( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""DeleteBranchRule deletes a branch rule. @@ -2711,8 +2778,10 @@ def sample_delete_branch_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2800,7 +2869,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2811,8 +2880,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2853,7 +2924,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2864,8 +2935,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2906,7 +2979,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2922,8 +2995,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2960,7 +3035,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2975,8 +3050,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3013,7 +3090,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -3026,8 +3103,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3132,7 +3211,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -3146,8 +3225,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3252,7 +3333,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3267,8 +3348,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3310,7 +3393,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3321,8 +3404,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -3363,7 +3448,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3374,8 +3459,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py index 9174200ff2f1..cb52a19fa30e 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = secure_source_manager.ListInstancesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = secure_source_manager.ListInstancesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = secure_source_manager.ListRepositoriesRequest(request) @@ -295,7 +301,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -309,8 +315,10 @@ def __init__( 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, 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`. """ self._method = method self._request = secure_source_manager.ListRepositoriesRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = secure_source_manager.ListBranchRulesRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = secure_source_manager.ListBranchRulesRequest(request) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py index c6c97119853e..e4e7fd4a1d4c 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securesourcemanager_v1.types import secure_source_manager from .base import DEFAULT_CLIENT_INFO, SecureSourceManagerTransport +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.securesourcemanager.v1.SecureSourceManager", + "rpcName": 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.securesourcemanager.v1.SecureSourceManager", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecureSourceManagerGrpcTransport(SecureSourceManagerTransport): """gRPC backend transport for SecureSourceManager. @@ -208,7 +289,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +358,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -299,7 +387,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListInstances", request_serializer=secure_source_manager.ListInstancesRequest.serialize, response_deserializer=secure_source_manager.ListInstancesResponse.deserialize, @@ -327,7 +415,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetInstance", request_serializer=secure_source_manager.GetInstanceRequest.serialize, response_deserializer=secure_source_manager.Instance.deserialize, @@ -356,7 +444,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateInstance", request_serializer=secure_source_manager.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -384,7 +472,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteInstance", request_serializer=secure_source_manager.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +503,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListRepositories", request_serializer=secure_source_manager.ListRepositoriesRequest.serialize, response_deserializer=secure_source_manager.ListRepositoriesResponse.deserialize, @@ -445,7 +533,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetRepository", request_serializer=secure_source_manager.GetRepositoryRequest.serialize, response_deserializer=secure_source_manager.Repository.deserialize, @@ -475,7 +563,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateRepository", request_serializer=secure_source_manager.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -505,7 +593,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteRepository", request_serializer=secure_source_manager.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +619,7 @@ def get_iam_policy_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy_repo" not in self._stubs: - self._stubs["get_iam_policy_repo"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIamPolicyRepo", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -557,7 +645,7 @@ def set_iam_policy_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy_repo" not in self._stubs: - self._stubs["set_iam_policy_repo"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/SetIamPolicyRepo", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -587,7 +675,7 @@ def test_iam_permissions_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions_repo" not in self._stubs: - self._stubs["test_iam_permissions_repo"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/TestIamPermissionsRepo", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -616,7 +704,7 @@ def create_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_branch_rule" not in self._stubs: - self._stubs["create_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateBranchRule", request_serializer=secure_source_manager.CreateBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -646,7 +734,7 @@ def list_branch_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_branch_rules" not in self._stubs: - self._stubs["list_branch_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_branch_rules"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListBranchRules", request_serializer=secure_source_manager.ListBranchRulesRequest.serialize, response_deserializer=secure_source_manager.ListBranchRulesResponse.deserialize, @@ -674,7 +762,7 @@ def get_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_branch_rule" not in self._stubs: - self._stubs["get_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetBranchRule", request_serializer=secure_source_manager.GetBranchRuleRequest.serialize, response_deserializer=secure_source_manager.BranchRule.deserialize, @@ -702,7 +790,7 @@ def update_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_branch_rule" not in self._stubs: - self._stubs["update_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateBranchRule", request_serializer=secure_source_manager.UpdateBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -730,7 +818,7 @@ def delete_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_branch_rule" not in self._stubs: - self._stubs["delete_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteBranchRule", request_serializer=secure_source_manager.DeleteBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -738,7 +826,7 @@ def delete_branch_rule( return self._stubs["delete_branch_rule"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -750,7 +838,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -767,7 +855,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -784,7 +872,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -803,7 +891,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -822,7 +910,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -839,7 +927,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -864,7 +952,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -890,7 +978,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -919,7 +1007,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py index b6d7443bda6f..056667bacf96 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securesourcemanager_v1.types import secure_source_manager from .base import DEFAULT_CLIENT_INFO, SecureSourceManagerTransport from .grpc import SecureSourceManagerGrpcTransport +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.securesourcemanager.v1.SecureSourceManager", + "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.securesourcemanager.v1.SecureSourceManager", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecureSourceManagerGrpcAsyncIOTransport(SecureSourceManagerTransport): """gRPC AsyncIO backend transport for SecureSourceManager. @@ -255,10 +337,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -281,7 +366,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -309,7 +394,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListInstances", request_serializer=secure_source_manager.ListInstancesRequest.serialize, response_deserializer=secure_source_manager.ListInstancesResponse.deserialize, @@ -338,7 +423,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetInstance", request_serializer=secure_source_manager.GetInstanceRequest.serialize, response_deserializer=secure_source_manager.Instance.deserialize, @@ -368,7 +453,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateInstance", request_serializer=secure_source_manager.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteInstance", request_serializer=secure_source_manager.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +513,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListRepositories", request_serializer=secure_source_manager.ListRepositoriesRequest.serialize, response_deserializer=secure_source_manager.ListRepositoriesResponse.deserialize, @@ -459,7 +544,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetRepository", request_serializer=secure_source_manager.GetRepositoryRequest.serialize, response_deserializer=secure_source_manager.Repository.deserialize, @@ -490,7 +575,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateRepository", request_serializer=secure_source_manager.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -521,7 +606,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteRepository", request_serializer=secure_source_manager.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -547,7 +632,7 @@ def get_iam_policy_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy_repo" not in self._stubs: - self._stubs["get_iam_policy_repo"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIamPolicyRepo", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -573,7 +658,7 @@ def set_iam_policy_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy_repo" not in self._stubs: - self._stubs["set_iam_policy_repo"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/SetIamPolicyRepo", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -603,7 +688,7 @@ def test_iam_permissions_repo( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions_repo" not in self._stubs: - self._stubs["test_iam_permissions_repo"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions_repo"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/TestIamPermissionsRepo", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -633,7 +718,7 @@ def create_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_branch_rule" not in self._stubs: - self._stubs["create_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateBranchRule", request_serializer=secure_source_manager.CreateBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -663,7 +748,7 @@ def list_branch_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_branch_rules" not in self._stubs: - self._stubs["list_branch_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_branch_rules"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListBranchRules", request_serializer=secure_source_manager.ListBranchRulesRequest.serialize, response_deserializer=secure_source_manager.ListBranchRulesResponse.deserialize, @@ -692,7 +777,7 @@ def get_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_branch_rule" not in self._stubs: - self._stubs["get_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetBranchRule", request_serializer=secure_source_manager.GetBranchRuleRequest.serialize, response_deserializer=secure_source_manager.BranchRule.deserialize, @@ -721,7 +806,7 @@ def update_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_branch_rule" not in self._stubs: - self._stubs["update_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateBranchRule", request_serializer=secure_source_manager.UpdateBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -750,7 +835,7 @@ def delete_branch_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_branch_rule" not in self._stubs: - self._stubs["delete_branch_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_branch_rule"] = self._logged_channel.unary_unary( "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteBranchRule", request_serializer=secure_source_manager.DeleteBranchRuleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1023,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -954,7 +1039,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -971,7 +1056,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -988,7 +1073,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1007,7 +1092,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1026,7 +1111,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1043,7 +1128,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1068,7 +1153,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1094,7 +1179,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1123,7 +1208,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py index 93c180c6b202..d8e051e3f7d9 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -201,9 +209,10 @@ def post_update_branch_rule(self, response): def pre_create_branch_rule( self, request: secure_source_manager.CreateBranchRuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.CreateBranchRuleRequest, Sequence[Tuple[str, str]] + secure_source_manager.CreateBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_branch_rule @@ -226,8 +235,11 @@ def post_create_branch_rule( def pre_create_instance( self, request: secure_source_manager.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.CreateInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -249,9 +261,10 @@ def post_create_instance( def pre_create_repository( self, request: secure_source_manager.CreateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.CreateRepositoryRequest, Sequence[Tuple[str, str]] + secure_source_manager.CreateRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_repository @@ -274,9 +287,10 @@ def post_create_repository( def pre_delete_branch_rule( self, request: secure_source_manager.DeleteBranchRuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.DeleteBranchRuleRequest, Sequence[Tuple[str, str]] + secure_source_manager.DeleteBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_branch_rule @@ -299,8 +313,11 @@ def post_delete_branch_rule( def pre_delete_instance( self, request: secure_source_manager.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.DeleteInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -322,9 +339,10 @@ def post_delete_instance( def pre_delete_repository( self, request: secure_source_manager.DeleteRepositoryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.DeleteRepositoryRequest, Sequence[Tuple[str, str]] + secure_source_manager.DeleteRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_repository @@ -347,8 +365,11 @@ def post_delete_repository( def pre_get_branch_rule( self, request: secure_source_manager.GetBranchRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.GetBranchRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_branch_rule Override in a subclass to manipulate the request or metadata @@ -370,8 +391,10 @@ def post_get_branch_rule( def pre_get_iam_policy_repo( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy_repo Override in a subclass to manipulate the request or metadata @@ -393,8 +416,11 @@ def post_get_iam_policy_repo( def pre_get_instance( self, request: secure_source_manager.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -416,8 +442,11 @@ def post_get_instance( def pre_get_repository( self, request: secure_source_manager.GetRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.GetRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_repository Override in a subclass to manipulate the request or metadata @@ -439,8 +468,11 @@ def post_get_repository( def pre_list_branch_rules( self, request: secure_source_manager.ListBranchRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.ListBranchRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListBranchRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_branch_rules Override in a subclass to manipulate the request or metadata @@ -462,8 +494,11 @@ def post_list_branch_rules( def pre_list_instances( self, request: secure_source_manager.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[secure_source_manager.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -485,9 +520,10 @@ def post_list_instances( def pre_list_repositories( self, request: secure_source_manager.ListRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.ListRepositoriesRequest, Sequence[Tuple[str, str]] + secure_source_manager.ListRepositoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_repositories @@ -510,8 +546,10 @@ def post_list_repositories( def pre_set_iam_policy_repo( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy_repo Override in a subclass to manipulate the request or metadata @@ -533,8 +571,11 @@ def post_set_iam_policy_repo( def pre_test_iam_permissions_repo( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions_repo Override in a subclass to manipulate the request or metadata @@ -556,9 +597,10 @@ def post_test_iam_permissions_repo( def pre_update_branch_rule( self, request: secure_source_manager.UpdateBranchRuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.UpdateBranchRuleRequest, Sequence[Tuple[str, str]] + secure_source_manager.UpdateBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_branch_rule @@ -581,8 +623,10 @@ def post_update_branch_rule( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -604,8 +648,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -627,8 +673,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -648,8 +696,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -669,8 +719,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -692,8 +745,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -713,8 +768,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -734,8 +791,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -757,8 +816,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -978,7 +1039,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create branch rule method over HTTP. @@ -989,8 +1050,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1003,6 +1066,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_branch_rule( request, metadata ) @@ -1019,6 +1083,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.CreateBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._CreateBranchRule._get_response( self._host, @@ -1038,7 +1129,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_branch_rule(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.securesourcemanager_v1.SecureSourceManagerClient.create_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstance( @@ -1077,7 +1190,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -1088,8 +1201,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1102,6 +1217,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -1116,6 +1232,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.CreateInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._CreateInstance._get_response( self._host, @@ -1135,7 +1278,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(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.securesourcemanager_v1.SecureSourceManagerClient.create_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRepository( @@ -1174,7 +1339,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create repository method over HTTP. @@ -1185,8 +1350,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1199,6 +1366,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_create_repository( request, metadata ) @@ -1215,6 +1383,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.CreateRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._CreateRepository._get_response( self._host, @@ -1234,7 +1429,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_repository(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.securesourcemanager_v1.SecureSourceManagerClient.create_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBranchRule( @@ -1272,7 +1489,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete branch rule method over HTTP. @@ -1283,8 +1500,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1297,6 +1516,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_branch_rule( request, metadata ) @@ -1309,6 +1529,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.DeleteBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._DeleteBranchRule._get_response( self._host, @@ -1327,7 +1574,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_branch_rule(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.securesourcemanager_v1.SecureSourceManagerClient.delete_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -1365,7 +1634,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -1376,8 +1645,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1390,6 +1661,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -1400,6 +1672,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._DeleteInstance._get_response( self._host, @@ -1418,7 +1717,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(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.securesourcemanager_v1.SecureSourceManagerClient.delete_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRepository( @@ -1456,7 +1777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete repository method over HTTP. @@ -1467,8 +1788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1481,6 +1804,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_http_options() ) + request, metadata = self._interceptor.pre_delete_repository( request, metadata ) @@ -1493,6 +1817,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.DeleteRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._DeleteRepository._get_response( self._host, @@ -1511,7 +1862,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_repository(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.securesourcemanager_v1.SecureSourceManagerClient.delete_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBranchRule( @@ -1549,7 +1922,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.BranchRule: r"""Call the get branch rule method over HTTP. @@ -1560,8 +1933,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.BranchRule: @@ -1575,6 +1950,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_branch_rule(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_transcoded_request( http_options, request @@ -1585,6 +1961,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetBranchRule._get_response( self._host, @@ -1605,7 +2008,31 @@ def __call__( pb_resp = secure_source_manager.BranchRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_branch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.BranchRule.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.securesourcemanager_v1.SecureSourceManagerClient.get_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicyRepo( @@ -1643,7 +2070,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy repo method over HTTP. @@ -1653,8 +2080,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1739,6 +2168,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy_repo( request, metadata ) @@ -1751,6 +2181,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetIamPolicyRepo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicyRepo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetIamPolicyRepo._get_response( self._host, @@ -1771,7 +2228,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy_repo(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.securesourcemanager_v1.SecureSourceManagerClient.get_iam_policy_repo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicyRepo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -1809,7 +2288,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Instance: r"""Call the get instance method over HTTP. @@ -1820,8 +2299,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.Instance: @@ -1833,6 +2314,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_transcoded_request( http_options, request @@ -1843,6 +2325,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetInstance._get_response( self._host, @@ -1863,7 +2372,29 @@ def __call__( pb_resp = secure_source_manager.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Instance.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.securesourcemanager_v1.SecureSourceManagerClient.get_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRepository( @@ -1901,7 +2432,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.Repository: r"""Call the get repository method over HTTP. @@ -1912,8 +2443,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.Repository: @@ -1925,6 +2458,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_http_options() ) + request, metadata = self._interceptor.pre_get_repository(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_transcoded_request( http_options, request @@ -1935,6 +2469,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetRepository._get_response( self._host, @@ -1955,7 +2516,31 @@ def __call__( pb_resp = secure_source_manager.Repository.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Repository.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.securesourcemanager_v1.SecureSourceManagerClient.get_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBranchRules( @@ -1993,7 +2578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.ListBranchRulesResponse: r"""Call the list branch rules method over HTTP. @@ -2004,8 +2589,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.ListBranchRulesResponse: @@ -2017,6 +2604,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_branch_rules( request, metadata ) @@ -2029,6 +2617,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.ListBranchRules", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListBranchRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._ListBranchRules._get_response( self._host, @@ -2049,7 +2664,31 @@ def __call__( pb_resp = secure_source_manager.ListBranchRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_branch_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListBranchRulesResponse.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.securesourcemanager_v1.SecureSourceManagerClient.list_branch_rules", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListBranchRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -2087,7 +2726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -2098,8 +2737,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.ListInstancesResponse: @@ -2109,6 +2750,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -2119,6 +2761,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.ListInstances", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._ListInstances._get_response( self._host, @@ -2139,7 +2808,31 @@ def __call__( pb_resp = secure_source_manager.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListInstancesResponse.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.securesourcemanager_v1.SecureSourceManagerClient.list_instances", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRepositories( @@ -2177,7 +2870,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> secure_source_manager.ListRepositoriesResponse: r"""Call the list repositories method over HTTP. @@ -2188,8 +2881,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.secure_source_manager.ListRepositoriesResponse: @@ -2199,6 +2894,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_list_repositories( request, metadata ) @@ -2211,6 +2907,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.ListRepositories", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._ListRepositories._get_response( self._host, @@ -2231,7 +2954,31 @@ def __call__( pb_resp = secure_source_manager.ListRepositoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_repositories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListRepositoriesResponse.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.securesourcemanager_v1.SecureSourceManagerClient.list_repositories", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicyRepo( @@ -2270,7 +3017,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy repo method over HTTP. @@ -2280,8 +3027,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2366,6 +3115,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy_repo( request, metadata ) @@ -2382,6 +3132,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.SetIamPolicyRepo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicyRepo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._SetIamPolicyRepo._get_response( self._host, @@ -2403,7 +3180,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy_repo(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.securesourcemanager_v1.SecureSourceManagerClient.set_iam_policy_repo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicyRepo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissionsRepo( @@ -2442,7 +3241,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions repo method over HTTP. @@ -2452,8 +3251,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2463,6 +3264,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions_repo( request, metadata ) @@ -2479,6 +3281,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.TestIamPermissionsRepo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "TestIamPermissionsRepo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecureSourceManagerRestTransport._TestIamPermissionsRepo._get_response( @@ -2502,7 +3331,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions_repo(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.securesourcemanager_v1.SecureSourceManagerClient.test_iam_permissions_repo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "TestIamPermissionsRepo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBranchRule( @@ -2541,7 +3392,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update branch rule method over HTTP. @@ -2552,8 +3403,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2566,6 +3419,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_branch_rule( request, metadata ) @@ -2582,6 +3436,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.UpdateBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "UpdateBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._UpdateBranchRule._get_response( self._host, @@ -2601,7 +3482,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_branch_rule(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.securesourcemanager_v1.SecureSourceManagerClient.update_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "UpdateBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2803,7 +3706,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2813,8 +3716,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2823,6 +3728,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2833,6 +3739,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetLocation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetLocation._get_response( self._host, @@ -2852,6 +3785,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.securesourcemanager_v1.SecureSourceManagerAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2893,7 +3847,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2903,8 +3857,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2913,6 +3869,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2923,6 +3880,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.ListLocations", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._ListLocations._get_response( self._host, @@ -2942,6 +3926,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.securesourcemanager_v1.SecureSourceManagerAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2983,7 +3988,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -2993,8 +3998,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -3003,6 +4010,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3013,6 +4021,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetIamPolicy._get_response( self._host, @@ -3032,6 +4067,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.securesourcemanager_v1.SecureSourceManagerAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3074,7 +4130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -3084,8 +4140,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -3094,6 +4152,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3108,6 +4167,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._SetIamPolicy._get_response( self._host, @@ -3128,6 +4214,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.securesourcemanager_v1.SecureSourceManagerAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3170,7 +4277,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -3180,8 +4287,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -3190,6 +4299,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3206,6 +4316,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecureSourceManagerRestTransport._TestIamPermissions._get_response( @@ -3228,6 +4365,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.securesourcemanager_v1.SecureSourceManagerAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3270,7 +4428,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3280,13 +4438,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecureSourceManagerRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3303,6 +4464,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.CancelOperation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._CancelOperation._get_response( self._host, @@ -3360,7 +4548,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3370,13 +4558,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecureSourceManagerRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3389,6 +4580,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._DeleteOperation._get_response( self._host, @@ -3445,7 +4663,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3455,8 +4673,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -3465,6 +4685,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3475,6 +4696,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.GetOperation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._GetOperation._get_response( self._host, @@ -3494,6 +4742,27 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3535,7 +4804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3545,8 +4814,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3555,6 +4826,7 @@ def __call__( http_options = ( _BaseSecureSourceManagerRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3565,6 +4837,33 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerClient.ListOperations", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecureSourceManagerRestTransport._ListOperations._get_response( self._host, @@ -3584,6 +4883,27 @@ def __call__( 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.securesourcemanager_v1.SecureSourceManagerAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json b/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json index 1ba46dadbee3..61b28fdc2e03 100644 --- a/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securesourcemanager", - "version": "0.1.11" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.Instance", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.Instance", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.Repository", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.types.Repository", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesPager", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesAsyncPager", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesPager", @@ -2188,7 +2188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2514,7 +2514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2598,7 +2598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py b/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py index 3b9222499989..041910d28985 100644 --- a/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py +++ b/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py @@ -7456,6 +7456,7 @@ def test_list_instances_rest_required_fields( response_value._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_instances(request) @@ -7511,6 +7512,7 @@ def test_list_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instances(**mock_args) @@ -7704,6 +7706,7 @@ def test_get_instance_rest_required_fields( response_value._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_instance(request) @@ -7751,6 +7754,7 @@ def test_get_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -7897,6 +7901,7 @@ def test_create_instance_rest_required_fields( response_value._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_instance(request) @@ -7962,6 +7967,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -8097,6 +8103,7 @@ def test_delete_instance_rest_required_fields( response_value._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_instance(request) @@ -8142,6 +8149,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -8285,6 +8293,7 @@ def test_list_repositories_rest_required_fields( response_value._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_repositories(request) @@ -8340,6 +8349,7 @@ def test_list_repositories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_repositories(**mock_args) @@ -8534,6 +8544,7 @@ def test_get_repository_rest_required_fields( response_value._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_repository(request) @@ -8581,6 +8592,7 @@ def test_get_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_repository(**mock_args) @@ -8725,6 +8737,7 @@ def test_create_repository_rest_required_fields( response_value._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_repository(request) @@ -8785,6 +8798,7 @@ def test_create_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_repository(**mock_args) @@ -8923,6 +8937,7 @@ def test_delete_repository_rest_required_fields( response_value._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_repository(request) @@ -8968,6 +8983,7 @@ def test_delete_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_repository(**mock_args) @@ -9103,6 +9119,7 @@ def test_get_iam_policy_repo_rest_required_fields( response_value._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_iam_policy_repo(request) @@ -9148,6 +9165,7 @@ def test_get_iam_policy_repo_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy_repo(**mock_args) @@ -9282,6 +9300,7 @@ def test_set_iam_policy_repo_rest_required_fields( response_value._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.set_iam_policy_repo(request) @@ -9335,6 +9354,7 @@ def test_set_iam_policy_repo_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy_repo(**mock_args) @@ -9474,6 +9494,7 @@ def test_test_iam_permissions_repo_rest_required_fields( response_value._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.test_iam_permissions_repo(request) @@ -9527,6 +9548,7 @@ def test_test_iam_permissions_repo_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions_repo(**mock_args) @@ -9673,6 +9695,7 @@ def test_create_branch_rule_rest_required_fields( response_value._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_branch_rule(request) @@ -9735,6 +9758,7 @@ def test_create_branch_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch_rule(**mock_args) @@ -9879,6 +9903,7 @@ def test_list_branch_rules_rest_required_fields( response_value._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_branch_rules(request) @@ -9934,6 +9959,7 @@ def test_list_branch_rules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch_rules(**mock_args) @@ -10130,6 +10156,7 @@ def test_get_branch_rule_rest_required_fields( response_value._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_branch_rule(request) @@ -10177,6 +10204,7 @@ def test_get_branch_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch_rule(**mock_args) @@ -10316,6 +10344,7 @@ def test_update_branch_rule_rest_required_fields( response_value._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_branch_rule(request) @@ -10377,6 +10406,7 @@ def test_update_branch_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch_rule(**mock_args) @@ -10516,6 +10546,7 @@ def test_delete_branch_rule_rest_required_fields( response_value._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_branch_rule(request) @@ -10561,6 +10592,7 @@ def test_delete_branch_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_branch_rule(**mock_args) @@ -11552,6 +11584,7 @@ def test_list_instances_rest_bad_request( 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_instances(request) @@ -11588,6 +11621,7 @@ def test_list_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instances(request) # Establish that the response is the type that we expect. @@ -11629,6 +11663,7 @@ def test_list_instances_rest_interceptors(null_interceptor): 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 = secure_source_manager.ListInstancesResponse.to_json( secure_source_manager.ListInstancesResponse() ) @@ -11675,6 +11710,7 @@ def test_get_instance_rest_bad_request( 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_instance(request) @@ -11713,6 +11749,7 @@ def test_get_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -11759,6 +11796,7 @@ def test_get_instance_rest_interceptors(null_interceptor): 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 = secure_source_manager.Instance.to_json( secure_source_manager.Instance() ) @@ -11805,6 +11843,7 @@ def test_create_instance_rest_bad_request( 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_instance(request) @@ -11927,6 +11966,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -11968,6 +12008,7 @@ def test_create_instance_rest_interceptors(null_interceptor): 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 @@ -12012,6 +12053,7 @@ def test_delete_instance_rest_bad_request( 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_instance(request) @@ -12042,6 +12084,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -12083,6 +12126,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): 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 @@ -12127,6 +12171,7 @@ def test_list_repositories_rest_bad_request( 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_repositories(request) @@ -12162,6 +12207,7 @@ def test_list_repositories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_repositories(request) # Establish that the response is the type that we expect. @@ -12202,6 +12248,7 @@ def test_list_repositories_rest_interceptors(null_interceptor): 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 = secure_source_manager.ListRepositoriesResponse.to_json( secure_source_manager.ListRepositoriesResponse() ) @@ -12248,6 +12295,7 @@ def test_get_repository_rest_bad_request( 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_repository(request) @@ -12287,6 +12335,7 @@ def test_get_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_repository(request) # Establish that the response is the type that we expect. @@ -12331,6 +12380,7 @@ def test_get_repository_rest_interceptors(null_interceptor): 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 = secure_source_manager.Repository.to_json( secure_source_manager.Repository() ) @@ -12377,6 +12427,7 @@ def test_create_repository_rest_bad_request( 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_repository(request) @@ -12494,6 +12545,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_repository(request) # Establish that the response is the type that we expect. @@ -12535,6 +12587,7 @@ def test_create_repository_rest_interceptors(null_interceptor): 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 @@ -12579,6 +12632,7 @@ def test_delete_repository_rest_bad_request( 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_repository(request) @@ -12609,6 +12663,7 @@ def test_delete_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_repository(request) # Establish that the response is the type that we expect. @@ -12650,6 +12705,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): 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 @@ -12696,6 +12752,7 @@ def test_get_iam_policy_repo_rest_bad_request( 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_iam_policy_repo(request) @@ -12731,6 +12788,7 @@ def test_get_iam_policy_repo_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy_repo(request) # Establish that the response is the type that we expect. @@ -12770,6 +12828,7 @@ def test_get_iam_policy_repo_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -12816,6 +12875,7 @@ def test_set_iam_policy_repo_rest_bad_request( 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.set_iam_policy_repo(request) @@ -12851,6 +12911,7 @@ def test_set_iam_policy_repo_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy_repo(request) # Establish that the response is the type that we expect. @@ -12890,6 +12951,7 @@ def test_set_iam_policy_repo_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -12936,6 +12998,7 @@ def test_test_iam_permissions_repo_rest_bad_request( 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.test_iam_permissions_repo(request) @@ -12970,6 +13033,7 @@ def test_test_iam_permissions_repo_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions_repo(request) # Establish that the response is the type that we expect. @@ -13008,6 +13072,7 @@ def test_test_iam_permissions_repo_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -13054,6 +13119,7 @@ def test_create_branch_rule_rest_bad_request( 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_branch_rule(request) @@ -13170,6 +13236,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch_rule(request) # Establish that the response is the type that we expect. @@ -13211,6 +13278,7 @@ def test_create_branch_rule_rest_interceptors(null_interceptor): 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 @@ -13255,6 +13323,7 @@ def test_list_branch_rules_rest_bad_request( 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_branch_rules(request) @@ -13290,6 +13359,7 @@ def test_list_branch_rules_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch_rules(request) # Establish that the response is the type that we expect. @@ -13330,6 +13400,7 @@ def test_list_branch_rules_rest_interceptors(null_interceptor): 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 = secure_source_manager.ListBranchRulesResponse.to_json( secure_source_manager.ListBranchRulesResponse() ) @@ -13378,6 +13449,7 @@ def test_get_branch_rule_rest_bad_request( 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_branch_rule(request) @@ -13425,6 +13497,7 @@ def test_get_branch_rule_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch_rule(request) # Establish that the response is the type that we expect. @@ -13475,6 +13548,7 @@ def test_get_branch_rule_rest_interceptors(null_interceptor): 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 = secure_source_manager.BranchRule.to_json( secure_source_manager.BranchRule() ) @@ -13525,6 +13599,7 @@ def test_update_branch_rule_rest_bad_request( 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_branch_rule(request) @@ -13645,6 +13720,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch_rule(request) # Establish that the response is the type that we expect. @@ -13686,6 +13762,7 @@ def test_update_branch_rule_rest_interceptors(null_interceptor): 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 @@ -13732,6 +13809,7 @@ def test_delete_branch_rule_rest_bad_request( 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_branch_rule(request) @@ -13764,6 +13842,7 @@ def test_delete_branch_rule_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_branch_rule(request) # Establish that the response is the type that we expect. @@ -13805,6 +13884,7 @@ def test_delete_branch_rule_rest_interceptors(null_interceptor): 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 @@ -13849,6 +13929,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -13879,6 +13960,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -13907,6 +13989,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -13937,6 +14020,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -13967,6 +14051,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -13997,6 +14082,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -14027,6 +14113,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -14057,6 +14144,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -14087,6 +14175,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -14117,6 +14206,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -14147,6 +14237,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -14177,6 +14268,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -14207,6 +14299,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -14237,6 +14330,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -14267,6 +14361,7 @@ def test_get_operation_rest_bad_request( 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) @@ -14297,6 +14392,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -14327,6 +14423,7 @@ def test_list_operations_rest_bad_request( 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) @@ -14357,6 +14454,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter/gapic_version.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter/gapic_version.py index 56614055fa74..558c8aab67c5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter/gapic_version.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.35.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/gapic_version.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/gapic_version.py index 56614055fa74..558c8aab67c5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/gapic_version.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.35.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/async_client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/async_client.py index c0dcf57d8629..7d6bf0bf047a 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/async_client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -137,6 +138,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .transports.grpc_asyncio import SecurityCenterGrpcAsyncIOTransport +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 SecurityCenterAsyncClient: """V1 APIs for Security Center service.""" @@ -420,6 +430,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securitycenter_v1.SecurityCenterAsyncClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "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.securitycenter.v1.SecurityCenter", + "credentialsType": None, + }, + ) + async def bulk_mute_findings( self, request: Optional[ @@ -429,7 +461,7 @@ async def bulk_mute_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Kicks off an LRO to bulk mute findings for a parent based on a filter. The parent can be either an @@ -490,8 +522,10 @@ async def sample_bulk_mute_findings(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -572,7 +606,7 @@ async def create_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: r"""Creates a resident SecurityHealthAnalyticsCustomModule at the scope of the @@ -634,8 +668,10 @@ async def sample_create_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -718,7 +754,7 @@ async def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -770,8 +806,10 @@ async def sample_create_source(): 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, 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: google.cloud.securitycenter_v1.types.Source: @@ -842,7 +880,7 @@ async def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -907,8 +945,10 @@ async def sample_create_finding(): 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, 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: google.cloud.securitycenter_v1.types.Finding: @@ -985,7 +1025,7 @@ async def create_mute_config( mute_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Creates a mute config. @@ -1055,8 +1095,10 @@ async def sample_create_mute_config(): 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, 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -1128,7 +1170,7 @@ async def create_notification_config( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -1195,8 +1237,10 @@ async def sample_create_notification_config(): 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, 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -1269,7 +1313,7 @@ async def delete_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing mute config. @@ -1317,8 +1361,10 @@ async def sample_delete_mute_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1372,7 +1418,7 @@ async def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -1417,8 +1463,10 @@ async def sample_delete_notification_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1477,7 +1525,7 @@ async def delete_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified SecurityHealthAnalyticsCustomModule and all of its @@ -1525,8 +1573,10 @@ async def sample_delete_security_health_analytics_custom_module(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1587,7 +1637,7 @@ async def get_simulation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Get the simulation by name or the latest simulation for the given organization. @@ -1639,8 +1689,10 @@ async def sample_get_simulation(): 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, 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: google.cloud.securitycenter_v1.types.Simulation: @@ -1701,7 +1753,7 @@ async def get_valued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Get the valued resource by name @@ -1747,8 +1799,10 @@ async def sample_get_valued_resource(): 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, 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: google.cloud.securitycenter_v1.types.ValuedResource: @@ -1811,7 +1865,7 @@ async def get_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Gets a BigQuery export. @@ -1858,8 +1912,10 @@ async def sample_get_big_query_export(): 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, 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -1920,7 +1976,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -1967,8 +2023,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2056,7 +2114,7 @@ async def get_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Gets a mute config. @@ -2107,8 +2165,10 @@ async def sample_get_mute_config(): 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, 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -2172,7 +2232,7 @@ async def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -2220,8 +2280,10 @@ async def sample_get_notification_config(): 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, 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -2288,7 +2350,7 @@ async def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -2333,8 +2395,10 @@ async def sample_get_organization_settings(): 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, 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: google.cloud.securitycenter_v1.types.OrganizationSettings: @@ -2403,7 +2467,7 @@ async def get_effective_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule: r"""Retrieves an EffectiveSecurityHealthAnalyticsCustomModule. @@ -2453,8 +2517,10 @@ async def sample_get_effective_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: @@ -2537,7 +2603,7 @@ async def get_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: r"""Retrieves a SecurityHealthAnalyticsCustomModule. @@ -2585,8 +2651,10 @@ async def sample_get_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -2662,7 +2730,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -2706,8 +2774,10 @@ async def sample_get_source(): 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, 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: google.cloud.securitycenter_v1.types.Source: @@ -2773,7 +2843,7 @@ async def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsAsyncPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -2813,8 +2883,10 @@ async def sample_group_assets(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.GroupAssetsAsyncPager: @@ -2882,7 +2954,7 @@ async def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsAsyncPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -2954,8 +3026,10 @@ async def sample_group_findings(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.GroupFindingsAsyncPager: @@ -3031,7 +3105,7 @@ async def list_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Lists an organization's assets. @@ -3068,8 +3142,10 @@ async def sample_list_assets(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListAssetsAsyncPager: @@ -3139,7 +3215,7 @@ async def list_descendant_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all resident SecurityHealthAnalyticsCustomModules under the given CRM @@ -3190,8 +3266,10 @@ async def sample_list_descendant_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -3274,7 +3352,7 @@ async def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""Lists an organization or source's findings. @@ -3314,8 +3392,10 @@ async def sample_list_findings(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListFindingsAsyncPager: @@ -3378,7 +3458,7 @@ async def list_mute_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMuteConfigsAsyncPager: r"""Lists mute configs. @@ -3426,8 +3506,10 @@ async def sample_list_mute_configs(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListMuteConfigsAsyncPager: @@ -3504,7 +3586,7 @@ async def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsAsyncPager: r"""Lists notification configs. @@ -3551,8 +3633,10 @@ async def sample_list_notification_configs(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListNotificationConfigsAsyncPager: @@ -3634,7 +3718,7 @@ async def list_effective_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all EffectiveSecurityHealthAnalyticsCustomModules for the @@ -3687,8 +3771,10 @@ async def sample_list_effective_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -3775,7 +3861,7 @@ async def list_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all SecurityHealthAnalyticsCustomModules for the given @@ -3827,8 +3913,10 @@ async def sample_list_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -3912,7 +4000,7 @@ async def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesAsyncPager: r"""Lists all sources belonging to an organization. @@ -3958,8 +4046,10 @@ async def sample_list_sources(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListSourcesAsyncPager: @@ -4036,7 +4126,7 @@ async def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -4090,8 +4180,10 @@ async def sample_run_asset_discovery(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4172,7 +4264,7 @@ async def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -4235,8 +4327,10 @@ async def sample_set_finding_state(): 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, 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: google.cloud.securitycenter_v1.types.Finding: @@ -4310,7 +4404,7 @@ async def set_mute( mute: Optional[finding.Finding.Mute] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the mute state of a finding. @@ -4366,8 +4460,10 @@ async def sample_set_mute(): 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, 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: google.cloud.securitycenter_v1.types.Finding: @@ -4436,7 +4532,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -4483,8 +4579,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -4571,7 +4669,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -4628,8 +4726,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -4698,7 +4798,7 @@ async def simulate_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse: r"""Simulates a given SecurityHealthAnalyticsCustomModule and Resource. @@ -4766,8 +4866,10 @@ async def sample_simulate_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -4840,7 +4942,7 @@ async def update_external_system( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Updates external system. This is for a given finding. @@ -4892,8 +4994,10 @@ async def sample_update_external_system(): 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, 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: google.cloud.securitycenter_v1.types.ExternalSystem: @@ -4960,7 +5064,7 @@ async def update_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -5009,8 +5113,10 @@ async def sample_update_finding(): 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, 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: google.cloud.securitycenter_v1.types.Finding: @@ -5084,7 +5190,7 @@ async def update_mute_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Updates a mute config. @@ -5139,8 +5245,10 @@ async def sample_update_mute_config(): 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, 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -5211,7 +5319,7 @@ async def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -5264,8 +5372,10 @@ async def sample_update_notification_config(): 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, 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -5340,7 +5450,7 @@ async def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -5383,8 +5493,10 @@ async def sample_update_organization_settings(): 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, 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: google.cloud.securitycenter_v1.types.OrganizationSettings: @@ -5458,7 +5570,7 @@ async def update_security_health_analytics_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: r"""Updates the SecurityHealthAnalyticsCustomModule under the given name based on the given update mask. Updating @@ -5517,8 +5629,10 @@ async def sample_update_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -5609,7 +5723,7 @@ async def update_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -5652,8 +5766,10 @@ async def sample_update_source(): 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, 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: google.cloud.securitycenter_v1.types.Source: @@ -5722,7 +5838,7 @@ async def update_security_marks( security_marks: Optional[gcs_security_marks.SecurityMarks] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -5765,8 +5881,10 @@ async def sample_update_security_marks(): 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, 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: google.cloud.securitycenter_v1.types.SecurityMarks: @@ -5839,7 +5957,7 @@ async def create_big_query_export( big_query_export_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Creates a BigQuery export. @@ -5905,8 +6023,10 @@ async def sample_create_big_query_export(): 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, 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -5973,7 +6093,7 @@ async def delete_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing BigQuery export. @@ -6017,8 +6137,10 @@ async def sample_delete_big_query_export(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -6073,7 +6195,7 @@ async def update_big_query_export( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Updates a BigQuery export. @@ -6124,8 +6246,10 @@ async def sample_update_big_query_export(): 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, 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -6192,7 +6316,7 @@ async def list_big_query_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryExportsAsyncPager: r"""Lists BigQuery exports. Note that when requesting BigQuery exports at a given level all exports under that @@ -6245,8 +6369,10 @@ async def sample_list_big_query_exports(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListBigQueryExportsAsyncPager: @@ -6329,7 +6455,7 @@ async def create_event_threat_detection_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Creates a resident Event Threat Detection custom module at the scope of the given Resource Manager @@ -6390,8 +6516,10 @@ async def sample_create_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -6475,7 +6603,7 @@ async def delete_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified Event Threat Detection custom module and all of its descendants in the Resource @@ -6524,8 +6652,10 @@ async def sample_delete_event_threat_detection_custom_module(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -6588,7 +6718,7 @@ async def get_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Gets an Event Threat Detection custom module. @@ -6637,8 +6767,10 @@ async def sample_get_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -6715,7 +6847,7 @@ async def list_descendant_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: r"""Lists all resident Event Threat Detection custom modules under the given Resource Manager parent and its @@ -6769,8 +6901,10 @@ async def sample_list_descendant_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: @@ -6857,7 +6991,7 @@ async def list_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesAsyncPager: r"""Lists all Event Threat Detection custom modules for the given Resource Manager parent. This includes @@ -6911,8 +7045,10 @@ async def sample_list_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEventThreatDetectionCustomModulesAsyncPager: @@ -7001,7 +7137,7 @@ async def update_event_threat_detection_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Updates the Event Threat Detection custom module with the given name based on the given update mask. Updating @@ -7057,8 +7193,10 @@ async def sample_update_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -7148,7 +7286,7 @@ async def validate_event_threat_detection_custom_module( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse: r"""Validates the given Event Threat Detection custom module. @@ -7188,8 +7326,10 @@ async def sample_validate_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.ValidateEventThreatDetectionCustomModuleResponse: @@ -7248,7 +7388,7 @@ async def get_effective_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule: r"""Gets an effective Event Threat Detection custom module at the given level. @@ -7299,8 +7439,10 @@ async def sample_get_effective_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycenter_v1.types.EffectiveEventThreatDetectionCustomModule: @@ -7383,7 +7525,7 @@ async def list_effective_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: r"""Lists all effective Event Threat Detection custom modules for the given parent. This includes resident @@ -7436,8 +7578,10 @@ async def sample_list_effective_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: @@ -7522,7 +7666,7 @@ async def batch_create_resource_value_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Creates a ResourceValueConfig for an organization. Maps user's tags to difference resource values for use @@ -7585,8 +7729,10 @@ async def sample_batch_create_resource_value_configs(): 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, 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: google.cloud.securitycenter_v1.types.BatchCreateResourceValueConfigsResponse: @@ -7655,7 +7801,7 @@ async def delete_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ResourceValueConfig. @@ -7696,8 +7842,10 @@ async def sample_delete_resource_value_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -7753,7 +7901,7 @@ async def get_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Gets a ResourceValueConfig. @@ -7798,8 +7946,10 @@ async def sample_get_resource_value_config(): 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, 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: google.cloud.securitycenter_v1.types.ResourceValueConfig: @@ -7866,7 +8016,7 @@ async def list_resource_value_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListResourceValueConfigsAsyncPager: r"""Lists all ResourceValueConfigs. @@ -7912,8 +8062,10 @@ async def sample_list_resource_value_configs(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListResourceValueConfigsAsyncPager: @@ -7995,7 +8147,7 @@ async def update_resource_value_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Updates an existing ResourceValueConfigs with new rules. @@ -8052,8 +8204,10 @@ async def sample_update_resource_value_config(): 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, 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: google.cloud.securitycenter_v1.types.ResourceValueConfig: @@ -8124,7 +8278,7 @@ async def list_valued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListValuedResourcesAsyncPager: r"""Lists the valued resources for a set of simulation results and filter. @@ -8173,8 +8327,10 @@ async def sample_list_valued_resources(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListValuedResourcesAsyncPager: @@ -8251,7 +8407,7 @@ async def list_attack_paths( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttackPathsAsyncPager: r"""Lists the attack paths for a set of simulation results or valued resources and filter. @@ -8302,8 +8458,10 @@ async def sample_list_attack_paths(): 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, 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListAttackPathsAsyncPager: @@ -8379,7 +8537,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -8390,8 +8548,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -8432,7 +8592,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -8443,8 +8603,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -8485,7 +8647,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -8501,8 +8663,10 @@ async def delete_operation( 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, 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: None """ @@ -8539,7 +8703,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -8554,8 +8718,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/client.py index c0bfed5d59eb..065d5d806c79 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -1069,6 +1079,10 @@ def __init__( # 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( @@ -1134,6 +1148,29 @@ def __init__( 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.securitycenter_v1.SecurityCenterClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "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.securitycenter.v1.SecurityCenter", + "credentialsType": None, + }, + ) + def bulk_mute_findings( self, request: Optional[ @@ -1143,7 +1180,7 @@ def bulk_mute_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Kicks off an LRO to bulk mute findings for a parent based on a filter. The parent can be either an @@ -1204,8 +1241,10 @@ def sample_bulk_mute_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1283,7 +1322,7 @@ def create_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule ): @@ -1347,8 +1386,10 @@ def sample_create_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1430,7 +1471,7 @@ def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -1482,8 +1523,10 @@ def sample_create_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Source: @@ -1551,7 +1594,7 @@ def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -1616,8 +1659,10 @@ def sample_create_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Finding: @@ -1691,7 +1736,7 @@ def create_mute_config( mute_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Creates a mute config. @@ -1761,8 +1806,10 @@ def sample_create_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -1831,7 +1878,7 @@ def create_notification_config( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -1898,8 +1945,10 @@ def sample_create_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -1971,7 +2020,7 @@ def delete_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing mute config. @@ -2019,8 +2068,10 @@ def sample_delete_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2071,7 +2122,7 @@ def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -2116,8 +2167,10 @@ def sample_delete_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2175,7 +2228,7 @@ def delete_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified SecurityHealthAnalyticsCustomModule and all of its @@ -2223,8 +2276,10 @@ def sample_delete_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2284,7 +2339,7 @@ def get_simulation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Get the simulation by name or the latest simulation for the given organization. @@ -2336,8 +2391,10 @@ def sample_get_simulation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Simulation: @@ -2395,7 +2452,7 @@ def get_valued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Get the valued resource by name @@ -2441,8 +2498,10 @@ def sample_get_valued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.ValuedResource: @@ -2502,7 +2561,7 @@ def get_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Gets a BigQuery export. @@ -2549,8 +2608,10 @@ def sample_get_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -2608,7 +2669,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -2655,8 +2716,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2745,7 +2808,7 @@ def get_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Gets a mute config. @@ -2796,8 +2859,10 @@ def sample_get_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -2858,7 +2923,7 @@ def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -2906,8 +2971,10 @@ def sample_get_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -2971,7 +3038,7 @@ def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -3016,8 +3083,10 @@ def sample_get_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1.types.OrganizationSettings: @@ -3085,7 +3154,7 @@ def get_effective_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule ): @@ -3137,8 +3206,10 @@ def sample_get_effective_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: @@ -3220,7 +3291,7 @@ def get_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: r"""Retrieves a SecurityHealthAnalyticsCustomModule. @@ -3268,8 +3339,10 @@ def sample_get_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -3344,7 +3417,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -3388,8 +3461,10 @@ def sample_get_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Source: @@ -3452,7 +3527,7 @@ def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -3492,8 +3567,10 @@ def sample_group_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.GroupAssetsPager: @@ -3559,7 +3636,7 @@ def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -3631,8 +3708,10 @@ def sample_group_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.GroupFindingsPager: @@ -3705,7 +3784,7 @@ def list_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Lists an organization's assets. @@ -3742,8 +3821,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListAssetsPager: @@ -3811,7 +3892,7 @@ def list_descendant_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all resident SecurityHealthAnalyticsCustomModules under the given CRM @@ -3862,8 +3943,10 @@ def sample_list_descendant_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: @@ -3945,7 +4028,7 @@ def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""Lists an organization or source's findings. @@ -3985,8 +4068,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListFindingsPager: @@ -4047,7 +4132,7 @@ def list_mute_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMuteConfigsPager: r"""Lists mute configs. @@ -4095,8 +4180,10 @@ def sample_list_mute_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListMuteConfigsPager: @@ -4170,7 +4257,7 @@ def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsPager: r"""Lists notification configs. @@ -4217,8 +4304,10 @@ def sample_list_notification_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListNotificationConfigsPager: @@ -4299,7 +4388,7 @@ def list_effective_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all EffectiveSecurityHealthAnalyticsCustomModules for the @@ -4352,8 +4441,10 @@ def sample_list_effective_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: @@ -4439,7 +4530,7 @@ def list_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all SecurityHealthAnalyticsCustomModules for the given @@ -4491,8 +4582,10 @@ def sample_list_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListSecurityHealthAnalyticsCustomModulesPager: @@ -4575,7 +4668,7 @@ def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesPager: r"""Lists all sources belonging to an organization. @@ -4621,8 +4714,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListSourcesPager: @@ -4696,7 +4791,7 @@ def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -4750,8 +4845,10 @@ def sample_run_asset_discovery(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4828,7 +4925,7 @@ def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -4891,8 +4988,10 @@ def sample_set_finding_state(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Finding: @@ -4963,7 +5062,7 @@ def set_mute( mute: Optional[finding.Finding.Mute] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the mute state of a finding. @@ -5019,8 +5118,10 @@ def sample_set_mute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Finding: @@ -5088,7 +5189,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -5135,8 +5236,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -5224,7 +5327,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -5281,8 +5384,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -5352,7 +5457,7 @@ def simulate_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse: r"""Simulates a given SecurityHealthAnalyticsCustomModule and Resource. @@ -5420,8 +5525,10 @@ def sample_simulate_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -5493,7 +5600,7 @@ def update_external_system( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Updates external system. This is for a given finding. @@ -5545,8 +5652,10 @@ def sample_update_external_system(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.ExternalSystem: @@ -5610,7 +5719,7 @@ def update_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -5659,8 +5768,10 @@ def sample_update_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Finding: @@ -5731,7 +5842,7 @@ def update_mute_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Updates a mute config. @@ -5786,8 +5897,10 @@ def sample_update_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.MuteConfig: @@ -5855,7 +5968,7 @@ def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -5908,8 +6021,10 @@ def sample_update_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.NotificationConfig: @@ -5983,7 +6098,7 @@ def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -6026,8 +6141,10 @@ def sample_update_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1.types.OrganizationSettings: @@ -6100,7 +6217,7 @@ def update_security_health_analytics_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule ): @@ -6161,8 +6278,10 @@ def sample_update_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule: @@ -6252,7 +6371,7 @@ def update_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -6295,8 +6414,10 @@ def sample_update_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.Source: @@ -6362,7 +6483,7 @@ def update_security_marks( security_marks: Optional[gcs_security_marks.SecurityMarks] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -6405,8 +6526,10 @@ def sample_update_security_marks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.SecurityMarks: @@ -6476,7 +6599,7 @@ def create_big_query_export( big_query_export_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Creates a BigQuery export. @@ -6542,8 +6665,10 @@ def sample_create_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -6607,7 +6732,7 @@ def delete_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing BigQuery export. @@ -6651,8 +6776,10 @@ def sample_delete_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -6704,7 +6831,7 @@ def update_big_query_export( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Updates a BigQuery export. @@ -6755,8 +6882,10 @@ def sample_update_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.BigQueryExport: @@ -6820,7 +6949,7 @@ def list_big_query_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryExportsPager: r"""Lists BigQuery exports. Note that when requesting BigQuery exports at a given level all exports under that @@ -6873,8 +7002,10 @@ def sample_list_big_query_exports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListBigQueryExportsPager: @@ -6954,7 +7085,7 @@ def create_event_threat_detection_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Creates a resident Event Threat Detection custom module at the scope of the given Resource Manager @@ -7015,8 +7146,10 @@ def sample_create_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -7099,7 +7232,7 @@ def delete_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified Event Threat Detection custom module and all of its descendants in the Resource @@ -7148,8 +7281,10 @@ def sample_delete_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -7211,7 +7346,7 @@ def get_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Gets an Event Threat Detection custom module. @@ -7260,8 +7395,10 @@ def sample_get_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -7337,7 +7474,7 @@ def list_descendant_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesPager: r"""Lists all resident Event Threat Detection custom modules under the given Resource Manager parent and its @@ -7391,8 +7528,10 @@ def sample_list_descendant_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantEventThreatDetectionCustomModulesPager: @@ -7478,7 +7617,7 @@ def list_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesPager: r"""Lists all Event Threat Detection custom modules for the given Resource Manager parent. This includes @@ -7532,8 +7671,10 @@ def sample_list_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEventThreatDetectionCustomModulesPager: @@ -7621,7 +7762,7 @@ def update_event_threat_detection_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Updates the Event Threat Detection custom module with the given name based on the given update mask. Updating @@ -7677,8 +7818,10 @@ def sample_update_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule: @@ -7767,7 +7910,7 @@ def validate_event_threat_detection_custom_module( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse: r"""Validates the given Event Threat Detection custom module. @@ -7807,8 +7950,10 @@ def sample_validate_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.ValidateEventThreatDetectionCustomModuleResponse: @@ -7867,7 +8012,7 @@ def get_effective_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule ): @@ -7920,8 +8065,10 @@ def sample_get_effective_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.EffectiveEventThreatDetectionCustomModule: @@ -8003,7 +8150,7 @@ def list_effective_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesPager: r"""Lists all effective Event Threat Detection custom modules for the given parent. This includes resident @@ -8056,8 +8203,10 @@ def sample_list_effective_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveEventThreatDetectionCustomModulesPager: @@ -8141,7 +8290,7 @@ def batch_create_resource_value_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Creates a ResourceValueConfig for an organization. Maps user's tags to difference resource values for use @@ -8204,8 +8353,10 @@ def sample_batch_create_resource_value_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.BatchCreateResourceValueConfigsResponse: @@ -8273,7 +8424,7 @@ def delete_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ResourceValueConfig. @@ -8314,8 +8465,10 @@ def sample_delete_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -8370,7 +8523,7 @@ def get_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Gets a ResourceValueConfig. @@ -8415,8 +8568,10 @@ def sample_get_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.ResourceValueConfig: @@ -8482,7 +8637,7 @@ def list_resource_value_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListResourceValueConfigsPager: r"""Lists all ResourceValueConfigs. @@ -8528,8 +8683,10 @@ def sample_list_resource_value_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListResourceValueConfigsPager: @@ -8610,7 +8767,7 @@ def update_resource_value_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Updates an existing ResourceValueConfigs with new rules. @@ -8667,8 +8824,10 @@ def sample_update_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.types.ResourceValueConfig: @@ -8738,7 +8897,7 @@ def list_valued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListValuedResourcesPager: r"""Lists the valued resources for a set of simulation results and filter. @@ -8787,8 +8946,10 @@ def sample_list_valued_resources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListValuedResourcesPager: @@ -8862,7 +9023,7 @@ def list_attack_paths( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttackPathsPager: r"""Lists the attack paths for a set of simulation results or valued resources and filter. @@ -8913,8 +9074,10 @@ def sample_list_attack_paths(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1.services.security_center.pagers.ListAttackPathsPager: @@ -9000,7 +9163,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -9011,8 +9174,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -9053,7 +9218,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -9064,8 +9229,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -9106,7 +9273,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -9122,8 +9289,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -9160,7 +9329,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -9175,8 +9344,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/pagers.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/pagers.py index 98820357a8f3..6ea50ed3824e 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/pagers.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/pagers.py @@ -80,7 +80,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -94,8 +94,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -154,7 +156,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -168,8 +170,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -232,7 +236,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -246,8 +250,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -306,7 +312,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -320,8 +326,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -386,7 +394,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -400,8 +408,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -462,7 +472,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -476,8 +486,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -545,7 +557,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -559,8 +571,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( @@ -634,7 +648,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -648,8 +662,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( @@ -722,7 +738,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -736,8 +752,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -798,7 +816,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -812,8 +830,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -878,7 +898,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -892,8 +912,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListMuteConfigsRequest(request) @@ -954,7 +976,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -968,8 +990,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListMuteConfigsRequest(request) @@ -1034,7 +1058,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1048,8 +1072,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -1110,7 +1136,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1124,8 +1150,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -1193,7 +1221,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1207,8 +1235,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( @@ -1282,7 +1312,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1296,8 +1326,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( @@ -1372,7 +1404,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1386,8 +1418,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -1463,7 +1497,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1477,8 +1511,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -1553,7 +1589,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1567,8 +1603,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -1627,7 +1665,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1641,8 +1679,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -1705,7 +1745,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1719,8 +1759,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListBigQueryExportsRequest(request) @@ -1781,7 +1823,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1795,8 +1837,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListBigQueryExportsRequest(request) @@ -1864,7 +1908,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1878,8 +1922,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest( @@ -1953,7 +1999,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1967,8 +2013,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest( @@ -2043,7 +2091,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2057,8 +2105,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -2130,7 +2180,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2144,8 +2194,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -2221,7 +2273,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2235,8 +2287,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest( @@ -2310,7 +2364,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2324,8 +2378,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest( @@ -2398,7 +2454,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2412,8 +2468,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListResourceValueConfigsRequest(request) @@ -2476,7 +2534,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2490,8 +2548,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListResourceValueConfigsRequest(request) @@ -2556,7 +2616,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2570,8 +2630,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListValuedResourcesRequest(request) @@ -2632,7 +2694,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2646,8 +2708,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListValuedResourcesRequest(request) @@ -2712,7 +2776,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2726,8 +2790,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListAttackPathsRequest(request) @@ -2788,7 +2854,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -2802,8 +2868,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListAttackPathsRequest(request) diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc.py index 7d26a42f4652..6d048d1598ca 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1.types import ( bigquery_export, @@ -64,6 +70,81 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport +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.securitycenter.v1.SecurityCenter", + "rpcName": 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.securitycenter.v1.SecurityCenter", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcTransport(SecurityCenterTransport): """gRPC backend transport for SecurityCenter. @@ -218,7 +299,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -282,7 +368,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -311,7 +399,7 @@ def bulk_mute_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "bulk_mute_findings" not in self._stubs: - self._stubs["bulk_mute_findings"] = self.grpc_channel.unary_unary( + self._stubs["bulk_mute_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/BulkMuteFindings", request_serializer=securitycenter_service.BulkMuteFindingsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -348,7 +436,7 @@ def create_security_health_analytics_custom_module( if "create_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "create_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -374,7 +462,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -401,7 +489,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -429,7 +517,7 @@ def create_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_mute_config" not in self._stubs: - self._stubs["create_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["create_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateMuteConfig", request_serializer=securitycenter_service.CreateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -458,7 +546,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -484,7 +574,7 @@ def delete_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_mute_config" not in self._stubs: - self._stubs["delete_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteMuteConfig", request_serializer=securitycenter_service.DeleteMuteConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -512,7 +602,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -547,7 +639,7 @@ def delete_security_health_analytics_custom_module( if "delete_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "delete_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -574,7 +666,7 @@ def get_simulation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_simulation" not in self._stubs: - self._stubs["get_simulation"] = self.grpc_channel.unary_unary( + self._stubs["get_simulation"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSimulation", request_serializer=securitycenter_service.GetSimulationRequest.serialize, response_deserializer=simulation.Simulation.deserialize, @@ -603,7 +695,7 @@ def get_valued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_valued_resource" not in self._stubs: - self._stubs["get_valued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_valued_resource"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetValuedResource", request_serializer=securitycenter_service.GetValuedResourceRequest.serialize, response_deserializer=valued_resource.ValuedResource.deserialize, @@ -632,7 +724,7 @@ def get_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_export" not in self._stubs: - self._stubs["get_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetBigQueryExport", request_serializer=securitycenter_service.GetBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -659,7 +751,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -687,7 +779,7 @@ def get_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_mute_config" not in self._stubs: - self._stubs["get_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["get_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetMuteConfig", request_serializer=securitycenter_service.GetMuteConfigRequest.serialize, response_deserializer=mute_config.MuteConfig.deserialize, @@ -716,7 +808,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -745,7 +837,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -778,7 +870,7 @@ def get_effective_security_health_analytics_custom_module( if "get_effective_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_effective_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEffectiveSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, @@ -810,7 +902,7 @@ def get_security_health_analytics_custom_module( if "get_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -836,7 +928,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -866,7 +958,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -901,7 +993,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -930,7 +1022,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -969,7 +1061,7 @@ def list_descendant_security_health_analytics_custom_modules( ): self._stubs[ "list_descendant_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListDescendantSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1001,7 +1093,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -1030,7 +1122,7 @@ def list_mute_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_mute_configs" not in self._stubs: - self._stubs["list_mute_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_mute_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListMuteConfigs", request_serializer=securitycenter_service.ListMuteConfigsRequest.serialize, response_deserializer=securitycenter_service.ListMuteConfigsResponse.deserialize, @@ -1059,7 +1151,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -1097,7 +1189,7 @@ def list_effective_security_health_analytics_custom_modules( if "list_effective_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_effective_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEffectiveSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1133,7 +1225,7 @@ def list_security_health_analytics_custom_modules( if "list_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1162,7 +1254,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -1195,7 +1287,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1221,7 +1313,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1247,7 +1339,7 @@ def set_mute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_mute" not in self._stubs: - self._stubs["set_mute"] = self.grpc_channel.unary_unary( + self._stubs["set_mute"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetMute", request_serializer=securitycenter_service.SetMuteRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1274,7 +1366,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1304,7 +1396,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1337,7 +1429,7 @@ def simulate_security_health_analytics_custom_module( if "simulate_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "simulate_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SimulateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, @@ -1366,7 +1458,7 @@ def update_external_system( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_system" not in self._stubs: - self._stubs["update_external_system"] = self.grpc_channel.unary_unary( + self._stubs["update_external_system"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateExternalSystem", request_serializer=securitycenter_service.UpdateExternalSystemRequest.serialize, response_deserializer=gcs_external_system.ExternalSystem.deserialize, @@ -1393,7 +1485,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -1421,7 +1513,7 @@ def update_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_mute_config" not in self._stubs: - self._stubs["update_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["update_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateMuteConfig", request_serializer=securitycenter_service.UpdateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -1451,7 +1543,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -1480,7 +1574,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -1518,7 +1614,7 @@ def update_security_health_analytics_custom_module( if "update_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "update_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -1544,7 +1640,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -1573,7 +1669,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -1602,7 +1698,7 @@ def create_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_export" not in self._stubs: - self._stubs["create_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateBigQueryExport", request_serializer=securitycenter_service.CreateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1630,7 +1726,7 @@ def delete_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_export" not in self._stubs: - self._stubs["delete_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteBigQueryExport", request_serializer=securitycenter_service.DeleteBigQueryExportRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1659,7 +1755,7 @@ def update_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_export" not in self._stubs: - self._stubs["update_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateBigQueryExport", request_serializer=securitycenter_service.UpdateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1693,7 +1789,7 @@ def list_big_query_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_exports" not in self._stubs: - self._stubs["list_big_query_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_exports"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListBigQueryExports", request_serializer=securitycenter_service.ListBigQueryExportsRequest.serialize, response_deserializer=securitycenter_service.ListBigQueryExportsResponse.deserialize, @@ -1729,7 +1825,7 @@ def create_event_threat_detection_custom_module( if "create_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "create_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.CreateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1764,7 +1860,7 @@ def delete_event_threat_detection_custom_module( if "delete_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "delete_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteEventThreatDetectionCustomModule", request_serializer=securitycenter_service.DeleteEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1796,7 +1892,7 @@ def get_event_threat_detection_custom_module( if "get_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEventThreatDetectionCustomModule", request_serializer=securitycenter_service.GetEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1830,7 +1926,7 @@ def list_descendant_event_threat_detection_custom_modules( if "list_descendant_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_descendant_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListDescendantEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, @@ -1865,7 +1961,7 @@ def list_event_threat_detection_custom_modules( if "list_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEventThreatDetectionCustomModulesResponse.deserialize, @@ -1904,7 +2000,7 @@ def update_event_threat_detection_custom_module( if "update_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "update_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.UpdateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1937,7 +2033,7 @@ def validate_event_threat_detection_custom_module( if "validate_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "validate_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ValidateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.ValidateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse.deserialize, @@ -1970,7 +2066,7 @@ def get_effective_event_threat_detection_custom_module( if "get_effective_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_effective_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEffectiveEventThreatDetectionCustomModule", request_serializer=securitycenter_service.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule.deserialize, @@ -2005,7 +2101,7 @@ def list_effective_event_threat_detection_custom_modules( if "list_effective_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_effective_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEffectiveEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, @@ -2039,7 +2135,7 @@ def batch_create_resource_value_configs( if "batch_create_resource_value_configs" not in self._stubs: self._stubs[ "batch_create_resource_value_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/BatchCreateResourceValueConfigs", request_serializer=securitycenter_service.BatchCreateResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.BatchCreateResourceValueConfigsResponse.deserialize, @@ -2067,7 +2163,9 @@ def delete_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_value_config" not in self._stubs: - self._stubs["delete_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteResourceValueConfig", request_serializer=securitycenter_service.DeleteResourceValueConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2096,7 +2194,7 @@ def get_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_value_config" not in self._stubs: - self._stubs["get_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_value_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetResourceValueConfig", request_serializer=securitycenter_service.GetResourceValueConfigRequest.serialize, response_deserializer=resource_value_config.ResourceValueConfig.deserialize, @@ -2125,7 +2223,9 @@ def list_resource_value_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_value_configs" not in self._stubs: - self._stubs["list_resource_value_configs"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_resource_value_configs" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListResourceValueConfigs", request_serializer=securitycenter_service.ListResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.ListResourceValueConfigsResponse.deserialize, @@ -2155,7 +2255,9 @@ def update_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_value_config" not in self._stubs: - self._stubs["update_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateResourceValueConfig", request_serializer=securitycenter_service.UpdateResourceValueConfigRequest.serialize, response_deserializer=gcs_resource_value_config.ResourceValueConfig.deserialize, @@ -2185,7 +2287,7 @@ def list_valued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_valued_resources" not in self._stubs: - self._stubs["list_valued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_valued_resources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListValuedResources", request_serializer=securitycenter_service.ListValuedResourcesRequest.serialize, response_deserializer=securitycenter_service.ListValuedResourcesResponse.deserialize, @@ -2215,7 +2317,7 @@ def list_attack_paths( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attack_paths" not in self._stubs: - self._stubs["list_attack_paths"] = self.grpc_channel.unary_unary( + self._stubs["list_attack_paths"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListAttackPaths", request_serializer=securitycenter_service.ListAttackPathsRequest.serialize, response_deserializer=securitycenter_service.ListAttackPathsResponse.deserialize, @@ -2223,7 +2325,7 @@ def list_attack_paths( return self._stubs["list_attack_paths"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -2235,7 +2337,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -2252,7 +2354,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -2269,7 +2371,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -2288,7 +2390,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc_asyncio.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc_asyncio.py index 31b5a112ee29..fb1792326e38 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1.types import ( bigquery_export, @@ -68,6 +74,82 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .grpc import SecurityCenterGrpcTransport +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.securitycenter.v1.SecurityCenter", + "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.securitycenter.v1.SecurityCenter", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcAsyncIOTransport(SecurityCenterTransport): """gRPC AsyncIO backend transport for SecurityCenter. @@ -265,10 +347,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -291,7 +376,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -322,7 +407,7 @@ def bulk_mute_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "bulk_mute_findings" not in self._stubs: - self._stubs["bulk_mute_findings"] = self.grpc_channel.unary_unary( + self._stubs["bulk_mute_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/BulkMuteFindings", request_serializer=securitycenter_service.BulkMuteFindingsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -361,7 +446,7 @@ def create_security_health_analytics_custom_module( if "create_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "create_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -389,7 +474,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -418,7 +503,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -447,7 +532,7 @@ def create_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_mute_config" not in self._stubs: - self._stubs["create_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["create_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateMuteConfig", request_serializer=securitycenter_service.CreateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -476,7 +561,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -504,7 +591,7 @@ def delete_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_mute_config" not in self._stubs: - self._stubs["delete_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteMuteConfig", request_serializer=securitycenter_service.DeleteMuteConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -533,7 +620,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -568,7 +657,7 @@ def delete_security_health_analytics_custom_module( if "delete_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "delete_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -597,7 +686,7 @@ def get_simulation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_simulation" not in self._stubs: - self._stubs["get_simulation"] = self.grpc_channel.unary_unary( + self._stubs["get_simulation"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSimulation", request_serializer=securitycenter_service.GetSimulationRequest.serialize, response_deserializer=simulation.Simulation.deserialize, @@ -626,7 +715,7 @@ def get_valued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_valued_resource" not in self._stubs: - self._stubs["get_valued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_valued_resource"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetValuedResource", request_serializer=securitycenter_service.GetValuedResourceRequest.serialize, response_deserializer=valued_resource.ValuedResource.deserialize, @@ -655,7 +744,7 @@ def get_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_export" not in self._stubs: - self._stubs["get_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetBigQueryExport", request_serializer=securitycenter_service.GetBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -682,7 +771,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -710,7 +799,7 @@ def get_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_mute_config" not in self._stubs: - self._stubs["get_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["get_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetMuteConfig", request_serializer=securitycenter_service.GetMuteConfigRequest.serialize, response_deserializer=mute_config.MuteConfig.deserialize, @@ -739,7 +828,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -768,7 +857,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -803,7 +892,7 @@ def get_effective_security_health_analytics_custom_module( if "get_effective_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_effective_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEffectiveSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, @@ -837,7 +926,7 @@ def get_security_health_analytics_custom_module( if "get_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -863,7 +952,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -893,7 +982,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -928,7 +1017,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -957,7 +1046,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -998,7 +1087,7 @@ def list_descendant_security_health_analytics_custom_modules( ): self._stubs[ "list_descendant_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListDescendantSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1030,7 +1119,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -1059,7 +1148,7 @@ def list_mute_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_mute_configs" not in self._stubs: - self._stubs["list_mute_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_mute_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListMuteConfigs", request_serializer=securitycenter_service.ListMuteConfigsRequest.serialize, response_deserializer=securitycenter_service.ListMuteConfigsResponse.deserialize, @@ -1088,7 +1177,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -1128,7 +1217,7 @@ def list_effective_security_health_analytics_custom_modules( if "list_effective_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_effective_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEffectiveSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1166,7 +1255,7 @@ def list_security_health_analytics_custom_modules( if "list_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListSecurityHealthAnalyticsCustomModules", request_serializer=securitycenter_service.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -1195,7 +1284,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -1229,7 +1318,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1257,7 +1346,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1283,7 +1372,7 @@ def set_mute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_mute" not in self._stubs: - self._stubs["set_mute"] = self.grpc_channel.unary_unary( + self._stubs["set_mute"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetMute", request_serializer=securitycenter_service.SetMuteRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1310,7 +1399,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1340,7 +1429,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1375,7 +1464,7 @@ def simulate_security_health_analytics_custom_module( if "simulate_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "simulate_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/SimulateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, @@ -1404,7 +1493,7 @@ def update_external_system( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_system" not in self._stubs: - self._stubs["update_external_system"] = self.grpc_channel.unary_unary( + self._stubs["update_external_system"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateExternalSystem", request_serializer=securitycenter_service.UpdateExternalSystemRequest.serialize, response_deserializer=gcs_external_system.ExternalSystem.deserialize, @@ -1433,7 +1522,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -1462,7 +1551,7 @@ def update_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_mute_config" not in self._stubs: - self._stubs["update_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["update_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateMuteConfig", request_serializer=securitycenter_service.UpdateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -1492,7 +1581,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -1521,7 +1612,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -1561,7 +1654,7 @@ def update_security_health_analytics_custom_module( if "update_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "update_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSecurityHealthAnalyticsCustomModule", request_serializer=securitycenter_service.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.deserialize, @@ -1589,7 +1682,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -1618,7 +1711,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -1647,7 +1740,7 @@ def create_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_export" not in self._stubs: - self._stubs["create_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateBigQueryExport", request_serializer=securitycenter_service.CreateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1675,7 +1768,7 @@ def delete_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_export" not in self._stubs: - self._stubs["delete_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteBigQueryExport", request_serializer=securitycenter_service.DeleteBigQueryExportRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1704,7 +1797,7 @@ def update_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_export" not in self._stubs: - self._stubs["update_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateBigQueryExport", request_serializer=securitycenter_service.UpdateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1738,7 +1831,7 @@ def list_big_query_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_exports" not in self._stubs: - self._stubs["list_big_query_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_exports"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListBigQueryExports", request_serializer=securitycenter_service.ListBigQueryExportsRequest.serialize, response_deserializer=securitycenter_service.ListBigQueryExportsResponse.deserialize, @@ -1776,7 +1869,7 @@ def create_event_threat_detection_custom_module( if "create_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "create_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/CreateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.CreateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1811,7 +1904,7 @@ def delete_event_threat_detection_custom_module( if "delete_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "delete_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteEventThreatDetectionCustomModule", request_serializer=securitycenter_service.DeleteEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1845,7 +1938,7 @@ def get_event_threat_detection_custom_module( if "get_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEventThreatDetectionCustomModule", request_serializer=securitycenter_service.GetEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1881,7 +1974,7 @@ def list_descendant_event_threat_detection_custom_modules( if "list_descendant_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_descendant_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListDescendantEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, @@ -1916,7 +2009,7 @@ def list_event_threat_detection_custom_modules( if "list_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEventThreatDetectionCustomModulesResponse.deserialize, @@ -1957,7 +2050,7 @@ def update_event_threat_detection_custom_module( if "update_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "update_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.UpdateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.deserialize, @@ -1992,7 +2085,7 @@ def validate_event_threat_detection_custom_module( if "validate_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "validate_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ValidateEventThreatDetectionCustomModule", request_serializer=securitycenter_service.ValidateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse.deserialize, @@ -2027,7 +2120,7 @@ def get_effective_event_threat_detection_custom_module( if "get_effective_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_effective_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetEffectiveEventThreatDetectionCustomModule", request_serializer=securitycenter_service.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule.deserialize, @@ -2064,7 +2157,7 @@ def list_effective_event_threat_detection_custom_modules( if "list_effective_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_effective_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListEffectiveEventThreatDetectionCustomModules", request_serializer=securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, @@ -2098,7 +2191,7 @@ def batch_create_resource_value_configs( if "batch_create_resource_value_configs" not in self._stubs: self._stubs[ "batch_create_resource_value_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/BatchCreateResourceValueConfigs", request_serializer=securitycenter_service.BatchCreateResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.BatchCreateResourceValueConfigsResponse.deserialize, @@ -2127,7 +2220,9 @@ def delete_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_value_config" not in self._stubs: - self._stubs["delete_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/DeleteResourceValueConfig", request_serializer=securitycenter_service.DeleteResourceValueConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2156,7 +2251,7 @@ def get_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_value_config" not in self._stubs: - self._stubs["get_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_value_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/GetResourceValueConfig", request_serializer=securitycenter_service.GetResourceValueConfigRequest.serialize, response_deserializer=resource_value_config.ResourceValueConfig.deserialize, @@ -2185,7 +2280,9 @@ def list_resource_value_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_value_configs" not in self._stubs: - self._stubs["list_resource_value_configs"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_resource_value_configs" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListResourceValueConfigs", request_serializer=securitycenter_service.ListResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.ListResourceValueConfigsResponse.deserialize, @@ -2215,7 +2312,9 @@ def update_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_value_config" not in self._stubs: - self._stubs["update_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/UpdateResourceValueConfig", request_serializer=securitycenter_service.UpdateResourceValueConfigRequest.serialize, response_deserializer=gcs_resource_value_config.ResourceValueConfig.deserialize, @@ -2245,7 +2344,7 @@ def list_valued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_valued_resources" not in self._stubs: - self._stubs["list_valued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_valued_resources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListValuedResources", request_serializer=securitycenter_service.ListValuedResourcesRequest.serialize, response_deserializer=securitycenter_service.ListValuedResourcesResponse.deserialize, @@ -2275,7 +2374,7 @@ def list_attack_paths( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attack_paths" not in self._stubs: - self._stubs["list_attack_paths"] = self.grpc_channel.unary_unary( + self._stubs["list_attack_paths"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1.SecurityCenter/ListAttackPaths", request_serializer=securitycenter_service.ListAttackPathsRequest.serialize, response_deserializer=securitycenter_service.ListAttackPathsResponse.deserialize, @@ -2788,7 +2887,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -2804,7 +2903,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -2821,7 +2920,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -2838,7 +2937,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -2857,7 +2956,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/rest.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/rest.py index 925061fe92d5..7a5837104048 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/rest.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1/services/security_center/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -75,6 +75,14 @@ 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, @@ -587,10 +595,10 @@ def post_validate_event_threat_detection_custom_module(self, response): def pre_batch_create_resource_value_configs( self, request: securitycenter_service.BatchCreateResourceValueConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.BatchCreateResourceValueConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_create_resource_value_configs @@ -613,9 +621,10 @@ def post_batch_create_resource_value_configs( def pre_bulk_mute_findings( self, request: securitycenter_service.BulkMuteFindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.BulkMuteFindingsRequest, Sequence[Tuple[str, str]] + securitycenter_service.BulkMuteFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for bulk_mute_findings @@ -638,9 +647,10 @@ def post_bulk_mute_findings( def pre_create_big_query_export( self, request: securitycenter_service.CreateBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.CreateBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.CreateBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_big_query_export @@ -663,10 +673,10 @@ def post_create_big_query_export( def pre_create_event_threat_detection_custom_module( self, request: securitycenter_service.CreateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.CreateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_event_threat_detection_custom_module @@ -690,8 +700,11 @@ def post_create_event_threat_detection_custom_module( def pre_create_finding( self, request: securitycenter_service.CreateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_finding Override in a subclass to manipulate the request or metadata @@ -711,9 +724,10 @@ def post_create_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_create_mute_config( self, request: securitycenter_service.CreateMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.CreateMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.CreateMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_mute_config @@ -736,10 +750,10 @@ def post_create_mute_config( def pre_create_notification_config( self, request: securitycenter_service.CreateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.CreateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_notification_config @@ -762,10 +776,10 @@ def post_create_notification_config( def pre_create_security_health_analytics_custom_module( self, request: securitycenter_service.CreateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.CreateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_security_health_analytics_custom_module @@ -791,8 +805,11 @@ def post_create_security_health_analytics_custom_module( def pre_create_source( self, request: securitycenter_service.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -812,9 +829,10 @@ def post_create_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_delete_big_query_export( self, request: securitycenter_service.DeleteBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.DeleteBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.DeleteBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_big_query_export @@ -826,10 +844,10 @@ def pre_delete_big_query_export( def pre_delete_event_threat_detection_custom_module( self, request: securitycenter_service.DeleteEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_event_threat_detection_custom_module @@ -841,9 +859,10 @@ def pre_delete_event_threat_detection_custom_module( def pre_delete_mute_config( self, request: securitycenter_service.DeleteMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.DeleteMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.DeleteMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_mute_config @@ -855,10 +874,10 @@ def pre_delete_mute_config( def pre_delete_notification_config( self, request: securitycenter_service.DeleteNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_notification_config @@ -870,10 +889,10 @@ def pre_delete_notification_config( def pre_delete_resource_value_config( self, request: securitycenter_service.DeleteResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteResourceValueConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_resource_value_config @@ -885,10 +904,10 @@ def pre_delete_resource_value_config( def pre_delete_security_health_analytics_custom_module( self, request: securitycenter_service.DeleteSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_security_health_analytics_custom_module @@ -900,9 +919,10 @@ def pre_delete_security_health_analytics_custom_module( def pre_get_big_query_export( self, request: securitycenter_service.GetBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_big_query_export @@ -925,10 +945,10 @@ def post_get_big_query_export( def pre_get_effective_event_threat_detection_custom_module( self, request: securitycenter_service.GetEffectiveEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.GetEffectiveEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_effective_event_threat_detection_custom_module @@ -954,10 +974,10 @@ def post_get_effective_event_threat_detection_custom_module( def pre_get_effective_security_health_analytics_custom_module( self, request: securitycenter_service.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_effective_security_health_analytics_custom_module @@ -983,10 +1003,10 @@ def post_get_effective_security_health_analytics_custom_module( def pre_get_event_threat_detection_custom_module( self, request: securitycenter_service.GetEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.GetEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_event_threat_detection_custom_module @@ -1010,8 +1030,10 @@ def post_get_event_threat_detection_custom_module( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -1031,8 +1053,11 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_mute_config( self, request: securitycenter_service.GetMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetMuteConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_mute_config Override in a subclass to manipulate the request or metadata @@ -1054,9 +1079,10 @@ def post_get_mute_config( def pre_get_notification_config( self, request: securitycenter_service.GetNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetNotificationConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetNotificationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_notification_config @@ -1079,9 +1105,10 @@ def post_get_notification_config( def pre_get_organization_settings( self, request: securitycenter_service.GetOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetOrganizationSettingsRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetOrganizationSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_organization_settings @@ -1104,9 +1131,10 @@ def post_get_organization_settings( def pre_get_resource_value_config( self, request: securitycenter_service.GetResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetResourceValueConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetResourceValueConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_resource_value_config @@ -1129,10 +1157,10 @@ def post_get_resource_value_config( def pre_get_security_health_analytics_custom_module( self, request: securitycenter_service.GetSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.GetSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_security_health_analytics_custom_module @@ -1156,8 +1184,11 @@ def post_get_security_health_analytics_custom_module( def pre_get_simulation( self, request: securitycenter_service.GetSimulationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSimulationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSimulationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_simulation Override in a subclass to manipulate the request or metadata @@ -1179,8 +1210,10 @@ def post_get_simulation( def pre_get_source( self, request: securitycenter_service.GetSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -1200,9 +1233,10 @@ def post_get_source(self, response: source.Source) -> source.Source: def pre_get_valued_resource( self, request: securitycenter_service.GetValuedResourceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetValuedResourceRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetValuedResourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_valued_resource @@ -1225,8 +1259,11 @@ def post_get_valued_resource( def pre_group_assets( self, request: securitycenter_service.GroupAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_assets Override in a subclass to manipulate the request or metadata @@ -1248,8 +1285,11 @@ def post_group_assets( def pre_group_findings( self, request: securitycenter_service.GroupFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_findings Override in a subclass to manipulate the request or metadata @@ -1271,8 +1311,11 @@ def post_group_findings( def pre_list_assets( self, request: securitycenter_service.ListAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -1294,9 +1337,10 @@ def post_list_assets( def pre_list_attack_paths( self, request: securitycenter_service.ListAttackPathsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListAttackPathsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListAttackPathsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_attack_paths @@ -1319,9 +1363,10 @@ def post_list_attack_paths( def pre_list_big_query_exports( self, request: securitycenter_service.ListBigQueryExportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListBigQueryExportsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListBigQueryExportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_big_query_exports @@ -1344,10 +1389,10 @@ def post_list_big_query_exports( def pre_list_descendant_event_threat_detection_custom_modules( self, request: securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListDescendantEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_descendant_event_threat_detection_custom_modules @@ -1371,10 +1416,10 @@ def post_list_descendant_event_threat_detection_custom_modules( def pre_list_descendant_security_health_analytics_custom_modules( self, request: securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_descendant_security_health_analytics_custom_modules @@ -1400,10 +1445,10 @@ def post_list_descendant_security_health_analytics_custom_modules( def pre_list_effective_event_threat_detection_custom_modules( self, request: securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_effective_event_threat_detection_custom_modules @@ -1427,10 +1472,10 @@ def post_list_effective_event_threat_detection_custom_modules( def pre_list_effective_security_health_analytics_custom_modules( self, request: securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_effective_security_health_analytics_custom_modules @@ -1456,10 +1501,10 @@ def post_list_effective_security_health_analytics_custom_modules( def pre_list_event_threat_detection_custom_modules( self, request: securitycenter_service.ListEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_event_threat_detection_custom_modules @@ -1483,8 +1528,11 @@ def post_list_event_threat_detection_custom_modules( def pre_list_findings( self, request: securitycenter_service.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -1506,9 +1554,10 @@ def post_list_findings( def pre_list_mute_configs( self, request: securitycenter_service.ListMuteConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListMuteConfigsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListMuteConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_mute_configs @@ -1531,9 +1580,10 @@ def post_list_mute_configs( def pre_list_notification_configs( self, request: securitycenter_service.ListNotificationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListNotificationConfigsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListNotificationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_notification_configs @@ -1556,10 +1606,10 @@ def post_list_notification_configs( def pre_list_resource_value_configs( self, request: securitycenter_service.ListResourceValueConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListResourceValueConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_resource_value_configs @@ -1582,10 +1632,10 @@ def post_list_resource_value_configs( def pre_list_security_health_analytics_custom_modules( self, request: securitycenter_service.ListSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_security_health_analytics_custom_modules @@ -1609,8 +1659,11 @@ def post_list_security_health_analytics_custom_modules( def pre_list_sources( self, request: securitycenter_service.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListSourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -1632,9 +1685,10 @@ def post_list_sources( def pre_list_valued_resources( self, request: securitycenter_service.ListValuedResourcesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListValuedResourcesRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListValuedResourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_valued_resources @@ -1657,9 +1711,10 @@ def post_list_valued_resources( def pre_run_asset_discovery( self, request: securitycenter_service.RunAssetDiscoveryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.RunAssetDiscoveryRequest, Sequence[Tuple[str, str]] + securitycenter_service.RunAssetDiscoveryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for run_asset_discovery @@ -1682,9 +1737,10 @@ def post_run_asset_discovery( def pre_set_finding_state( self, request: securitycenter_service.SetFindingStateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.SetFindingStateRequest, Sequence[Tuple[str, str]] + securitycenter_service.SetFindingStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_finding_state @@ -1705,8 +1761,10 @@ def post_set_finding_state(self, response: finding.Finding) -> finding.Finding: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -1726,8 +1784,10 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_mute( self, request: securitycenter_service.SetMuteRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.SetMuteRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.SetMuteRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_mute Override in a subclass to manipulate the request or metadata @@ -1747,10 +1807,10 @@ def post_set_mute(self, response: finding.Finding) -> finding.Finding: def pre_simulate_security_health_analytics_custom_module( self, request: securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for simulate_security_health_analytics_custom_module @@ -1774,8 +1834,11 @@ def post_simulate_security_health_analytics_custom_module( def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -1797,9 +1860,10 @@ def post_test_iam_permissions( def pre_update_big_query_export( self, request: securitycenter_service.UpdateBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_big_query_export @@ -1822,10 +1886,10 @@ def post_update_big_query_export( def pre_update_event_threat_detection_custom_module( self, request: securitycenter_service.UpdateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_event_threat_detection_custom_module @@ -1849,9 +1913,10 @@ def post_update_event_threat_detection_custom_module( def pre_update_external_system( self, request: securitycenter_service.UpdateExternalSystemRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateExternalSystemRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateExternalSystemRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_external_system @@ -1874,8 +1939,11 @@ def post_update_external_system( def pre_update_finding( self, request: securitycenter_service.UpdateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_finding Override in a subclass to manipulate the request or metadata @@ -1895,9 +1963,10 @@ def post_update_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_update_mute_config( self, request: securitycenter_service.UpdateMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_mute_config @@ -1920,10 +1989,10 @@ def post_update_mute_config( def pre_update_notification_config( self, request: securitycenter_service.UpdateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_notification_config @@ -1946,10 +2015,10 @@ def post_update_notification_config( def pre_update_organization_settings( self, request: securitycenter_service.UpdateOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateOrganizationSettingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_organization_settings @@ -1972,10 +2041,10 @@ def post_update_organization_settings( def pre_update_resource_value_config( self, request: securitycenter_service.UpdateResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateResourceValueConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_resource_value_config @@ -1998,10 +2067,10 @@ def post_update_resource_value_config( def pre_update_security_health_analytics_custom_module( self, request: securitycenter_service.UpdateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_health_analytics_custom_module @@ -2027,9 +2096,10 @@ def post_update_security_health_analytics_custom_module( def pre_update_security_marks( self, request: securitycenter_service.UpdateSecurityMarksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateSecurityMarksRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateSecurityMarksRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_marks @@ -2052,8 +2122,11 @@ def post_update_security_marks( def pre_update_source( self, request: securitycenter_service.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -2073,10 +2146,10 @@ def post_update_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_validate_event_threat_detection_custom_module( self, request: securitycenter_service.ValidateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ValidateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for validate_event_threat_detection_custom_module @@ -2100,8 +2173,10 @@ def post_validate_event_threat_detection_custom_module( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2121,8 +2196,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2142,8 +2219,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2165,8 +2244,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -2361,7 +2442,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Call the batch create resource value configs method over HTTP. @@ -2373,8 +2454,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.BatchCreateResourceValueConfigsResponse: @@ -2386,6 +2469,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseBatchCreateResourceValueConfigs._get_http_options() ) + ( request, metadata, @@ -2405,6 +2489,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.BatchCreateResourceValueConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "BatchCreateResourceValueConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._BatchCreateResourceValueConfigs._get_response( self._host, @@ -2428,7 +2539,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_resource_value_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.BatchCreateResourceValueConfigsResponse.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.securitycenter_v1.SecurityCenterClient.batch_create_resource_value_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "BatchCreateResourceValueConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BulkMuteFindings( @@ -2466,7 +2601,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the bulk mute findings method over HTTP. @@ -2485,8 +2620,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2499,6 +2636,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseBulkMuteFindings._get_http_options() ) + request, metadata = self._interceptor.pre_bulk_mute_findings( request, metadata ) @@ -2515,6 +2653,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.BulkMuteFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "BulkMuteFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._BulkMuteFindings._get_response( self._host, @@ -2534,7 +2699,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_mute_findings(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.securitycenter_v1.SecurityCenterClient.bulk_mute_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "BulkMuteFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBigQueryExport( @@ -2573,7 +2760,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the create big query export method over HTTP. @@ -2584,8 +2771,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -2597,6 +2786,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_create_big_query_export( request, metadata ) @@ -2613,6 +2803,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateBigQueryExport._get_response( self._host, @@ -2634,7 +2851,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v1.SecurityCenterClient.create_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEventThreatDetectionCustomModule( @@ -2675,7 +2914,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Call the create event threat detection custom module method over HTTP. @@ -2687,8 +2926,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: @@ -2707,6 +2948,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -2726,6 +2968,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateEventThreatDetectionCustomModule._get_response( self._host, @@ -2751,9 +3020,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.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.securitycenter_v1.SecurityCenterClient.create_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateFinding( @@ -2791,7 +3084,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the create finding method over HTTP. @@ -2802,8 +3095,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -2823,6 +3118,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateFinding._get_transcoded_request( http_options, request @@ -2837,6 +3133,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateFinding._get_response( self._host, @@ -2858,7 +3181,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1.SecurityCenterClient.create_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMuteConfig( @@ -2896,7 +3241,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Call the create mute config method over HTTP. @@ -2907,8 +3252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_mute_config.MuteConfig: @@ -2921,6 +3268,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_mute_config( request, metadata ) @@ -2937,6 +3285,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateMuteConfig._get_response( self._host, @@ -2958,7 +3333,29 @@ def __call__( pb_resp = gcs_mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_mute_config.MuteConfig.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.securitycenter_v1.SecurityCenterClient.create_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNotificationConfig( @@ -2997,7 +3394,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the create notification config method over HTTP. @@ -3009,8 +3406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -3026,6 +3425,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_notification_config( request, metadata ) @@ -3042,6 +3442,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._CreateNotificationConfig._get_response( @@ -3065,7 +3492,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v1.SecurityCenterClient.create_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecurityHealthAnalyticsCustomModule( @@ -3106,7 +3557,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule ): @@ -3120,8 +3571,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: @@ -3141,6 +3594,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -3160,6 +3614,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -3185,11 +3666,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_create_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.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.securitycenter_v1.SecurityCenterClient.create_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -3227,7 +3732,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the create source method over HTTP. @@ -3238,8 +3743,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -3255,6 +3762,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateSource._get_transcoded_request( http_options, request @@ -3269,6 +3777,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CreateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateSource._get_response( self._host, @@ -3290,7 +3825,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1.SecurityCenterClient.create_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBigQueryExport( @@ -3328,7 +3885,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete big query export method over HTTP. @@ -3339,13 +3896,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_delete_big_query_export( request, metadata ) @@ -3358,6 +3918,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteBigQueryExport._get_response( self._host, @@ -3410,7 +3997,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete event threat detection custom module method over HTTP. @@ -3422,13 +4009,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -3444,6 +4034,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteEventThreatDetectionCustomModule._get_response( self._host, @@ -3493,7 +4110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete mute config method over HTTP. @@ -3504,13 +4121,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_mute_config( request, metadata ) @@ -3523,6 +4143,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteMuteConfig._get_response( self._host, @@ -3573,7 +4220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete notification config method over HTTP. @@ -3585,13 +4232,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_notification_config( request, metadata ) @@ -3604,6 +4254,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._DeleteNotificationConfig._get_response( @@ -3656,7 +4333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete resource value config method over HTTP. @@ -3668,13 +4345,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_resource_value_config( request, metadata ) @@ -3687,6 +4367,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._DeleteResourceValueConfig._get_response( @@ -3741,7 +4448,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete security health analytics custom module method over HTTP. @@ -3753,13 +4460,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -3775,6 +4485,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -3824,7 +4561,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the get big query export method over HTTP. @@ -3835,8 +4572,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -3848,6 +4587,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_get_big_query_export( request, metadata ) @@ -3860,6 +4600,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetBigQueryExport._get_response( self._host, @@ -3880,7 +4647,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v1.SecurityCenterClient.get_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveEventThreatDetectionCustomModule( @@ -3920,7 +4709,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule ): @@ -3934,8 +4723,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule: @@ -3958,6 +4749,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetEffectiveEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -3973,6 +4765,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetEffectiveEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEffectiveEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetEffectiveEventThreatDetectionCustomModule._get_response( self._host, @@ -3997,9 +4816,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule.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.securitycenter_v1.SecurityCenterClient.get_effective_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEffectiveEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveSecurityHealthAnalyticsCustomModule( @@ -4039,7 +4882,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule ): @@ -4054,8 +4897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule: @@ -4079,6 +4924,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetEffectiveSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -4094,6 +4940,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetEffectiveSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEffectiveSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetEffectiveSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -4118,9 +4991,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_security_health_analytics_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule.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.securitycenter_v1.SecurityCenterClient.get_effective_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEffectiveSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEventThreatDetectionCustomModule( @@ -4160,7 +5057,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Call the get event threat detection custom module method over HTTP. @@ -4172,8 +5069,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_threat_detection_custom_module.EventThreatDetectionCustomModule: @@ -4192,6 +5091,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -4207,6 +5107,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetEventThreatDetectionCustomModule._get_response( self._host, @@ -4231,7 +5158,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_threat_detection_custom_module(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_threat_detection_custom_module.EventThreatDetectionCustomModule.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.securitycenter_v1.SecurityCenterClient.get_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -4269,7 +5220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -4279,8 +5230,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -4365,6 +5318,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -4379,6 +5333,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetIamPolicy._get_response( self._host, @@ -4400,7 +5381,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.securitycenter_v1.SecurityCenterClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMuteConfig( @@ -4437,7 +5440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Call the get mute config method over HTTP. @@ -4448,8 +5451,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.mute_config.MuteConfig: @@ -4462,6 +5467,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_mute_config(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetMuteConfig._get_transcoded_request( http_options, request @@ -4472,6 +5478,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetMuteConfig._get_response( self._host, @@ -4492,7 +5525,29 @@ def __call__( pb_resp = mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = mute_config.MuteConfig.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.securitycenter_v1.SecurityCenterClient.get_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNotificationConfig( @@ -4530,7 +5585,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Call the get notification config method over HTTP. @@ -4541,8 +5596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.notification_config.NotificationConfig: @@ -4558,6 +5615,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_notification_config( request, metadata ) @@ -4570,6 +5628,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetNotificationConfig._get_response( self._host, @@ -4590,7 +5675,31 @@ def __call__( pb_resp = notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = notification_config.NotificationConfig.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.securitycenter_v1.SecurityCenterClient.get_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganizationSettings( @@ -4628,7 +5737,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Call the get organization settings method over HTTP. @@ -4639,8 +5748,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.organization_settings.OrganizationSettings: @@ -4653,6 +5764,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization_settings( request, metadata ) @@ -4665,6 +5777,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._GetOrganizationSettings._get_response( @@ -4687,7 +5826,31 @@ def __call__( pb_resp = organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + organization_settings.OrganizationSettings.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.securitycenter_v1.SecurityCenterClient.get_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetResourceValueConfig( @@ -4725,7 +5888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Call the get resource value config method over HTTP. @@ -4736,8 +5899,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource_value_config.ResourceValueConfig: @@ -4751,6 +5916,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_resource_value_config( request, metadata ) @@ -4763,6 +5929,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._GetResourceValueConfig._get_response( @@ -4785,7 +5978,31 @@ def __call__( pb_resp = resource_value_config.ResourceValueConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_resource_value_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resource_value_config.ResourceValueConfig.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.securitycenter_v1.SecurityCenterClient.get_resource_value_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetResourceValueConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecurityHealthAnalyticsCustomModule( @@ -4825,7 +6042,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule ): @@ -4839,8 +6056,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: @@ -4860,6 +6079,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -4875,6 +6095,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -4899,9 +6146,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_security_health_analytics_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.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.securitycenter_v1.SecurityCenterClient.get_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSimulation( @@ -4938,7 +6209,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Call the get simulation method over HTTP. @@ -4952,8 +6223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.simulation.Simulation: @@ -4963,6 +6236,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSimulation._get_http_options() ) + request, metadata = self._interceptor.pre_get_simulation(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetSimulation._get_transcoded_request( http_options, request @@ -4973,6 +6247,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetSimulation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSimulation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSimulation._get_response( self._host, @@ -4993,7 +6294,29 @@ def __call__( pb_resp = simulation.Simulation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_simulation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = simulation.Simulation.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.securitycenter_v1.SecurityCenterClient.get_simulation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSimulation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource( @@ -5030,7 +6353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Call the get source method over HTTP. @@ -5040,8 +6363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.source.Source: @@ -5057,6 +6382,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_transcoded_request( @@ -5071,6 +6397,33 @@ def __call__( ) ) + 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.securitycenter_v1.SecurityCenterClient.GetSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSource._get_response( self._host, @@ -5091,7 +6444,29 @@ def __call__( pb_resp = source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = source.Source.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.securitycenter_v1.SecurityCenterClient.get_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetValuedResource( @@ -5128,7 +6503,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Call the get valued resource method over HTTP. @@ -5139,8 +6514,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.valued_resource.ValuedResource: @@ -5152,6 +6529,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetValuedResource._get_http_options() ) + request, metadata = self._interceptor.pre_get_valued_resource( request, metadata ) @@ -5164,6 +6542,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetValuedResource", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetValuedResource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetValuedResource._get_response( self._host, @@ -5184,7 +6589,29 @@ def __call__( pb_resp = valued_resource.ValuedResource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_valued_resource(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = valued_resource.ValuedResource.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.securitycenter_v1.SecurityCenterClient.get_valued_resource", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetValuedResource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupAssets( @@ -5222,7 +6649,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupAssetsResponse: r"""Call the group assets method over HTTP. @@ -5233,8 +6660,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupAssetsResponse: @@ -5246,6 +6675,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupAssets._get_http_options() ) + request, metadata = self._interceptor.pre_group_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupAssets._get_transcoded_request( http_options, request @@ -5260,6 +6690,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GroupAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GroupAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupAssets._get_response( self._host, @@ -5281,7 +6738,31 @@ def __call__( pb_resp = securitycenter_service.GroupAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupAssetsResponse.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.securitycenter_v1.SecurityCenterClient.group_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GroupAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupFindings( @@ -5319,7 +6800,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupFindingsResponse: r"""Call the group findings method over HTTP. @@ -5330,8 +6811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupFindingsResponse: @@ -5343,6 +6826,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupFindings._get_http_options() ) + request, metadata = self._interceptor.pre_group_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupFindings._get_transcoded_request( http_options, request @@ -5357,6 +6841,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GroupFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GroupFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupFindings._get_response( self._host, @@ -5378,7 +6889,31 @@ def __call__( pb_resp = securitycenter_service.GroupFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupFindingsResponse.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.securitycenter_v1.SecurityCenterClient.group_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GroupFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -5415,7 +6950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -5425,8 +6960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListAssetsResponse: @@ -5436,6 +6973,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListAssets._get_transcoded_request( http_options, request @@ -5448,6 +6986,33 @@ def __call__( ) ) + 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.securitycenter_v1.SecurityCenterClient.ListAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListAssets._get_response( self._host, @@ -5468,7 +7033,31 @@ def __call__( pb_resp = securitycenter_service.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListAssetsResponse.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.securitycenter_v1.SecurityCenterClient.list_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttackPaths( @@ -5505,7 +7094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListAttackPathsResponse: r"""Call the list attack paths method over HTTP. @@ -5517,8 +7106,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListAttackPathsResponse: @@ -5531,6 +7122,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListAttackPaths._get_http_options() ) + request, metadata = self._interceptor.pre_list_attack_paths( request, metadata ) @@ -5543,6 +7135,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListAttackPaths", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListAttackPaths", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListAttackPaths._get_response( self._host, @@ -5563,7 +7182,31 @@ def __call__( pb_resp = securitycenter_service.ListAttackPathsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attack_paths(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListAttackPathsResponse.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.securitycenter_v1.SecurityCenterClient.list_attack_paths", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListAttackPaths", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBigQueryExports( @@ -5601,7 +7244,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListBigQueryExportsResponse: r"""Call the list big query exports method over HTTP. @@ -5613,8 +7256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListBigQueryExportsResponse: @@ -5626,6 +7271,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListBigQueryExports._get_http_options() ) + request, metadata = self._interceptor.pre_list_big_query_exports( request, metadata ) @@ -5638,6 +7284,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListBigQueryExports", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListBigQueryExports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListBigQueryExports._get_response( self._host, @@ -5658,7 +7331,33 @@ def __call__( pb_resp = securitycenter_service.ListBigQueryExportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_big_query_exports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListBigQueryExportsResponse.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.securitycenter_v1.SecurityCenterClient.list_big_query_exports", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListBigQueryExports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDescendantEventThreatDetectionCustomModules( @@ -5698,7 +7397,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse ): @@ -5713,8 +7412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse: @@ -5727,6 +7428,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListDescendantEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -5742,6 +7444,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListDescendantEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListDescendantEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListDescendantEventThreatDetectionCustomModules._get_response( self._host, @@ -5766,9 +7495,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_descendant_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListDescendantEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDescendantSecurityHealthAnalyticsCustomModules( @@ -5808,7 +7561,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse ): @@ -5823,8 +7576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: @@ -5837,6 +7592,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListDescendantSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -5852,6 +7608,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListDescendantSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListDescendantSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListDescendantSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -5876,9 +7659,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_descendant_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListDescendantSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEffectiveEventThreatDetectionCustomModules( @@ -5918,7 +7725,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse ): @@ -5932,8 +7739,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse: @@ -5945,6 +7754,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListEffectiveEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -5960,6 +7770,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListEffectiveEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEffectiveEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListEffectiveEventThreatDetectionCustomModules._get_response( self._host, @@ -5984,9 +7821,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_effective_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEffectiveEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEffectiveSecurityHealthAnalyticsCustomModules( @@ -6026,7 +7887,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse ): @@ -6041,8 +7902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: @@ -6055,6 +7918,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListEffectiveSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -6070,6 +7934,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListEffectiveSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEffectiveSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListEffectiveSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -6094,9 +7985,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_effective_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEffectiveSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEventThreatDetectionCustomModules( @@ -6136,7 +8051,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListEventThreatDetectionCustomModulesResponse: r"""Call the list event threat detection custom modules method over HTTP. @@ -6148,8 +8063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListEventThreatDetectionCustomModulesResponse: @@ -6161,6 +8078,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -6176,6 +8094,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListEventThreatDetectionCustomModules._get_response( self._host, @@ -6202,9 +8147,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListEventThreatDetectionCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -6241,7 +8210,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -6251,8 +8220,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListFindingsResponse: @@ -6264,6 +8235,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -6274,6 +8246,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListFindings._get_response( self._host, @@ -6294,7 +8293,31 @@ def __call__( pb_resp = securitycenter_service.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListFindingsResponse.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.securitycenter_v1.SecurityCenterClient.list_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMuteConfigs( @@ -6331,7 +8354,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListMuteConfigsResponse: r"""Call the list mute configs method over HTTP. @@ -6343,8 +8366,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListMuteConfigsResponse: @@ -6356,6 +8381,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListMuteConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_mute_configs( request, metadata ) @@ -6368,6 +8394,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListMuteConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListMuteConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListMuteConfigs._get_response( self._host, @@ -6388,7 +8441,31 @@ def __call__( pb_resp = securitycenter_service.ListMuteConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_mute_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListMuteConfigsResponse.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.securitycenter_v1.SecurityCenterClient.list_mute_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListMuteConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNotificationConfigs( @@ -6426,7 +8503,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListNotificationConfigsResponse: r"""Call the list notification configs method over HTTP. @@ -6437,8 +8514,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListNotificationConfigsResponse: @@ -6450,6 +8529,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListNotificationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_notification_configs( request, metadata ) @@ -6462,6 +8542,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListNotificationConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._ListNotificationConfigs._get_response( @@ -6484,7 +8591,33 @@ def __call__( pb_resp = securitycenter_service.ListNotificationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_notification_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListNotificationConfigsResponse.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.securitycenter_v1.SecurityCenterClient.list_notification_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListResourceValueConfigs( @@ -6522,7 +8655,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListResourceValueConfigsResponse: r"""Call the list resource value configs method over HTTP. @@ -6534,8 +8667,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListResourceValueConfigsResponse: @@ -6547,6 +8682,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListResourceValueConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_resource_value_configs( request, metadata ) @@ -6559,6 +8695,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListResourceValueConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListResourceValueConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._ListResourceValueConfigs._get_response( @@ -6581,7 +8744,33 @@ def __call__( pb_resp = securitycenter_service.ListResourceValueConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_resource_value_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListResourceValueConfigsResponse.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.securitycenter_v1.SecurityCenterClient.list_resource_value_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListResourceValueConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecurityHealthAnalyticsCustomModules( @@ -6621,7 +8810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse: r"""Call the list security health analytics custom modules method over HTTP. @@ -6633,8 +8822,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse: @@ -6646,6 +8837,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -6661,6 +8853,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -6685,9 +8904,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse.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.securitycenter_v1.SecurityCenterClient.list_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -6724,7 +8967,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -6734,8 +8977,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListSourcesResponse: @@ -6745,6 +8990,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListSources._get_transcoded_request( http_options, request @@ -6755,6 +9001,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListSources", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListSources._get_response( self._host, @@ -6775,7 +9048,31 @@ def __call__( pb_resp = securitycenter_service.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListSourcesResponse.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.securitycenter_v1.SecurityCenterClient.list_sources", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListValuedResources( @@ -6813,7 +9110,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListValuedResourcesResponse: r"""Call the list valued resources method over HTTP. @@ -6824,8 +9121,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListValuedResourcesResponse: @@ -6837,6 +9136,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListValuedResources._get_http_options() ) + request, metadata = self._interceptor.pre_list_valued_resources( request, metadata ) @@ -6849,6 +9149,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListValuedResources", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListValuedResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListValuedResources._get_response( self._host, @@ -6869,7 +9196,33 @@ def __call__( pb_resp = securitycenter_service.ListValuedResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_valued_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListValuedResourcesResponse.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.securitycenter_v1.SecurityCenterClient.list_valued_resources", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListValuedResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunAssetDiscovery( @@ -6907,7 +9260,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run asset discovery method over HTTP. @@ -6918,8 +9271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -6932,6 +9287,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseRunAssetDiscovery._get_http_options() ) + request, metadata = self._interceptor.pre_run_asset_discovery( request, metadata ) @@ -6948,6 +9304,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.RunAssetDiscovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._RunAssetDiscovery._get_response( self._host, @@ -6967,7 +9350,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_asset_discovery(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.securitycenter_v1.SecurityCenterClient.run_asset_discovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetFindingState( @@ -7005,7 +9410,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set finding state method over HTTP. @@ -7016,8 +9421,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -7037,6 +9444,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetFindingState._get_http_options() ) + request, metadata = self._interceptor.pre_set_finding_state( request, metadata ) @@ -7053,6 +9461,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.SetFindingState", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetFindingState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetFindingState._get_response( self._host, @@ -7074,7 +9509,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_finding_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v1.SecurityCenterClient.set_finding_state", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetFindingState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -7112,7 +9569,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -7122,8 +9579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -7208,6 +9667,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -7222,6 +9682,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetIamPolicy._get_response( self._host, @@ -7243,7 +9730,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.securitycenter_v1.SecurityCenterClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMute( @@ -7281,7 +9790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set mute method over HTTP. @@ -7292,8 +9801,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -7313,6 +9824,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetMute._get_http_options() ) + request, metadata = self._interceptor.pre_set_mute(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseSetMute._get_transcoded_request( @@ -7331,6 +9843,33 @@ def __call__( ) ) + 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.securitycenter_v1.SecurityCenterClient.SetMute", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetMute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetMute._get_response( self._host, @@ -7352,7 +9891,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_mute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v1.SecurityCenterClient.set_mute", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SetMute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SimulateSecurityHealthAnalyticsCustomModule( @@ -7393,7 +9954,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse: r"""Call the simulate security health analytics custom module method over HTTP. @@ -7407,8 +9968,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -7421,6 +9984,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSimulateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -7440,6 +10004,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.SimulateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SimulateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SimulateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -7465,11 +10056,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_simulate_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse.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.securitycenter_v1.SecurityCenterClient.simulate_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "SimulateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -7507,7 +10122,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -7517,8 +10132,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -7528,6 +10145,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -7544,6 +10162,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._TestIamPermissions._get_response( self._host, @@ -7565,7 +10210,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.securitycenter_v1.SecurityCenterClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBigQueryExport( @@ -7604,7 +10271,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the update big query export method over HTTP. @@ -7615,8 +10282,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -7628,6 +10297,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_update_big_query_export( request, metadata ) @@ -7644,6 +10314,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateBigQueryExport._get_response( self._host, @@ -7665,7 +10362,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v1.SecurityCenterClient.update_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEventThreatDetectionCustomModule( @@ -7706,7 +10425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: r"""Call the update event threat detection custom module method over HTTP. @@ -7718,8 +10437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule: @@ -7738,6 +10459,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -7757,6 +10479,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateEventThreatDetectionCustomModule._get_response( self._host, @@ -7782,9 +10531,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.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.securitycenter_v1.SecurityCenterClient.update_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalSystem( @@ -7823,7 +10596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Call the update external system method over HTTP. @@ -7834,8 +10607,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_external_system.ExternalSystem: @@ -7847,6 +10622,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateExternalSystem._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_system( request, metadata ) @@ -7863,6 +10639,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateExternalSystem", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateExternalSystem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateExternalSystem._get_response( self._host, @@ -7884,7 +10687,31 @@ def __call__( pb_resp = gcs_external_system.ExternalSystem.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_external_system(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_external_system.ExternalSystem.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.securitycenter_v1.SecurityCenterClient.update_external_system", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateExternalSystem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFinding( @@ -7922,7 +10749,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the update finding method over HTTP. @@ -7933,8 +10760,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -7954,6 +10783,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_update_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_transcoded_request( http_options, request @@ -7968,6 +10798,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateFinding._get_response( self._host, @@ -7989,7 +10846,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1.SecurityCenterClient.update_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMuteConfig( @@ -8027,7 +10906,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Call the update mute config method over HTTP. @@ -8038,8 +10917,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_mute_config.MuteConfig: @@ -8052,6 +10933,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_mute_config( request, metadata ) @@ -8068,6 +10950,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateMuteConfig._get_response( self._host, @@ -8089,7 +10998,29 @@ def __call__( pb_resp = gcs_mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_mute_config.MuteConfig.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.securitycenter_v1.SecurityCenterClient.update_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNotificationConfig( @@ -8128,7 +11059,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the update notification config method over HTTP. @@ -8140,8 +11071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -8157,6 +11090,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_notification_config( request, metadata ) @@ -8173,6 +11107,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateNotificationConfig._get_response( @@ -8196,7 +11157,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v1.SecurityCenterClient.update_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOrganizationSettings( @@ -8235,7 +11220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Call the update organization settings method over HTTP. @@ -8247,8 +11232,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_organization_settings.OrganizationSettings: @@ -8261,6 +11248,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_organization_settings( request, metadata ) @@ -8277,6 +11265,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateOrganizationSettings._get_response( @@ -8300,7 +11315,31 @@ def __call__( pb_resp = gcs_organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_organization_settings.OrganizationSettings.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.securitycenter_v1.SecurityCenterClient.update_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateResourceValueConfig( @@ -8339,7 +11378,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Call the update resource value config method over HTTP. @@ -8351,8 +11390,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_resource_value_config.ResourceValueConfig: @@ -8366,6 +11407,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_resource_value_config( request, metadata ) @@ -8382,6 +11424,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateResourceValueConfig._get_response( @@ -8405,7 +11474,31 @@ def __call__( pb_resp = gcs_resource_value_config.ResourceValueConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_resource_value_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_resource_value_config.ResourceValueConfig.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.securitycenter_v1.SecurityCenterClient.update_resource_value_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateResourceValueConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityHealthAnalyticsCustomModule( @@ -8446,7 +11539,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule ): @@ -8460,8 +11553,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule: @@ -8481,6 +11576,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -8500,6 +11596,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -8525,11 +11648,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_update_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.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.securitycenter_v1.SecurityCenterClient.update_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityMarks( @@ -8568,7 +11715,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Call the update security marks method over HTTP. @@ -8579,8 +11726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_marks.SecurityMarks: @@ -8598,6 +11747,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSecurityMarks._get_http_options() ) + request, metadata = self._interceptor.pre_update_security_marks( request, metadata ) @@ -8614,6 +11764,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateSecurityMarks", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSecurityMarks._get_response( self._host, @@ -8635,7 +11812,31 @@ def __call__( pb_resp = gcs_security_marks.SecurityMarks.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_marks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_marks.SecurityMarks.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.securitycenter_v1.SecurityCenterClient.update_security_marks", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -8673,7 +11874,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the update source method over HTTP. @@ -8684,8 +11885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -8701,6 +11904,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateSource._get_transcoded_request( http_options, request @@ -8715,6 +11919,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.UpdateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSource._get_response( self._host, @@ -8736,7 +11967,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1.SecurityCenterClient.update_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ValidateEventThreatDetectionCustomModule( @@ -8777,7 +12030,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse: r"""Call the validate event threat detection custom module method over HTTP. @@ -8789,8 +12042,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse: @@ -8802,6 +12057,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseValidateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -8821,6 +12077,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ValidateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ValidateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ValidateEventThreatDetectionCustomModule._get_response( self._host, @@ -8846,9 +12129,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse.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.securitycenter_v1.SecurityCenterClient.validate_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ValidateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -9545,7 +12852,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -9555,13 +12862,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -9574,6 +12884,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.CancelOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CancelOperation._get_response( self._host, @@ -9629,7 +12966,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -9639,13 +12976,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -9658,6 +12998,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteOperation._get_response( self._host, @@ -9713,7 +13080,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -9723,8 +13090,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -9733,6 +13102,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -9743,6 +13113,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.GetOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetOperation._get_response( self._host, @@ -9762,6 +13159,27 @@ def __call__( 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.securitycenter_v1.SecurityCenterAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -9802,7 +13220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -9812,8 +13230,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -9822,6 +13242,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -9832,6 +13253,33 @@ def __call__( 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.securitycenter_v1.SecurityCenterClient.ListOperations", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListOperations._get_response( self._host, @@ -9851,6 +13299,27 @@ def __call__( 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.securitycenter_v1.SecurityCenterAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.securitycenter.v1.SecurityCenter", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/gapic_version.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/gapic_version.py index 56614055fa74..558c8aab67c5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/gapic_version.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.35.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/async_client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/async_client.py index e0b55ad39ed7..ac0e8232d1e8 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/async_client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -68,6 +69,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .transports.grpc_asyncio import SecurityCenterGrpcAsyncIOTransport +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 SecurityCenterAsyncClient: """V1 Beta APIs for Security Center service.""" @@ -287,6 +297,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securitycenter_v1beta1.SecurityCenterAsyncClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "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.securitycenter.v1beta1.SecurityCenter", + "credentialsType": None, + }, + ) + async def create_source( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -349,8 +381,10 @@ async def sample_create_source(): 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, 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -421,7 +455,7 @@ async def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -486,8 +520,10 @@ async def sample_create_finding(): 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, 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -560,7 +596,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -607,8 +643,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -696,7 +734,7 @@ async def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -741,8 +779,10 @@ async def sample_get_organization_settings(): 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, 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: google.cloud.securitycenter_v1beta1.types.OrganizationSettings: @@ -806,7 +846,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -850,8 +890,10 @@ async def sample_get_source(): 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, 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -917,7 +959,7 @@ async def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsAsyncPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -957,8 +999,10 @@ async def sample_group_assets(): 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, 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupAssetsAsyncPager: @@ -1022,7 +1066,7 @@ async def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsAsyncPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -1092,8 +1136,10 @@ async def sample_group_findings(): 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, 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupFindingsAsyncPager: @@ -1169,7 +1215,7 @@ async def list_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Lists an organization's assets. @@ -1206,8 +1252,10 @@ async def sample_list_assets(): 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, 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListAssetsAsyncPager: @@ -1269,7 +1317,7 @@ async def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""Lists an organization or source's findings. @@ -1310,8 +1358,10 @@ async def sample_list_findings(): 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, 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListFindingsAsyncPager: @@ -1374,7 +1424,7 @@ async def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesAsyncPager: r"""Lists all sources belonging to an organization. @@ -1419,8 +1469,10 @@ async def sample_list_sources(): 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, 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListSourcesAsyncPager: @@ -1497,7 +1549,7 @@ async def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -1551,8 +1603,10 @@ async def sample_run_asset_discovery(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1635,7 +1689,7 @@ async def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -1697,8 +1751,10 @@ async def sample_set_finding_state(): 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, 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -1771,7 +1827,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -1818,8 +1874,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1906,7 +1964,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -1963,8 +2021,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2024,7 +2084,7 @@ async def update_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -2073,8 +2133,10 @@ async def sample_update_finding(): 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, 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -2149,7 +2211,7 @@ async def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -2192,8 +2254,10 @@ async def sample_update_organization_settings(): 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, 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: google.cloud.securitycenter_v1beta1.types.OrganizationSettings: @@ -2261,7 +2325,7 @@ async def update_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -2304,8 +2368,10 @@ async def sample_update_source(): 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, 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -2374,7 +2440,7 @@ async def update_security_marks( security_marks: Optional[gcs_security_marks.SecurityMarks] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -2417,8 +2483,10 @@ async def sample_update_security_marks(): 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, 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: google.cloud.securitycenter_v1beta1.types.SecurityMarks: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/client.py index 27e9eb8df288..ed3d279ae01b 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -674,6 +684,10 @@ def __init__( # 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( @@ -739,6 +753,29 @@ def __init__( 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.securitycenter_v1beta1.SecurityCenterClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "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.securitycenter.v1beta1.SecurityCenter", + "credentialsType": None, + }, + ) + def create_source( self, request: Optional[ @@ -749,7 +786,7 @@ def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -801,8 +838,10 @@ def sample_create_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -870,7 +909,7 @@ def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -935,8 +974,10 @@ def sample_create_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -1006,7 +1047,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -1053,8 +1094,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1143,7 +1186,7 @@ def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -1188,8 +1231,10 @@ def sample_get_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1beta1.types.OrganizationSettings: @@ -1252,7 +1297,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -1296,8 +1341,10 @@ def sample_get_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -1360,7 +1407,7 @@ def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -1400,8 +1447,10 @@ def sample_group_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupAssetsPager: @@ -1463,7 +1512,7 @@ def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -1533,8 +1582,10 @@ def sample_group_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupFindingsPager: @@ -1607,7 +1658,7 @@ def list_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Lists an organization's assets. @@ -1644,8 +1695,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListAssetsPager: @@ -1705,7 +1758,7 @@ def list_findings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""Lists an organization or source's findings. @@ -1746,8 +1799,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListFindingsPager: @@ -1808,7 +1863,7 @@ def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesPager: r"""Lists all sources belonging to an organization. @@ -1853,8 +1908,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListSourcesPager: @@ -1928,7 +1985,7 @@ def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -1982,8 +2039,10 @@ def sample_run_asset_discovery(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2063,7 +2122,7 @@ def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -2125,8 +2184,10 @@ def sample_set_finding_state(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -2196,7 +2257,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -2243,8 +2304,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2332,7 +2395,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -2389,8 +2452,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2451,7 +2516,7 @@ def update_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -2500,8 +2565,10 @@ def sample_update_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Finding: @@ -2573,7 +2640,7 @@ def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -2616,8 +2683,10 @@ def sample_update_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1beta1.types.OrganizationSettings: @@ -2684,7 +2753,7 @@ def update_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -2727,8 +2796,10 @@ def sample_update_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.Source: @@ -2794,7 +2865,7 @@ def update_security_marks( security_marks: Optional[gcs_security_marks.SecurityMarks] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -2837,8 +2908,10 @@ def sample_update_security_marks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1beta1.types.SecurityMarks: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/pagers.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/pagers.py index 13c7fe58c82e..2428bdef2a8c 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/pagers.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -377,7 +385,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -391,8 +399,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -607,7 +621,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -621,8 +635,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -685,7 +701,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -699,8 +715,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -759,7 +777,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -773,8 +791,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc.py index f4881a7a7825..e151eea20b6a 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,7 +26,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1beta1.types import ( organization_settings as gcs_organization_settings, @@ -40,6 +46,81 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport +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.securitycenter.v1beta1.SecurityCenter", + "rpcName": 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.securitycenter.v1beta1.SecurityCenter", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcTransport(SecurityCenterTransport): """gRPC backend transport for SecurityCenter. @@ -194,7 +275,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -282,7 +370,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -309,7 +397,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -336,7 +424,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -365,7 +453,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -391,7 +479,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -421,7 +509,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -455,7 +543,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -484,7 +572,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -517,7 +605,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -546,7 +634,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -579,7 +667,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -605,7 +693,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -632,7 +720,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -662,7 +750,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -689,7 +777,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -718,7 +806,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -744,7 +834,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -773,7 +863,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -781,7 +871,7 @@ def update_security_marks( return self._stubs["update_security_marks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc_asyncio.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc_asyncio.py index b54641eeb17c..39945461d483 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,8 +28,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1beta1.types import ( organization_settings as gcs_organization_settings, @@ -44,6 +50,82 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .grpc import SecurityCenterGrpcTransport +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.securitycenter.v1beta1.SecurityCenter", + "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.securitycenter.v1beta1.SecurityCenter", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcAsyncIOTransport(SecurityCenterTransport): """gRPC AsyncIO backend transport for SecurityCenter. @@ -241,10 +323,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -294,7 +379,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -323,7 +408,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -350,7 +435,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -379,7 +464,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -405,7 +490,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -435,7 +520,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -469,7 +554,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -498,7 +583,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -531,7 +616,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -560,7 +645,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -594,7 +679,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -622,7 +707,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -649,7 +734,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -679,7 +764,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -708,7 +793,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -737,7 +822,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -765,7 +852,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -794,7 +881,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -992,7 +1079,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/rest.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/rest.py index 7a2297e35db0..e56acf1a5153 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/rest.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1beta1/services/security_center/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -51,6 +51,14 @@ 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, @@ -227,8 +235,11 @@ def post_update_source(self, response): def pre_create_finding( self, request: securitycenter_service.CreateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_finding Override in a subclass to manipulate the request or metadata @@ -248,8 +259,11 @@ def post_create_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_create_source( self, request: securitycenter_service.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -269,8 +283,10 @@ def post_create_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -290,9 +306,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_organization_settings( self, request: securitycenter_service.GetOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetOrganizationSettingsRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetOrganizationSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_organization_settings @@ -315,8 +332,10 @@ def post_get_organization_settings( def pre_get_source( self, request: securitycenter_service.GetSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -336,8 +355,11 @@ def post_get_source(self, response: source.Source) -> source.Source: def pre_group_assets( self, request: securitycenter_service.GroupAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_assets Override in a subclass to manipulate the request or metadata @@ -359,8 +381,11 @@ def post_group_assets( def pre_group_findings( self, request: securitycenter_service.GroupFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_findings Override in a subclass to manipulate the request or metadata @@ -382,8 +407,11 @@ def post_group_findings( def pre_list_assets( self, request: securitycenter_service.ListAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -405,8 +433,11 @@ def post_list_assets( def pre_list_findings( self, request: securitycenter_service.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -428,8 +459,11 @@ def post_list_findings( def pre_list_sources( self, request: securitycenter_service.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListSourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -451,9 +485,10 @@ def post_list_sources( def pre_run_asset_discovery( self, request: securitycenter_service.RunAssetDiscoveryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.RunAssetDiscoveryRequest, Sequence[Tuple[str, str]] + securitycenter_service.RunAssetDiscoveryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for run_asset_discovery @@ -476,9 +511,10 @@ def post_run_asset_discovery( def pre_set_finding_state( self, request: securitycenter_service.SetFindingStateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.SetFindingStateRequest, Sequence[Tuple[str, str]] + securitycenter_service.SetFindingStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_finding_state @@ -499,8 +535,10 @@ def post_set_finding_state(self, response: finding.Finding) -> finding.Finding: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -520,8 +558,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -543,8 +584,11 @@ def post_test_iam_permissions( def pre_update_finding( self, request: securitycenter_service.UpdateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_finding Override in a subclass to manipulate the request or metadata @@ -564,10 +608,10 @@ def post_update_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_update_organization_settings( self, request: securitycenter_service.UpdateOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateOrganizationSettingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_organization_settings @@ -590,9 +634,10 @@ def post_update_organization_settings( def pre_update_security_marks( self, request: securitycenter_service.UpdateSecurityMarksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateSecurityMarksRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateSecurityMarksRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_marks @@ -615,8 +660,11 @@ def post_update_security_marks( def pre_update_source( self, request: securitycenter_service.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -809,7 +857,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the create finding method over HTTP. @@ -820,8 +868,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -841,6 +891,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateFinding._get_transcoded_request( http_options, request @@ -855,6 +906,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.CreateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "CreateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateFinding._get_response( self._host, @@ -876,7 +954,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1beta1.SecurityCenterClient.create_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "CreateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -914,7 +1014,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the create source method over HTTP. @@ -925,8 +1025,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -942,6 +1044,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateSource._get_transcoded_request( http_options, request @@ -956,6 +1059,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.CreateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateSource._get_response( self._host, @@ -977,7 +1107,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1beta1.SecurityCenterClient.create_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1015,7 +1167,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1025,8 +1177,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1111,6 +1265,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1125,6 +1280,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetIamPolicy._get_response( self._host, @@ -1146,7 +1328,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.securitycenter_v1beta1.SecurityCenterClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganizationSettings( @@ -1184,7 +1388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Call the get organization settings method over HTTP. @@ -1195,8 +1399,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.organization_settings.OrganizationSettings: @@ -1209,6 +1415,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization_settings( request, metadata ) @@ -1221,6 +1428,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.GetOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._GetOrganizationSettings._get_response( @@ -1243,7 +1477,31 @@ def __call__( pb_resp = organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + organization_settings.OrganizationSettings.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.securitycenter_v1beta1.SecurityCenterClient.get_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource( @@ -1280,7 +1538,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Call the get source method over HTTP. @@ -1290,8 +1548,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.source.Source: @@ -1307,6 +1567,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_transcoded_request( @@ -1321,6 +1582,33 @@ def __call__( ) ) + 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.securitycenter_v1beta1.SecurityCenterClient.GetSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSource._get_response( self._host, @@ -1341,7 +1629,29 @@ def __call__( pb_resp = source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = source.Source.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.securitycenter_v1beta1.SecurityCenterClient.get_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupAssets( @@ -1379,7 +1689,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupAssetsResponse: r"""Call the group assets method over HTTP. @@ -1390,8 +1700,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupAssetsResponse: @@ -1403,6 +1715,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupAssets._get_http_options() ) + request, metadata = self._interceptor.pre_group_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupAssets._get_transcoded_request( http_options, request @@ -1417,6 +1730,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.GroupAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GroupAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupAssets._get_response( self._host, @@ -1438,7 +1778,31 @@ def __call__( pb_resp = securitycenter_service.GroupAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupAssetsResponse.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.securitycenter_v1beta1.SecurityCenterClient.group_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GroupAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupFindings( @@ -1476,7 +1840,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupFindingsResponse: r"""Call the group findings method over HTTP. @@ -1487,8 +1851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupFindingsResponse: @@ -1500,6 +1866,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupFindings._get_http_options() ) + request, metadata = self._interceptor.pre_group_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupFindings._get_transcoded_request( http_options, request @@ -1514,6 +1881,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.GroupFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GroupFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupFindings._get_response( self._host, @@ -1535,7 +1929,31 @@ def __call__( pb_resp = securitycenter_service.GroupFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupFindingsResponse.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.securitycenter_v1beta1.SecurityCenterClient.group_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "GroupFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -1572,7 +1990,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -1582,8 +2000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListAssetsResponse: @@ -1593,6 +2013,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListAssets._get_transcoded_request( http_options, request @@ -1605,6 +2026,33 @@ def __call__( ) ) + 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.securitycenter_v1beta1.SecurityCenterClient.ListAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListAssets._get_response( self._host, @@ -1625,7 +2073,31 @@ def __call__( pb_resp = securitycenter_service.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListAssetsResponse.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.securitycenter_v1beta1.SecurityCenterClient.list_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -1662,7 +2134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -1672,8 +2144,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListFindingsResponse: @@ -1685,6 +2159,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -1695,6 +2170,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.ListFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListFindings._get_response( self._host, @@ -1715,7 +2217,31 @@ def __call__( pb_resp = securitycenter_service.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListFindingsResponse.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.securitycenter_v1beta1.SecurityCenterClient.list_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -1752,7 +2278,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -1762,8 +2288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListSourcesResponse: @@ -1773,6 +2301,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListSources._get_transcoded_request( http_options, request @@ -1783,6 +2312,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.ListSources", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListSources._get_response( self._host, @@ -1803,7 +2359,31 @@ def __call__( pb_resp = securitycenter_service.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListSourcesResponse.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.securitycenter_v1beta1.SecurityCenterClient.list_sources", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunAssetDiscovery( @@ -1841,7 +2421,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run asset discovery method over HTTP. @@ -1852,8 +2432,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1866,6 +2448,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseRunAssetDiscovery._get_http_options() ) + request, metadata = self._interceptor.pre_run_asset_discovery( request, metadata ) @@ -1882,6 +2465,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.RunAssetDiscovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._RunAssetDiscovery._get_response( self._host, @@ -1901,7 +2511,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_asset_discovery(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.securitycenter_v1beta1.SecurityCenterClient.run_asset_discovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetFindingState( @@ -1939,7 +2571,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set finding state method over HTTP. @@ -1950,8 +2582,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -1971,6 +2605,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetFindingState._get_http_options() ) + request, metadata = self._interceptor.pre_set_finding_state( request, metadata ) @@ -1987,6 +2622,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.SetFindingState", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "SetFindingState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetFindingState._get_response( self._host, @@ -2008,7 +2670,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_finding_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v1beta1.SecurityCenterClient.set_finding_state", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "SetFindingState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2046,7 +2730,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2056,8 +2740,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2142,6 +2828,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2156,6 +2843,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetIamPolicy._get_response( self._host, @@ -2177,7 +2891,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.securitycenter_v1beta1.SecurityCenterClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2215,7 +2951,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2225,8 +2961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2236,6 +2974,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2252,6 +2991,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._TestIamPermissions._get_response( self._host, @@ -2273,7 +3039,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.securitycenter_v1beta1.SecurityCenterClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFinding( @@ -2311,7 +3099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the update finding method over HTTP. @@ -2322,8 +3110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -2343,6 +3133,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_update_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_transcoded_request( http_options, request @@ -2357,6 +3148,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.UpdateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateFinding._get_response( self._host, @@ -2378,7 +3196,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1beta1.SecurityCenterClient.update_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOrganizationSettings( @@ -2417,7 +3257,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Call the update organization settings method over HTTP. @@ -2429,8 +3269,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_organization_settings.OrganizationSettings: @@ -2443,6 +3285,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_organization_settings( request, metadata ) @@ -2459,6 +3302,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.UpdateOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateOrganizationSettings._get_response( @@ -2482,7 +3352,31 @@ def __call__( pb_resp = gcs_organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_organization_settings.OrganizationSettings.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.securitycenter_v1beta1.SecurityCenterClient.update_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityMarks( @@ -2521,7 +3415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Call the update security marks method over HTTP. @@ -2532,8 +3426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_marks.SecurityMarks: @@ -2551,6 +3447,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSecurityMarks._get_http_options() ) + request, metadata = self._interceptor.pre_update_security_marks( request, metadata ) @@ -2567,6 +3464,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.UpdateSecurityMarks", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSecurityMarks._get_response( self._host, @@ -2588,7 +3512,31 @@ def __call__( pb_resp = gcs_security_marks.SecurityMarks.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_marks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_marks.SecurityMarks.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.securitycenter_v1beta1.SecurityCenterClient.update_security_marks", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -2626,7 +3574,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the update source method over HTTP. @@ -2637,8 +3585,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -2654,6 +3604,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateSource._get_transcoded_request( http_options, request @@ -2668,6 +3619,33 @@ def __call__( 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.securitycenter_v1beta1.SecurityCenterClient.UpdateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSource._get_response( self._host, @@ -2689,7 +3667,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1beta1.SecurityCenterClient.update_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1beta1.SecurityCenter", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/gapic_version.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/gapic_version.py index 56614055fa74..558c8aab67c5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.35.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/async_client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/async_client.py index 70acba68fe13..87c6b04410eb 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/async_client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -74,6 +75,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .transports.grpc_asyncio import SecurityCenterGrpcAsyncIOTransport +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 SecurityCenterAsyncClient: """V1p1Beta1 APIs for Security Center service.""" @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securitycenter_v1p1beta1.SecurityCenterAsyncClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "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.securitycenter.v1p1beta1.SecurityCenter", + "credentialsType": None, + }, + ) + async def create_source( self, request: Optional[ @@ -311,7 +343,7 @@ async def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -363,8 +395,10 @@ async def sample_create_source(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -435,7 +469,7 @@ async def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -497,8 +531,10 @@ async def sample_create_finding(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -577,7 +613,7 @@ async def create_notification_config( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -641,8 +677,10 @@ async def sample_create_notification_config(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -716,7 +754,7 @@ async def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -758,8 +796,10 @@ async def sample_delete_notification_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -813,7 +853,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -860,8 +900,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -949,7 +991,7 @@ async def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -994,8 +1036,10 @@ async def sample_get_notification_config(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -1063,7 +1107,7 @@ async def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -1108,8 +1152,10 @@ async def sample_get_organization_settings(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings: @@ -1173,7 +1219,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -1217,8 +1263,10 @@ async def sample_get_source(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -1284,7 +1332,7 @@ async def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsAsyncPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -1324,8 +1372,10 @@ async def sample_group_assets(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupAssetsAsyncPager: @@ -1389,7 +1439,7 @@ async def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsAsyncPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -1469,8 +1519,10 @@ async def sample_group_findings(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupFindingsAsyncPager: @@ -1547,7 +1599,7 @@ async def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsAsyncPager: r"""Lists an organization's assets. @@ -1592,8 +1644,10 @@ async def sample_list_assets(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListAssetsAsyncPager: @@ -1670,7 +1724,7 @@ async def list_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""Lists an organization or source's findings. @@ -1725,8 +1779,10 @@ async def sample_list_findings(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListFindingsAsyncPager: @@ -1803,7 +1859,7 @@ async def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsAsyncPager: r"""Lists notification configs. @@ -1849,8 +1905,10 @@ async def sample_list_notification_configs(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListNotificationConfigsAsyncPager: @@ -1929,7 +1987,7 @@ async def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesAsyncPager: r"""Lists all sources belonging to an organization. @@ -1975,8 +2033,10 @@ async def sample_list_sources(): 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, 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListSourcesAsyncPager: @@ -2053,7 +2113,7 @@ async def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -2107,8 +2167,10 @@ async def sample_run_asset_discovery(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2184,7 +2246,7 @@ async def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -2246,8 +2308,10 @@ async def sample_set_finding_state(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -2320,7 +2384,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -2367,8 +2431,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2455,7 +2521,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -2512,8 +2578,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2574,7 +2642,7 @@ async def update_finding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -2637,8 +2705,10 @@ async def sample_update_finding(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -2716,7 +2786,7 @@ async def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -2769,8 +2839,10 @@ async def sample_update_notification_config(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -2846,7 +2918,7 @@ async def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -2889,8 +2961,10 @@ async def sample_update_organization_settings(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings: @@ -2959,7 +3033,7 @@ async def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -3011,8 +3085,10 @@ async def sample_update_source(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -3084,7 +3160,7 @@ async def update_security_marks( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -3139,8 +3215,10 @@ async def sample_update_security_marks(): 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, 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: google.cloud.securitycenter_v1p1beta1.types.SecurityMarks: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/client.py index 4a3c05266667..e9fc41549b89 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -717,6 +727,10 @@ def __init__( # 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( @@ -782,6 +796,29 @@ def __init__( 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.securitycenter_v1p1beta1.SecurityCenterClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "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.securitycenter.v1p1beta1.SecurityCenter", + "credentialsType": None, + }, + ) + def create_source( self, request: Optional[ @@ -792,7 +829,7 @@ def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -844,8 +881,10 @@ def sample_create_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -913,7 +952,7 @@ def create_finding( finding: Optional[gcs_finding.Finding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding. The corresponding source must exist for finding creation to succeed. @@ -975,8 +1014,10 @@ def sample_create_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -1052,7 +1093,7 @@ def create_notification_config( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -1116,8 +1157,10 @@ def sample_create_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -1190,7 +1233,7 @@ def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -1232,8 +1275,10 @@ def sample_delete_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1286,7 +1331,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -1333,8 +1378,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1423,7 +1470,7 @@ def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -1468,8 +1515,10 @@ def sample_get_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -1534,7 +1583,7 @@ def get_organization_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Gets the settings for an organization. @@ -1579,8 +1628,10 @@ def sample_get_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1p1beta1.types.OrganizationSettings: @@ -1643,7 +1694,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -1687,8 +1738,10 @@ def sample_get_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -1751,7 +1804,7 @@ def group_assets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupAssetsPager: r"""Filters an organization's assets and groups them by their specified properties. @@ -1791,8 +1844,10 @@ def sample_group_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupAssetsPager: @@ -1854,7 +1909,7 @@ def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsPager: r"""Filters an organization or source's findings and groups them by their specified properties. @@ -1934,8 +1989,10 @@ def sample_group_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupFindingsPager: @@ -2009,7 +2066,7 @@ def list_assets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssetsPager: r"""Lists an organization's assets. @@ -2054,8 +2111,10 @@ def sample_list_assets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListAssetsPager: @@ -2129,7 +2188,7 @@ def list_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""Lists an organization or source's findings. @@ -2184,8 +2243,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListFindingsPager: @@ -2259,7 +2320,7 @@ def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsPager: r"""Lists notification configs. @@ -2305,8 +2366,10 @@ def sample_list_notification_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListNotificationConfigsPager: @@ -2384,7 +2447,7 @@ def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesPager: r"""Lists all sources belonging to an organization. @@ -2430,8 +2493,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListSourcesPager: @@ -2505,7 +2570,7 @@ def run_asset_discovery( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Runs asset discovery. The discovery is tracked with a long-running operation. @@ -2559,8 +2624,10 @@ def sample_run_asset_discovery(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2633,7 +2700,7 @@ def set_finding_state( start_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. @@ -2695,8 +2762,10 @@ def sample_set_finding_state(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -2766,7 +2835,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -2813,8 +2882,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2902,7 +2973,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -2959,8 +3030,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -3022,7 +3095,7 @@ def update_finding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. The corresponding source must exist for a finding creation to succeed. @@ -3085,8 +3158,10 @@ def sample_update_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Finding: @@ -3161,7 +3236,7 @@ def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -3214,8 +3289,10 @@ def sample_update_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.NotificationConfig: @@ -3290,7 +3367,7 @@ def update_organization_settings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Updates an organization's settings. @@ -3333,8 +3410,10 @@ def sample_update_organization_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.securitycenter_v1p1beta1.types.OrganizationSettings: @@ -3402,7 +3481,7 @@ def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -3454,8 +3533,10 @@ def sample_update_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.Source: @@ -3524,7 +3605,7 @@ def update_security_marks( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. @@ -3579,8 +3660,10 @@ def sample_update_security_marks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v1p1beta1.types.SecurityMarks: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/pagers.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/pagers.py index e792ec3cadb3..929f9f7168c9 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/pagers.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupAssetsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -377,7 +385,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -391,8 +399,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListAssetsRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -609,7 +623,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -623,8 +637,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -689,7 +705,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -703,8 +719,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -765,7 +783,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -779,8 +797,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -845,7 +865,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -859,8 +879,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -919,7 +941,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -933,8 +955,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc.py index 85dc303a077d..1a35d127bd6a 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1p1beta1.types import ( notification_config as gcs_notification_config, @@ -45,6 +51,81 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport +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.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": 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.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcTransport(SecurityCenterTransport): """gRPC backend transport for SecurityCenter. @@ -199,7 +280,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +349,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -287,7 +375,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -314,7 +402,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -343,7 +431,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -371,7 +461,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -398,7 +490,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -427,7 +519,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -456,7 +548,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -482,7 +574,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -512,7 +604,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -547,7 +639,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -576,7 +668,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -609,7 +701,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -638,7 +730,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -667,7 +759,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -700,7 +792,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -726,7 +818,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -753,7 +845,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -783,7 +875,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -810,7 +902,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -840,7 +932,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -869,7 +963,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -895,7 +991,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -924,7 +1020,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -932,7 +1028,7 @@ def update_security_marks( return self._stubs["update_security_marks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc_asyncio.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc_asyncio.py index cc2c4ae8b771..d5b41a551437 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v1p1beta1.types import ( notification_config as gcs_notification_config, @@ -49,6 +55,82 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .grpc import SecurityCenterGrpcTransport +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.securitycenter.v1p1beta1.SecurityCenter", + "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.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcAsyncIOTransport(SecurityCenterTransport): """gRPC AsyncIO backend transport for SecurityCenter. @@ -246,10 +328,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +357,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -299,7 +384,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -328,7 +413,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -357,7 +442,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -386,7 +473,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -413,7 +502,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -442,7 +531,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -471,7 +560,7 @@ def get_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_settings" not in self._stubs: - self._stubs["get_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_settings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetOrganizationSettings", request_serializer=securitycenter_service.GetOrganizationSettingsRequest.serialize, response_deserializer=organization_settings.OrganizationSettings.deserialize, @@ -497,7 +586,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -527,7 +616,7 @@ def group_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_assets" not in self._stubs: - self._stubs["group_assets"] = self.grpc_channel.unary_unary( + self._stubs["group_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupAssets", request_serializer=securitycenter_service.GroupAssetsRequest.serialize, response_deserializer=securitycenter_service.GroupAssetsResponse.deserialize, @@ -562,7 +651,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -591,7 +680,7 @@ def list_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assets" not in self._stubs: - self._stubs["list_assets"] = self.grpc_channel.unary_unary( + self._stubs["list_assets"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListAssets", request_serializer=securitycenter_service.ListAssetsRequest.serialize, response_deserializer=securitycenter_service.ListAssetsResponse.deserialize, @@ -624,7 +713,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -653,7 +742,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -682,7 +771,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -716,7 +805,7 @@ def run_asset_discovery( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_asset_discovery" not in self._stubs: - self._stubs["run_asset_discovery"] = self.grpc_channel.unary_unary( + self._stubs["run_asset_discovery"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/RunAssetDiscovery", request_serializer=securitycenter_service.RunAssetDiscoveryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -744,7 +833,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -771,7 +860,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -801,7 +890,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -830,7 +919,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -860,7 +949,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -889,7 +980,9 @@ def update_organization_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_organization_settings" not in self._stubs: - self._stubs["update_organization_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_organization_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateOrganizationSettings", request_serializer=securitycenter_service.UpdateOrganizationSettingsRequest.serialize, response_deserializer=gcs_organization_settings.OrganizationSettings.deserialize, @@ -917,7 +1010,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -946,7 +1039,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -1189,7 +1282,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/rest.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/rest.py index 701f310e9931..94b165382eeb 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/rest.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v1p1beta1/services/security_center/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -56,6 +56,14 @@ 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, @@ -268,8 +276,11 @@ def post_update_source(self, response): def pre_create_finding( self, request: securitycenter_service.CreateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_finding Override in a subclass to manipulate the request or metadata @@ -289,10 +300,10 @@ def post_create_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_create_notification_config( self, request: securitycenter_service.CreateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.CreateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_notification_config @@ -315,8 +326,11 @@ def post_create_notification_config( def pre_create_source( self, request: securitycenter_service.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -336,10 +350,10 @@ def post_create_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_delete_notification_config( self, request: securitycenter_service.DeleteNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_notification_config @@ -351,8 +365,10 @@ def pre_delete_notification_config( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -372,9 +388,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_notification_config( self, request: securitycenter_service.GetNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetNotificationConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetNotificationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_notification_config @@ -397,9 +414,10 @@ def post_get_notification_config( def pre_get_organization_settings( self, request: securitycenter_service.GetOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetOrganizationSettingsRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetOrganizationSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_organization_settings @@ -422,8 +440,10 @@ def post_get_organization_settings( def pre_get_source( self, request: securitycenter_service.GetSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -443,8 +463,11 @@ def post_get_source(self, response: source.Source) -> source.Source: def pre_group_assets( self, request: securitycenter_service.GroupAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_assets Override in a subclass to manipulate the request or metadata @@ -466,8 +489,11 @@ def post_group_assets( def pre_group_findings( self, request: securitycenter_service.GroupFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_findings Override in a subclass to manipulate the request or metadata @@ -489,8 +515,11 @@ def post_group_findings( def pre_list_assets( self, request: securitycenter_service.ListAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -512,8 +541,11 @@ def post_list_assets( def pre_list_findings( self, request: securitycenter_service.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -535,9 +567,10 @@ def post_list_findings( def pre_list_notification_configs( self, request: securitycenter_service.ListNotificationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListNotificationConfigsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListNotificationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_notification_configs @@ -560,8 +593,11 @@ def post_list_notification_configs( def pre_list_sources( self, request: securitycenter_service.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListSourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -583,9 +619,10 @@ def post_list_sources( def pre_run_asset_discovery( self, request: securitycenter_service.RunAssetDiscoveryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.RunAssetDiscoveryRequest, Sequence[Tuple[str, str]] + securitycenter_service.RunAssetDiscoveryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for run_asset_discovery @@ -608,9 +645,10 @@ def post_run_asset_discovery( def pre_set_finding_state( self, request: securitycenter_service.SetFindingStateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.SetFindingStateRequest, Sequence[Tuple[str, str]] + securitycenter_service.SetFindingStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_finding_state @@ -631,8 +669,10 @@ def post_set_finding_state(self, response: finding.Finding) -> finding.Finding: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -652,8 +692,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -675,8 +718,11 @@ def post_test_iam_permissions( def pre_update_finding( self, request: securitycenter_service.UpdateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_finding Override in a subclass to manipulate the request or metadata @@ -696,10 +742,10 @@ def post_update_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_update_notification_config( self, request: securitycenter_service.UpdateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_notification_config @@ -722,10 +768,10 @@ def post_update_notification_config( def pre_update_organization_settings( self, request: securitycenter_service.UpdateOrganizationSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateOrganizationSettingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_organization_settings @@ -748,9 +794,10 @@ def post_update_organization_settings( def pre_update_security_marks( self, request: securitycenter_service.UpdateSecurityMarksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateSecurityMarksRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateSecurityMarksRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_marks @@ -773,8 +820,11 @@ def post_update_security_marks( def pre_update_source( self, request: securitycenter_service.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -967,7 +1017,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the create finding method over HTTP. @@ -978,8 +1028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -999,6 +1051,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateFinding._get_transcoded_request( http_options, request @@ -1013,6 +1066,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.CreateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateFinding._get_response( self._host, @@ -1034,7 +1114,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1p1beta1.SecurityCenterClient.create_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNotificationConfig( @@ -1073,7 +1175,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the create notification config method over HTTP. @@ -1085,8 +1187,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -1103,6 +1207,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_notification_config( request, metadata ) @@ -1119,6 +1224,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.CreateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._CreateNotificationConfig._get_response( @@ -1142,7 +1274,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v1p1beta1.SecurityCenterClient.create_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -1180,7 +1336,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the create source method over HTTP. @@ -1191,8 +1347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -1208,6 +1366,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateSource._get_transcoded_request( http_options, request @@ -1222,6 +1381,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.CreateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateSource._get_response( self._host, @@ -1243,7 +1429,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1p1beta1.SecurityCenterClient.create_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNotificationConfig( @@ -1281,7 +1489,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete notification config method over HTTP. @@ -1293,13 +1501,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_notification_config( request, metadata ) @@ -1312,6 +1523,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.DeleteNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "DeleteNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._DeleteNotificationConfig._get_response( @@ -1364,7 +1602,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1374,8 +1612,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1460,6 +1700,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1474,6 +1715,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetIamPolicy._get_response( self._host, @@ -1495,7 +1763,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.securitycenter_v1p1beta1.SecurityCenterClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNotificationConfig( @@ -1533,7 +1823,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Call the get notification config method over HTTP. @@ -1544,8 +1834,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.notification_config.NotificationConfig: @@ -1562,6 +1854,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_notification_config( request, metadata ) @@ -1574,6 +1867,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.GetNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetNotificationConfig._get_response( self._host, @@ -1594,7 +1914,31 @@ def __call__( pb_resp = notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = notification_config.NotificationConfig.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.securitycenter_v1p1beta1.SecurityCenterClient.get_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganizationSettings( @@ -1632,7 +1976,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organization_settings.OrganizationSettings: r"""Call the get organization settings method over HTTP. @@ -1643,8 +1987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.organization_settings.OrganizationSettings: @@ -1657,6 +2003,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization_settings( request, metadata ) @@ -1669,6 +2016,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.GetOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._GetOrganizationSettings._get_response( @@ -1691,7 +2065,31 @@ def __call__( pb_resp = organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + organization_settings.OrganizationSettings.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.securitycenter_v1p1beta1.SecurityCenterClient.get_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource( @@ -1728,7 +2126,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Call the get source method over HTTP. @@ -1738,8 +2136,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.source.Source: @@ -1755,6 +2155,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_transcoded_request( @@ -1769,6 +2170,33 @@ def __call__( ) ) + 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.securitycenter_v1p1beta1.SecurityCenterClient.GetSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSource._get_response( self._host, @@ -1789,7 +2217,29 @@ def __call__( pb_resp = source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = source.Source.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.securitycenter_v1p1beta1.SecurityCenterClient.get_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupAssets( @@ -1827,7 +2277,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupAssetsResponse: r"""Call the group assets method over HTTP. @@ -1838,8 +2288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupAssetsResponse: @@ -1851,6 +2303,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupAssets._get_http_options() ) + request, metadata = self._interceptor.pre_group_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupAssets._get_transcoded_request( http_options, request @@ -1865,6 +2318,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.GroupAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GroupAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupAssets._get_response( self._host, @@ -1886,7 +2366,31 @@ def __call__( pb_resp = securitycenter_service.GroupAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupAssetsResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.group_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GroupAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupFindings( @@ -1924,7 +2428,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupFindingsResponse: r"""Call the group findings method over HTTP. @@ -1935,8 +2439,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupFindingsResponse: @@ -1948,6 +2454,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupFindings._get_http_options() ) + request, metadata = self._interceptor.pre_group_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupFindings._get_transcoded_request( http_options, request @@ -1962,6 +2469,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.GroupFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GroupFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupFindings._get_response( self._host, @@ -1983,7 +2517,31 @@ def __call__( pb_resp = securitycenter_service.GroupFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupFindingsResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.group_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "GroupFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -2020,7 +2578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2030,8 +2588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListAssetsResponse: @@ -2041,6 +2601,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListAssets._get_transcoded_request( http_options, request @@ -2053,6 +2614,33 @@ def __call__( ) ) + 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.securitycenter_v1p1beta1.SecurityCenterClient.ListAssets", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListAssets._get_response( self._host, @@ -2073,7 +2661,31 @@ def __call__( pb_resp = securitycenter_service.ListAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListAssetsResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.list_assets", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -2110,7 +2722,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -2120,8 +2732,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListFindingsResponse: @@ -2133,6 +2747,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -2143,6 +2758,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.ListFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListFindings._get_response( self._host, @@ -2163,7 +2805,31 @@ def __call__( pb_resp = securitycenter_service.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListFindingsResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.list_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNotificationConfigs( @@ -2201,7 +2867,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListNotificationConfigsResponse: r"""Call the list notification configs method over HTTP. @@ -2212,8 +2878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListNotificationConfigsResponse: @@ -2225,6 +2893,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListNotificationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_notification_configs( request, metadata ) @@ -2237,6 +2906,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.ListNotificationConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._ListNotificationConfigs._get_response( @@ -2259,7 +2955,33 @@ def __call__( pb_resp = securitycenter_service.ListNotificationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_notification_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListNotificationConfigsResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.list_notification_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -2296,7 +3018,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -2306,8 +3028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListSourcesResponse: @@ -2317,6 +3041,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListSources._get_transcoded_request( http_options, request @@ -2327,6 +3052,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.ListSources", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListSources._get_response( self._host, @@ -2347,7 +3099,31 @@ def __call__( pb_resp = securitycenter_service.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListSourcesResponse.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.securitycenter_v1p1beta1.SecurityCenterClient.list_sources", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunAssetDiscovery( @@ -2385,7 +3161,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run asset discovery method over HTTP. @@ -2396,8 +3172,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2410,6 +3188,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseRunAssetDiscovery._get_http_options() ) + request, metadata = self._interceptor.pre_run_asset_discovery( request, metadata ) @@ -2426,6 +3205,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.RunAssetDiscovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._RunAssetDiscovery._get_response( self._host, @@ -2445,7 +3251,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_asset_discovery(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.securitycenter_v1p1beta1.SecurityCenterClient.run_asset_discovery", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "RunAssetDiscovery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetFindingState( @@ -2483,7 +3311,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set finding state method over HTTP. @@ -2494,8 +3322,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -2515,6 +3345,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetFindingState._get_http_options() ) + request, metadata = self._interceptor.pre_set_finding_state( request, metadata ) @@ -2531,6 +3362,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.SetFindingState", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "SetFindingState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetFindingState._get_response( self._host, @@ -2552,7 +3410,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_finding_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v1p1beta1.SecurityCenterClient.set_finding_state", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "SetFindingState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2590,7 +3470,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2600,8 +3480,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2686,6 +3568,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2700,6 +3583,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetIamPolicy._get_response( self._host, @@ -2721,7 +3631,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.securitycenter_v1p1beta1.SecurityCenterClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2759,7 +3691,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2769,8 +3701,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2780,6 +3714,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2796,6 +3731,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._TestIamPermissions._get_response( self._host, @@ -2817,7 +3779,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.securitycenter_v1p1beta1.SecurityCenterClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFinding( @@ -2855,7 +3839,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the update finding method over HTTP. @@ -2866,8 +3850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -2887,6 +3873,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_update_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_transcoded_request( http_options, request @@ -2901,6 +3888,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.UpdateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateFinding._get_response( self._host, @@ -2922,7 +3936,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v1p1beta1.SecurityCenterClient.update_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNotificationConfig( @@ -2961,7 +3997,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the update notification config method over HTTP. @@ -2973,8 +4009,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -2991,6 +4029,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_notification_config( request, metadata ) @@ -3007,6 +4046,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.UpdateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateNotificationConfig._get_response( @@ -3030,7 +4096,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v1p1beta1.SecurityCenterClient.update_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOrganizationSettings( @@ -3069,7 +4159,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_organization_settings.OrganizationSettings: r"""Call the update organization settings method over HTTP. @@ -3081,8 +4171,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_organization_settings.OrganizationSettings: @@ -3095,6 +4187,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateOrganizationSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_organization_settings( request, metadata ) @@ -3111,6 +4204,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.UpdateOrganizationSettings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateOrganizationSettings._get_response( @@ -3134,7 +4254,31 @@ def __call__( pb_resp = gcs_organization_settings.OrganizationSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_organization_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_organization_settings.OrganizationSettings.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.securitycenter_v1p1beta1.SecurityCenterClient.update_organization_settings", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateOrganizationSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityMarks( @@ -3173,7 +4317,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Call the update security marks method over HTTP. @@ -3184,8 +4328,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_marks.SecurityMarks: @@ -3203,6 +4349,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSecurityMarks._get_http_options() ) + request, metadata = self._interceptor.pre_update_security_marks( request, metadata ) @@ -3219,6 +4366,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.UpdateSecurityMarks", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSecurityMarks._get_response( self._host, @@ -3240,7 +4414,31 @@ def __call__( pb_resp = gcs_security_marks.SecurityMarks.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_marks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_marks.SecurityMarks.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.securitycenter_v1p1beta1.SecurityCenterClient.update_security_marks", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -3278,7 +4476,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the update source method over HTTP. @@ -3289,8 +4487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -3306,6 +4506,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateSource._get_transcoded_request( http_options, request @@ -3320,6 +4521,33 @@ def __call__( 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.securitycenter_v1p1beta1.SecurityCenterClient.UpdateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSource._get_response( self._host, @@ -3341,7 +4569,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v1p1beta1.SecurityCenterClient.update_source", + extra={ + "serviceName": "google.cloud.securitycenter.v1p1beta1.SecurityCenter", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/gapic_version.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/gapic_version.py index 56614055fa74..558c8aab67c5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/gapic_version.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.35.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/async_client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/async_client.py index e3253c3006a7..1b47ed36d4c8 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/async_client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -113,6 +114,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .transports.grpc_asyncio import SecurityCenterGrpcAsyncIOTransport +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 SecurityCenterAsyncClient: """V2 APIs for Security Center service.""" @@ -364,6 +374,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securitycenter_v2.SecurityCenterAsyncClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "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.securitycenter.v2.SecurityCenter", + "credentialsType": None, + }, + ) + async def batch_create_resource_value_configs( self, request: Optional[ @@ -376,7 +408,7 @@ async def batch_create_resource_value_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Creates a ResourceValueConfig for an organization. Maps user's tags to difference resource values for use @@ -437,8 +469,10 @@ async def sample_batch_create_resource_value_configs(): 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, 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: google.cloud.securitycenter_v2.types.BatchCreateResourceValueConfigsResponse: @@ -507,7 +541,7 @@ async def bulk_mute_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Kicks off an LRO to bulk mute findings for a parent based on a filter. If no location is specified, findings @@ -576,8 +610,10 @@ async def sample_bulk_mute_findings(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -654,7 +690,7 @@ async def create_big_query_export( big_query_export_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Creates a BigQuery export. @@ -721,8 +757,10 @@ async def sample_create_big_query_export(): 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, 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -791,7 +829,7 @@ async def create_finding( finding_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding in a location. The corresponding source must exist for finding creation to succeed. @@ -858,8 +896,10 @@ async def sample_create_finding(): 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, 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: google.cloud.securitycenter_v2.types.Finding: @@ -936,7 +976,7 @@ async def create_mute_config( mute_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Creates a mute config. @@ -1008,8 +1048,10 @@ async def sample_create_mute_config(): 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, 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -1103,7 +1145,7 @@ async def create_notification_config( config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -1171,8 +1213,10 @@ async def sample_create_notification_config(): 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, 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -1246,7 +1290,7 @@ async def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -1298,8 +1342,10 @@ async def sample_create_source(): 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, 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: google.cloud.securitycenter_v2.types.Source: @@ -1368,7 +1414,7 @@ async def delete_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing BigQuery export. @@ -1416,8 +1462,10 @@ async def sample_delete_big_query_export(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1471,7 +1519,7 @@ async def delete_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing mute config. If no location is specified, default is global. @@ -1524,8 +1572,10 @@ async def sample_delete_mute_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1601,7 +1651,7 @@ async def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -1650,8 +1700,10 @@ async def sample_delete_notification_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1707,7 +1759,7 @@ async def delete_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ResourceValueConfig. @@ -1748,8 +1800,10 @@ async def sample_delete_resource_value_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1805,7 +1859,7 @@ async def get_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Gets a BigQuery export. @@ -1856,8 +1910,10 @@ async def sample_get_big_query_export(): 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, 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -1920,7 +1976,7 @@ async def get_simulation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Get the simulation by name or the latest simulation for the given organization. @@ -1972,8 +2028,10 @@ async def sample_get_simulation(): 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, 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: google.cloud.securitycenter_v2.types.Simulation: @@ -2034,7 +2092,7 @@ async def get_valued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Get the valued resource by name @@ -2080,8 +2138,10 @@ async def sample_get_valued_resource(): 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, 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: google.cloud.securitycenter_v2.types.ValuedResource: @@ -2142,7 +2202,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -2189,8 +2249,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2278,7 +2340,7 @@ async def get_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Gets a mute config. If no location is specified, default is global. @@ -2334,8 +2396,10 @@ async def sample_get_mute_config(): 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, 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -2421,7 +2485,7 @@ async def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -2473,8 +2537,10 @@ async def sample_get_notification_config(): 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, 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -2541,7 +2607,7 @@ async def get_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Gets a ResourceValueConfig. @@ -2586,8 +2652,10 @@ async def sample_get_resource_value_config(): 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, 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: google.cloud.securitycenter_v2.types.ResourceValueConfig: @@ -2652,7 +2720,7 @@ async def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -2696,8 +2764,10 @@ async def sample_get_source(): 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, 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: google.cloud.securitycenter_v2.types.Source: @@ -2765,7 +2835,7 @@ async def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsAsyncPager: r"""Filters an organization or source's findings and groups them by their specified properties in a location. If no location is @@ -2856,8 +2926,10 @@ async def sample_group_findings(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.GroupFindingsAsyncPager: @@ -2936,7 +3008,7 @@ async def list_attack_paths( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttackPathsAsyncPager: r"""Lists the attack paths for a set of simulation results or valued resources and filter. @@ -2987,8 +3059,10 @@ async def sample_list_attack_paths(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListAttackPathsAsyncPager: @@ -3067,7 +3141,7 @@ async def list_big_query_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryExportsAsyncPager: r"""Lists BigQuery exports. Note that when requesting BigQuery exports at a given level all exports under that @@ -3121,8 +3195,10 @@ async def sample_list_big_query_exports(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListBigQueryExportsAsyncPager: @@ -3199,7 +3275,7 @@ async def list_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsAsyncPager: r"""Lists an organization or source's findings. @@ -3273,8 +3349,10 @@ async def sample_list_findings(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListFindingsAsyncPager: @@ -3351,7 +3429,7 @@ async def list_mute_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMuteConfigsAsyncPager: r"""Lists mute configs. If no location is specified, default is global. @@ -3405,8 +3483,10 @@ async def sample_list_mute_configs(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListMuteConfigsAsyncPager: @@ -3505,7 +3585,7 @@ async def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsAsyncPager: r"""Lists notification configs. @@ -3553,8 +3633,10 @@ async def sample_list_notification_configs(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListNotificationConfigsAsyncPager: @@ -3633,7 +3715,7 @@ async def list_resource_value_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListResourceValueConfigsAsyncPager: r"""Lists all ResourceValueConfigs. @@ -3679,8 +3761,10 @@ async def sample_list_resource_value_configs(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListResourceValueConfigsAsyncPager: @@ -3759,7 +3843,7 @@ async def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesAsyncPager: r"""Lists all sources belonging to an organization. @@ -3805,8 +3889,10 @@ async def sample_list_sources(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListSourcesAsyncPager: @@ -3883,7 +3969,7 @@ async def list_valued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListValuedResourcesAsyncPager: r"""Lists the valued resources for a set of simulation results and filter. @@ -3932,8 +4018,10 @@ async def sample_list_valued_resources(): 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, 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListValuedResourcesAsyncPager: @@ -4011,7 +4099,7 @@ async def set_finding_state( state: Optional[finding.Finding.State] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. If no location is specified, finding is assumed to be in global @@ -4083,8 +4171,10 @@ async def sample_set_finding_state(): 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, 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: google.cloud.securitycenter_v2.types.Finding: @@ -4155,7 +4245,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -4202,8 +4292,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -4290,7 +4382,7 @@ async def set_mute( mute: Optional[finding.Finding.Mute] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the mute state of a finding. If no location is specified, finding is assumed to be in global @@ -4362,8 +4454,10 @@ async def sample_set_mute(): 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, 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: google.cloud.securitycenter_v2.types.Finding: @@ -4433,7 +4527,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -4490,8 +4584,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -4552,7 +4648,7 @@ async def update_big_query_export( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Updates a BigQuery export. @@ -4603,8 +4699,10 @@ async def sample_update_big_query_export(): 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, 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -4672,7 +4770,7 @@ async def update_external_system( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Updates external system. This is for a given finding. If no location is specified, finding is assumed to be in @@ -4726,8 +4824,10 @@ async def sample_update_external_system(): 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, 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: google.cloud.securitycenter_v2.types.ExternalSystem: @@ -4795,7 +4895,7 @@ async def update_finding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. If no location is specified, finding is assumed to be in global. The @@ -4860,8 +4960,10 @@ async def sample_update_finding(): 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, 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: google.cloud.securitycenter_v2.types.Finding: @@ -4937,7 +5039,7 @@ async def update_mute_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Updates a mute config. If no location is specified, default is global. @@ -4994,8 +5096,10 @@ async def sample_update_mute_config(): 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, 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -5086,7 +5190,7 @@ async def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -5139,8 +5243,10 @@ async def sample_update_notification_config(): 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, 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -5216,7 +5322,7 @@ async def update_resource_value_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Updates an existing ResourceValueConfigs with new rules. @@ -5272,8 +5378,10 @@ async def sample_update_resource_value_config(): 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, 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: google.cloud.securitycenter_v2.types.ResourceValueConfig: @@ -5345,7 +5453,7 @@ async def update_security_marks( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. For Finding Security marks, if no location is specified, finding is assumed to be in @@ -5403,8 +5511,10 @@ async def sample_update_security_marks(): 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, 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: google.cloud.securitycenter_v2.types.SecurityMarks: @@ -5478,7 +5588,7 @@ async def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -5530,8 +5640,10 @@ async def sample_update_source(): 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, 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: google.cloud.securitycenter_v2.types.Source: @@ -5599,7 +5711,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5610,8 +5722,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -5652,7 +5766,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -5663,8 +5777,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5705,7 +5821,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -5721,8 +5837,10 @@ async def delete_operation( 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, 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: None """ @@ -5759,7 +5877,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -5774,8 +5892,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/client.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/client.py index 52f24179fb3c..dbb08c720ab5 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/client.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -930,6 +940,10 @@ def __init__( # 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( @@ -995,6 +1009,29 @@ def __init__( 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.securitycenter_v2.SecurityCenterClient`.", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "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.securitycenter.v2.SecurityCenter", + "credentialsType": None, + }, + ) + def batch_create_resource_value_configs( self, request: Optional[ @@ -1007,7 +1044,7 @@ def batch_create_resource_value_configs( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Creates a ResourceValueConfig for an organization. Maps user's tags to difference resource values for use @@ -1068,8 +1105,10 @@ def sample_batch_create_resource_value_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.BatchCreateResourceValueConfigsResponse: @@ -1137,7 +1176,7 @@ def bulk_mute_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Kicks off an LRO to bulk mute findings for a parent based on a filter. If no location is specified, findings @@ -1206,8 +1245,10 @@ def sample_bulk_mute_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1281,7 +1322,7 @@ def create_big_query_export( big_query_export_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Creates a BigQuery export. @@ -1348,8 +1389,10 @@ def sample_create_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -1415,7 +1458,7 @@ def create_finding( finding_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates a finding in a location. The corresponding source must exist for finding creation to succeed. @@ -1482,8 +1525,10 @@ def sample_create_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Finding: @@ -1557,7 +1602,7 @@ def create_mute_config( mute_config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Creates a mute config. @@ -1629,8 +1674,10 @@ def sample_create_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -1721,7 +1768,7 @@ def create_notification_config( config_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Creates a notification config. @@ -1789,8 +1836,10 @@ def sample_create_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -1863,7 +1912,7 @@ def create_source( source: Optional[gcs_source.Source] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Creates a source. @@ -1915,8 +1964,10 @@ def sample_create_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Source: @@ -1982,7 +2033,7 @@ def delete_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing BigQuery export. @@ -2030,8 +2081,10 @@ def sample_delete_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2082,7 +2135,7 @@ def delete_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing mute config. If no location is specified, default is global. @@ -2135,8 +2188,10 @@ def sample_delete_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2209,7 +2264,7 @@ def delete_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a notification config. @@ -2258,8 +2313,10 @@ def sample_delete_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2314,7 +2371,7 @@ def delete_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ResourceValueConfig. @@ -2355,8 +2412,10 @@ def sample_delete_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2411,7 +2470,7 @@ def get_big_query_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Gets a BigQuery export. @@ -2462,8 +2521,10 @@ def sample_get_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -2523,7 +2584,7 @@ def get_simulation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Get the simulation by name or the latest simulation for the given organization. @@ -2575,8 +2636,10 @@ def sample_get_simulation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Simulation: @@ -2634,7 +2697,7 @@ def get_valued_resource( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Get the valued resource by name @@ -2680,8 +2743,10 @@ def sample_get_valued_resource(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.ValuedResource: @@ -2739,7 +2804,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy on the specified Source. @@ -2786,8 +2851,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2876,7 +2943,7 @@ def get_mute_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Gets a mute config. If no location is specified, default is global. @@ -2932,8 +2999,10 @@ def sample_get_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -3016,7 +3085,7 @@ def get_notification_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Gets a notification config. @@ -3068,8 +3137,10 @@ def sample_get_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -3133,7 +3204,7 @@ def get_resource_value_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Gets a ResourceValueConfig. @@ -3178,8 +3249,10 @@ def sample_get_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.ResourceValueConfig: @@ -3243,7 +3316,7 @@ def get_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Gets a source. @@ -3287,8 +3360,10 @@ def sample_get_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Source: @@ -3353,7 +3428,7 @@ def group_findings( group_by: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.GroupFindingsPager: r"""Filters an organization or source's findings and groups them by their specified properties in a location. If no location is @@ -3444,8 +3519,10 @@ def sample_group_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.GroupFindingsPager: @@ -3521,7 +3598,7 @@ def list_attack_paths( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttackPathsPager: r"""Lists the attack paths for a set of simulation results or valued resources and filter. @@ -3572,8 +3649,10 @@ def sample_list_attack_paths(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListAttackPathsPager: @@ -3649,7 +3728,7 @@ def list_big_query_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryExportsPager: r"""Lists BigQuery exports. Note that when requesting BigQuery exports at a given level all exports under that @@ -3703,8 +3782,10 @@ def sample_list_big_query_exports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListBigQueryExportsPager: @@ -3778,7 +3859,7 @@ def list_findings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFindingsPager: r"""Lists an organization or source's findings. @@ -3852,8 +3933,10 @@ def sample_list_findings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListFindingsPager: @@ -3927,7 +4010,7 @@ def list_mute_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMuteConfigsPager: r"""Lists mute configs. If no location is specified, default is global. @@ -3981,8 +4064,10 @@ def sample_list_mute_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListMuteConfigsPager: @@ -4078,7 +4163,7 @@ def list_notification_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationConfigsPager: r"""Lists notification configs. @@ -4126,8 +4211,10 @@ def sample_list_notification_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListNotificationConfigsPager: @@ -4205,7 +4292,7 @@ def list_resource_value_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListResourceValueConfigsPager: r"""Lists all ResourceValueConfigs. @@ -4251,8 +4338,10 @@ def sample_list_resource_value_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListResourceValueConfigsPager: @@ -4330,7 +4419,7 @@ def list_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSourcesPager: r"""Lists all sources belonging to an organization. @@ -4376,8 +4465,10 @@ def sample_list_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListSourcesPager: @@ -4451,7 +4542,7 @@ def list_valued_resources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListValuedResourcesPager: r"""Lists the valued resources for a set of simulation results and filter. @@ -4500,8 +4591,10 @@ def sample_list_valued_resources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.services.security_center.pagers.ListValuedResourcesPager: @@ -4576,7 +4669,7 @@ def set_finding_state( state: Optional[finding.Finding.State] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the state of a finding. If no location is specified, finding is assumed to be in global @@ -4648,8 +4741,10 @@ def sample_set_finding_state(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Finding: @@ -4717,7 +4812,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified Source. @@ -4764,8 +4859,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -4853,7 +4950,7 @@ def set_mute( mute: Optional[finding.Finding.Mute] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Updates the mute state of a finding. If no location is specified, finding is assumed to be in global @@ -4925,8 +5022,10 @@ def sample_set_mute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Finding: @@ -4995,7 +5094,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified source. @@ -5052,8 +5151,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -5115,7 +5216,7 @@ def update_big_query_export( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Updates a BigQuery export. @@ -5166,8 +5267,10 @@ def sample_update_big_query_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.BigQueryExport: @@ -5232,7 +5335,7 @@ def update_external_system( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Updates external system. This is for a given finding. If no location is specified, finding is assumed to be in @@ -5286,8 +5389,10 @@ def sample_update_external_system(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.ExternalSystem: @@ -5352,7 +5457,7 @@ def update_finding( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Creates or updates a finding. If no location is specified, finding is assumed to be in global. The @@ -5417,8 +5522,10 @@ def sample_update_finding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Finding: @@ -5491,7 +5598,7 @@ def update_mute_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Updates a mute config. If no location is specified, default is global. @@ -5548,8 +5655,10 @@ def sample_update_mute_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.MuteConfig: @@ -5637,7 +5746,7 @@ def update_notification_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Updates a notification config. The following update fields are allowed: description, pubsub_topic, streaming_config.filter @@ -5690,8 +5799,10 @@ def sample_update_notification_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.NotificationConfig: @@ -5766,7 +5877,7 @@ def update_resource_value_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Updates an existing ResourceValueConfigs with new rules. @@ -5822,8 +5933,10 @@ def sample_update_resource_value_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.ResourceValueConfig: @@ -5894,7 +6007,7 @@ def update_security_marks( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Updates security marks. For Finding Security marks, if no location is specified, finding is assumed to be in @@ -5952,8 +6065,10 @@ def sample_update_security_marks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.SecurityMarks: @@ -6024,7 +6139,7 @@ def update_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Updates a source. @@ -6076,8 +6191,10 @@ def sample_update_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycenter_v2.types.Source: @@ -6155,7 +6272,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -6166,8 +6283,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -6208,7 +6327,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -6219,8 +6338,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -6261,7 +6382,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -6277,8 +6398,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -6315,7 +6438,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -6330,8 +6453,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/pagers.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/pagers.py index 15dcc04913f7..44f92afbb453 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/pagers.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/pagers.py @@ -76,7 +76,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -90,8 +90,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -150,7 +152,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -164,8 +166,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.GroupFindingsRequest(request) @@ -230,7 +234,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -244,8 +248,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListAttackPathsRequest(request) @@ -306,7 +312,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -320,8 +326,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListAttackPathsRequest(request) @@ -386,7 +394,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -400,8 +408,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListBigQueryExportsRequest(request) @@ -462,7 +472,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -476,8 +486,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListBigQueryExportsRequest(request) @@ -542,7 +554,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -556,8 +568,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -618,7 +632,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -632,8 +646,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListFindingsRequest(request) @@ -698,7 +714,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -712,8 +728,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListMuteConfigsRequest(request) @@ -774,7 +792,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -788,8 +806,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListMuteConfigsRequest(request) @@ -854,7 +874,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -868,8 +888,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -930,7 +952,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -944,8 +966,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListNotificationConfigsRequest(request) @@ -1010,7 +1034,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1024,8 +1048,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListResourceValueConfigsRequest(request) @@ -1088,7 +1114,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1102,8 +1128,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListResourceValueConfigsRequest(request) @@ -1168,7 +1196,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1182,8 +1210,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -1242,7 +1272,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1256,8 +1286,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListSourcesRequest(request) @@ -1320,7 +1352,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1334,8 +1366,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = securitycenter_service.ListValuedResourcesRequest(request) @@ -1396,7 +1430,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1410,8 +1444,10 @@ def __init__( 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, 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`. """ self._method = method self._request = securitycenter_service.ListValuedResourcesRequest(request) diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc.py index af286019b53a..09fceaa4eda4 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v2.types import securitycenter_service, simulation from google.cloud.securitycenter_v2.types import external_system as gcs_external_system @@ -48,6 +54,81 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport +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.securitycenter.v2.SecurityCenter", + "rpcName": 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.securitycenter.v2.SecurityCenter", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcTransport(SecurityCenterTransport): """gRPC backend transport for SecurityCenter. @@ -202,7 +283,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -298,7 +386,7 @@ def batch_create_resource_value_configs( if "batch_create_resource_value_configs" not in self._stubs: self._stubs[ "batch_create_resource_value_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/BatchCreateResourceValueConfigs", request_serializer=securitycenter_service.BatchCreateResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.BatchCreateResourceValueConfigsResponse.deserialize, @@ -330,7 +418,7 @@ def bulk_mute_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "bulk_mute_findings" not in self._stubs: - self._stubs["bulk_mute_findings"] = self.grpc_channel.unary_unary( + self._stubs["bulk_mute_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/BulkMuteFindings", request_serializer=securitycenter_service.BulkMuteFindingsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -359,7 +447,7 @@ def create_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_export" not in self._stubs: - self._stubs["create_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateBigQueryExport", request_serializer=securitycenter_service.CreateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -386,7 +474,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -414,7 +502,7 @@ def create_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_mute_config" not in self._stubs: - self._stubs["create_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["create_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateMuteConfig", request_serializer=securitycenter_service.CreateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -443,7 +531,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -469,7 +559,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -497,7 +587,7 @@ def delete_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_export" not in self._stubs: - self._stubs["delete_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteBigQueryExport", request_serializer=securitycenter_service.DeleteBigQueryExportRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -524,7 +614,7 @@ def delete_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_mute_config" not in self._stubs: - self._stubs["delete_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteMuteConfig", request_serializer=securitycenter_service.DeleteMuteConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -552,7 +642,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -580,7 +672,9 @@ def delete_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_value_config" not in self._stubs: - self._stubs["delete_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteResourceValueConfig", request_serializer=securitycenter_service.DeleteResourceValueConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -609,7 +703,7 @@ def get_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_export" not in self._stubs: - self._stubs["get_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetBigQueryExport", request_serializer=securitycenter_service.GetBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -636,7 +730,7 @@ def get_simulation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_simulation" not in self._stubs: - self._stubs["get_simulation"] = self.grpc_channel.unary_unary( + self._stubs["get_simulation"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetSimulation", request_serializer=securitycenter_service.GetSimulationRequest.serialize, response_deserializer=simulation.Simulation.deserialize, @@ -665,7 +759,7 @@ def get_valued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_valued_resource" not in self._stubs: - self._stubs["get_valued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_valued_resource"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetValuedResource", request_serializer=securitycenter_service.GetValuedResourceRequest.serialize, response_deserializer=valued_resource.ValuedResource.deserialize, @@ -692,7 +786,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -721,7 +815,7 @@ def get_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_mute_config" not in self._stubs: - self._stubs["get_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["get_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetMuteConfig", request_serializer=securitycenter_service.GetMuteConfigRequest.serialize, response_deserializer=mute_config.MuteConfig.deserialize, @@ -750,7 +844,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -779,7 +873,7 @@ def get_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_value_config" not in self._stubs: - self._stubs["get_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_value_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetResourceValueConfig", request_serializer=securitycenter_service.GetResourceValueConfigRequest.serialize, response_deserializer=resource_value_config.ResourceValueConfig.deserialize, @@ -805,7 +899,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -849,7 +943,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -879,7 +973,7 @@ def list_attack_paths( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attack_paths" not in self._stubs: - self._stubs["list_attack_paths"] = self.grpc_channel.unary_unary( + self._stubs["list_attack_paths"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListAttackPaths", request_serializer=securitycenter_service.ListAttackPathsRequest.serialize, response_deserializer=securitycenter_service.ListAttackPathsResponse.deserialize, @@ -913,7 +1007,7 @@ def list_big_query_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_exports" not in self._stubs: - self._stubs["list_big_query_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_exports"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListBigQueryExports", request_serializer=securitycenter_service.ListBigQueryExportsRequest.serialize, response_deserializer=securitycenter_service.ListBigQueryExportsResponse.deserialize, @@ -951,7 +1045,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -981,7 +1075,7 @@ def list_mute_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_mute_configs" not in self._stubs: - self._stubs["list_mute_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_mute_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListMuteConfigs", request_serializer=securitycenter_service.ListMuteConfigsRequest.serialize, response_deserializer=securitycenter_service.ListMuteConfigsResponse.deserialize, @@ -1010,7 +1104,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -1039,7 +1133,9 @@ def list_resource_value_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_value_configs" not in self._stubs: - self._stubs["list_resource_value_configs"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_resource_value_configs" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListResourceValueConfigs", request_serializer=securitycenter_service.ListResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.ListResourceValueConfigsResponse.deserialize, @@ -1068,7 +1164,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -1098,7 +1194,7 @@ def list_valued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_valued_resources" not in self._stubs: - self._stubs["list_valued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_valued_resources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListValuedResources", request_serializer=securitycenter_service.ListValuedResourcesRequest.serialize, response_deserializer=securitycenter_service.ListValuedResourcesResponse.deserialize, @@ -1125,7 +1221,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1152,7 +1248,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1179,7 +1275,7 @@ def set_mute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_mute" not in self._stubs: - self._stubs["set_mute"] = self.grpc_channel.unary_unary( + self._stubs["set_mute"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetMute", request_serializer=securitycenter_service.SetMuteRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1209,7 +1305,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1238,7 +1334,7 @@ def update_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_export" not in self._stubs: - self._stubs["update_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateBigQueryExport", request_serializer=securitycenter_service.UpdateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1269,7 +1365,7 @@ def update_external_system( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_system" not in self._stubs: - self._stubs["update_external_system"] = self.grpc_channel.unary_unary( + self._stubs["update_external_system"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateExternalSystem", request_serializer=securitycenter_service.UpdateExternalSystemRequest.serialize, response_deserializer=gcs_external_system.ExternalSystem.deserialize, @@ -1298,7 +1394,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -1327,7 +1423,7 @@ def update_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_mute_config" not in self._stubs: - self._stubs["update_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["update_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateMuteConfig", request_serializer=securitycenter_service.UpdateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -1357,7 +1453,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -1387,7 +1485,9 @@ def update_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_value_config" not in self._stubs: - self._stubs["update_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateResourceValueConfig", request_serializer=securitycenter_service.UpdateResourceValueConfigRequest.serialize, response_deserializer=gcs_resource_value_config.ResourceValueConfig.deserialize, @@ -1419,7 +1519,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -1445,7 +1545,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -1453,7 +1553,7 @@ def update_source( return self._stubs["update_source"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1465,7 +1565,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1482,7 +1582,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1499,7 +1599,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1518,7 +1618,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc_asyncio.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc_asyncio.py index 0d497030c54c..1a19d1596f40 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securitycenter_v2.types import securitycenter_service, simulation from google.cloud.securitycenter_v2.types import external_system as gcs_external_system @@ -52,6 +58,82 @@ from .base import DEFAULT_CLIENT_INFO, SecurityCenterTransport from .grpc import SecurityCenterGrpcTransport +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.securitycenter.v2.SecurityCenter", + "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.securitycenter.v2.SecurityCenter", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterGrpcAsyncIOTransport(SecurityCenterTransport): """gRPC AsyncIO backend transport for SecurityCenter. @@ -249,10 +331,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -275,7 +360,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -308,7 +393,7 @@ def batch_create_resource_value_configs( if "batch_create_resource_value_configs" not in self._stubs: self._stubs[ "batch_create_resource_value_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/BatchCreateResourceValueConfigs", request_serializer=securitycenter_service.BatchCreateResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.BatchCreateResourceValueConfigsResponse.deserialize, @@ -341,7 +426,7 @@ def bulk_mute_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "bulk_mute_findings" not in self._stubs: - self._stubs["bulk_mute_findings"] = self.grpc_channel.unary_unary( + self._stubs["bulk_mute_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/BulkMuteFindings", request_serializer=securitycenter_service.BulkMuteFindingsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -370,7 +455,7 @@ def create_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_export" not in self._stubs: - self._stubs["create_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateBigQueryExport", request_serializer=securitycenter_service.CreateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -399,7 +484,7 @@ def create_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_finding" not in self._stubs: - self._stubs["create_finding"] = self.grpc_channel.unary_unary( + self._stubs["create_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateFinding", request_serializer=securitycenter_service.CreateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -428,7 +513,7 @@ def create_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_mute_config" not in self._stubs: - self._stubs["create_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["create_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateMuteConfig", request_serializer=securitycenter_service.CreateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -457,7 +542,9 @@ def create_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_notification_config" not in self._stubs: - self._stubs["create_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateNotificationConfig", request_serializer=securitycenter_service.CreateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -485,7 +572,7 @@ def create_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_source" not in self._stubs: - self._stubs["create_source"] = self.grpc_channel.unary_unary( + self._stubs["create_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/CreateSource", request_serializer=securitycenter_service.CreateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -513,7 +600,7 @@ def delete_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_export" not in self._stubs: - self._stubs["delete_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteBigQueryExport", request_serializer=securitycenter_service.DeleteBigQueryExportRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -542,7 +629,7 @@ def delete_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_mute_config" not in self._stubs: - self._stubs["delete_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteMuteConfig", request_serializer=securitycenter_service.DeleteMuteConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -571,7 +658,9 @@ def delete_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_notification_config" not in self._stubs: - self._stubs["delete_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteNotificationConfig", request_serializer=securitycenter_service.DeleteNotificationConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -600,7 +689,9 @@ def delete_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_value_config" not in self._stubs: - self._stubs["delete_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/DeleteResourceValueConfig", request_serializer=securitycenter_service.DeleteResourceValueConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -629,7 +720,7 @@ def get_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_export" not in self._stubs: - self._stubs["get_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetBigQueryExport", request_serializer=securitycenter_service.GetBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -658,7 +749,7 @@ def get_simulation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_simulation" not in self._stubs: - self._stubs["get_simulation"] = self.grpc_channel.unary_unary( + self._stubs["get_simulation"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetSimulation", request_serializer=securitycenter_service.GetSimulationRequest.serialize, response_deserializer=simulation.Simulation.deserialize, @@ -687,7 +778,7 @@ def get_valued_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_valued_resource" not in self._stubs: - self._stubs["get_valued_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_valued_resource"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetValuedResource", request_serializer=securitycenter_service.GetValuedResourceRequest.serialize, response_deserializer=valued_resource.ValuedResource.deserialize, @@ -714,7 +805,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -743,7 +834,7 @@ def get_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_mute_config" not in self._stubs: - self._stubs["get_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["get_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetMuteConfig", request_serializer=securitycenter_service.GetMuteConfigRequest.serialize, response_deserializer=mute_config.MuteConfig.deserialize, @@ -772,7 +863,7 @@ def get_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification_config" not in self._stubs: - self._stubs["get_notification_config"] = self.grpc_channel.unary_unary( + self._stubs["get_notification_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetNotificationConfig", request_serializer=securitycenter_service.GetNotificationConfigRequest.serialize, response_deserializer=notification_config.NotificationConfig.deserialize, @@ -801,7 +892,7 @@ def get_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_value_config" not in self._stubs: - self._stubs["get_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_value_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetResourceValueConfig", request_serializer=securitycenter_service.GetResourceValueConfigRequest.serialize, response_deserializer=resource_value_config.ResourceValueConfig.deserialize, @@ -827,7 +918,7 @@ def get_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_source" not in self._stubs: - self._stubs["get_source"] = self.grpc_channel.unary_unary( + self._stubs["get_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GetSource", request_serializer=securitycenter_service.GetSourceRequest.serialize, response_deserializer=source.Source.deserialize, @@ -871,7 +962,7 @@ def group_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "group_findings" not in self._stubs: - self._stubs["group_findings"] = self.grpc_channel.unary_unary( + self._stubs["group_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/GroupFindings", request_serializer=securitycenter_service.GroupFindingsRequest.serialize, response_deserializer=securitycenter_service.GroupFindingsResponse.deserialize, @@ -901,7 +992,7 @@ def list_attack_paths( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attack_paths" not in self._stubs: - self._stubs["list_attack_paths"] = self.grpc_channel.unary_unary( + self._stubs["list_attack_paths"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListAttackPaths", request_serializer=securitycenter_service.ListAttackPathsRequest.serialize, response_deserializer=securitycenter_service.ListAttackPathsResponse.deserialize, @@ -935,7 +1026,7 @@ def list_big_query_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_exports" not in self._stubs: - self._stubs["list_big_query_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_exports"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListBigQueryExports", request_serializer=securitycenter_service.ListBigQueryExportsRequest.serialize, response_deserializer=securitycenter_service.ListBigQueryExportsResponse.deserialize, @@ -973,7 +1064,7 @@ def list_findings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_findings" not in self._stubs: - self._stubs["list_findings"] = self.grpc_channel.unary_unary( + self._stubs["list_findings"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListFindings", request_serializer=securitycenter_service.ListFindingsRequest.serialize, response_deserializer=securitycenter_service.ListFindingsResponse.deserialize, @@ -1003,7 +1094,7 @@ def list_mute_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_mute_configs" not in self._stubs: - self._stubs["list_mute_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_mute_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListMuteConfigs", request_serializer=securitycenter_service.ListMuteConfigsRequest.serialize, response_deserializer=securitycenter_service.ListMuteConfigsResponse.deserialize, @@ -1032,7 +1123,7 @@ def list_notification_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notification_configs" not in self._stubs: - self._stubs["list_notification_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_notification_configs"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListNotificationConfigs", request_serializer=securitycenter_service.ListNotificationConfigsRequest.serialize, response_deserializer=securitycenter_service.ListNotificationConfigsResponse.deserialize, @@ -1061,7 +1152,9 @@ def list_resource_value_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_value_configs" not in self._stubs: - self._stubs["list_resource_value_configs"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_resource_value_configs" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListResourceValueConfigs", request_serializer=securitycenter_service.ListResourceValueConfigsRequest.serialize, response_deserializer=securitycenter_service.ListResourceValueConfigsResponse.deserialize, @@ -1090,7 +1183,7 @@ def list_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sources" not in self._stubs: - self._stubs["list_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_sources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListSources", request_serializer=securitycenter_service.ListSourcesRequest.serialize, response_deserializer=securitycenter_service.ListSourcesResponse.deserialize, @@ -1120,7 +1213,7 @@ def list_valued_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_valued_resources" not in self._stubs: - self._stubs["list_valued_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_valued_resources"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/ListValuedResources", request_serializer=securitycenter_service.ListValuedResourcesRequest.serialize, response_deserializer=securitycenter_service.ListValuedResourcesResponse.deserialize, @@ -1149,7 +1242,7 @@ def set_finding_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_finding_state" not in self._stubs: - self._stubs["set_finding_state"] = self.grpc_channel.unary_unary( + self._stubs["set_finding_state"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetFindingState", request_serializer=securitycenter_service.SetFindingStateRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1176,7 +1269,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1203,7 +1296,7 @@ def set_mute( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_mute" not in self._stubs: - self._stubs["set_mute"] = self.grpc_channel.unary_unary( + self._stubs["set_mute"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/SetMute", request_serializer=securitycenter_service.SetMuteRequest.serialize, response_deserializer=finding.Finding.deserialize, @@ -1233,7 +1326,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1262,7 +1355,7 @@ def update_big_query_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_export" not in self._stubs: - self._stubs["update_big_query_export"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_export"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateBigQueryExport", request_serializer=securitycenter_service.UpdateBigQueryExportRequest.serialize, response_deserializer=bigquery_export.BigQueryExport.deserialize, @@ -1293,7 +1386,7 @@ def update_external_system( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_external_system" not in self._stubs: - self._stubs["update_external_system"] = self.grpc_channel.unary_unary( + self._stubs["update_external_system"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateExternalSystem", request_serializer=securitycenter_service.UpdateExternalSystemRequest.serialize, response_deserializer=gcs_external_system.ExternalSystem.deserialize, @@ -1324,7 +1417,7 @@ def update_finding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_finding" not in self._stubs: - self._stubs["update_finding"] = self.grpc_channel.unary_unary( + self._stubs["update_finding"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateFinding", request_serializer=securitycenter_service.UpdateFindingRequest.serialize, response_deserializer=gcs_finding.Finding.deserialize, @@ -1354,7 +1447,7 @@ def update_mute_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_mute_config" not in self._stubs: - self._stubs["update_mute_config"] = self.grpc_channel.unary_unary( + self._stubs["update_mute_config"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateMuteConfig", request_serializer=securitycenter_service.UpdateMuteConfigRequest.serialize, response_deserializer=gcs_mute_config.MuteConfig.deserialize, @@ -1384,7 +1477,9 @@ def update_notification_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_notification_config" not in self._stubs: - self._stubs["update_notification_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_notification_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateNotificationConfig", request_serializer=securitycenter_service.UpdateNotificationConfigRequest.serialize, response_deserializer=gcs_notification_config.NotificationConfig.deserialize, @@ -1414,7 +1509,9 @@ def update_resource_value_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_value_config" not in self._stubs: - self._stubs["update_resource_value_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_resource_value_config" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateResourceValueConfig", request_serializer=securitycenter_service.UpdateResourceValueConfigRequest.serialize, response_deserializer=gcs_resource_value_config.ResourceValueConfig.deserialize, @@ -1446,7 +1543,7 @@ def update_security_marks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_security_marks" not in self._stubs: - self._stubs["update_security_marks"] = self.grpc_channel.unary_unary( + self._stubs["update_security_marks"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateSecurityMarks", request_serializer=securitycenter_service.UpdateSecurityMarksRequest.serialize, response_deserializer=gcs_security_marks.SecurityMarks.deserialize, @@ -1474,7 +1571,7 @@ def update_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_source" not in self._stubs: - self._stubs["update_source"] = self.grpc_channel.unary_unary( + self._stubs["update_source"] = self._logged_channel.unary_unary( "/google.cloud.securitycenter.v2.SecurityCenter/UpdateSource", request_serializer=securitycenter_service.UpdateSourceRequest.serialize, response_deserializer=gcs_source.Source.deserialize, @@ -1712,7 +1809,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1728,7 +1825,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1745,7 +1842,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1762,7 +1859,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1781,7 +1878,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/rest.py b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/rest.py index dd75418c6be2..6b6f0b18a414 100644 --- a/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/rest.py +++ b/packages/google-cloud-securitycenter/google/cloud/securitycenter_v2/services/security_center/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -59,6 +59,14 @@ 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, @@ -395,10 +403,10 @@ def post_update_source(self, response): def pre_batch_create_resource_value_configs( self, request: securitycenter_service.BatchCreateResourceValueConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.BatchCreateResourceValueConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_create_resource_value_configs @@ -421,9 +429,10 @@ def post_batch_create_resource_value_configs( def pre_bulk_mute_findings( self, request: securitycenter_service.BulkMuteFindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.BulkMuteFindingsRequest, Sequence[Tuple[str, str]] + securitycenter_service.BulkMuteFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for bulk_mute_findings @@ -446,9 +455,10 @@ def post_bulk_mute_findings( def pre_create_big_query_export( self, request: securitycenter_service.CreateBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.CreateBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.CreateBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_big_query_export @@ -471,8 +481,11 @@ def post_create_big_query_export( def pre_create_finding( self, request: securitycenter_service.CreateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_finding Override in a subclass to manipulate the request or metadata @@ -492,9 +505,10 @@ def post_create_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_create_mute_config( self, request: securitycenter_service.CreateMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.CreateMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.CreateMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_mute_config @@ -517,10 +531,10 @@ def post_create_mute_config( def pre_create_notification_config( self, request: securitycenter_service.CreateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.CreateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_notification_config @@ -543,8 +557,11 @@ def post_create_notification_config( def pre_create_source( self, request: securitycenter_service.CreateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.CreateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.CreateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_source Override in a subclass to manipulate the request or metadata @@ -564,9 +581,10 @@ def post_create_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_delete_big_query_export( self, request: securitycenter_service.DeleteBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.DeleteBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.DeleteBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_big_query_export @@ -578,9 +596,10 @@ def pre_delete_big_query_export( def pre_delete_mute_config( self, request: securitycenter_service.DeleteMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.DeleteMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.DeleteMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_mute_config @@ -592,10 +611,10 @@ def pre_delete_mute_config( def pre_delete_notification_config( self, request: securitycenter_service.DeleteNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_notification_config @@ -607,10 +626,10 @@ def pre_delete_notification_config( def pre_delete_resource_value_config( self, request: securitycenter_service.DeleteResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.DeleteResourceValueConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_resource_value_config @@ -622,9 +641,10 @@ def pre_delete_resource_value_config( def pre_get_big_query_export( self, request: securitycenter_service.GetBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_big_query_export @@ -647,8 +667,10 @@ def post_get_big_query_export( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -668,8 +690,11 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_mute_config( self, request: securitycenter_service.GetMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetMuteConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_mute_config Override in a subclass to manipulate the request or metadata @@ -691,9 +716,10 @@ def post_get_mute_config( def pre_get_notification_config( self, request: securitycenter_service.GetNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetNotificationConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetNotificationConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_notification_config @@ -716,9 +742,10 @@ def post_get_notification_config( def pre_get_resource_value_config( self, request: securitycenter_service.GetResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetResourceValueConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetResourceValueConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_resource_value_config @@ -741,8 +768,11 @@ def post_get_resource_value_config( def pre_get_simulation( self, request: securitycenter_service.GetSimulationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSimulationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSimulationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_simulation Override in a subclass to manipulate the request or metadata @@ -764,8 +794,10 @@ def post_get_simulation( def pre_get_source( self, request: securitycenter_service.GetSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GetSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GetSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_source Override in a subclass to manipulate the request or metadata @@ -785,9 +817,10 @@ def post_get_source(self, response: source.Source) -> source.Source: def pre_get_valued_resource( self, request: securitycenter_service.GetValuedResourceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.GetValuedResourceRequest, Sequence[Tuple[str, str]] + securitycenter_service.GetValuedResourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_valued_resource @@ -810,8 +843,11 @@ def post_get_valued_resource( def pre_group_findings( self, request: securitycenter_service.GroupFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.GroupFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.GroupFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for group_findings Override in a subclass to manipulate the request or metadata @@ -833,9 +869,10 @@ def post_group_findings( def pre_list_attack_paths( self, request: securitycenter_service.ListAttackPathsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListAttackPathsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListAttackPathsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_attack_paths @@ -858,9 +895,10 @@ def post_list_attack_paths( def pre_list_big_query_exports( self, request: securitycenter_service.ListBigQueryExportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListBigQueryExportsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListBigQueryExportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_big_query_exports @@ -883,8 +921,11 @@ def post_list_big_query_exports( def pre_list_findings( self, request: securitycenter_service.ListFindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListFindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListFindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_findings Override in a subclass to manipulate the request or metadata @@ -906,9 +947,10 @@ def post_list_findings( def pre_list_mute_configs( self, request: securitycenter_service.ListMuteConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListMuteConfigsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListMuteConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_mute_configs @@ -931,9 +973,10 @@ def post_list_mute_configs( def pre_list_notification_configs( self, request: securitycenter_service.ListNotificationConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListNotificationConfigsRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListNotificationConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_notification_configs @@ -956,10 +999,10 @@ def post_list_notification_configs( def pre_list_resource_value_configs( self, request: securitycenter_service.ListResourceValueConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.ListResourceValueConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_resource_value_configs @@ -982,8 +1025,11 @@ def post_list_resource_value_configs( def pre_list_sources( self, request: securitycenter_service.ListSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.ListSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.ListSourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_sources Override in a subclass to manipulate the request or metadata @@ -1005,9 +1051,10 @@ def post_list_sources( def pre_list_valued_resources( self, request: securitycenter_service.ListValuedResourcesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.ListValuedResourcesRequest, Sequence[Tuple[str, str]] + securitycenter_service.ListValuedResourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_valued_resources @@ -1030,9 +1077,10 @@ def post_list_valued_resources( def pre_set_finding_state( self, request: securitycenter_service.SetFindingStateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.SetFindingStateRequest, Sequence[Tuple[str, str]] + securitycenter_service.SetFindingStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_finding_state @@ -1053,8 +1101,10 @@ def post_set_finding_state(self, response: finding.Finding) -> finding.Finding: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -1074,8 +1124,10 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_mute( self, request: securitycenter_service.SetMuteRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.SetMuteRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.SetMuteRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_mute Override in a subclass to manipulate the request or metadata @@ -1095,8 +1147,11 @@ def post_set_mute(self, response: finding.Finding) -> finding.Finding: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -1118,9 +1173,10 @@ def post_test_iam_permissions( def pre_update_big_query_export( self, request: securitycenter_service.UpdateBigQueryExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateBigQueryExportRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateBigQueryExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_big_query_export @@ -1143,9 +1199,10 @@ def post_update_big_query_export( def pre_update_external_system( self, request: securitycenter_service.UpdateExternalSystemRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateExternalSystemRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateExternalSystemRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_external_system @@ -1168,8 +1225,11 @@ def post_update_external_system( def pre_update_finding( self, request: securitycenter_service.UpdateFindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateFindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateFindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_finding Override in a subclass to manipulate the request or metadata @@ -1189,9 +1249,10 @@ def post_update_finding(self, response: gcs_finding.Finding) -> gcs_finding.Find def pre_update_mute_config( self, request: securitycenter_service.UpdateMuteConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateMuteConfigRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateMuteConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_mute_config @@ -1214,10 +1275,10 @@ def post_update_mute_config( def pre_update_notification_config( self, request: securitycenter_service.UpdateNotificationConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateNotificationConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_notification_config @@ -1240,10 +1301,10 @@ def post_update_notification_config( def pre_update_resource_value_config( self, request: securitycenter_service.UpdateResourceValueConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ securitycenter_service.UpdateResourceValueConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_resource_value_config @@ -1266,9 +1327,10 @@ def post_update_resource_value_config( def pre_update_security_marks( self, request: securitycenter_service.UpdateSecurityMarksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - securitycenter_service.UpdateSecurityMarksRequest, Sequence[Tuple[str, str]] + securitycenter_service.UpdateSecurityMarksRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_marks @@ -1291,8 +1353,11 @@ def post_update_security_marks( def pre_update_source( self, request: securitycenter_service.UpdateSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[securitycenter_service.UpdateSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + securitycenter_service.UpdateSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_source Override in a subclass to manipulate the request or metadata @@ -1312,8 +1377,10 @@ def post_update_source(self, response: gcs_source.Source) -> gcs_source.Source: def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1333,8 +1400,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1354,8 +1423,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1377,8 +1448,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1573,7 +1646,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.BatchCreateResourceValueConfigsResponse: r"""Call the batch create resource value configs method over HTTP. @@ -1585,8 +1658,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.BatchCreateResourceValueConfigsResponse: @@ -1598,6 +1673,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseBatchCreateResourceValueConfigs._get_http_options() ) + ( request, metadata, @@ -1617,6 +1693,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.BatchCreateResourceValueConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "BatchCreateResourceValueConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._BatchCreateResourceValueConfigs._get_response( self._host, @@ -1640,7 +1743,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_resource_value_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = securitycenter_service.BatchCreateResourceValueConfigsResponse.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.securitycenter_v2.SecurityCenterClient.batch_create_resource_value_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "BatchCreateResourceValueConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BulkMuteFindings( @@ -1678,7 +1805,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the bulk mute findings method over HTTP. @@ -1697,8 +1824,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1711,6 +1840,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseBulkMuteFindings._get_http_options() ) + request, metadata = self._interceptor.pre_bulk_mute_findings( request, metadata ) @@ -1727,6 +1857,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.BulkMuteFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "BulkMuteFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._BulkMuteFindings._get_response( self._host, @@ -1746,7 +1903,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_mute_findings(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.securitycenter_v2.SecurityCenterClient.bulk_mute_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "BulkMuteFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBigQueryExport( @@ -1785,7 +1964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the create big query export method over HTTP. @@ -1796,8 +1975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -1809,6 +1990,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_create_big_query_export( request, metadata ) @@ -1825,6 +2007,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CreateBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateBigQueryExport._get_response( self._host, @@ -1846,7 +2055,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v2.SecurityCenterClient.create_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateFinding( @@ -1884,7 +2115,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the create finding method over HTTP. @@ -1895,8 +2126,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -1916,6 +2149,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateFinding._get_transcoded_request( http_options, request @@ -1930,6 +2164,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CreateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateFinding._get_response( self._host, @@ -1951,7 +2212,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v2.SecurityCenterClient.create_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMuteConfig( @@ -1989,7 +2272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Call the create mute config method over HTTP. @@ -2000,8 +2283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_mute_config.MuteConfig: @@ -2014,6 +2299,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_mute_config( request, metadata ) @@ -2030,6 +2316,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CreateMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateMuteConfig._get_response( self._host, @@ -2051,7 +2364,29 @@ def __call__( pb_resp = gcs_mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_mute_config.MuteConfig.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.securitycenter_v2.SecurityCenterClient.create_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNotificationConfig( @@ -2090,7 +2425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the create notification config method over HTTP. @@ -2102,8 +2437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -2119,6 +2456,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_notification_config( request, metadata ) @@ -2135,6 +2473,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CreateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._CreateNotificationConfig._get_response( @@ -2158,7 +2523,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v2.SecurityCenterClient.create_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSource( @@ -2196,7 +2585,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the create source method over HTTP. @@ -2207,8 +2596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -2224,6 +2615,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseCreateSource._get_http_options() ) + request, metadata = self._interceptor.pre_create_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseCreateSource._get_transcoded_request( http_options, request @@ -2238,6 +2630,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CreateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CreateSource._get_response( self._host, @@ -2259,7 +2678,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v2.SecurityCenterClient.create_source", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CreateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBigQueryExport( @@ -2297,7 +2738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete big query export method over HTTP. @@ -2308,13 +2749,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_delete_big_query_export( request, metadata ) @@ -2327,6 +2771,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.DeleteBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "DeleteBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteBigQueryExport._get_response( self._host, @@ -2376,7 +2847,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete mute config method over HTTP. @@ -2388,13 +2859,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_mute_config( request, metadata ) @@ -2407,6 +2881,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.DeleteMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "DeleteMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteMuteConfig._get_response( self._host, @@ -2457,7 +2958,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete notification config method over HTTP. @@ -2469,13 +2970,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_notification_config( request, metadata ) @@ -2488,6 +2992,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.DeleteNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "DeleteNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._DeleteNotificationConfig._get_response( @@ -2540,7 +3071,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete resource value config method over HTTP. @@ -2552,13 +3083,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_resource_value_config( request, metadata ) @@ -2571,6 +3105,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.DeleteResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "DeleteResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._DeleteResourceValueConfig._get_response( @@ -2622,7 +3183,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the get big query export method over HTTP. @@ -2633,8 +3194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -2646,6 +3209,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_get_big_query_export( request, metadata ) @@ -2658,6 +3222,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetBigQueryExport._get_response( self._host, @@ -2678,7 +3269,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v2.SecurityCenterClient.get_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -2716,7 +3329,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -2726,8 +3339,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2812,6 +3427,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -2826,6 +3442,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetIamPolicy._get_response( self._host, @@ -2847,7 +3490,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.securitycenter_v2.SecurityCenterClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMuteConfig( @@ -2884,7 +3549,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> mute_config.MuteConfig: r"""Call the get mute config method over HTTP. @@ -2896,8 +3561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.mute_config.MuteConfig: @@ -2910,6 +3577,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_mute_config(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetMuteConfig._get_transcoded_request( http_options, request @@ -2920,6 +3588,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetMuteConfig._get_response( self._host, @@ -2940,7 +3635,29 @@ def __call__( pb_resp = mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = mute_config.MuteConfig.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.securitycenter_v2.SecurityCenterClient.get_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNotificationConfig( @@ -2978,7 +3695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> notification_config.NotificationConfig: r"""Call the get notification config method over HTTP. @@ -2989,8 +3706,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.notification_config.NotificationConfig: @@ -3006,6 +3725,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_notification_config( request, metadata ) @@ -3018,6 +3738,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetNotificationConfig._get_response( self._host, @@ -3038,7 +3785,31 @@ def __call__( pb_resp = notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = notification_config.NotificationConfig.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.securitycenter_v2.SecurityCenterClient.get_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetResourceValueConfig( @@ -3076,7 +3847,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_value_config.ResourceValueConfig: r"""Call the get resource value config method over HTTP. @@ -3087,8 +3858,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource_value_config.ResourceValueConfig: @@ -3102,6 +3875,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_resource_value_config( request, metadata ) @@ -3114,6 +3888,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._GetResourceValueConfig._get_response( @@ -3136,7 +3937,31 @@ def __call__( pb_resp = resource_value_config.ResourceValueConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_resource_value_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resource_value_config.ResourceValueConfig.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.securitycenter_v2.SecurityCenterClient.get_resource_value_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetResourceValueConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSimulation( @@ -3173,7 +3998,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulation.Simulation: r"""Call the get simulation method over HTTP. @@ -3187,8 +4012,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.simulation.Simulation: @@ -3198,6 +4025,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSimulation._get_http_options() ) + request, metadata = self._interceptor.pre_get_simulation(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetSimulation._get_transcoded_request( http_options, request @@ -3208,6 +4036,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetSimulation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetSimulation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSimulation._get_response( self._host, @@ -3228,7 +4083,29 @@ def __call__( pb_resp = simulation.Simulation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_simulation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = simulation.Simulation.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.securitycenter_v2.SecurityCenterClient.get_simulation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetSimulation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSource( @@ -3265,7 +4142,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> source.Source: r"""Call the get source method over HTTP. @@ -3275,8 +4152,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.source.Source: @@ -3292,6 +4171,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_source(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseGetSource._get_transcoded_request( @@ -3306,6 +4186,33 @@ def __call__( ) ) + 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.securitycenter_v2.SecurityCenterClient.GetSource", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetSource._get_response( self._host, @@ -3326,7 +4233,29 @@ def __call__( pb_resp = source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = source.Source.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.securitycenter_v2.SecurityCenterClient.get_source", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetValuedResource( @@ -3363,7 +4292,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> valued_resource.ValuedResource: r"""Call the get valued resource method over HTTP. @@ -3374,8 +4303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.valued_resource.ValuedResource: @@ -3387,6 +4318,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetValuedResource._get_http_options() ) + request, metadata = self._interceptor.pre_get_valued_resource( request, metadata ) @@ -3399,6 +4331,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetValuedResource", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetValuedResource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetValuedResource._get_response( self._host, @@ -3419,7 +4378,29 @@ def __call__( pb_resp = valued_resource.ValuedResource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_valued_resource(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = valued_resource.ValuedResource.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.securitycenter_v2.SecurityCenterClient.get_valued_resource", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetValuedResource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GroupFindings( @@ -3457,7 +4438,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.GroupFindingsResponse: r"""Call the group findings method over HTTP. @@ -3468,8 +4449,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.GroupFindingsResponse: @@ -3481,6 +4464,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGroupFindings._get_http_options() ) + request, metadata = self._interceptor.pre_group_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGroupFindings._get_transcoded_request( http_options, request @@ -3495,6 +4479,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GroupFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GroupFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GroupFindings._get_response( self._host, @@ -3516,7 +4527,31 @@ def __call__( pb_resp = securitycenter_service.GroupFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_group_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.GroupFindingsResponse.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.securitycenter_v2.SecurityCenterClient.group_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GroupFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttackPaths( @@ -3553,7 +4588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListAttackPathsResponse: r"""Call the list attack paths method over HTTP. @@ -3565,8 +4600,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListAttackPathsResponse: @@ -3579,6 +4616,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListAttackPaths._get_http_options() ) + request, metadata = self._interceptor.pre_list_attack_paths( request, metadata ) @@ -3591,6 +4629,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListAttackPaths", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListAttackPaths", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListAttackPaths._get_response( self._host, @@ -3611,7 +4676,31 @@ def __call__( pb_resp = securitycenter_service.ListAttackPathsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attack_paths(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListAttackPathsResponse.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.securitycenter_v2.SecurityCenterClient.list_attack_paths", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListAttackPaths", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBigQueryExports( @@ -3649,7 +4738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListBigQueryExportsResponse: r"""Call the list big query exports method over HTTP. @@ -3661,8 +4750,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListBigQueryExportsResponse: @@ -3674,6 +4765,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListBigQueryExports._get_http_options() ) + request, metadata = self._interceptor.pre_list_big_query_exports( request, metadata ) @@ -3686,6 +4778,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListBigQueryExports", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListBigQueryExports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListBigQueryExports._get_response( self._host, @@ -3706,7 +4825,33 @@ def __call__( pb_resp = securitycenter_service.ListBigQueryExportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_big_query_exports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListBigQueryExportsResponse.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.securitycenter_v2.SecurityCenterClient.list_big_query_exports", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListBigQueryExports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFindings( @@ -3743,7 +4888,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListFindingsResponse: r"""Call the list findings method over HTTP. @@ -3753,8 +4898,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListFindingsResponse: @@ -3766,6 +4913,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListFindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_findings(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListFindings._get_transcoded_request( http_options, request @@ -3776,6 +4924,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListFindings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListFindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListFindings._get_response( self._host, @@ -3796,7 +4971,31 @@ def __call__( pb_resp = securitycenter_service.ListFindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_findings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListFindingsResponse.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.securitycenter_v2.SecurityCenterClient.list_findings", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListFindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMuteConfigs( @@ -3833,7 +5032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListMuteConfigsResponse: r"""Call the list mute configs method over HTTP. @@ -3847,8 +5046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListMuteConfigsResponse: @@ -3860,6 +5061,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListMuteConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_mute_configs( request, metadata ) @@ -3872,6 +5074,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListMuteConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListMuteConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListMuteConfigs._get_response( self._host, @@ -3892,7 +5121,31 @@ def __call__( pb_resp = securitycenter_service.ListMuteConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_mute_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListMuteConfigsResponse.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.securitycenter_v2.SecurityCenterClient.list_mute_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListMuteConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNotificationConfigs( @@ -3930,7 +5183,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListNotificationConfigsResponse: r"""Call the list notification configs method over HTTP. @@ -3941,8 +5194,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListNotificationConfigsResponse: @@ -3954,6 +5209,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListNotificationConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_notification_configs( request, metadata ) @@ -3966,6 +5222,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListNotificationConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._ListNotificationConfigs._get_response( @@ -3988,7 +5271,33 @@ def __call__( pb_resp = securitycenter_service.ListNotificationConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_notification_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListNotificationConfigsResponse.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.securitycenter_v2.SecurityCenterClient.list_notification_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListNotificationConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListResourceValueConfigs( @@ -4026,7 +5335,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListResourceValueConfigsResponse: r"""Call the list resource value configs method over HTTP. @@ -4038,8 +5347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListResourceValueConfigsResponse: @@ -4051,6 +5362,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListResourceValueConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_resource_value_configs( request, metadata ) @@ -4063,6 +5375,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListResourceValueConfigs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListResourceValueConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._ListResourceValueConfigs._get_response( @@ -4085,7 +5424,33 @@ def __call__( pb_resp = securitycenter_service.ListResourceValueConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_resource_value_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListResourceValueConfigsResponse.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.securitycenter_v2.SecurityCenterClient.list_resource_value_configs", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListResourceValueConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSources( @@ -4122,7 +5487,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListSourcesResponse: r"""Call the list sources method over HTTP. @@ -4132,8 +5497,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListSourcesResponse: @@ -4143,6 +5510,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_sources(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListSources._get_transcoded_request( http_options, request @@ -4153,6 +5521,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListSources", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListSources._get_response( self._host, @@ -4173,7 +5568,31 @@ def __call__( pb_resp = securitycenter_service.ListSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListSourcesResponse.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.securitycenter_v2.SecurityCenterClient.list_sources", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListValuedResources( @@ -4211,7 +5630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> securitycenter_service.ListValuedResourcesResponse: r"""Call the list valued resources method over HTTP. @@ -4222,8 +5641,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.securitycenter_service.ListValuedResourcesResponse: @@ -4235,6 +5656,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListValuedResources._get_http_options() ) + request, metadata = self._interceptor.pre_list_valued_resources( request, metadata ) @@ -4247,6 +5669,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListValuedResources", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListValuedResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListValuedResources._get_response( self._host, @@ -4267,7 +5716,33 @@ def __call__( pb_resp = securitycenter_service.ListValuedResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_valued_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + securitycenter_service.ListValuedResourcesResponse.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.securitycenter_v2.SecurityCenterClient.list_valued_resources", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListValuedResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetFindingState( @@ -4305,7 +5780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set finding state method over HTTP. @@ -4316,8 +5791,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -4337,6 +5814,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetFindingState._get_http_options() ) + request, metadata = self._interceptor.pre_set_finding_state( request, metadata ) @@ -4353,6 +5831,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.SetFindingState", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetFindingState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetFindingState._get_response( self._host, @@ -4374,7 +5879,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_finding_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v2.SecurityCenterClient.set_finding_state", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetFindingState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -4412,7 +5939,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -4422,8 +5949,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -4508,6 +6037,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -4522,6 +6052,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetIamPolicy._get_response( self._host, @@ -4543,7 +6100,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.securitycenter_v2.SecurityCenterClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMute( @@ -4581,7 +6160,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> finding.Finding: r"""Call the set mute method over HTTP. @@ -4592,8 +6171,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.finding.Finding: @@ -4613,6 +6194,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseSetMute._get_http_options() ) + request, metadata = self._interceptor.pre_set_mute(request, metadata) transcoded_request = ( _BaseSecurityCenterRestTransport._BaseSetMute._get_transcoded_request( @@ -4631,6 +6213,33 @@ def __call__( ) ) + 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.securitycenter_v2.SecurityCenterClient.SetMute", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetMute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._SetMute._get_response( self._host, @@ -4652,7 +6261,29 @@ def __call__( pb_resp = finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_mute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = finding.Finding.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.securitycenter_v2.SecurityCenterClient.set_mute", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "SetMute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -4690,7 +6321,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -4700,8 +6331,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -4711,6 +6344,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4727,6 +6361,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._TestIamPermissions._get_response( self._host, @@ -4748,7 +6409,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.securitycenter_v2.SecurityCenterClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBigQueryExport( @@ -4787,7 +6470,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> bigquery_export.BigQueryExport: r"""Call the update big query export method over HTTP. @@ -4798,8 +6481,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.bigquery_export.BigQueryExport: @@ -4811,6 +6496,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateBigQueryExport._get_http_options() ) + request, metadata = self._interceptor.pre_update_big_query_export( request, metadata ) @@ -4827,6 +6513,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateBigQueryExport", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateBigQueryExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateBigQueryExport._get_response( self._host, @@ -4848,7 +6561,29 @@ def __call__( pb_resp = bigquery_export.BigQueryExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_big_query_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = bigquery_export.BigQueryExport.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.securitycenter_v2.SecurityCenterClient.update_big_query_export", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateBigQueryExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalSystem( @@ -4887,7 +6622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_external_system.ExternalSystem: r"""Call the update external system method over HTTP. @@ -4898,8 +6633,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_external_system.ExternalSystem: @@ -4911,6 +6648,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateExternalSystem._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_system( request, metadata ) @@ -4927,6 +6665,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateExternalSystem", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateExternalSystem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateExternalSystem._get_response( self._host, @@ -4948,7 +6713,31 @@ def __call__( pb_resp = gcs_external_system.ExternalSystem.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_external_system(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_external_system.ExternalSystem.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.securitycenter_v2.SecurityCenterClient.update_external_system", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateExternalSystem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFinding( @@ -4986,7 +6775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_finding.Finding: r"""Call the update finding method over HTTP. @@ -4997,8 +6786,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_finding.Finding: @@ -5018,6 +6809,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_http_options() ) + request, metadata = self._interceptor.pre_update_finding(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateFinding._get_transcoded_request( http_options, request @@ -5032,6 +6824,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateFinding", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateFinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateFinding._get_response( self._host, @@ -5053,7 +6872,29 @@ def __call__( pb_resp = gcs_finding.Finding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_finding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_finding.Finding.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.securitycenter_v2.SecurityCenterClient.update_finding", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateFinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMuteConfig( @@ -5091,7 +6932,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_mute_config.MuteConfig: r"""Call the update mute config method over HTTP. @@ -5102,8 +6943,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_mute_config.MuteConfig: @@ -5116,6 +6959,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateMuteConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_mute_config( request, metadata ) @@ -5132,6 +6976,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateMuteConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateMuteConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateMuteConfig._get_response( self._host, @@ -5153,7 +7024,29 @@ def __call__( pb_resp = gcs_mute_config.MuteConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_mute_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_mute_config.MuteConfig.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.securitycenter_v2.SecurityCenterClient.update_mute_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateMuteConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNotificationConfig( @@ -5192,7 +7085,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_notification_config.NotificationConfig: r"""Call the update notification config method over HTTP. @@ -5204,8 +7097,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_notification_config.NotificationConfig: @@ -5221,6 +7116,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateNotificationConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_notification_config( request, metadata ) @@ -5237,6 +7133,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateNotificationConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateNotificationConfig._get_response( @@ -5260,7 +7183,31 @@ def __call__( pb_resp = gcs_notification_config.NotificationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_notification_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_notification_config.NotificationConfig.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.securitycenter_v2.SecurityCenterClient.update_notification_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateNotificationConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateResourceValueConfig( @@ -5299,7 +7246,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_resource_value_config.ResourceValueConfig: r"""Call the update resource value config method over HTTP. @@ -5311,8 +7258,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_resource_value_config.ResourceValueConfig: @@ -5326,6 +7275,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateResourceValueConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_resource_value_config( request, metadata ) @@ -5342,6 +7292,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateResourceValueConfig", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateResourceValueConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterRestTransport._UpdateResourceValueConfig._get_response( @@ -5365,7 +7342,31 @@ def __call__( pb_resp = gcs_resource_value_config.ResourceValueConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_resource_value_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcs_resource_value_config.ResourceValueConfig.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.securitycenter_v2.SecurityCenterClient.update_resource_value_config", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateResourceValueConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityMarks( @@ -5404,7 +7405,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_security_marks.SecurityMarks: r"""Call the update security marks method over HTTP. @@ -5415,8 +7416,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_security_marks.SecurityMarks: @@ -5434,6 +7437,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSecurityMarks._get_http_options() ) + request, metadata = self._interceptor.pre_update_security_marks( request, metadata ) @@ -5450,6 +7454,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateSecurityMarks", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSecurityMarks._get_response( self._host, @@ -5471,7 +7502,31 @@ def __call__( pb_resp = gcs_security_marks.SecurityMarks.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_marks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_security_marks.SecurityMarks.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.securitycenter_v2.SecurityCenterClient.update_security_marks", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateSecurityMarks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSource( @@ -5509,7 +7564,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_source.Source: r"""Call the update source method over HTTP. @@ -5520,8 +7575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_source.Source: @@ -5537,6 +7594,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseUpdateSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_source(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseUpdateSource._get_transcoded_request( http_options, request @@ -5551,6 +7609,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.UpdateSource", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._UpdateSource._get_response( self._host, @@ -5572,7 +7657,29 @@ def __call__( pb_resp = gcs_source.Source.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_source.Source.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.securitycenter_v2.SecurityCenterClient.update_source", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "UpdateSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -6013,7 +8120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -6023,13 +8130,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -6042,6 +8152,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.CancelOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._CancelOperation._get_response( self._host, @@ -6097,7 +8234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -6107,13 +8244,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -6126,6 +8266,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._DeleteOperation._get_response( self._host, @@ -6181,7 +8348,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -6191,8 +8358,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -6201,6 +8370,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -6211,6 +8381,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.GetOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._GetOperation._get_response( self._host, @@ -6230,6 +8427,27 @@ def __call__( 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.securitycenter_v2.SecurityCenterAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6270,7 +8488,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -6280,8 +8498,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -6290,6 +8510,7 @@ def __call__( http_options = ( _BaseSecurityCenterRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSecurityCenterRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -6300,6 +8521,33 @@ def __call__( 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.securitycenter_v2.SecurityCenterClient.ListOperations", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterRestTransport._ListOperations._get_response( self._host, @@ -6319,6 +8567,27 @@ def __call__( 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.securitycenter_v2.SecurityCenterAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.securitycenter.v2.SecurityCenter", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1.json b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1.json index c4bdf4bdecda..efb11fe5de6c 100644 --- a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1.json +++ b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycenter", - "version": "1.35.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BatchCreateResourceValueConfigsResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BatchCreateResourceValueConfigsResponse", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -908,7 +908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -996,7 +996,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -1342,7 +1342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -1427,7 +1427,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -1511,7 +1511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_big_query_export" @@ -1669,7 +1669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_big_query_export" @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event_threat_detection_custom_module" @@ -1824,7 +1824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event_threat_detection_custom_module" @@ -1902,7 +1902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_mute_config" @@ -1979,7 +1979,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_mute_config" @@ -2057,7 +2057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -2134,7 +2134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -2212,7 +2212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_resource_value_config" @@ -2289,7 +2289,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_resource_value_config" @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_security_health_analytics_custom_module" @@ -2444,7 +2444,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_security_health_analytics_custom_module" @@ -2522,7 +2522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -2602,7 +2602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -2683,7 +2683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EffectiveEventThreatDetectionCustomModule", @@ -2763,7 +2763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EffectiveEventThreatDetectionCustomModule", @@ -2844,7 +2844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", @@ -2924,7 +2924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", @@ -3005,7 +3005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -3085,7 +3085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -3166,7 +3166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3246,7 +3246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3327,7 +3327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -3407,7 +3407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -3488,7 +3488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -3568,7 +3568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -3649,7 +3649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.OrganizationSettings", @@ -3729,7 +3729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.OrganizationSettings", @@ -3810,7 +3810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ResourceValueConfig", @@ -3890,7 +3890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ResourceValueConfig", @@ -3971,7 +3971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -4051,7 +4051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -4132,7 +4132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Simulation", @@ -4212,7 +4212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Simulation", @@ -4293,7 +4293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -4373,7 +4373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -4454,7 +4454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ValuedResource", @@ -4534,7 +4534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ValuedResource", @@ -4611,7 +4611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.GroupAssetsAsyncPager", @@ -4687,7 +4687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.GroupAssetsPager", @@ -4772,7 +4772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.GroupFindingsAsyncPager", @@ -4856,7 +4856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.GroupFindingsPager", @@ -4933,7 +4933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListAssetsAsyncPager", @@ -5009,7 +5009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListAssetsPager", @@ -5090,7 +5090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListAttackPathsAsyncPager", @@ -5170,7 +5170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListAttackPathsPager", @@ -5251,7 +5251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListBigQueryExportsAsyncPager", @@ -5331,7 +5331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListBigQueryExportsPager", @@ -5412,7 +5412,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager", @@ -5492,7 +5492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantEventThreatDetectionCustomModulesPager", @@ -5573,7 +5573,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -5653,7 +5653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager", @@ -5734,7 +5734,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager", @@ -5814,7 +5814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveEventThreatDetectionCustomModulesPager", @@ -5895,7 +5895,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -5975,7 +5975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager", @@ -6056,7 +6056,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEventThreatDetectionCustomModulesAsyncPager", @@ -6136,7 +6136,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListEventThreatDetectionCustomModulesPager", @@ -6213,7 +6213,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListFindingsAsyncPager", @@ -6289,7 +6289,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListFindingsPager", @@ -6370,7 +6370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListMuteConfigsAsyncPager", @@ -6450,7 +6450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListMuteConfigsPager", @@ -6531,7 +6531,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListNotificationConfigsAsyncPager", @@ -6611,7 +6611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListNotificationConfigsPager", @@ -6692,7 +6692,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListResourceValueConfigsAsyncPager", @@ -6772,7 +6772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListResourceValueConfigsPager", @@ -6853,7 +6853,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -6933,7 +6933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListSecurityHealthAnalyticsCustomModulesPager", @@ -7014,7 +7014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListSourcesAsyncPager", @@ -7094,7 +7094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListSourcesPager", @@ -7175,7 +7175,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListValuedResourcesAsyncPager", @@ -7255,7 +7255,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.services.security_center.pagers.ListValuedResourcesPager", @@ -7336,7 +7336,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7416,7 +7416,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7505,7 +7505,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -7593,7 +7593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -7674,7 +7674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -7754,7 +7754,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -7839,7 +7839,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -7923,7 +7923,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -8012,7 +8012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", @@ -8100,7 +8100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", @@ -8185,7 +8185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -8269,7 +8269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -8354,7 +8354,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -8438,7 +8438,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.BigQueryExport", @@ -8523,7 +8523,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -8607,7 +8607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.EventThreatDetectionCustomModule", @@ -8692,7 +8692,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ExternalSystem", @@ -8776,7 +8776,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ExternalSystem", @@ -8857,7 +8857,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -8937,7 +8937,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Finding", @@ -9022,7 +9022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -9106,7 +9106,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.MuteConfig", @@ -9191,7 +9191,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -9275,7 +9275,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.NotificationConfig", @@ -9356,7 +9356,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.OrganizationSettings", @@ -9436,7 +9436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.OrganizationSettings", @@ -9521,7 +9521,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ResourceValueConfig", @@ -9605,7 +9605,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ResourceValueConfig", @@ -9690,7 +9690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -9774,7 +9774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityHealthAnalyticsCustomModule", @@ -9855,7 +9855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityMarks", @@ -9935,7 +9935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.SecurityMarks", @@ -10016,7 +10016,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -10096,7 +10096,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.Source", @@ -10173,7 +10173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ValidateEventThreatDetectionCustomModuleResponse", @@ -10249,7 +10249,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1.types.ValidateEventThreatDetectionCustomModuleResponse", diff --git a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1beta1.json b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1beta1.json index 66d1034542b7..dc6a6d6dd78d 100644 --- a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1beta1.json +++ b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycenter", - "version": "1.35.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.OrganizationSettings", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.OrganizationSettings", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupAssetsAsyncPager", @@ -948,7 +948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupAssetsPager", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupFindingsAsyncPager", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.GroupFindingsPager", @@ -1194,7 +1194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListAssetsAsyncPager", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListAssetsPager", @@ -1347,7 +1347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListFindingsAsyncPager", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListFindingsPager", @@ -1504,7 +1504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListSourcesAsyncPager", @@ -1584,7 +1584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.services.security_center.pagers.ListSourcesPager", @@ -1665,7 +1665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1745,7 +1745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1834,7 +1834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -1922,7 +1922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -2003,7 +2003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2083,7 +2083,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2168,7 +2168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2252,7 +2252,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2333,7 +2333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -2413,7 +2413,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Finding", @@ -2494,7 +2494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.OrganizationSettings", @@ -2574,7 +2574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.OrganizationSettings", @@ -2655,7 +2655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.SecurityMarks", @@ -2735,7 +2735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.SecurityMarks", @@ -2816,7 +2816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", @@ -2896,7 +2896,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1beta1.types.Source", diff --git a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1p1beta1.json b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1p1beta1.json index 2facdaceadab..7eed8e8dc8ab 100644 --- a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1p1beta1.json +++ b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycenter", - "version": "1.35.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -405,7 +405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", @@ -570,7 +570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -647,7 +647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -805,7 +805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -886,7 +886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -966,7 +966,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings", @@ -1127,7 +1127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings", @@ -1208,7 +1208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", @@ -1288,7 +1288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", @@ -1365,7 +1365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupAssetsAsyncPager", @@ -1441,7 +1441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupAssetsPager", @@ -1526,7 +1526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupFindingsAsyncPager", @@ -1610,7 +1610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.GroupFindingsPager", @@ -1691,7 +1691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListAssetsAsyncPager", @@ -1771,7 +1771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListAssetsPager", @@ -1852,7 +1852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListFindingsAsyncPager", @@ -1932,7 +1932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListFindingsPager", @@ -2013,7 +2013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListNotificationConfigsAsyncPager", @@ -2093,7 +2093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListNotificationConfigsPager", @@ -2174,7 +2174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListSourcesAsyncPager", @@ -2254,7 +2254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.services.security_center.pagers.ListSourcesPager", @@ -2335,7 +2335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2415,7 +2415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2504,7 +2504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -2592,7 +2592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -2673,7 +2673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2753,7 +2753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2838,7 +2838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2922,7 +2922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3007,7 +3007,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -3091,7 +3091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Finding", @@ -3176,7 +3176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -3260,7 +3260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.NotificationConfig", @@ -3341,7 +3341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings", @@ -3421,7 +3421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.OrganizationSettings", @@ -3506,7 +3506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.SecurityMarks", @@ -3590,7 +3590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.SecurityMarks", @@ -3675,7 +3675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", @@ -3759,7 +3759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v1p1beta1.types.Source", diff --git a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v2.json b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v2.json index b3c0b2d6ab3a..e176e0b8c043 100644 --- a/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v2.json +++ b/packages/google-cloud-securitycenter/samples/generated_samples/snippet_metadata_google.cloud.securitycenter.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycenter", - "version": "1.35.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BatchCreateResourceValueConfigsResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BatchCreateResourceValueConfigsResponse", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -827,7 +827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -1004,7 +1004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -1089,7 +1089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_big_query_export" @@ -1331,7 +1331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_big_query_export" @@ -1409,7 +1409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_mute_config" @@ -1486,7 +1486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_mute_config" @@ -1564,7 +1564,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -1641,7 +1641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_notification_config" @@ -1719,7 +1719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_resource_value_config" @@ -1796,7 +1796,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_resource_value_config" @@ -1874,7 +1874,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -1954,7 +1954,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -2035,7 +2035,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2115,7 +2115,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2196,7 +2196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -2276,7 +2276,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -2357,7 +2357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -2437,7 +2437,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -2518,7 +2518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ResourceValueConfig", @@ -2598,7 +2598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ResourceValueConfig", @@ -2679,7 +2679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Simulation", @@ -2759,7 +2759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Simulation", @@ -2840,7 +2840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", @@ -2920,7 +2920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", @@ -3001,7 +3001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ValuedResource", @@ -3081,7 +3081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ValuedResource", @@ -3166,7 +3166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.GroupFindingsAsyncPager", @@ -3250,7 +3250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.GroupFindingsPager", @@ -3331,7 +3331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListAttackPathsAsyncPager", @@ -3411,7 +3411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListAttackPathsPager", @@ -3492,7 +3492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListBigQueryExportsAsyncPager", @@ -3572,7 +3572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListBigQueryExportsPager", @@ -3653,7 +3653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListFindingsAsyncPager", @@ -3733,7 +3733,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListFindingsPager", @@ -3814,7 +3814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListMuteConfigsAsyncPager", @@ -3894,7 +3894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListMuteConfigsPager", @@ -3975,7 +3975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListNotificationConfigsAsyncPager", @@ -4055,7 +4055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListNotificationConfigsPager", @@ -4136,7 +4136,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListResourceValueConfigsAsyncPager", @@ -4216,7 +4216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListResourceValueConfigsPager", @@ -4297,7 +4297,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListSourcesAsyncPager", @@ -4377,7 +4377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListSourcesPager", @@ -4458,7 +4458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListValuedResourcesAsyncPager", @@ -4538,7 +4538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.services.security_center.pagers.ListValuedResourcesPager", @@ -4623,7 +4623,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -4707,7 +4707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -4788,7 +4788,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -4868,7 +4868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -4953,7 +4953,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -5037,7 +5037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -5122,7 +5122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -5206,7 +5206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -5291,7 +5291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -5375,7 +5375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.BigQueryExport", @@ -5460,7 +5460,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ExternalSystem", @@ -5544,7 +5544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ExternalSystem", @@ -5629,7 +5629,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -5713,7 +5713,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Finding", @@ -5798,7 +5798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -5882,7 +5882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.MuteConfig", @@ -5967,7 +5967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -6051,7 +6051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.NotificationConfig", @@ -6136,7 +6136,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ResourceValueConfig", @@ -6220,7 +6220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.ResourceValueConfig", @@ -6305,7 +6305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.SecurityMarks", @@ -6389,7 +6389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.SecurityMarks", @@ -6474,7 +6474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", @@ -6558,7 +6558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycenter_v2.types.Source", diff --git a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1/test_security_center.py b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1/test_security_center.py index a29519e6ce8a..9c8943e4714d 100644 --- a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1/test_security_center.py +++ b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1/test_security_center.py @@ -27357,6 +27357,7 @@ def test_bulk_mute_findings_rest_required_fields( response_value._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.bulk_mute_findings(request) @@ -27400,6 +27401,7 @@ def test_bulk_mute_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.bulk_mute_findings(**mock_args) @@ -27544,6 +27546,7 @@ def test_create_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -27608,6 +27611,7 @@ def test_create_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -27745,6 +27749,7 @@ def test_create_source_rest_required_fields( response_value._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_source(request) @@ -27799,6 +27804,7 @@ def test_create_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -27939,6 +27945,7 @@ def test_create_finding_rest_required_fields( response_value._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_finding(request) @@ -28001,6 +28008,7 @@ def test_create_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -28148,6 +28156,7 @@ def test_create_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -28210,6 +28219,7 @@ def test_create_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -28357,6 +28367,7 @@ def test_create_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -28421,6 +28432,7 @@ def test_create_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -28557,6 +28569,7 @@ def test_delete_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -28600,6 +28613,7 @@ def test_delete_mute_config_rest_flattened(): 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"} client.delete_mute_config(**mock_args) @@ -28732,6 +28746,7 @@ def test_delete_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -28775,6 +28790,7 @@ def test_delete_notification_config_rest_flattened(): 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"} client.delete_notification_config(**mock_args) @@ -28912,6 +28928,7 @@ def test_delete_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -28959,6 +28976,7 @@ def test_delete_security_health_analytics_custom_module_rest_flattened(): 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"} client.delete_security_health_analytics_custom_module(**mock_args) @@ -29092,6 +29110,7 @@ def test_get_simulation_rest_required_fields( response_value._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_simulation(request) @@ -29137,6 +29156,7 @@ def test_get_simulation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_simulation(**mock_args) @@ -29271,6 +29291,7 @@ def test_get_valued_resource_rest_required_fields( response_value._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_valued_resource(request) @@ -29318,6 +29339,7 @@ def test_get_valued_resource_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_valued_resource(**mock_args) @@ -29453,6 +29475,7 @@ def test_get_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -29498,6 +29521,7 @@ def test_get_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -29627,6 +29651,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -29670,6 +29695,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -29801,6 +29827,7 @@ def test_get_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -29846,6 +29873,7 @@ def test_get_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -29981,6 +30009,7 @@ def test_get_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -30026,6 +30055,7 @@ def test_get_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -30162,6 +30192,7 @@ def test_get_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -30207,6 +30238,7 @@ def test_get_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -30351,6 +30383,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_required_fie response_value._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_effective_security_health_analytics_custom_module( request @@ -30406,6 +30439,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_security_health_analytics_custom_module(**mock_args) @@ -30552,6 +30586,7 @@ def test_get_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -30605,6 +30640,7 @@ def test_get_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -30738,6 +30774,7 @@ def test_get_source_rest_required_fields( response_value._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_source(request) @@ -30783,6 +30820,7 @@ def test_get_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -30917,6 +30955,7 @@ def test_group_assets_rest_required_fields( response_value._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.group_assets(request) @@ -31112,6 +31151,7 @@ def test_group_findings_rest_required_fields( response_value._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.group_findings(request) @@ -31166,6 +31206,7 @@ def test_group_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.group_findings(**mock_args) @@ -31373,6 +31414,7 @@ def test_list_assets_rest_required_fields( response_value._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_assets(request) @@ -31591,6 +31633,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_required_ response_value._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_descendant_security_health_analytics_custom_modules( request @@ -31654,6 +31697,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_flattened json_return_value = json_format.MessageToJson(return_value) response_value._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_descendant_security_health_analytics_custom_modules(**mock_args) @@ -31881,6 +31925,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -32092,6 +32137,7 @@ def test_list_mute_configs_rest_required_fields( response_value._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_mute_configs(request) @@ -32145,6 +32191,7 @@ def test_list_mute_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_configs(**mock_args) @@ -32352,6 +32399,7 @@ def test_list_notification_configs_rest_required_fields( response_value._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_notification_configs(request) @@ -32407,6 +32455,7 @@ def test_list_notification_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_configs(**mock_args) @@ -32624,6 +32673,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_required_f response_value._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_effective_security_health_analytics_custom_modules( request @@ -32687,6 +32737,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_flattened( json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_security_health_analytics_custom_modules(**mock_args) @@ -32922,6 +32973,7 @@ def test_list_security_health_analytics_custom_modules_rest_required_fields( response_value._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_security_health_analytics_custom_modules(request) @@ -32985,6 +33037,7 @@ def test_list_security_health_analytics_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_modules(**mock_args) @@ -33207,6 +33260,7 @@ def test_list_sources_rest_required_fields( response_value._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_sources(request) @@ -33260,6 +33314,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_sources(**mock_args) @@ -33458,6 +33513,7 @@ def test_run_asset_discovery_rest_required_fields( response_value._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.run_asset_discovery(request) @@ -33501,6 +33557,7 @@ def test_run_asset_discovery_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_asset_discovery(**mock_args) @@ -33635,6 +33692,7 @@ def test_set_finding_state_rest_required_fields( response_value._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.set_finding_state(request) @@ -33693,6 +33751,7 @@ def test_set_finding_state_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_finding_state(**mock_args) @@ -33827,6 +33886,7 @@ def test_set_mute_rest_required_fields( response_value._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.set_mute(request) @@ -33883,6 +33943,7 @@ def test_set_mute_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_mute(**mock_args) @@ -34014,6 +34075,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -34065,6 +34127,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -34203,6 +34266,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -34255,6 +34319,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -34401,6 +34466,7 @@ def test_simulate_security_health_analytics_custom_module_rest_required_fields( response_value._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.simulate_security_health_analytics_custom_module(request) @@ -34469,6 +34535,7 @@ def test_simulate_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.simulate_security_health_analytics_custom_module(**mock_args) @@ -34611,6 +34678,7 @@ def test_update_external_system_rest_required_fields( response_value._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_external_system(request) @@ -34661,6 +34729,7 @@ def test_update_external_system_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_system(**mock_args) @@ -34791,6 +34860,7 @@ def test_update_finding_rest_required_fields( response_value._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_finding(request) @@ -34840,6 +34910,7 @@ def test_update_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -34973,6 +35044,7 @@ def test_update_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -35021,6 +35093,7 @@ def test_update_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -35156,6 +35229,7 @@ def test_update_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -35208,6 +35282,7 @@ def test_update_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -35347,6 +35422,7 @@ def test_update_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -35398,6 +35474,7 @@ def test_update_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -35542,6 +35619,7 @@ def test_update_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -35602,6 +35680,7 @@ def test_update_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -35736,6 +35815,7 @@ def test_update_source_rest_required_fields( response_value._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_source(request) @@ -35781,6 +35861,7 @@ def test_update_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -35919,6 +36000,7 @@ def test_update_security_marks_rest_required_fields( response_value._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_security_marks(request) @@ -35976,6 +36058,7 @@ def test_update_security_marks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_marks(**mock_args) @@ -36122,6 +36205,7 @@ def test_create_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -36184,6 +36268,7 @@ def test_create_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -36318,6 +36403,7 @@ def test_delete_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -36361,6 +36447,7 @@ def test_delete_big_query_export_rest_flattened(): 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"} client.delete_big_query_export(**mock_args) @@ -36494,6 +36581,7 @@ def test_update_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -36544,6 +36632,7 @@ def test_update_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -36690,6 +36779,7 @@ def test_list_big_query_exports_rest_required_fields( response_value._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_big_query_exports(request) @@ -36745,6 +36835,7 @@ def test_list_big_query_exports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_exports(**mock_args) @@ -36953,6 +37044,7 @@ def test_create_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -37017,6 +37109,7 @@ def test_create_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -37159,6 +37252,7 @@ def test_delete_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -37206,6 +37300,7 @@ def test_delete_event_threat_detection_custom_module_rest_flattened(): 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"} client.delete_event_threat_detection_custom_module(**mock_args) @@ -37352,6 +37447,7 @@ def test_get_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -37409,6 +37505,7 @@ def test_get_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -37562,6 +37659,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_required_fie response_value._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_descendant_event_threat_detection_custom_modules( request @@ -37625,6 +37723,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_descendant_event_threat_detection_custom_modules(**mock_args) @@ -37861,6 +37960,7 @@ def test_list_event_threat_detection_custom_modules_rest_required_fields( response_value._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_event_threat_detection_custom_modules(request) @@ -37926,6 +38026,7 @@ def test_list_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_modules(**mock_args) @@ -38149,6 +38250,7 @@ def test_update_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -38209,6 +38311,7 @@ def test_update_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -38367,6 +38470,7 @@ def test_validate_event_threat_detection_custom_module_rest_required_fields( response_value._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.validate_event_threat_detection_custom_module(request) @@ -38510,6 +38614,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_required_fields response_value._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_effective_event_threat_detection_custom_module( request @@ -38565,6 +38670,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_event_threat_detection_custom_module(**mock_args) @@ -38718,6 +38824,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_required_fiel response_value._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_effective_event_threat_detection_custom_modules( request @@ -38781,6 +38888,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_event_threat_detection_custom_modules(**mock_args) @@ -39006,6 +39114,7 @@ def test_batch_create_resource_value_configs_rest_required_fields( response_value._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.batch_create_resource_value_configs(request) @@ -39070,6 +39179,7 @@ def test_batch_create_resource_value_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_create_resource_value_configs(**mock_args) @@ -39210,6 +39320,7 @@ def test_delete_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -39253,6 +39364,7 @@ def test_delete_resource_value_config_rest_flattened(): 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"} client.delete_resource_value_config(**mock_args) @@ -39389,6 +39501,7 @@ def test_get_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -39434,6 +39547,7 @@ def test_get_resource_value_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_config(**mock_args) @@ -39579,6 +39693,7 @@ def test_list_resource_value_configs_rest_required_fields( response_value._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_resource_value_configs(request) @@ -39634,6 +39749,7 @@ def test_list_resource_value_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_configs(**mock_args) @@ -39836,6 +39952,7 @@ def test_update_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -39888,6 +40005,7 @@ def test_update_resource_value_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_config(**mock_args) @@ -40038,6 +40156,7 @@ def test_list_valued_resources_rest_required_fields( response_value._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_valued_resources(request) @@ -40095,6 +40214,7 @@ def test_list_valued_resources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_valued_resources(**mock_args) @@ -40302,6 +40422,7 @@ def test_list_attack_paths_rest_required_fields( response_value._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_attack_paths(request) @@ -40356,6 +40477,7 @@ def test_list_attack_paths_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attack_paths(**mock_args) @@ -44081,6 +44203,7 @@ def test_bulk_mute_findings_rest_bad_request( 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.bulk_mute_findings(request) @@ -44111,6 +44234,7 @@ def test_bulk_mute_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.bulk_mute_findings(request) # Establish that the response is the type that we expect. @@ -44152,6 +44276,7 @@ def test_bulk_mute_findings_rest_interceptors(null_interceptor): 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 @@ -44196,6 +44321,7 @@ def test_create_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -44340,6 +44466,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -44394,6 +44521,7 @@ def test_create_security_health_analytics_custom_module_rest_interceptors( 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 = gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.to_json( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule() ) @@ -44444,6 +44572,7 @@ def test_create_source_rest_bad_request( 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_source(request) @@ -44555,6 +44684,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -44598,6 +44728,7 @@ def test_create_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -44642,6 +44773,7 @@ def test_create_finding_rest_bad_request( 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_finding(request) @@ -45078,6 +45210,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -45132,6 +45265,7 @@ def test_create_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -45176,6 +45310,7 @@ def test_create_mute_config_rest_bad_request( 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_mute_config(request) @@ -45296,6 +45431,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -45341,6 +45477,7 @@ def test_create_mute_config_rest_interceptors(null_interceptor): 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 = gcs_mute_config.MuteConfig.to_json(gcs_mute_config.MuteConfig()) req.return_value.content = return_value @@ -45385,6 +45522,7 @@ def test_create_notification_config_rest_bad_request( 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_notification_config(request) @@ -45499,6 +45637,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -45542,6 +45681,7 @@ def test_create_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -45588,6 +45728,7 @@ def test_delete_mute_config_rest_bad_request( 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_mute_config(request) @@ -45618,6 +45759,7 @@ def test_delete_mute_config_rest_call_success(request_type): 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_mute_config(request) # Establish that the response is the type that we expect. @@ -45654,6 +45796,7 @@ def test_delete_mute_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteMuteConfigRequest() metadata = [ @@ -45694,6 +45837,7 @@ def test_delete_notification_config_rest_bad_request( 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_notification_config(request) @@ -45724,6 +45868,7 @@ def test_delete_notification_config_rest_call_success(request_type): 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_notification_config(request) # Establish that the response is the type that we expect. @@ -45760,6 +45905,7 @@ def test_delete_notification_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteNotificationConfigRequest() metadata = [ @@ -45802,6 +45948,7 @@ def test_delete_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -45834,6 +45981,7 @@ def test_delete_security_health_analytics_custom_module_rest_call_success(reques 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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -45873,6 +46021,7 @@ def test_delete_security_health_analytics_custom_module_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( securitycenter_service.DeleteSecurityHealthAnalyticsCustomModuleRequest() @@ -45915,6 +46064,7 @@ def test_get_simulation_rest_bad_request( 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_simulation(request) @@ -45951,6 +46101,7 @@ def test_get_simulation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_simulation(request) # Establish that the response is the type that we expect. @@ -45992,6 +46143,7 @@ def test_get_simulation_rest_interceptors(null_interceptor): 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 = simulation.Simulation.to_json(simulation.Simulation()) req.return_value.content = return_value @@ -46038,6 +46190,7 @@ def test_get_valued_resource_rest_bad_request( 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_valued_resource(request) @@ -46080,6 +46233,7 @@ def test_get_valued_resource_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_valued_resource(request) # Establish that the response is the type that we expect. @@ -46128,6 +46282,7 @@ def test_get_valued_resource_rest_interceptors(null_interceptor): 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 = valued_resource.ValuedResource.to_json( valued_resource.ValuedResource() ) @@ -46174,6 +46329,7 @@ def test_get_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -46214,6 +46370,7 @@ def test_get_big_query_export_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -46259,6 +46416,7 @@ def test_get_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -46305,6 +46463,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -46338,6 +46497,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -46377,6 +46537,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -46421,6 +46582,7 @@ def test_get_mute_config_rest_bad_request( 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_mute_config(request) @@ -46461,6 +46623,7 @@ def test_get_mute_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -46506,6 +46669,7 @@ def test_get_mute_config_rest_interceptors(null_interceptor): 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 = mute_config.MuteConfig.to_json(mute_config.MuteConfig()) req.return_value.content = return_value @@ -46550,6 +46714,7 @@ def test_get_notification_config_rest_bad_request( 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_notification_config(request) @@ -46588,6 +46753,7 @@ def test_get_notification_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -46631,6 +46797,7 @@ def test_get_notification_config_rest_interceptors(null_interceptor): 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 = notification_config.NotificationConfig.to_json( notification_config.NotificationConfig() ) @@ -46677,6 +46844,7 @@ def test_get_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -46713,6 +46881,7 @@ def test_get_organization_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -46754,6 +46923,7 @@ def test_get_organization_settings_rest_interceptors(null_interceptor): 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 = organization_settings.OrganizationSettings.to_json( organization_settings.OrganizationSettings() ) @@ -46802,6 +46972,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_bad_request( 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_effective_security_health_analytics_custom_module(request) @@ -46845,6 +47016,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_call_success json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -46897,6 +47069,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_interceptors 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 = effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule.to_json( effective_security_health_analytics_custom_module.EffectiveSecurityHealthAnalyticsCustomModule() ) @@ -46949,6 +47122,7 @@ def test_get_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -46992,6 +47166,7 @@ def test_get_security_health_analytics_custom_module_rest_call_success(request_t json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -47048,6 +47223,7 @@ def test_get_security_health_analytics_custom_module_rest_interceptors( 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 = security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.to_json( security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule() ) @@ -47096,6 +47272,7 @@ def test_get_source_rest_bad_request( 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_source(request) @@ -47134,6 +47311,7 @@ def test_get_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -47177,6 +47355,7 @@ def test_get_source_rest_interceptors(null_interceptor): 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 = source.Source.to_json(source.Source()) req.return_value.content = return_value @@ -47221,6 +47400,7 @@ def test_group_assets_rest_bad_request( 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.group_assets(request) @@ -47257,6 +47437,7 @@ def test_group_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_assets(request) # Establish that the response is the type that we expect. @@ -47298,6 +47479,7 @@ def test_group_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupAssetsResponse.to_json( securitycenter_service.GroupAssetsResponse() ) @@ -47344,6 +47526,7 @@ def test_group_findings_rest_bad_request( 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.group_findings(request) @@ -47380,6 +47563,7 @@ def test_group_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_findings(request) # Establish that the response is the type that we expect. @@ -47421,6 +47605,7 @@ def test_group_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupFindingsResponse.to_json( securitycenter_service.GroupFindingsResponse() ) @@ -47467,6 +47652,7 @@ def test_list_assets_rest_bad_request( 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_assets(request) @@ -47503,6 +47689,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -47544,6 +47731,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListAssetsResponse.to_json( securitycenter_service.ListAssetsResponse() ) @@ -47590,6 +47778,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_bad_reque 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_descendant_security_health_analytics_custom_modules(request) @@ -47629,6 +47818,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_call_succ json_return_value = json_format.MessageToJson(return_value) response_value.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_descendant_security_health_analytics_custom_modules( request ) @@ -47677,6 +47867,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_intercept 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 = securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json( securitycenter_service.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() ) @@ -47727,6 +47918,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -47763,6 +47955,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -47804,6 +47997,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListFindingsResponse.to_json( securitycenter_service.ListFindingsResponse() ) @@ -47850,6 +48044,7 @@ def test_list_mute_configs_rest_bad_request( 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_mute_configs(request) @@ -47885,6 +48080,7 @@ def test_list_mute_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_configs(request) # Establish that the response is the type that we expect. @@ -47925,6 +48121,7 @@ def test_list_mute_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListMuteConfigsResponse.to_json( securitycenter_service.ListMuteConfigsResponse() ) @@ -47971,6 +48168,7 @@ def test_list_notification_configs_rest_bad_request( 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_notification_configs(request) @@ -48008,6 +48206,7 @@ def test_list_notification_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_configs(request) # Establish that the response is the type that we expect. @@ -48048,6 +48247,7 @@ def test_list_notification_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListNotificationConfigsResponse.to_json( securitycenter_service.ListNotificationConfigsResponse() ) @@ -48094,6 +48294,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_bad_reques 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_effective_security_health_analytics_custom_modules(request) @@ -48133,6 +48334,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_call_succe json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_security_health_analytics_custom_modules( request ) @@ -48181,6 +48383,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_intercepto 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 = securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json( securitycenter_service.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() ) @@ -48231,6 +48434,7 @@ def test_list_security_health_analytics_custom_modules_rest_bad_request( 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_security_health_analytics_custom_modules(request) @@ -48272,6 +48476,7 @@ def test_list_security_health_analytics_custom_modules_rest_call_success(request json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_modules(request) # Establish that the response is the type that we expect. @@ -48318,6 +48523,7 @@ def test_list_security_health_analytics_custom_modules_rest_interceptors( 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 = securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse.to_json( securitycenter_service.ListSecurityHealthAnalyticsCustomModulesResponse() ) @@ -48368,6 +48574,7 @@ def test_list_sources_rest_bad_request( 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_sources(request) @@ -48403,6 +48610,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_sources(request) # Establish that the response is the type that we expect. @@ -48443,6 +48651,7 @@ def test_list_sources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListSourcesResponse.to_json( securitycenter_service.ListSourcesResponse() ) @@ -48489,6 +48698,7 @@ def test_run_asset_discovery_rest_bad_request( 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.run_asset_discovery(request) @@ -48519,6 +48729,7 @@ def test_run_asset_discovery_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_asset_discovery(request) # Establish that the response is the type that we expect. @@ -48560,6 +48771,7 @@ def test_run_asset_discovery_rest_interceptors(null_interceptor): 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 @@ -48604,6 +48816,7 @@ def test_set_finding_state_rest_bad_request( 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.set_finding_state(request) @@ -48653,6 +48866,7 @@ def test_set_finding_state_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_finding_state(request) # Establish that the response is the type that we expect. @@ -48707,6 +48921,7 @@ def test_set_finding_state_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -48749,6 +48964,7 @@ def test_set_mute_rest_bad_request(request_type=securitycenter_service.SetMuteRe 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.set_mute(request) @@ -48798,6 +49014,7 @@ def test_set_mute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_mute(request) # Establish that the response is the type that we expect. @@ -48852,6 +49069,7 @@ def test_set_mute_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -48896,6 +49114,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -48929,6 +49148,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -48968,6 +49188,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -49012,6 +49233,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -49044,6 +49266,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -49082,6 +49305,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -49128,6 +49352,7 @@ def test_simulate_security_health_analytics_custom_module_rest_bad_request( 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.simulate_security_health_analytics_custom_module(request) @@ -49167,6 +49392,7 @@ def test_simulate_security_health_analytics_custom_module_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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.simulate_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -49213,6 +49439,7 @@ def test_simulate_security_health_analytics_custom_module_rest_interceptors( 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 = securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse.to_json( securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse() ) @@ -49267,6 +49494,7 @@ def test_update_external_system_rest_bad_request( 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_external_system(request) @@ -49400,6 +49628,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_system(request) # Establish that the response is the type that we expect. @@ -49445,6 +49674,7 @@ def test_update_external_system_rest_interceptors(null_interceptor): 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 = gcs_external_system.ExternalSystem.to_json( gcs_external_system.ExternalSystem() ) @@ -49493,6 +49723,7 @@ def test_update_finding_rest_bad_request( 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_finding(request) @@ -49931,6 +50162,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -49985,6 +50217,7 @@ def test_update_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -50031,6 +50264,7 @@ def test_update_mute_config_rest_bad_request( 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_mute_config(request) @@ -50153,6 +50387,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -50198,6 +50433,7 @@ def test_update_mute_config_rest_interceptors(null_interceptor): 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 = gcs_mute_config.MuteConfig.to_json(gcs_mute_config.MuteConfig()) req.return_value.content = return_value @@ -50246,6 +50482,7 @@ def test_update_notification_config_rest_bad_request( 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_notification_config(request) @@ -50364,6 +50601,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -50407,6 +50645,7 @@ def test_update_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -50455,6 +50694,7 @@ def test_update_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -50573,6 +50813,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -50614,6 +50855,7 @@ def test_update_organization_settings_rest_interceptors(null_interceptor): 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 = gcs_organization_settings.OrganizationSettings.to_json( gcs_organization_settings.OrganizationSettings() ) @@ -50664,6 +50906,7 @@ def test_update_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -50812,6 +51055,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -50866,6 +51110,7 @@ def test_update_security_health_analytics_custom_module_rest_interceptors( 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 = gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule.to_json( gcs_security_health_analytics_custom_module.SecurityHealthAnalyticsCustomModule() ) @@ -50916,6 +51161,7 @@ def test_update_source_rest_bad_request( 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_source(request) @@ -51027,6 +51273,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -51070,6 +51317,7 @@ def test_update_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -51116,6 +51364,7 @@ def test_update_security_marks_rest_bad_request( 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_security_marks(request) @@ -51228,6 +51477,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_marks(request) # Establish that the response is the type that we expect. @@ -51269,6 +51519,7 @@ def test_update_security_marks_rest_interceptors(null_interceptor): 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 = gcs_security_marks.SecurityMarks.to_json( gcs_security_marks.SecurityMarks() ) @@ -51315,6 +51566,7 @@ def test_create_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -51434,6 +51686,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -51479,6 +51732,7 @@ def test_create_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -51525,6 +51779,7 @@ def test_delete_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -51555,6 +51810,7 @@ def test_delete_big_query_export_rest_call_success(request_type): 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_big_query_export(request) # Establish that the response is the type that we expect. @@ -51591,6 +51847,7 @@ def test_delete_big_query_export_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteBigQueryExportRequest() metadata = [ @@ -51633,6 +51890,7 @@ def test_update_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -51754,6 +52012,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -51799,6 +52058,7 @@ def test_update_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -51845,6 +52105,7 @@ def test_list_big_query_exports_rest_bad_request( 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_big_query_exports(request) @@ -51882,6 +52143,7 @@ def test_list_big_query_exports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_exports(request) # Establish that the response is the type that we expect. @@ -51922,6 +52184,7 @@ def test_list_big_query_exports_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListBigQueryExportsResponse.to_json( securitycenter_service.ListBigQueryExportsResponse() ) @@ -51968,6 +52231,7 @@ def test_create_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -52099,6 +52363,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -52157,6 +52422,7 @@ def test_create_event_threat_detection_custom_module_rest_interceptors( 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 = gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.to_json( gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule() ) @@ -52207,6 +52473,7 @@ def test_delete_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -52239,6 +52506,7 @@ def test_delete_event_threat_detection_custom_module_rest_call_success(request_t 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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -52280,6 +52548,7 @@ def test_delete_event_threat_detection_custom_module_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteEventThreatDetectionCustomModuleRequest() metadata = [ @@ -52322,6 +52591,7 @@ def test_get_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -52369,6 +52639,7 @@ def test_get_event_threat_detection_custom_module_rest_call_success(request_type json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -52424,6 +52695,7 @@ def test_get_event_threat_detection_custom_module_rest_interceptors(null_interce 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 = event_threat_detection_custom_module.EventThreatDetectionCustomModule.to_json( event_threat_detection_custom_module.EventThreatDetectionCustomModule() ) @@ -52472,6 +52744,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_bad_request( 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_descendant_event_threat_detection_custom_modules(request) @@ -52511,6 +52784,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_call_success json_return_value = json_format.MessageToJson(return_value) response_value.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_descendant_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -52557,6 +52831,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_interceptors 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 = securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse.to_json( securitycenter_service.ListDescendantEventThreatDetectionCustomModulesResponse() ) @@ -52607,6 +52882,7 @@ def test_list_event_threat_detection_custom_modules_rest_bad_request( 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_event_threat_detection_custom_modules(request) @@ -52648,6 +52924,7 @@ def test_list_event_threat_detection_custom_modules_rest_call_success(request_ty json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -52692,6 +52969,7 @@ def test_list_event_threat_detection_custom_modules_rest_interceptors(null_inter 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 = securitycenter_service.ListEventThreatDetectionCustomModulesResponse.to_json( securitycenter_service.ListEventThreatDetectionCustomModulesResponse() ) @@ -52744,6 +53022,7 @@ def test_update_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -52879,6 +53158,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -52937,6 +53217,7 @@ def test_update_event_threat_detection_custom_module_rest_interceptors( 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 = gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule.to_json( gcs_event_threat_detection_custom_module.EventThreatDetectionCustomModule() ) @@ -52985,6 +53266,7 @@ def test_validate_event_threat_detection_custom_module_rest_bad_request( 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.validate_event_threat_detection_custom_module(request) @@ -53024,6 +53306,7 @@ def test_validate_event_threat_detection_custom_module_rest_call_success(request json_return_value = json_format.MessageToJson(return_value) response_value.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.validate_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -53072,6 +53355,7 @@ def test_validate_event_threat_detection_custom_module_rest_interceptors( 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 = securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse.to_json( securitycenter_service.ValidateEventThreatDetectionCustomModuleResponse() ) @@ -53124,6 +53408,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_bad_request( 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_effective_event_threat_detection_custom_module(request) @@ -53169,6 +53454,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -53223,6 +53509,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_interceptors( 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 = effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule.to_json( effective_event_threat_detection_custom_module.EffectiveEventThreatDetectionCustomModule() ) @@ -53273,6 +53560,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_bad_request( 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_effective_event_threat_detection_custom_modules(request) @@ -53312,6 +53600,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -53358,6 +53647,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_interceptors( 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 = securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json( securitycenter_service.ListEffectiveEventThreatDetectionCustomModulesResponse() ) @@ -53408,6 +53698,7 @@ def test_batch_create_resource_value_configs_rest_bad_request( 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.batch_create_resource_value_configs(request) @@ -53445,6 +53736,7 @@ def test_batch_create_resource_value_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_create_resource_value_configs(request) # Establish that the response is the type that we expect. @@ -53488,6 +53780,7 @@ def test_batch_create_resource_value_configs_rest_interceptors(null_interceptor) 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 = ( securitycenter_service.BatchCreateResourceValueConfigsResponse.to_json( securitycenter_service.BatchCreateResourceValueConfigsResponse() @@ -53538,6 +53831,7 @@ def test_delete_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -53568,6 +53862,7 @@ def test_delete_resource_value_config_rest_call_success(request_type): 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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -53604,6 +53899,7 @@ def test_delete_resource_value_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteResourceValueConfigRequest() metadata = [ @@ -53644,6 +53940,7 @@ def test_get_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -53685,6 +53982,7 @@ def test_get_resource_value_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -53731,6 +54029,7 @@ def test_get_resource_value_config_rest_interceptors(null_interceptor): 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 = resource_value_config.ResourceValueConfig.to_json( resource_value_config.ResourceValueConfig() ) @@ -53777,6 +54076,7 @@ def test_list_resource_value_configs_rest_bad_request( 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_resource_value_configs(request) @@ -53814,6 +54114,7 @@ def test_list_resource_value_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_configs(request) # Establish that the response is the type that we expect. @@ -53854,6 +54155,7 @@ def test_list_resource_value_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListResourceValueConfigsResponse.to_json( securitycenter_service.ListResourceValueConfigsResponse() ) @@ -53904,6 +54206,7 @@ def test_update_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -54036,6 +54339,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -54082,6 +54386,7 @@ def test_update_resource_value_config_rest_interceptors(null_interceptor): 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 = gcs_resource_value_config.ResourceValueConfig.to_json( gcs_resource_value_config.ResourceValueConfig() ) @@ -54128,6 +54433,7 @@ def test_list_valued_resources_rest_bad_request( 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_valued_resources(request) @@ -54166,6 +54472,7 @@ def test_list_valued_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_valued_resources(request) # Establish that the response is the type that we expect. @@ -54207,6 +54514,7 @@ def test_list_valued_resources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListValuedResourcesResponse.to_json( securitycenter_service.ListValuedResourcesResponse() ) @@ -54253,6 +54561,7 @@ def test_list_attack_paths_rest_bad_request( 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_attack_paths(request) @@ -54288,6 +54597,7 @@ def test_list_attack_paths_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attack_paths(request) # Establish that the response is the type that we expect. @@ -54328,6 +54638,7 @@ def test_list_attack_paths_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListAttackPathsResponse.to_json( securitycenter_service.ListAttackPathsResponse() ) @@ -54376,6 +54687,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -54406,6 +54718,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -54436,6 +54749,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -54466,6 +54780,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -54496,6 +54811,7 @@ def test_get_operation_rest_bad_request( 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) @@ -54526,6 +54842,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -54556,6 +54873,7 @@ def test_list_operations_rest_bad_request( 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) @@ -54586,6 +54904,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1beta1/test_security_center.py b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1beta1/test_security_center.py index 756bb69087d2..674b5f8fc263 100644 --- a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1beta1/test_security_center.py +++ b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1beta1/test_security_center.py @@ -8085,6 +8085,7 @@ def test_create_source_rest_required_fields( response_value._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_source(request) @@ -8139,6 +8140,7 @@ def test_create_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -8280,6 +8282,7 @@ def test_create_finding_rest_required_fields( response_value._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_finding(request) @@ -8342,6 +8345,7 @@ def test_create_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -8474,6 +8478,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -8517,6 +8522,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -8653,6 +8659,7 @@ def test_get_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -8698,6 +8705,7 @@ def test_get_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -8829,6 +8837,7 @@ def test_get_source_rest_required_fields( response_value._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_source(request) @@ -8874,6 +8883,7 @@ def test_get_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -9009,6 +9019,7 @@ def test_group_assets_rest_required_fields( response_value._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.group_assets(request) @@ -9204,6 +9215,7 @@ def test_group_findings_rest_required_fields( response_value._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.group_findings(request) @@ -9258,6 +9270,7 @@ def test_group_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.group_findings(**mock_args) @@ -9465,6 +9478,7 @@ def test_list_assets_rest_required_fields( response_value._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_assets(request) @@ -9674,6 +9688,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -9875,6 +9890,7 @@ def test_list_sources_rest_required_fields( response_value._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_sources(request) @@ -9928,6 +9944,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_sources(**mock_args) @@ -10127,6 +10144,7 @@ def test_run_asset_discovery_rest_required_fields( response_value._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.run_asset_discovery(request) @@ -10170,6 +10188,7 @@ def test_run_asset_discovery_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_asset_discovery(**mock_args) @@ -10304,6 +10323,7 @@ def test_set_finding_state_rest_required_fields( response_value._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.set_finding_state(request) @@ -10362,6 +10382,7 @@ def test_set_finding_state_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_finding_state(**mock_args) @@ -10494,6 +10515,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -10545,6 +10567,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -10683,6 +10706,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -10735,6 +10759,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -10865,6 +10890,7 @@ def test_update_finding_rest_required_fields( response_value._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_finding(request) @@ -10914,6 +10940,7 @@ def test_update_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -11050,6 +11077,7 @@ def test_update_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -11101,6 +11129,7 @@ def test_update_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -11232,6 +11261,7 @@ def test_update_source_rest_required_fields( response_value._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_source(request) @@ -11277,6 +11307,7 @@ def test_update_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -11416,6 +11447,7 @@ def test_update_security_marks_rest_required_fields( response_value._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_security_marks(request) @@ -11473,6 +11505,7 @@ def test_update_security_marks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_marks(**mock_args) @@ -12563,6 +12596,7 @@ def test_create_source_rest_bad_request( 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_source(request) @@ -12672,6 +12706,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -12714,6 +12749,7 @@ def test_create_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -12758,6 +12794,7 @@ def test_create_finding_rest_bad_request( 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_finding(request) @@ -12877,6 +12914,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -12922,6 +12960,7 @@ def test_create_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -12966,6 +13005,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -12999,6 +13039,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -13038,6 +13079,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -13082,6 +13124,7 @@ def test_get_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -13118,6 +13161,7 @@ def test_get_organization_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -13159,6 +13203,7 @@ def test_get_organization_settings_rest_interceptors(null_interceptor): 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 = organization_settings.OrganizationSettings.to_json( organization_settings.OrganizationSettings() ) @@ -13205,6 +13250,7 @@ def test_get_source_rest_bad_request( 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_source(request) @@ -13242,6 +13288,7 @@ def test_get_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -13284,6 +13331,7 @@ def test_get_source_rest_interceptors(null_interceptor): 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 = source.Source.to_json(source.Source()) req.return_value.content = return_value @@ -13328,6 +13376,7 @@ def test_group_assets_rest_bad_request( 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.group_assets(request) @@ -13363,6 +13412,7 @@ def test_group_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_assets(request) # Establish that the response is the type that we expect. @@ -13403,6 +13453,7 @@ def test_group_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupAssetsResponse.to_json( securitycenter_service.GroupAssetsResponse() ) @@ -13449,6 +13500,7 @@ def test_group_findings_rest_bad_request( 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.group_findings(request) @@ -13484,6 +13536,7 @@ def test_group_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_findings(request) # Establish that the response is the type that we expect. @@ -13524,6 +13577,7 @@ def test_group_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupFindingsResponse.to_json( securitycenter_service.GroupFindingsResponse() ) @@ -13570,6 +13624,7 @@ def test_list_assets_rest_bad_request( 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_assets(request) @@ -13606,6 +13661,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -13647,6 +13703,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListAssetsResponse.to_json( securitycenter_service.ListAssetsResponse() ) @@ -13693,6 +13750,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -13729,6 +13787,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -13770,6 +13829,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListFindingsResponse.to_json( securitycenter_service.ListFindingsResponse() ) @@ -13816,6 +13876,7 @@ def test_list_sources_rest_bad_request( 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_sources(request) @@ -13851,6 +13912,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_sources(request) # Establish that the response is the type that we expect. @@ -13891,6 +13953,7 @@ def test_list_sources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListSourcesResponse.to_json( securitycenter_service.ListSourcesResponse() ) @@ -13937,6 +14000,7 @@ def test_run_asset_discovery_rest_bad_request( 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.run_asset_discovery(request) @@ -13967,6 +14031,7 @@ def test_run_asset_discovery_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_asset_discovery(request) # Establish that the response is the type that we expect. @@ -14008,6 +14073,7 @@ def test_run_asset_discovery_rest_interceptors(null_interceptor): 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 @@ -14052,6 +14118,7 @@ def test_set_finding_state_rest_bad_request( 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.set_finding_state(request) @@ -14092,6 +14159,7 @@ def test_set_finding_state_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_finding_state(request) # Establish that the response is the type that we expect. @@ -14137,6 +14205,7 @@ def test_set_finding_state_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -14181,6 +14250,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -14214,6 +14284,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -14253,6 +14324,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -14297,6 +14369,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -14329,6 +14402,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -14367,6 +14441,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -14415,6 +14490,7 @@ def test_update_finding_rest_bad_request( 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_finding(request) @@ -14536,6 +14612,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -14581,6 +14658,7 @@ def test_update_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -14627,6 +14705,7 @@ def test_update_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -14744,6 +14823,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -14785,6 +14865,7 @@ def test_update_organization_settings_rest_interceptors(null_interceptor): 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 = gcs_organization_settings.OrganizationSettings.to_json( gcs_organization_settings.OrganizationSettings() ) @@ -14831,6 +14912,7 @@ def test_update_source_rest_bad_request( 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_source(request) @@ -14940,6 +15022,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -14982,6 +15065,7 @@ def test_update_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -15028,6 +15112,7 @@ def test_update_security_marks_rest_bad_request( 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_security_marks(request) @@ -15138,6 +15223,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_marks(request) # Establish that the response is the type that we expect. @@ -15178,6 +15264,7 @@ def test_update_security_marks_rest_interceptors(null_interceptor): 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 = gcs_security_marks.SecurityMarks.to_json( gcs_security_marks.SecurityMarks() ) diff --git a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1p1beta1/test_security_center.py b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1p1beta1/test_security_center.py index 7c130ddb8a90..dc96962e6107 100644 --- a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1p1beta1/test_security_center.py +++ b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v1p1beta1/test_security_center.py @@ -10363,6 +10363,7 @@ def test_create_source_rest_required_fields( response_value._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_source(request) @@ -10417,6 +10418,7 @@ def test_create_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -10558,6 +10560,7 @@ def test_create_finding_rest_required_fields( response_value._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_finding(request) @@ -10620,6 +10623,7 @@ def test_create_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -10768,6 +10772,7 @@ def test_create_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -10832,6 +10837,7 @@ def test_create_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -10969,6 +10975,7 @@ def test_delete_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -11012,6 +11019,7 @@ def test_delete_notification_config_rest_flattened(): 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"} client.delete_notification_config(**mock_args) @@ -11142,6 +11150,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -11185,6 +11194,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -11321,6 +11331,7 @@ def test_get_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -11366,6 +11377,7 @@ def test_get_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -11502,6 +11514,7 @@ def test_get_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -11547,6 +11560,7 @@ def test_get_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -11678,6 +11692,7 @@ def test_get_source_rest_required_fields( response_value._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_source(request) @@ -11723,6 +11738,7 @@ def test_get_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -11858,6 +11874,7 @@ def test_group_assets_rest_required_fields( response_value._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.group_assets(request) @@ -12053,6 +12070,7 @@ def test_group_findings_rest_required_fields( response_value._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.group_findings(request) @@ -12107,6 +12125,7 @@ def test_group_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.group_findings(**mock_args) @@ -12314,6 +12333,7 @@ def test_list_assets_rest_required_fields( response_value._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_assets(request) @@ -12372,6 +12392,7 @@ def test_list_assets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_assets(**mock_args) @@ -12580,6 +12601,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -12638,6 +12660,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_findings(**mock_args) @@ -12851,6 +12874,7 @@ def test_list_notification_configs_rest_required_fields( response_value._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_notification_configs(request) @@ -12906,6 +12930,7 @@ def test_list_notification_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_configs(**mock_args) @@ -13110,6 +13135,7 @@ def test_list_sources_rest_required_fields( response_value._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_sources(request) @@ -13163,6 +13189,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_sources(**mock_args) @@ -13362,6 +13389,7 @@ def test_run_asset_discovery_rest_required_fields( response_value._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.run_asset_discovery(request) @@ -13405,6 +13433,7 @@ def test_run_asset_discovery_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.run_asset_discovery(**mock_args) @@ -13539,6 +13568,7 @@ def test_set_finding_state_rest_required_fields( response_value._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.set_finding_state(request) @@ -13597,6 +13627,7 @@ def test_set_finding_state_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_finding_state(**mock_args) @@ -13729,6 +13760,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -13780,6 +13812,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -13918,6 +13951,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -13970,6 +14004,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -14100,6 +14135,7 @@ def test_update_finding_rest_required_fields( response_value._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_finding(request) @@ -14150,6 +14186,7 @@ def test_update_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -14285,6 +14322,7 @@ def test_update_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -14337,6 +14375,7 @@ def test_update_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -14476,6 +14515,7 @@ def test_update_organization_settings_rest_required_fields( response_value._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_organization_settings(request) @@ -14527,6 +14567,7 @@ def test_update_organization_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_settings(**mock_args) @@ -14658,6 +14699,7 @@ def test_update_source_rest_required_fields( response_value._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_source(request) @@ -14704,6 +14746,7 @@ def test_update_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -14844,6 +14887,7 @@ def test_update_security_marks_rest_required_fields( response_value._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_security_marks(request) @@ -14902,6 +14946,7 @@ def test_update_security_marks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_marks(**mock_args) @@ -16273,6 +16318,7 @@ def test_create_source_rest_bad_request( 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_source(request) @@ -16384,6 +16430,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -16427,6 +16474,7 @@ def test_create_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -16471,6 +16519,7 @@ def test_create_finding_rest_bad_request( 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_finding(request) @@ -16598,6 +16647,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -16645,6 +16695,7 @@ def test_create_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -16689,6 +16740,7 @@ def test_create_notification_config_rest_bad_request( 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_notification_config(request) @@ -16805,6 +16857,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -16852,6 +16905,7 @@ def test_create_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -16898,6 +16952,7 @@ def test_delete_notification_config_rest_bad_request( 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_notification_config(request) @@ -16928,6 +16983,7 @@ def test_delete_notification_config_rest_call_success(request_type): 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_notification_config(request) # Establish that the response is the type that we expect. @@ -16964,6 +17020,7 @@ def test_delete_notification_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteNotificationConfigRequest() metadata = [ @@ -17004,6 +17061,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -17037,6 +17095,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -17076,6 +17135,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -17120,6 +17180,7 @@ def test_get_notification_config_rest_bad_request( 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_notification_config(request) @@ -17159,6 +17220,7 @@ def test_get_notification_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -17205,6 +17267,7 @@ def test_get_notification_config_rest_interceptors(null_interceptor): 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 = notification_config.NotificationConfig.to_json( notification_config.NotificationConfig() ) @@ -17251,6 +17314,7 @@ def test_get_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -17287,6 +17351,7 @@ def test_get_organization_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -17328,6 +17393,7 @@ def test_get_organization_settings_rest_interceptors(null_interceptor): 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 = organization_settings.OrganizationSettings.to_json( organization_settings.OrganizationSettings() ) @@ -17374,6 +17440,7 @@ def test_get_source_rest_bad_request( 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_source(request) @@ -17412,6 +17479,7 @@ def test_get_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -17455,6 +17523,7 @@ def test_get_source_rest_interceptors(null_interceptor): 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 = source.Source.to_json(source.Source()) req.return_value.content = return_value @@ -17499,6 +17568,7 @@ def test_group_assets_rest_bad_request( 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.group_assets(request) @@ -17535,6 +17605,7 @@ def test_group_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_assets(request) # Establish that the response is the type that we expect. @@ -17576,6 +17647,7 @@ def test_group_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupAssetsResponse.to_json( securitycenter_service.GroupAssetsResponse() ) @@ -17622,6 +17694,7 @@ def test_group_findings_rest_bad_request( 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.group_findings(request) @@ -17658,6 +17731,7 @@ def test_group_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_findings(request) # Establish that the response is the type that we expect. @@ -17699,6 +17773,7 @@ def test_group_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupFindingsResponse.to_json( securitycenter_service.GroupFindingsResponse() ) @@ -17745,6 +17820,7 @@ def test_list_assets_rest_bad_request( 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_assets(request) @@ -17781,6 +17857,7 @@ def test_list_assets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_assets(request) # Establish that the response is the type that we expect. @@ -17822,6 +17899,7 @@ def test_list_assets_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListAssetsResponse.to_json( securitycenter_service.ListAssetsResponse() ) @@ -17868,6 +17946,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -17904,6 +17983,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -17945,6 +18025,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListFindingsResponse.to_json( securitycenter_service.ListFindingsResponse() ) @@ -17991,6 +18072,7 @@ def test_list_notification_configs_rest_bad_request( 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_notification_configs(request) @@ -18028,6 +18110,7 @@ def test_list_notification_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_configs(request) # Establish that the response is the type that we expect. @@ -18068,6 +18151,7 @@ def test_list_notification_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListNotificationConfigsResponse.to_json( securitycenter_service.ListNotificationConfigsResponse() ) @@ -18114,6 +18198,7 @@ def test_list_sources_rest_bad_request( 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_sources(request) @@ -18149,6 +18234,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_sources(request) # Establish that the response is the type that we expect. @@ -18189,6 +18275,7 @@ def test_list_sources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListSourcesResponse.to_json( securitycenter_service.ListSourcesResponse() ) @@ -18235,6 +18322,7 @@ def test_run_asset_discovery_rest_bad_request( 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.run_asset_discovery(request) @@ -18265,6 +18353,7 @@ def test_run_asset_discovery_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_asset_discovery(request) # Establish that the response is the type that we expect. @@ -18306,6 +18395,7 @@ def test_run_asset_discovery_rest_interceptors(null_interceptor): 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 @@ -18350,6 +18440,7 @@ def test_set_finding_state_rest_bad_request( 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.set_finding_state(request) @@ -18392,6 +18483,7 @@ def test_set_finding_state_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_finding_state(request) # Establish that the response is the type that we expect. @@ -18439,6 +18531,7 @@ def test_set_finding_state_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -18483,6 +18576,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -18516,6 +18610,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -18555,6 +18650,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -18599,6 +18695,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -18631,6 +18728,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -18669,6 +18767,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -18717,6 +18816,7 @@ def test_update_finding_rest_bad_request( 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_finding(request) @@ -18846,6 +18946,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -18893,6 +18994,7 @@ def test_update_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -18941,6 +19043,7 @@ def test_update_notification_config_rest_bad_request( 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_notification_config(request) @@ -19061,6 +19164,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -19108,6 +19212,7 @@ def test_update_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -19156,6 +19261,7 @@ def test_update_organization_settings_rest_bad_request( 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_organization_settings(request) @@ -19274,6 +19380,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_settings(request) # Establish that the response is the type that we expect. @@ -19315,6 +19422,7 @@ def test_update_organization_settings_rest_interceptors(null_interceptor): 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 = gcs_organization_settings.OrganizationSettings.to_json( gcs_organization_settings.OrganizationSettings() ) @@ -19361,6 +19469,7 @@ def test_update_source_rest_bad_request( 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_source(request) @@ -19472,6 +19581,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -19515,6 +19625,7 @@ def test_update_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -19561,6 +19672,7 @@ def test_update_security_marks_rest_bad_request( 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_security_marks(request) @@ -19673,6 +19785,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_marks(request) # Establish that the response is the type that we expect. @@ -19714,6 +19827,7 @@ def test_update_security_marks_rest_interceptors(null_interceptor): 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 = gcs_security_marks.SecurityMarks.to_json( gcs_security_marks.SecurityMarks() ) diff --git a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v2/test_security_center.py b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v2/test_security_center.py index 9742d10a54ee..0eecc5c1dda3 100644 --- a/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v2/test_security_center.py +++ b/packages/google-cloud-securitycenter/tests/unit/gapic/securitycenter_v2/test_security_center.py @@ -16977,6 +16977,7 @@ def test_batch_create_resource_value_configs_rest_required_fields( response_value._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.batch_create_resource_value_configs(request) @@ -17041,6 +17042,7 @@ def test_batch_create_resource_value_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_create_resource_value_configs(**mock_args) @@ -17185,6 +17187,7 @@ def test_bulk_mute_findings_rest_required_fields( response_value._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.bulk_mute_findings(request) @@ -17228,6 +17231,7 @@ def test_bulk_mute_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.bulk_mute_findings(**mock_args) @@ -17373,6 +17377,7 @@ def test_create_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -17435,6 +17440,7 @@ def test_create_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -17578,6 +17584,7 @@ def test_create_finding_rest_required_fields( response_value._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_finding(request) @@ -17642,6 +17649,7 @@ def test_create_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -17789,6 +17797,7 @@ def test_create_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -17851,6 +17860,7 @@ def test_create_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -17999,6 +18009,7 @@ def test_create_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -18063,6 +18074,7 @@ def test_create_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -18199,6 +18211,7 @@ def test_create_source_rest_required_fields( response_value._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_source(request) @@ -18253,6 +18266,7 @@ def test_create_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -18385,6 +18399,7 @@ def test_delete_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -18430,6 +18445,7 @@ def test_delete_big_query_export_rest_flattened(): 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"} client.delete_big_query_export(**mock_args) @@ -18562,6 +18578,7 @@ def test_delete_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -18605,6 +18622,7 @@ def test_delete_mute_config_rest_flattened(): 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"} client.delete_mute_config(**mock_args) @@ -18737,6 +18755,7 @@ def test_delete_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -18782,6 +18801,7 @@ def test_delete_notification_config_rest_flattened(): 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"} client.delete_notification_config(**mock_args) @@ -18915,6 +18935,7 @@ def test_delete_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -18958,6 +18979,7 @@ def test_delete_resource_value_config_rest_flattened(): 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"} client.delete_resource_value_config(**mock_args) @@ -19093,6 +19115,7 @@ def test_get_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -19140,6 +19163,7 @@ def test_get_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -19271,6 +19295,7 @@ def test_get_simulation_rest_required_fields( response_value._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_simulation(request) @@ -19316,6 +19341,7 @@ def test_get_simulation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_simulation(**mock_args) @@ -19450,6 +19476,7 @@ def test_get_valued_resource_rest_required_fields( response_value._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_valued_resource(request) @@ -19497,6 +19524,7 @@ def test_get_valued_resource_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_valued_resource(**mock_args) @@ -19627,6 +19655,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -19670,6 +19699,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -19801,6 +19831,7 @@ def test_get_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -19846,6 +19877,7 @@ def test_get_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -19981,6 +20013,7 @@ def test_get_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -20028,6 +20061,7 @@ def test_get_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -20164,6 +20198,7 @@ def test_get_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -20209,6 +20244,7 @@ def test_get_resource_value_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_config(**mock_args) @@ -20340,6 +20376,7 @@ def test_get_source_rest_required_fields( response_value._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_source(request) @@ -20385,6 +20422,7 @@ def test_get_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -20519,6 +20557,7 @@ def test_group_findings_rest_required_fields( response_value._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.group_findings(request) @@ -20573,6 +20612,7 @@ def test_group_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.group_findings(**mock_args) @@ -20780,6 +20820,7 @@ def test_list_attack_paths_rest_required_fields( response_value._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_attack_paths(request) @@ -20834,6 +20875,7 @@ def test_list_attack_paths_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attack_paths(**mock_args) @@ -21042,6 +21084,7 @@ def test_list_big_query_exports_rest_required_fields( response_value._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_big_query_exports(request) @@ -21097,6 +21140,7 @@ def test_list_big_query_exports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_exports(**mock_args) @@ -21302,6 +21346,7 @@ def test_list_findings_rest_required_fields( response_value._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_findings(request) @@ -21358,6 +21403,7 @@ def test_list_findings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_findings(**mock_args) @@ -21568,6 +21614,7 @@ def test_list_mute_configs_rest_required_fields( response_value._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_mute_configs(request) @@ -21621,6 +21668,7 @@ def test_list_mute_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_configs(**mock_args) @@ -21828,6 +21876,7 @@ def test_list_notification_configs_rest_required_fields( response_value._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_notification_configs(request) @@ -21883,6 +21932,7 @@ def test_list_notification_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_configs(**mock_args) @@ -22094,6 +22144,7 @@ def test_list_resource_value_configs_rest_required_fields( response_value._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_resource_value_configs(request) @@ -22149,6 +22200,7 @@ def test_list_resource_value_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_configs(**mock_args) @@ -22353,6 +22405,7 @@ def test_list_sources_rest_required_fields( response_value._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_sources(request) @@ -22406,6 +22459,7 @@ def test_list_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_sources(**mock_args) @@ -22614,6 +22668,7 @@ def test_list_valued_resources_rest_required_fields( response_value._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_valued_resources(request) @@ -22671,6 +22726,7 @@ def test_list_valued_resources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_valued_resources(**mock_args) @@ -22869,6 +22925,7 @@ def test_set_finding_state_rest_required_fields( response_value._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.set_finding_state(request) @@ -22925,6 +22982,7 @@ def test_set_finding_state_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_finding_state(**mock_args) @@ -23056,6 +23114,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -23107,6 +23166,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -23239,6 +23299,7 @@ def test_set_mute_rest_required_fields( response_value._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.set_mute(request) @@ -23295,6 +23356,7 @@ def test_set_mute_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_mute(**mock_args) @@ -23434,6 +23496,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -23486,6 +23549,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -23621,6 +23685,7 @@ def test_update_big_query_export_rest_required_fields( response_value._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_big_query_export(request) @@ -23671,6 +23736,7 @@ def test_update_big_query_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_big_query_export(**mock_args) @@ -23806,6 +23872,7 @@ def test_update_external_system_rest_required_fields( response_value._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_external_system(request) @@ -23856,6 +23923,7 @@ def test_update_external_system_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_system(**mock_args) @@ -23986,6 +24054,7 @@ def test_update_finding_rest_required_fields( response_value._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_finding(request) @@ -24036,6 +24105,7 @@ def test_update_finding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_finding(**mock_args) @@ -24170,6 +24240,7 @@ def test_update_mute_config_rest_required_fields( response_value._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_mute_config(request) @@ -24218,6 +24289,7 @@ def test_update_mute_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_mute_config(**mock_args) @@ -24353,6 +24425,7 @@ def test_update_notification_config_rest_required_fields( response_value._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_notification_config(request) @@ -24405,6 +24478,7 @@ def test_update_notification_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_notification_config(**mock_args) @@ -24544,6 +24618,7 @@ def test_update_resource_value_config_rest_required_fields( response_value._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_resource_value_config(request) @@ -24596,6 +24671,7 @@ def test_update_resource_value_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_resource_value_config(**mock_args) @@ -24733,6 +24809,7 @@ def test_update_security_marks_rest_required_fields( response_value._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_security_marks(request) @@ -24783,6 +24860,7 @@ def test_update_security_marks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_marks(**mock_args) @@ -24913,6 +24991,7 @@ def test_update_source_rest_required_fields( response_value._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_source(request) @@ -24959,6 +25038,7 @@ def test_update_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_source(**mock_args) @@ -28334,6 +28414,7 @@ def test_batch_create_resource_value_configs_rest_bad_request( 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.batch_create_resource_value_configs(request) @@ -28371,6 +28452,7 @@ def test_batch_create_resource_value_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_create_resource_value_configs(request) # Establish that the response is the type that we expect. @@ -28414,6 +28496,7 @@ def test_batch_create_resource_value_configs_rest_interceptors(null_interceptor) 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 = ( securitycenter_service.BatchCreateResourceValueConfigsResponse.to_json( securitycenter_service.BatchCreateResourceValueConfigsResponse() @@ -28464,6 +28547,7 @@ def test_bulk_mute_findings_rest_bad_request( 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.bulk_mute_findings(request) @@ -28494,6 +28578,7 @@ def test_bulk_mute_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.bulk_mute_findings(request) # Establish that the response is the type that we expect. @@ -28535,6 +28620,7 @@ def test_bulk_mute_findings_rest_interceptors(null_interceptor): 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 @@ -28579,6 +28665,7 @@ def test_create_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -28698,6 +28785,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -28743,6 +28831,7 @@ def test_create_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -28789,6 +28878,7 @@ def test_create_finding_rest_bad_request( 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_finding(request) @@ -29225,6 +29315,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -29279,6 +29370,7 @@ def test_create_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -29323,6 +29415,7 @@ def test_create_mute_config_rest_bad_request( 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_mute_config(request) @@ -29441,6 +29534,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -29485,6 +29579,7 @@ def test_create_mute_config_rest_interceptors(null_interceptor): 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 = gcs_mute_config.MuteConfig.to_json(gcs_mute_config.MuteConfig()) req.return_value.content = return_value @@ -29529,6 +29624,7 @@ def test_create_notification_config_rest_bad_request( 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_notification_config(request) @@ -29643,6 +29739,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -29686,6 +29783,7 @@ def test_create_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -29732,6 +29830,7 @@ def test_create_source_rest_bad_request( 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_source(request) @@ -29843,6 +29942,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -29886,6 +29986,7 @@ def test_create_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -29932,6 +30033,7 @@ def test_delete_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -29964,6 +30066,7 @@ def test_delete_big_query_export_rest_call_success(request_type): 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_big_query_export(request) # Establish that the response is the type that we expect. @@ -30000,6 +30103,7 @@ def test_delete_big_query_export_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteBigQueryExportRequest() metadata = [ @@ -30040,6 +30144,7 @@ def test_delete_mute_config_rest_bad_request( 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_mute_config(request) @@ -30070,6 +30175,7 @@ def test_delete_mute_config_rest_call_success(request_type): 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_mute_config(request) # Establish that the response is the type that we expect. @@ -30106,6 +30212,7 @@ def test_delete_mute_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteMuteConfigRequest() metadata = [ @@ -30148,6 +30255,7 @@ def test_delete_notification_config_rest_bad_request( 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_notification_config(request) @@ -30180,6 +30288,7 @@ def test_delete_notification_config_rest_call_success(request_type): 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_notification_config(request) # Establish that the response is the type that we expect. @@ -30216,6 +30325,7 @@ def test_delete_notification_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteNotificationConfigRequest() metadata = [ @@ -30256,6 +30366,7 @@ def test_delete_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -30286,6 +30397,7 @@ def test_delete_resource_value_config_rest_call_success(request_type): 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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -30322,6 +30434,7 @@ def test_delete_resource_value_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = securitycenter_service.DeleteResourceValueConfigRequest() metadata = [ @@ -30364,6 +30477,7 @@ def test_get_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -30406,6 +30520,7 @@ def test_get_big_query_export_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -30451,6 +30566,7 @@ def test_get_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -30497,6 +30613,7 @@ def test_get_simulation_rest_bad_request( 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_simulation(request) @@ -30533,6 +30650,7 @@ def test_get_simulation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_simulation(request) # Establish that the response is the type that we expect. @@ -30574,6 +30692,7 @@ def test_get_simulation_rest_interceptors(null_interceptor): 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 = simulation.Simulation.to_json(simulation.Simulation()) req.return_value.content = return_value @@ -30620,6 +30739,7 @@ def test_get_valued_resource_rest_bad_request( 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_valued_resource(request) @@ -30662,6 +30782,7 @@ def test_get_valued_resource_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_valued_resource(request) # Establish that the response is the type that we expect. @@ -30710,6 +30831,7 @@ def test_get_valued_resource_rest_interceptors(null_interceptor): 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 = valued_resource.ValuedResource.to_json( valued_resource.ValuedResource() ) @@ -30756,6 +30878,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -30789,6 +30912,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -30828,6 +30952,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -30872,6 +30997,7 @@ def test_get_mute_config_rest_bad_request( 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_mute_config(request) @@ -30911,6 +31037,7 @@ def test_get_mute_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -30955,6 +31082,7 @@ def test_get_mute_config_rest_interceptors(null_interceptor): 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 = mute_config.MuteConfig.to_json(mute_config.MuteConfig()) req.return_value.content = return_value @@ -31001,6 +31129,7 @@ def test_get_notification_config_rest_bad_request( 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_notification_config(request) @@ -31041,6 +31170,7 @@ def test_get_notification_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -31084,6 +31214,7 @@ def test_get_notification_config_rest_interceptors(null_interceptor): 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 = notification_config.NotificationConfig.to_json( notification_config.NotificationConfig() ) @@ -31130,6 +31261,7 @@ def test_get_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -31171,6 +31303,7 @@ def test_get_resource_value_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -31217,6 +31350,7 @@ def test_get_resource_value_config_rest_interceptors(null_interceptor): 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 = resource_value_config.ResourceValueConfig.to_json( resource_value_config.ResourceValueConfig() ) @@ -31263,6 +31397,7 @@ def test_get_source_rest_bad_request( 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_source(request) @@ -31301,6 +31436,7 @@ def test_get_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -31344,6 +31480,7 @@ def test_get_source_rest_interceptors(null_interceptor): 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 = source.Source.to_json(source.Source()) req.return_value.content = return_value @@ -31388,6 +31525,7 @@ def test_group_findings_rest_bad_request( 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.group_findings(request) @@ -31424,6 +31562,7 @@ def test_group_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.group_findings(request) # Establish that the response is the type that we expect. @@ -31465,6 +31604,7 @@ def test_group_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.GroupFindingsResponse.to_json( securitycenter_service.GroupFindingsResponse() ) @@ -31511,6 +31651,7 @@ def test_list_attack_paths_rest_bad_request( 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_attack_paths(request) @@ -31546,6 +31687,7 @@ def test_list_attack_paths_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attack_paths(request) # Establish that the response is the type that we expect. @@ -31586,6 +31728,7 @@ def test_list_attack_paths_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListAttackPathsResponse.to_json( securitycenter_service.ListAttackPathsResponse() ) @@ -31632,6 +31775,7 @@ def test_list_big_query_exports_rest_bad_request( 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_big_query_exports(request) @@ -31669,6 +31813,7 @@ def test_list_big_query_exports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_exports(request) # Establish that the response is the type that we expect. @@ -31709,6 +31854,7 @@ def test_list_big_query_exports_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListBigQueryExportsResponse.to_json( securitycenter_service.ListBigQueryExportsResponse() ) @@ -31755,6 +31901,7 @@ def test_list_findings_rest_bad_request( 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_findings(request) @@ -31791,6 +31938,7 @@ def test_list_findings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_findings(request) # Establish that the response is the type that we expect. @@ -31832,6 +31980,7 @@ def test_list_findings_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListFindingsResponse.to_json( securitycenter_service.ListFindingsResponse() ) @@ -31878,6 +32027,7 @@ def test_list_mute_configs_rest_bad_request( 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_mute_configs(request) @@ -31913,6 +32063,7 @@ def test_list_mute_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_configs(request) # Establish that the response is the type that we expect. @@ -31953,6 +32104,7 @@ def test_list_mute_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListMuteConfigsResponse.to_json( securitycenter_service.ListMuteConfigsResponse() ) @@ -31999,6 +32151,7 @@ def test_list_notification_configs_rest_bad_request( 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_notification_configs(request) @@ -32036,6 +32189,7 @@ def test_list_notification_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_configs(request) # Establish that the response is the type that we expect. @@ -32076,6 +32230,7 @@ def test_list_notification_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListNotificationConfigsResponse.to_json( securitycenter_service.ListNotificationConfigsResponse() ) @@ -32122,6 +32277,7 @@ def test_list_resource_value_configs_rest_bad_request( 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_resource_value_configs(request) @@ -32159,6 +32315,7 @@ def test_list_resource_value_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_configs(request) # Establish that the response is the type that we expect. @@ -32199,6 +32356,7 @@ def test_list_resource_value_configs_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListResourceValueConfigsResponse.to_json( securitycenter_service.ListResourceValueConfigsResponse() ) @@ -32245,6 +32403,7 @@ def test_list_sources_rest_bad_request( 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_sources(request) @@ -32280,6 +32439,7 @@ def test_list_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_sources(request) # Establish that the response is the type that we expect. @@ -32320,6 +32480,7 @@ def test_list_sources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListSourcesResponse.to_json( securitycenter_service.ListSourcesResponse() ) @@ -32366,6 +32527,7 @@ def test_list_valued_resources_rest_bad_request( 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_valued_resources(request) @@ -32404,6 +32566,7 @@ def test_list_valued_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_valued_resources(request) # Establish that the response is the type that we expect. @@ -32445,6 +32608,7 @@ def test_list_valued_resources_rest_interceptors(null_interceptor): 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 = securitycenter_service.ListValuedResourcesResponse.to_json( securitycenter_service.ListValuedResourcesResponse() ) @@ -32491,6 +32655,7 @@ def test_set_finding_state_rest_bad_request( 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.set_finding_state(request) @@ -32540,6 +32705,7 @@ def test_set_finding_state_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_finding_state(request) # Establish that the response is the type that we expect. @@ -32594,6 +32760,7 @@ def test_set_finding_state_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -32638,6 +32805,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -32671,6 +32839,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -32710,6 +32879,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -32752,6 +32922,7 @@ def test_set_mute_rest_bad_request(request_type=securitycenter_service.SetMuteRe 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.set_mute(request) @@ -32801,6 +32972,7 @@ def test_set_mute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_mute(request) # Establish that the response is the type that we expect. @@ -32855,6 +33027,7 @@ def test_set_mute_rest_interceptors(null_interceptor): 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 = finding.Finding.to_json(finding.Finding()) req.return_value.content = return_value @@ -32899,6 +33072,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -32931,6 +33105,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -32969,6 +33144,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -33019,6 +33195,7 @@ def test_update_big_query_export_rest_bad_request( 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_big_query_export(request) @@ -33142,6 +33319,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_big_query_export(request) # Establish that the response is the type that we expect. @@ -33187,6 +33365,7 @@ def test_update_big_query_export_rest_interceptors(null_interceptor): 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 = bigquery_export.BigQueryExport.to_json( bigquery_export.BigQueryExport() ) @@ -33237,6 +33416,7 @@ def test_update_external_system_rest_bad_request( 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_external_system(request) @@ -33370,6 +33550,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_system(request) # Establish that the response is the type that we expect. @@ -33415,6 +33596,7 @@ def test_update_external_system_rest_interceptors(null_interceptor): 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 = gcs_external_system.ExternalSystem.to_json( gcs_external_system.ExternalSystem() ) @@ -33463,6 +33645,7 @@ def test_update_finding_rest_bad_request( 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_finding(request) @@ -33901,6 +34084,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_finding(request) # Establish that the response is the type that we expect. @@ -33955,6 +34139,7 @@ def test_update_finding_rest_interceptors(null_interceptor): 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 = gcs_finding.Finding.to_json(gcs_finding.Finding()) req.return_value.content = return_value @@ -34001,6 +34186,7 @@ def test_update_mute_config_rest_bad_request( 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_mute_config(request) @@ -34121,6 +34307,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_mute_config(request) # Establish that the response is the type that we expect. @@ -34165,6 +34352,7 @@ def test_update_mute_config_rest_interceptors(null_interceptor): 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 = gcs_mute_config.MuteConfig.to_json(gcs_mute_config.MuteConfig()) req.return_value.content = return_value @@ -34213,6 +34401,7 @@ def test_update_notification_config_rest_bad_request( 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_notification_config(request) @@ -34331,6 +34520,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_notification_config(request) # Establish that the response is the type that we expect. @@ -34374,6 +34564,7 @@ def test_update_notification_config_rest_interceptors(null_interceptor): 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 = gcs_notification_config.NotificationConfig.to_json( gcs_notification_config.NotificationConfig() ) @@ -34424,6 +34615,7 @@ def test_update_resource_value_config_rest_bad_request( 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_resource_value_config(request) @@ -34556,6 +34748,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_resource_value_config(request) # Establish that the response is the type that we expect. @@ -34602,6 +34795,7 @@ def test_update_resource_value_config_rest_interceptors(null_interceptor): 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 = gcs_resource_value_config.ResourceValueConfig.to_json( gcs_resource_value_config.ResourceValueConfig() ) @@ -34652,6 +34846,7 @@ def test_update_security_marks_rest_bad_request( 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_security_marks(request) @@ -34766,6 +34961,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_marks(request) # Establish that the response is the type that we expect. @@ -34807,6 +35003,7 @@ def test_update_security_marks_rest_interceptors(null_interceptor): 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 = gcs_security_marks.SecurityMarks.to_json( gcs_security_marks.SecurityMarks() ) @@ -34853,6 +35050,7 @@ def test_update_source_rest_bad_request( 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_source(request) @@ -34964,6 +35162,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_source(request) # Establish that the response is the type that we expect. @@ -35007,6 +35206,7 @@ def test_update_source_rest_interceptors(null_interceptor): 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 = gcs_source.Source.to_json(gcs_source.Source()) req.return_value.content = return_value @@ -35053,6 +35253,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -35083,6 +35284,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -35113,6 +35315,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -35143,6 +35346,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -35173,6 +35377,7 @@ def test_get_operation_rest_bad_request( 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) @@ -35203,6 +35408,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -35233,6 +35439,7 @@ def test_list_operations_rest_bad_request( 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) @@ -35263,6 +35470,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py index cf4cc395ad87..558c8aab67c5 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.17" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py index cf4cc395ad87..558c8aab67c5 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.17" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py index 3028722cbfd5..45e932b1b809 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SecurityCenterManagementTransport from .transports.grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport +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 SecurityCenterManagementAsyncClient: """Service describing handlers for resources""" @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient`.", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "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.securitycentermanagement.v1.SecurityCenterManagement", + "credentialsType": None, + }, + ) + async def list_effective_security_health_analytics_custom_modules( self, request: Optional[ @@ -313,7 +345,7 @@ async def list_effective_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all [EffectiveSecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.EffectiveSecurityHealthAnalyticsCustomModule] @@ -367,8 +399,10 @@ async def sample_list_effective_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -453,7 +487,7 @@ async def get_effective_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: r"""Gets details of a single [EffectiveSecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.EffectiveSecurityHealthAnalyticsCustomModule]. @@ -502,8 +536,10 @@ async def sample_get_effective_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: @@ -582,7 +618,7 @@ async def list_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -637,8 +673,10 @@ async def sample_list_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -723,7 +761,7 @@ async def list_descendant_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: r"""Returns a list of all resident [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -776,8 +814,10 @@ async def sample_list_descendant_security_health_analytics_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: @@ -862,7 +902,7 @@ async def get_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Retrieves a [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule]. @@ -907,8 +947,10 @@ async def sample_get_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -990,7 +1032,7 @@ async def create_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Creates a resident [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1048,8 +1090,10 @@ async def sample_create_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1135,7 +1179,7 @@ async def update_security_health_analytics_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Updates the [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1195,8 +1239,10 @@ async def sample_update_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1288,7 +1334,7 @@ async def delete_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1336,8 +1382,10 @@ async def sample_delete_security_health_analytics_custom_module(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1403,7 +1451,7 @@ async def simulate_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: r"""Simulates the result of using a [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1471,8 +1519,10 @@ async def sample_simulate_security_health_analytics_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -1547,7 +1597,7 @@ async def list_effective_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: r"""Lists all effective Event Threat Detection custom modules for the given parent. This includes resident @@ -1599,8 +1649,10 @@ async def sample_list_effective_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: @@ -1685,7 +1737,7 @@ async def get_effective_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: r"""Gets the effective Event Threat Detection custom module at the given level. @@ -1747,8 +1799,10 @@ async def sample_get_effective_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: @@ -1827,7 +1881,7 @@ async def list_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesAsyncPager: r"""Lists all Event Threat Detection custom modules for the given organization, folder, or project. This @@ -1879,8 +1933,10 @@ async def sample_list_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager: @@ -1967,7 +2023,7 @@ async def list_descendant_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: r"""Lists all resident Event Threat Detection custom modules for the given organization, folder, or project @@ -2018,8 +2074,10 @@ async def sample_list_descendant_event_threat_detection_custom_modules(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: @@ -2104,7 +2162,7 @@ async def get_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Gets an Event Threat Detection custom module. @@ -2153,8 +2211,10 @@ async def sample_get_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2234,7 +2294,7 @@ async def create_event_threat_detection_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Creates a resident Event Threat Detection custom module at the scope of the given organization, folder, @@ -2295,8 +2355,10 @@ async def sample_create_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2378,7 +2440,7 @@ async def update_event_threat_detection_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Updates the Event Threat Detection custom module with the given name based on the given update mask. Updating @@ -2433,8 +2495,10 @@ async def sample_update_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2520,7 +2584,7 @@ async def delete_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified Event Threat Detection custom module and all of its descendants in the resource @@ -2569,8 +2633,10 @@ async def sample_delete_event_threat_detection_custom_module(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2631,7 +2697,7 @@ async def validate_event_threat_detection_custom_module( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: r"""Validates the given Event Threat Detection custom module. @@ -2671,8 +2737,10 @@ async def sample_validate_event_threat_detection_custom_module(): 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, 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: google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: @@ -2726,7 +2794,7 @@ async def get_security_center_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Gets service settings for the specified Security Command Center service. @@ -2783,8 +2851,10 @@ async def sample_get_security_center_service(): 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, 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: google.cloud.securitycentermanagement_v1.types.SecurityCenterService: @@ -2859,7 +2929,7 @@ async def list_security_center_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityCenterServicesAsyncPager: r"""Returns a list of all Security Command Center services for the given parent. @@ -2910,8 +2980,10 @@ async def sample_list_security_center_services(): 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, 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityCenterServicesAsyncPager: @@ -2995,7 +3067,7 @@ async def update_security_center_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Updates a Security Command Center service using the given update mask. @@ -3049,8 +3121,10 @@ async def sample_update_security_center_service(): 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, 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: google.cloud.securitycentermanagement_v1.types.SecurityCenterService: @@ -3131,7 +3205,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3142,8 +3216,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -3184,7 +3260,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3195,8 +3271,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py index ffbea0ec47f3..51252e3057e5 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -709,6 +719,10 @@ def __init__( # 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( @@ -775,6 +789,29 @@ def __init__( 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.securitycentermanagement_v1.SecurityCenterManagementClient`.", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "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.securitycentermanagement.v1.SecurityCenterManagement", + "credentialsType": None, + }, + ) + def list_effective_security_health_analytics_custom_modules( self, request: Optional[ @@ -787,7 +824,7 @@ def list_effective_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all [EffectiveSecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.EffectiveSecurityHealthAnalyticsCustomModule] @@ -841,8 +878,10 @@ def sample_list_effective_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: @@ -926,7 +965,7 @@ def get_effective_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: r"""Gets details of a single [EffectiveSecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.EffectiveSecurityHealthAnalyticsCustomModule]. @@ -975,8 +1014,10 @@ def sample_get_effective_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: @@ -1054,7 +1095,7 @@ def list_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1109,8 +1150,10 @@ def sample_list_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager: @@ -1194,7 +1237,7 @@ def list_descendant_security_health_analytics_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: r"""Returns a list of all resident [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1247,8 +1290,10 @@ def sample_list_descendant_security_health_analytics_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: @@ -1332,7 +1377,7 @@ def get_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Retrieves a [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule]. @@ -1377,8 +1422,10 @@ def sample_get_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1459,7 +1506,7 @@ def create_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Creates a resident [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1517,8 +1564,10 @@ def sample_create_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1603,7 +1652,7 @@ def update_security_health_analytics_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Updates the [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1663,8 +1712,10 @@ def sample_update_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: @@ -1755,7 +1806,7 @@ def delete_security_health_analytics_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1803,8 +1854,10 @@ def sample_delete_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1869,7 +1922,7 @@ def simulate_security_health_analytics_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: r"""Simulates the result of using a [SecurityHealthAnalyticsCustomModule][google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule] @@ -1937,8 +1990,10 @@ def sample_simulate_security_health_analytics_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -2012,7 +2067,7 @@ def list_effective_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesPager: r"""Lists all effective Event Threat Detection custom modules for the given parent. This includes resident @@ -2064,8 +2119,10 @@ def sample_list_effective_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager: @@ -2149,7 +2206,7 @@ def get_effective_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: r"""Gets the effective Event Threat Detection custom module at the given level. @@ -2211,8 +2268,10 @@ def sample_get_effective_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: @@ -2290,7 +2349,7 @@ def list_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesPager: r"""Lists all Event Threat Detection custom modules for the given organization, folder, or project. This @@ -2342,8 +2401,10 @@ def sample_list_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager: @@ -2429,7 +2490,7 @@ def list_descendant_event_threat_detection_custom_modules( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesPager: r"""Lists all resident Event Threat Detection custom modules for the given organization, folder, or project @@ -2480,8 +2541,10 @@ def sample_list_descendant_event_threat_detection_custom_modules(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager: @@ -2565,7 +2628,7 @@ def get_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Gets an Event Threat Detection custom module. @@ -2614,8 +2677,10 @@ def sample_get_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2694,7 +2759,7 @@ def create_event_threat_detection_custom_module( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Creates a resident Event Threat Detection custom module at the scope of the given organization, folder, @@ -2755,8 +2820,10 @@ def sample_create_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2837,7 +2904,7 @@ def update_event_threat_detection_custom_module( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Updates the Event Threat Detection custom module with the given name based on the given update mask. Updating @@ -2892,8 +2959,10 @@ def sample_update_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: @@ -2978,7 +3047,7 @@ def delete_event_threat_detection_custom_module( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified Event Threat Detection custom module and all of its descendants in the resource @@ -3027,8 +3096,10 @@ def sample_delete_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3088,7 +3159,7 @@ def validate_event_threat_detection_custom_module( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: r"""Validates the given Event Threat Detection custom module. @@ -3128,8 +3199,10 @@ def sample_validate_event_threat_detection_custom_module(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: @@ -3183,7 +3256,7 @@ def get_security_center_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Gets service settings for the specified Security Command Center service. @@ -3240,8 +3313,10 @@ def sample_get_security_center_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SecurityCenterService: @@ -3315,7 +3390,7 @@ def list_security_center_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSecurityCenterServicesPager: r"""Returns a list of all Security Command Center services for the given parent. @@ -3366,8 +3441,10 @@ def sample_list_security_center_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityCenterServicesPager: @@ -3450,7 +3527,7 @@ def update_security_center_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Updates a Security Command Center service using the given update mask. @@ -3504,8 +3581,10 @@ def sample_update_security_center_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.securitycentermanagement_v1.types.SecurityCenterService: @@ -3598,7 +3677,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3609,8 +3688,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -3651,7 +3732,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3662,8 +3743,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py index 3b50071becf0..f870cf96fdf7 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py @@ -70,7 +70,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -84,8 +84,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( @@ -159,7 +161,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -173,8 +175,10 @@ def __init__( 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, 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`. """ self._method = method self._request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( @@ -250,7 +254,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -264,8 +268,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -339,7 +345,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -353,8 +359,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -430,7 +438,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -444,8 +452,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( @@ -517,7 +527,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -531,8 +541,10 @@ def __init__( 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, 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`. """ self._method = method self._request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( @@ -606,7 +618,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -620,8 +632,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest( @@ -693,7 +707,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -707,8 +721,10 @@ def __init__( 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, 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`. """ self._method = method self._request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest( @@ -784,7 +800,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -798,8 +814,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -873,7 +891,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -887,8 +905,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -964,7 +984,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -978,8 +998,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest( @@ -1051,7 +1073,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1065,8 +1087,10 @@ def __init__( 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, 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`. """ self._method = method self._request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest( @@ -1139,7 +1163,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1153,8 +1177,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = security_center_management.ListSecurityCenterServicesRequest( @@ -1220,7 +1246,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1234,8 +1260,10 @@ def __init__( 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, 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`. """ self._method = method self._request = security_center_management.ListSecurityCenterServicesRequest( diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py index f24defbee76b..981282b41cb8 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.securitycentermanagement_v1.types import security_center_management from .base import DEFAULT_CLIENT_INFO, SecurityCenterManagementTransport +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.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": 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.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterManagementGrpcTransport(SecurityCenterManagementTransport): """gRPC backend transport for SecurityCenterManagement. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +354,7 @@ def list_effective_security_health_analytics_custom_modules( if "list_effective_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_effective_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -303,7 +389,7 @@ def get_effective_security_health_analytics_custom_module( if "get_effective_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_effective_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, @@ -340,7 +426,7 @@ def list_security_health_analytics_custom_modules( if "list_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -380,7 +466,7 @@ def list_descendant_security_health_analytics_custom_modules( ): self._stubs[ "list_descendant_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -413,7 +499,7 @@ def get_security_health_analytics_custom_module( if "get_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -450,7 +536,7 @@ def create_security_health_analytics_custom_module( if "create_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "create_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -488,7 +574,7 @@ def update_security_health_analytics_custom_module( if "update_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "update_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -523,7 +609,7 @@ def delete_security_health_analytics_custom_module( if "delete_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "delete_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -557,7 +643,7 @@ def simulate_security_health_analytics_custom_module( if "simulate_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "simulate_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, @@ -594,7 +680,7 @@ def list_effective_event_threat_detection_custom_modules( if "list_effective_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_effective_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules", request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, @@ -641,7 +727,7 @@ def get_effective_event_threat_detection_custom_module( if "get_effective_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_effective_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule", request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, @@ -676,7 +762,7 @@ def list_event_threat_detection_custom_modules( if "list_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules", request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, @@ -712,7 +798,7 @@ def list_descendant_event_threat_detection_custom_modules( if "list_descendant_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_descendant_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules", request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, @@ -744,7 +830,7 @@ def get_event_threat_detection_custom_module( if "get_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule", request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -780,7 +866,7 @@ def create_event_threat_detection_custom_module( if "create_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "create_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule", request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -819,7 +905,7 @@ def update_event_threat_detection_custom_module( if "update_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "update_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule", request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -854,7 +940,7 @@ def delete_event_threat_detection_custom_module( if "delete_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "delete_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule", request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -887,7 +973,7 @@ def validate_event_threat_detection_custom_module( if "validate_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "validate_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule", request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, @@ -917,7 +1003,9 @@ def get_security_center_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_security_center_service" not in self._stubs: - self._stubs["get_security_center_service"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_security_center_service" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityCenterService", request_serializer=security_center_management.GetSecurityCenterServiceRequest.serialize, response_deserializer=security_center_management.SecurityCenterService.deserialize, @@ -949,7 +1037,7 @@ def list_security_center_services( if "list_security_center_services" not in self._stubs: self._stubs[ "list_security_center_services" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityCenterServices", request_serializer=security_center_management.ListSecurityCenterServicesRequest.serialize, response_deserializer=security_center_management.ListSecurityCenterServicesResponse.deserialize, @@ -981,7 +1069,7 @@ def update_security_center_service( if "update_security_center_service" not in self._stubs: self._stubs[ "update_security_center_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityCenterService", request_serializer=security_center_management.UpdateSecurityCenterServiceRequest.serialize, response_deserializer=security_center_management.SecurityCenterService.deserialize, @@ -989,7 +1077,7 @@ def update_security_center_service( return self._stubs["update_security_center_service"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -1003,7 +1091,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1020,7 +1108,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py index 4d376db16761..2459f3fd51a1 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.securitycentermanagement_v1.types import security_center_management from .base import DEFAULT_CLIENT_INFO, SecurityCenterManagementTransport from .grpc import SecurityCenterManagementGrpcTransport +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.securitycentermanagement.v1.SecurityCenterManagement", + "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.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SecurityCenterManagementGrpcAsyncIOTransport(SecurityCenterManagementTransport): """gRPC AsyncIO backend transport for SecurityCenterManagement. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -278,7 +363,7 @@ def list_effective_security_health_analytics_custom_modules( if "list_effective_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_effective_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -315,7 +400,7 @@ def get_effective_security_health_analytics_custom_module( if "get_effective_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_effective_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, @@ -354,7 +439,7 @@ def list_security_health_analytics_custom_modules( if "list_security_health_analytics_custom_modules" not in self._stubs: self._stubs[ "list_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -396,7 +481,7 @@ def list_descendant_security_health_analytics_custom_modules( ): self._stubs[ "list_descendant_security_health_analytics_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules", request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, @@ -429,7 +514,7 @@ def get_security_health_analytics_custom_module( if "get_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "get_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -466,7 +551,7 @@ def create_security_health_analytics_custom_module( if "create_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "create_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -504,7 +589,7 @@ def update_security_health_analytics_custom_module( if "update_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "update_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, @@ -539,7 +624,7 @@ def delete_security_health_analytics_custom_module( if "delete_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "delete_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -575,7 +660,7 @@ def simulate_security_health_analytics_custom_module( if "simulate_security_health_analytics_custom_module" not in self._stubs: self._stubs[ "simulate_security_health_analytics_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule", request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, @@ -614,7 +699,7 @@ def list_effective_event_threat_detection_custom_modules( if "list_effective_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_effective_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules", request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, @@ -661,7 +746,7 @@ def get_effective_event_threat_detection_custom_module( if "get_effective_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_effective_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule", request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, @@ -698,7 +783,7 @@ def list_event_threat_detection_custom_modules( if "list_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules", request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, @@ -736,7 +821,7 @@ def list_descendant_event_threat_detection_custom_modules( if "list_descendant_event_threat_detection_custom_modules" not in self._stubs: self._stubs[ "list_descendant_event_threat_detection_custom_modules" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules", request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, @@ -768,7 +853,7 @@ def get_event_threat_detection_custom_module( if "get_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "get_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule", request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -804,7 +889,7 @@ def create_event_threat_detection_custom_module( if "create_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "create_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule", request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -843,7 +928,7 @@ def update_event_threat_detection_custom_module( if "update_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "update_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule", request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, @@ -878,7 +963,7 @@ def delete_event_threat_detection_custom_module( if "delete_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "delete_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule", request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -913,7 +998,7 @@ def validate_event_threat_detection_custom_module( if "validate_event_threat_detection_custom_module" not in self._stubs: self._stubs[ "validate_event_threat_detection_custom_module" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule", request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, @@ -943,7 +1028,9 @@ def get_security_center_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_security_center_service" not in self._stubs: - self._stubs["get_security_center_service"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_security_center_service" + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityCenterService", request_serializer=security_center_management.GetSecurityCenterServiceRequest.serialize, response_deserializer=security_center_management.SecurityCenterService.deserialize, @@ -975,7 +1062,7 @@ def list_security_center_services( if "list_security_center_services" not in self._stubs: self._stubs[ "list_security_center_services" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityCenterServices", request_serializer=security_center_management.ListSecurityCenterServicesRequest.serialize, response_deserializer=security_center_management.ListSecurityCenterServicesResponse.deserialize, @@ -1007,7 +1094,7 @@ def update_security_center_service( if "update_security_center_service" not in self._stubs: self._stubs[ "update_security_center_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityCenterService", request_serializer=security_center_management.UpdateSecurityCenterServiceRequest.serialize, response_deserializer=security_center_management.SecurityCenterService.deserialize, @@ -1260,7 +1347,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1278,7 +1365,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1295,7 +1382,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py index 750c72a082f5..46c9a45b4e5c 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -231,10 +239,10 @@ def post_validate_event_threat_detection_custom_module(self, response): def pre_create_event_threat_detection_custom_module( self, request: security_center_management.CreateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.CreateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_event_threat_detection_custom_module @@ -257,10 +265,10 @@ def post_create_event_threat_detection_custom_module( def pre_create_security_health_analytics_custom_module( self, request: security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_security_health_analytics_custom_module @@ -283,10 +291,10 @@ def post_create_security_health_analytics_custom_module( def pre_delete_event_threat_detection_custom_module( self, request: security_center_management.DeleteEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.DeleteEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_event_threat_detection_custom_module @@ -298,10 +306,10 @@ def pre_delete_event_threat_detection_custom_module( def pre_delete_security_health_analytics_custom_module( self, request: security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_security_health_analytics_custom_module @@ -313,10 +321,10 @@ def pre_delete_security_health_analytics_custom_module( def pre_get_effective_event_threat_detection_custom_module( self, request: security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_effective_event_threat_detection_custom_module @@ -340,10 +348,10 @@ def post_get_effective_event_threat_detection_custom_module( def pre_get_effective_security_health_analytics_custom_module( self, request: security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_effective_security_health_analytics_custom_module @@ -367,10 +375,10 @@ def post_get_effective_security_health_analytics_custom_module( def pre_get_event_threat_detection_custom_module( self, request: security_center_management.GetEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.GetEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_event_threat_detection_custom_module @@ -393,10 +401,10 @@ def post_get_event_threat_detection_custom_module( def pre_get_security_center_service( self, request: security_center_management.GetSecurityCenterServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.GetSecurityCenterServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_security_center_service @@ -419,10 +427,10 @@ def post_get_security_center_service( def pre_get_security_health_analytics_custom_module( self, request: security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_security_health_analytics_custom_module @@ -445,10 +453,10 @@ def post_get_security_health_analytics_custom_module( def pre_list_descendant_event_threat_detection_custom_modules( self, request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_descendant_event_threat_detection_custom_modules @@ -474,10 +482,10 @@ def post_list_descendant_event_threat_detection_custom_modules( def pre_list_descendant_security_health_analytics_custom_modules( self, request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_descendant_security_health_analytics_custom_modules @@ -503,10 +511,10 @@ def post_list_descendant_security_health_analytics_custom_modules( def pre_list_effective_event_threat_detection_custom_modules( self, request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_effective_event_threat_detection_custom_modules @@ -532,10 +540,10 @@ def post_list_effective_event_threat_detection_custom_modules( def pre_list_effective_security_health_analytics_custom_modules( self, request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_effective_security_health_analytics_custom_modules @@ -561,10 +569,10 @@ def post_list_effective_security_health_analytics_custom_modules( def pre_list_event_threat_detection_custom_modules( self, request: security_center_management.ListEventThreatDetectionCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListEventThreatDetectionCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_event_threat_detection_custom_modules @@ -588,10 +596,10 @@ def post_list_event_threat_detection_custom_modules( def pre_list_security_center_services( self, request: security_center_management.ListSecurityCenterServicesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListSecurityCenterServicesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_security_center_services @@ -614,10 +622,10 @@ def post_list_security_center_services( def pre_list_security_health_analytics_custom_modules( self, request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_security_health_analytics_custom_modules @@ -641,10 +649,10 @@ def post_list_security_health_analytics_custom_modules( def pre_simulate_security_health_analytics_custom_module( self, request: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for simulate_security_health_analytics_custom_module @@ -668,10 +676,10 @@ def post_simulate_security_health_analytics_custom_module( def pre_update_event_threat_detection_custom_module( self, request: security_center_management.UpdateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.UpdateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_event_threat_detection_custom_module @@ -694,10 +702,10 @@ def post_update_event_threat_detection_custom_module( def pre_update_security_center_service( self, request: security_center_management.UpdateSecurityCenterServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.UpdateSecurityCenterServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_center_service @@ -720,10 +728,10 @@ def post_update_security_center_service( def pre_update_security_health_analytics_custom_module( self, request: security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_security_health_analytics_custom_module @@ -746,10 +754,10 @@ def post_update_security_health_analytics_custom_module( def pre_validate_event_threat_detection_custom_module( self, request: security_center_management.ValidateEventThreatDetectionCustomModuleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ security_center_management.ValidateEventThreatDetectionCustomModuleRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for validate_event_threat_detection_custom_module @@ -773,8 +781,10 @@ def post_validate_event_threat_detection_custom_module( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -796,8 +806,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -941,7 +953,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Call the create event threat detection custom module method over HTTP. @@ -953,8 +965,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.EventThreatDetectionCustomModule: @@ -970,6 +984,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseCreateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -989,6 +1004,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.CreateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "CreateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._CreateEventThreatDetectionCustomModule._get_response( self._host, @@ -1012,9 +1054,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.EventThreatDetectionCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.create_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "CreateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecurityHealthAnalyticsCustomModule( @@ -1055,7 +1121,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Call the create security health analytics custom module method over HTTP. @@ -1067,8 +1133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SecurityHealthAnalyticsCustomModule: @@ -1088,6 +1156,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseCreateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -1107,6 +1176,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.CreateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "CreateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._CreateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -1130,11 +1226,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_create_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.SecurityHealthAnalyticsCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.create_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "CreateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEventThreatDetectionCustomModule( @@ -1174,7 +1294,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete event threat detection custom module method over HTTP. @@ -1186,13 +1306,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterManagementRestTransport._BaseDeleteEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -1208,6 +1331,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.DeleteEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "DeleteEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._DeleteEventThreatDetectionCustomModule._get_response( self._host, @@ -1260,7 +1410,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete security health analytics custom module method over HTTP. @@ -1272,13 +1422,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSecurityCenterManagementRestTransport._BaseDeleteSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -1294,6 +1447,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.DeleteSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "DeleteSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._DeleteSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -1346,7 +1526,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: r"""Call the get effective event threat detection custom module method over HTTP. @@ -1358,8 +1538,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.EffectiveEventThreatDetectionCustomModule: @@ -1378,6 +1560,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetEffectiveEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -1393,6 +1576,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetEffectiveEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEffectiveEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetEffectiveEventThreatDetectionCustomModule._get_response( self._host, @@ -1419,9 +1629,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.EffectiveEventThreatDetectionCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEffectiveEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveSecurityHealthAnalyticsCustomModule( @@ -1461,7 +1695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: r"""Call the get effective security health analytics custom module method over HTTP. @@ -1473,8 +1707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: @@ -1494,6 +1730,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetEffectiveSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -1509,6 +1746,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetEffectiveSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEffectiveSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetEffectiveSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -1533,9 +1797,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_security_health_analytics_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEffectiveSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEventThreatDetectionCustomModule( @@ -1575,7 +1863,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Call the get event threat detection custom module method over HTTP. @@ -1587,8 +1875,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.EventThreatDetectionCustomModule: @@ -1604,6 +1894,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -1619,6 +1910,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetEventThreatDetectionCustomModule._get_response( self._host, @@ -1641,7 +1959,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_threat_detection_custom_module(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.EventThreatDetectionCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.get_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecurityCenterService( @@ -1681,7 +2023,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Call the get security center service method over HTTP. @@ -1693,8 +2035,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SecurityCenterService: @@ -1714,6 +2058,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetSecurityCenterService._get_http_options() ) + request, metadata = self._interceptor.pre_get_security_center_service( request, metadata ) @@ -1726,6 +2071,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetSecurityCenterService", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetSecurityCenterService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetSecurityCenterService._get_response( self._host, @@ -1746,7 +2118,33 @@ def __call__( pb_resp = security_center_management.SecurityCenterService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_security_center_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + security_center_management.SecurityCenterService.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.securitycentermanagement_v1.SecurityCenterManagementClient.get_security_center_service", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetSecurityCenterService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSecurityHealthAnalyticsCustomModule( @@ -1786,7 +2184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Call the get security health analytics custom module method over HTTP. @@ -1798,8 +2196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SecurityHealthAnalyticsCustomModule: @@ -1819,6 +2219,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -1834,6 +2235,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -1856,9 +2284,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_security_health_analytics_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.SecurityHealthAnalyticsCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.get_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDescendantEventThreatDetectionCustomModules( @@ -1898,7 +2350,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse ): @@ -1912,8 +2364,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: @@ -1925,6 +2379,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListDescendantEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -1940,6 +2395,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListDescendantEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListDescendantEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListDescendantEventThreatDetectionCustomModules._get_response( self._host, @@ -1964,9 +2446,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListDescendantEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDescendantSecurityHealthAnalyticsCustomModules( @@ -2006,7 +2512,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse ): @@ -2020,8 +2526,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: @@ -2033,6 +2541,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListDescendantSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -2048,6 +2557,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListDescendantSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListDescendantSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListDescendantSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -2072,9 +2608,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListDescendantSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEffectiveEventThreatDetectionCustomModules( @@ -2114,7 +2674,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse ): @@ -2128,8 +2688,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: @@ -2141,6 +2703,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListEffectiveEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -2156,6 +2719,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListEffectiveEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEffectiveEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListEffectiveEventThreatDetectionCustomModules._get_response( self._host, @@ -2180,9 +2770,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEffectiveEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEffectiveSecurityHealthAnalyticsCustomModules( @@ -2222,7 +2836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse ): @@ -2236,8 +2850,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: @@ -2249,6 +2865,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListEffectiveSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -2264,6 +2881,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListEffectiveSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEffectiveSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListEffectiveSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -2288,9 +2932,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEffectiveSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEventThreatDetectionCustomModules( @@ -2330,7 +2998,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.ListEventThreatDetectionCustomModulesResponse: r"""Call the list event threat detection custom modules method over HTTP. @@ -2342,8 +3010,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListEventThreatDetectionCustomModulesResponse: @@ -2355,6 +3025,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListEventThreatDetectionCustomModules._get_http_options() ) + ( request, metadata, @@ -2370,6 +3041,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListEventThreatDetectionCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEventThreatDetectionCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListEventThreatDetectionCustomModules._get_response( self._host, @@ -2394,9 +3092,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_threat_detection_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListEventThreatDetectionCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_event_threat_detection_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListEventThreatDetectionCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecurityCenterServices( @@ -2436,7 +3158,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.ListSecurityCenterServicesResponse: r"""Call the list security center services method over HTTP. @@ -2448,8 +3170,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListSecurityCenterServicesResponse: @@ -2461,6 +3185,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListSecurityCenterServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_security_center_services( request, metadata ) @@ -2473,6 +3198,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListSecurityCenterServices", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListSecurityCenterServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListSecurityCenterServices._get_response( self._host, @@ -2495,7 +3247,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_security_center_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListSecurityCenterServicesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_security_center_services", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListSecurityCenterServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSecurityHealthAnalyticsCustomModules( @@ -2535,7 +3311,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse ): @@ -2549,8 +3325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: @@ -2562,6 +3340,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListSecurityHealthAnalyticsCustomModules._get_http_options() ) + ( request, metadata, @@ -2577,6 +3356,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListSecurityHealthAnalyticsCustomModules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListSecurityHealthAnalyticsCustomModules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ListSecurityHealthAnalyticsCustomModules._get_response( self._host, @@ -2601,9 +3407,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_security_health_analytics_custom_modules( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.list_security_health_analytics_custom_modules", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListSecurityHealthAnalyticsCustomModules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SimulateSecurityHealthAnalyticsCustomModule( @@ -2644,7 +3474,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse ): @@ -2659,8 +3489,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: @@ -2672,6 +3504,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseSimulateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -2691,6 +3524,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.SimulateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "SimulateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._SimulateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -2716,11 +3576,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_simulate_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.simulate_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "SimulateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEventThreatDetectionCustomModule( @@ -2761,7 +3645,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: r"""Call the update event threat detection custom module method over HTTP. @@ -2773,8 +3657,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.EventThreatDetectionCustomModule: @@ -2790,6 +3676,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseUpdateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -2809,6 +3696,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.UpdateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._UpdateEventThreatDetectionCustomModule._get_response( self._host, @@ -2832,9 +3746,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.EventThreatDetectionCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.update_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityCenterService( @@ -2875,7 +3813,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityCenterService: r"""Call the update security center service method over HTTP. @@ -2887,8 +3825,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SecurityCenterService: @@ -2908,6 +3848,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseUpdateSecurityCenterService._get_http_options() ) + request, metadata = self._interceptor.pre_update_security_center_service( request, metadata ) @@ -2924,6 +3865,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.UpdateSecurityCenterService", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateSecurityCenterService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._UpdateSecurityCenterService._get_response( self._host, @@ -2945,7 +3913,33 @@ def __call__( pb_resp = security_center_management.SecurityCenterService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_center_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + security_center_management.SecurityCenterService.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.securitycentermanagement_v1.SecurityCenterManagementClient.update_security_center_service", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateSecurityCenterService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSecurityHealthAnalyticsCustomModule( @@ -2986,7 +3980,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> security_center_management.SecurityHealthAnalyticsCustomModule: r"""Call the update security health analytics custom module method over HTTP. @@ -2998,8 +3992,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.SecurityHealthAnalyticsCustomModule: @@ -3019,6 +4015,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseUpdateSecurityHealthAnalyticsCustomModule._get_http_options() ) + ( request, metadata, @@ -3038,6 +4035,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.UpdateSecurityHealthAnalyticsCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateSecurityHealthAnalyticsCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._UpdateSecurityHealthAnalyticsCustomModule._get_response( self._host, @@ -3061,11 +4085,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_update_security_health_analytics_custom_module( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.SecurityHealthAnalyticsCustomModule.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.securitycentermanagement_v1.SecurityCenterManagementClient.update_security_health_analytics_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "UpdateSecurityHealthAnalyticsCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ValidateEventThreatDetectionCustomModule( @@ -3106,7 +4154,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( security_center_management.ValidateEventThreatDetectionCustomModuleResponse ): @@ -3120,8 +4168,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.security_center_management.ValidateEventThreatDetectionCustomModuleResponse: @@ -3133,6 +4183,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseValidateEventThreatDetectionCustomModule._get_http_options() ) + ( request, metadata, @@ -3152,6 +4203,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ValidateEventThreatDetectionCustomModule", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ValidateEventThreatDetectionCustomModule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._ValidateEventThreatDetectionCustomModule._get_response( self._host, @@ -3177,9 +4255,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_event_threat_detection_custom_module( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.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.securitycentermanagement_v1.SecurityCenterManagementClient.validate_event_threat_detection_custom_module", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ValidateEventThreatDetectionCustomModule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3464,7 +4566,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3474,8 +4576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -3484,6 +4588,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSecurityCenterManagementRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3494,6 +4599,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.GetLocation", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityCenterManagementRestTransport._GetLocation._get_response( self._host, @@ -3513,6 +4645,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3554,7 +4707,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3564,8 +4717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -3574,6 +4729,7 @@ def __call__( http_options = ( _BaseSecurityCenterManagementRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSecurityCenterManagementRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3584,6 +4740,33 @@ def __call__( 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.securitycentermanagement_v1.SecurityCenterManagementClient.ListLocations", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SecurityCenterManagementRestTransport._ListLocations._get_response( @@ -3605,6 +4788,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json b/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json index f976ee53f415..aa268d46e53c 100644 --- a/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json +++ b/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycentermanagement", - "version": "0.1.17" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event_threat_detection_custom_module" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_event_threat_detection_custom_module" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_security_health_analytics_custom_module" @@ -617,7 +617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_security_health_analytics_custom_module" @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", @@ -775,7 +775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", @@ -936,7 +936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -1097,7 +1097,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityCenterService", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityCenterService", @@ -1339,7 +1339,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -1419,7 +1419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -1500,7 +1500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager", @@ -1580,7 +1580,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager", @@ -1661,7 +1661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -1741,7 +1741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager", @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager", @@ -1902,7 +1902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager", @@ -1983,7 +1983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -2063,7 +2063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager", @@ -2144,7 +2144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager", @@ -2224,7 +2224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager", @@ -2305,7 +2305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityCenterServicesAsyncPager", @@ -2385,7 +2385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityCenterServicesPager", @@ -2466,7 +2466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager", @@ -2546,7 +2546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager", @@ -2635,7 +2635,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", @@ -2723,7 +2723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", @@ -2808,7 +2808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -2892,7 +2892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", @@ -2977,7 +2977,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityCenterService", @@ -3061,7 +3061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityCenterService", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -3230,7 +3230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", @@ -3307,7 +3307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", @@ -3383,7 +3383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", diff --git a/packages/google-cloud-securitycentermanagement/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py b/packages/google-cloud-securitycentermanagement/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py index c25fc675cb00..fd50a93af944 100644 --- a/packages/google-cloud-securitycentermanagement/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py +++ b/packages/google-cloud-securitycentermanagement/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py @@ -10763,6 +10763,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_required_f response_value._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_effective_security_health_analytics_custom_modules( request @@ -10824,6 +10825,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_flattened( json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_security_health_analytics_custom_modules(**mock_args) @@ -11050,6 +11052,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_required_fie response_value._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_effective_security_health_analytics_custom_module( request @@ -11107,6 +11110,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_security_health_analytics_custom_module(**mock_args) @@ -11260,6 +11264,7 @@ def test_list_security_health_analytics_custom_modules_rest_required_fields( response_value._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_security_health_analytics_custom_modules(request) @@ -11319,6 +11324,7 @@ def test_list_security_health_analytics_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_modules(**mock_args) @@ -11551,6 +11557,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_required_ response_value._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_descendant_security_health_analytics_custom_modules( request @@ -11612,6 +11619,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_flattened json_return_value = json_format.MessageToJson(return_value) response_value._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_descendant_security_health_analytics_custom_modules(**mock_args) @@ -11837,6 +11845,7 @@ def test_get_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -11890,6 +11899,7 @@ def test_get_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -12039,6 +12049,7 @@ def test_create_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -12101,6 +12112,7 @@ def test_create_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -12253,6 +12265,7 @@ def test_update_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -12324,6 +12337,7 @@ def test_update_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_health_analytics_custom_module(**mock_args) @@ -12468,6 +12482,7 @@ def test_delete_security_health_analytics_custom_module_rest_required_fields( response_value._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_security_health_analytics_custom_module(request) @@ -12515,6 +12530,7 @@ def test_delete_security_health_analytics_custom_module_rest_flattened(): 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"} client.delete_security_health_analytics_custom_module(**mock_args) @@ -12662,6 +12678,7 @@ def test_simulate_security_health_analytics_custom_module_rest_required_fields( response_value._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.simulate_security_health_analytics_custom_module(request) @@ -12728,6 +12745,7 @@ def test_simulate_security_health_analytics_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.simulate_security_health_analytics_custom_module(**mock_args) @@ -12887,6 +12905,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_required_fiel response_value._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_effective_event_threat_detection_custom_modules( request @@ -12948,6 +12967,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_event_threat_detection_custom_modules(**mock_args) @@ -13175,6 +13195,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_required_fields response_value._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_effective_event_threat_detection_custom_module( request @@ -13232,6 +13253,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_event_threat_detection_custom_module(**mock_args) @@ -13385,6 +13407,7 @@ def test_list_event_threat_detection_custom_modules_rest_required_fields( response_value._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_event_threat_detection_custom_modules(request) @@ -13448,6 +13471,7 @@ def test_list_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_modules(**mock_args) @@ -13676,6 +13700,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_required_fie response_value._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_descendant_event_threat_detection_custom_modules( request @@ -13737,6 +13762,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_descendant_event_threat_detection_custom_modules(**mock_args) @@ -13960,6 +13986,7 @@ def test_get_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -14013,6 +14040,7 @@ def test_get_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -14162,6 +14190,7 @@ def test_create_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -14222,6 +14251,7 @@ def test_create_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -14374,6 +14404,7 @@ def test_update_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -14443,6 +14474,7 @@ def test_update_event_threat_detection_custom_module_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event_threat_detection_custom_module(**mock_args) @@ -14587,6 +14619,7 @@ def test_delete_event_threat_detection_custom_module_rest_required_fields( response_value._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_event_threat_detection_custom_module(request) @@ -14634,6 +14667,7 @@ def test_delete_event_threat_detection_custom_module_rest_flattened(): 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"} client.delete_event_threat_detection_custom_module(**mock_args) @@ -14789,6 +14823,7 @@ def test_validate_event_threat_detection_custom_module_rest_required_fields( response_value._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.validate_event_threat_detection_custom_module(request) @@ -14928,6 +14963,7 @@ def test_get_security_center_service_rest_required_fields( response_value._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_security_center_service(request) @@ -14975,6 +15011,7 @@ def test_get_security_center_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_center_service(**mock_args) @@ -15123,6 +15160,7 @@ def test_list_security_center_services_rest_required_fields( response_value._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_security_center_services(request) @@ -15181,6 +15219,7 @@ def test_list_security_center_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_center_services(**mock_args) @@ -15389,6 +15428,7 @@ def test_update_security_center_service_rest_required_fields( response_value._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_security_center_service(request) @@ -15456,6 +15496,7 @@ def test_update_security_center_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_security_center_service(**mock_args) @@ -16886,6 +16927,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_bad_reques 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_effective_security_health_analytics_custom_modules(request) @@ -16925,6 +16967,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_call_succe json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_security_health_analytics_custom_modules( request ) @@ -16973,6 +17016,7 @@ def test_list_effective_security_health_analytics_custom_modules_rest_intercepto 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json( security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() ) @@ -17025,6 +17069,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_bad_request( 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_effective_security_health_analytics_custom_module(request) @@ -17070,6 +17115,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_call_success json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -17122,6 +17168,7 @@ def test_get_effective_security_health_analytics_custom_module_rest_interceptors 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 = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.to_json( security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() ) @@ -17172,6 +17219,7 @@ def test_list_security_health_analytics_custom_modules_rest_bad_request( 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_security_health_analytics_custom_modules(request) @@ -17211,6 +17259,7 @@ def test_list_security_health_analytics_custom_modules_rest_call_success(request json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_modules(request) # Establish that the response is the type that we expect. @@ -17255,6 +17304,7 @@ def test_list_security_health_analytics_custom_modules_rest_interceptors( 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.to_json( security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() ) @@ -17305,6 +17355,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_bad_reque 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_descendant_security_health_analytics_custom_modules(request) @@ -17344,6 +17395,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_call_succ json_return_value = json_format.MessageToJson(return_value) response_value.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_descendant_security_health_analytics_custom_modules( request ) @@ -17392,6 +17444,7 @@ def test_list_descendant_security_health_analytics_custom_modules_rest_intercept 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json( security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() ) @@ -17444,6 +17497,7 @@ def test_get_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -17489,6 +17543,7 @@ def test_get_security_health_analytics_custom_module_rest_call_success(request_t json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -17542,6 +17597,7 @@ def test_get_security_health_analytics_custom_module_rest_interceptors( 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 = ( security_center_management.SecurityHealthAnalyticsCustomModule.to_json( security_center_management.SecurityHealthAnalyticsCustomModule() @@ -17594,6 +17650,7 @@ def test_create_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -17740,6 +17797,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -17793,6 +17851,7 @@ def test_create_security_health_analytics_custom_module_rest_interceptors( 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 = ( security_center_management.SecurityHealthAnalyticsCustomModule.to_json( security_center_management.SecurityHealthAnalyticsCustomModule() @@ -17849,6 +17908,7 @@ def test_update_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -17999,6 +18059,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -18052,6 +18113,7 @@ def test_update_security_health_analytics_custom_module_rest_interceptors( 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 = ( security_center_management.SecurityHealthAnalyticsCustomModule.to_json( security_center_management.SecurityHealthAnalyticsCustomModule() @@ -18106,6 +18168,7 @@ def test_delete_security_health_analytics_custom_module_rest_bad_request( 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_security_health_analytics_custom_module(request) @@ -18138,6 +18201,7 @@ def test_delete_security_health_analytics_custom_module_rest_call_success(reques 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_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -18177,6 +18241,7 @@ def test_delete_security_health_analytics_custom_module_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() @@ -18219,6 +18284,7 @@ def test_simulate_security_health_analytics_custom_module_rest_bad_request( 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.simulate_security_health_analytics_custom_module(request) @@ -18258,6 +18324,7 @@ def test_simulate_security_health_analytics_custom_module_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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.simulate_security_health_analytics_custom_module(request) # Establish that the response is the type that we expect. @@ -18304,6 +18371,7 @@ def test_simulate_security_health_analytics_custom_module_rest_interceptors( 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.to_json( security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() ) @@ -18354,6 +18422,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_bad_request( 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_effective_event_threat_detection_custom_modules(request) @@ -18393,6 +18462,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -18439,6 +18509,7 @@ def test_list_effective_event_threat_detection_custom_modules_rest_interceptors( 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json( security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() ) @@ -18491,6 +18562,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_bad_request( 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_effective_event_threat_detection_custom_module(request) @@ -18538,6 +18610,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -18591,6 +18664,7 @@ def test_get_effective_event_threat_detection_custom_module_rest_interceptors( 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 = security_center_management.EffectiveEventThreatDetectionCustomModule.to_json( security_center_management.EffectiveEventThreatDetectionCustomModule() ) @@ -18641,6 +18715,7 @@ def test_list_event_threat_detection_custom_modules_rest_bad_request( 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_event_threat_detection_custom_modules(request) @@ -18682,6 +18757,7 @@ def test_list_event_threat_detection_custom_modules_rest_call_success(request_ty json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -18724,6 +18800,7 @@ def test_list_event_threat_detection_custom_modules_rest_interceptors(null_inter 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 = security_center_management.ListEventThreatDetectionCustomModulesResponse.to_json( security_center_management.ListEventThreatDetectionCustomModulesResponse() ) @@ -18774,6 +18851,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_bad_request( 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_descendant_event_threat_detection_custom_modules(request) @@ -18813,6 +18891,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_call_success json_return_value = json_format.MessageToJson(return_value) response_value.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_descendant_event_threat_detection_custom_modules(request) # Establish that the response is the type that we expect. @@ -18859,6 +18938,7 @@ def test_list_descendant_event_threat_detection_custom_modules_rest_interceptors 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.to_json( security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() ) @@ -18911,6 +18991,7 @@ def test_get_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -18956,6 +19037,7 @@ def test_get_event_threat_detection_custom_module_rest_call_success(request_type json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -19011,6 +19093,7 @@ def test_get_event_threat_detection_custom_module_rest_interceptors(null_interce 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 = ( security_center_management.EventThreatDetectionCustomModule.to_json( security_center_management.EventThreatDetectionCustomModule() @@ -19063,6 +19146,7 @@ def test_create_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -19194,6 +19278,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -19249,6 +19334,7 @@ def test_create_event_threat_detection_custom_module_rest_interceptors( 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 = ( security_center_management.EventThreatDetectionCustomModule.to_json( security_center_management.EventThreatDetectionCustomModule() @@ -19305,6 +19391,7 @@ def test_update_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -19440,6 +19527,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -19495,6 +19583,7 @@ def test_update_event_threat_detection_custom_module_rest_interceptors( 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 = ( security_center_management.EventThreatDetectionCustomModule.to_json( security_center_management.EventThreatDetectionCustomModule() @@ -19549,6 +19638,7 @@ def test_delete_event_threat_detection_custom_module_rest_bad_request( 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_event_threat_detection_custom_module(request) @@ -19581,6 +19671,7 @@ def test_delete_event_threat_detection_custom_module_rest_call_success(request_t 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_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -19620,6 +19711,7 @@ def test_delete_event_threat_detection_custom_module_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( security_center_management.DeleteEventThreatDetectionCustomModuleRequest() @@ -19662,6 +19754,7 @@ def test_validate_event_threat_detection_custom_module_rest_bad_request( 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.validate_event_threat_detection_custom_module(request) @@ -19699,6 +19792,7 @@ def test_validate_event_threat_detection_custom_module_rest_call_success(request json_return_value = json_format.MessageToJson(return_value) response_value.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.validate_event_threat_detection_custom_module(request) # Establish that the response is the type that we expect. @@ -19745,6 +19839,7 @@ def test_validate_event_threat_detection_custom_module_rest_interceptors( 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 = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.to_json( security_center_management.ValidateEventThreatDetectionCustomModuleResponse() ) @@ -19797,6 +19892,7 @@ def test_get_security_center_service_rest_bad_request( 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_security_center_service(request) @@ -19836,6 +19932,7 @@ def test_get_security_center_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_center_service(request) # Establish that the response is the type that we expect. @@ -19886,6 +19983,7 @@ def test_get_security_center_service_rest_interceptors(null_interceptor): 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 = security_center_management.SecurityCenterService.to_json( security_center_management.SecurityCenterService() ) @@ -19932,6 +20030,7 @@ def test_list_security_center_services_rest_bad_request( 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_security_center_services(request) @@ -19969,6 +20068,7 @@ def test_list_security_center_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_center_services(request) # Establish that the response is the type that we expect. @@ -20011,6 +20111,7 @@ def test_list_security_center_services_rest_interceptors(null_interceptor): 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 = ( security_center_management.ListSecurityCenterServicesResponse.to_json( security_center_management.ListSecurityCenterServicesResponse() @@ -20065,6 +20166,7 @@ def test_update_security_center_service_rest_bad_request( 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_security_center_service(request) @@ -20187,6 +20289,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_security_center_service(request) # Establish that the response is the type that we expect. @@ -20237,6 +20340,7 @@ def test_update_security_center_service_rest_interceptors(null_interceptor): 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 = security_center_management.SecurityCenterService.to_json( security_center_management.SecurityCenterService() ) @@ -20283,6 +20387,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -20313,6 +20418,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -20341,6 +20447,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -20371,6 +20478,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol/gapic_version.py b/packages/google-cloud-service-control/google/cloud/servicecontrol/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol/gapic_version.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/gapic_version.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/gapic_version.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/async_client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/async_client.py index 9f77b731e70b..615a8fda06c5 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/async_client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, QuotaControllerTransport from .transports.grpc_asyncio import QuotaControllerGrpcAsyncIOTransport +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 QuotaControllerAsyncClient: """`Google Quota Control API `__ @@ -257,13 +267,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.servicecontrol_v1.QuotaControllerAsyncClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v1.QuotaController", + "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.api.servicecontrol.v1.QuotaController", + "credentialsType": None, + }, + ) + async def allocate_quota( self, request: Optional[Union[quota_controller.AllocateQuotaRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> quota_controller.AllocateQuotaResponse: r"""Attempts to allocate quota for the specified consumer. It should be called before the operation is executed. @@ -310,8 +342,10 @@ async def sample_allocate_quota(): 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, 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: google.cloud.servicecontrol_v1.types.AllocateQuotaResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/client.py index f1f3b71024f2..460caa7387ce 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.servicecontrol_v1.types import metric_value, quota_controller from .transports.base import DEFAULT_CLIENT_INFO, QuotaControllerTransport @@ -561,6 +571,10 @@ def __init__( # 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( @@ -626,13 +640,36 @@ def __init__( 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.api.servicecontrol_v1.QuotaControllerClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v1.QuotaController", + "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.api.servicecontrol.v1.QuotaController", + "credentialsType": None, + }, + ) + def allocate_quota( self, request: Optional[Union[quota_controller.AllocateQuotaRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> quota_controller.AllocateQuotaResponse: r"""Attempts to allocate quota for the specified consumer. It should be called before the operation is executed. @@ -679,8 +716,10 @@ def sample_allocate_quota(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicecontrol_v1.types.AllocateQuotaResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc.py index 6695fe0998b0..1cf6a3e9bf80 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.servicecontrol_v1.types import quota_controller from .base import DEFAULT_CLIENT_INFO, QuotaControllerTransport +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.api.servicecontrol.v1.QuotaController", + "rpcName": 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.api.servicecontrol.v1.QuotaController", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class QuotaControllerGrpcTransport(QuotaControllerTransport): """gRPC backend transport for QuotaController. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +355,7 @@ def allocate_quota( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "allocate_quota" not in self._stubs: - self._stubs["allocate_quota"] = self.grpc_channel.unary_unary( + self._stubs["allocate_quota"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.QuotaController/AllocateQuota", request_serializer=quota_controller.AllocateQuotaRequest.serialize, response_deserializer=quota_controller.AllocateQuotaResponse.deserialize, @@ -277,7 +363,7 @@ def allocate_quota( return self._stubs["allocate_quota"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc_asyncio.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc_asyncio.py index 4b49e512eee7..1e34136ec241 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicecontrol_v1.types import quota_controller from .base import DEFAULT_CLIENT_INFO, QuotaControllerTransport from .grpc import QuotaControllerGrpcTransport +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.api.servicecontrol.v1.QuotaController", + "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.api.servicecontrol.v1.QuotaController", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class QuotaControllerGrpcAsyncIOTransport(QuotaControllerTransport): """gRPC AsyncIO backend transport for QuotaController. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -278,7 +363,7 @@ def allocate_quota( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "allocate_quota" not in self._stubs: - self._stubs["allocate_quota"] = self.grpc_channel.unary_unary( + self._stubs["allocate_quota"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.QuotaController/AllocateQuota", request_serializer=quota_controller.AllocateQuotaRequest.serialize, response_deserializer=quota_controller.AllocateQuotaResponse.deserialize, @@ -301,7 +386,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/rest.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/rest.py index 5d5b8e3a38a7..309d49d3c851 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/rest.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/quota_controller/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,10 @@ def post_allocate_quota(self, response): def pre_allocate_quota( self, request: quota_controller.AllocateQuotaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[quota_controller.AllocateQuotaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + quota_controller.AllocateQuotaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for allocate_quota Override in a subclass to manipulate the request or metadata @@ -222,7 +232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> quota_controller.AllocateQuotaResponse: r"""Call the allocate quota method over HTTP. @@ -233,8 +243,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.quota_controller.AllocateQuotaResponse: @@ -246,6 +258,7 @@ def __call__( http_options = ( _BaseQuotaControllerRestTransport._BaseAllocateQuota._get_http_options() ) + request, metadata = self._interceptor.pre_allocate_quota(request, metadata) transcoded_request = _BaseQuotaControllerRestTransport._BaseAllocateQuota._get_transcoded_request( http_options, request @@ -260,6 +273,33 @@ def __call__( 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.api.servicecontrol_v1.QuotaControllerClient.AllocateQuota", + extra={ + "serviceName": "google.api.servicecontrol.v1.QuotaController", + "rpcName": "AllocateQuota", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = QuotaControllerRestTransport._AllocateQuota._get_response( self._host, @@ -281,7 +321,31 @@ def __call__( pb_resp = quota_controller.AllocateQuotaResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_allocate_quota(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = quota_controller.AllocateQuotaResponse.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.api.servicecontrol_v1.QuotaControllerClient.allocate_quota", + extra={ + "serviceName": "google.api.servicecontrol.v1.QuotaController", + "rpcName": "AllocateQuota", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/async_client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/async_client.py index 1281c8c0c78a..004689e38dc1 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/async_client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServiceControllerTransport from .transports.grpc_asyncio import ServiceControllerGrpcAsyncIOTransport +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 ServiceControllerAsyncClient: """`Google Service Control API `__ @@ -259,13 +269,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.servicecontrol_v1.ServiceControllerAsyncClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "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.api.servicecontrol.v1.ServiceController", + "credentialsType": None, + }, + ) + async def check( self, request: Optional[Union[service_controller.CheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Checks whether an operation on a service should be allowed to proceed based on the configuration of the service and related @@ -318,8 +350,10 @@ async def sample_check(): 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, 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: google.cloud.servicecontrol_v1.types.CheckResponse: @@ -365,7 +399,7 @@ async def report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is @@ -418,8 +452,10 @@ async def sample_report(): 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, 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: google.cloud.servicecontrol_v1.types.ReportResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/client.py index 63aa5f6308ad..8f2abfe54994 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.servicecontrol_v1.types import check_error, service_controller from .transports.base import DEFAULT_CLIENT_INFO, ServiceControllerTransport @@ -563,6 +573,10 @@ def __init__( # 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( @@ -629,13 +643,36 @@ def __init__( 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.api.servicecontrol_v1.ServiceControllerClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "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.api.servicecontrol.v1.ServiceController", + "credentialsType": None, + }, + ) + def check( self, request: Optional[Union[service_controller.CheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Checks whether an operation on a service should be allowed to proceed based on the configuration of the service and related @@ -688,8 +725,10 @@ def sample_check(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicecontrol_v1.types.CheckResponse: @@ -735,7 +774,7 @@ def report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is @@ -788,8 +827,10 @@ def sample_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicecontrol_v1.types.ReportResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc.py index 73809fad8b3d..f8a7d7b52bea 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.servicecontrol_v1.types import service_controller from .base import DEFAULT_CLIENT_INFO, ServiceControllerTransport +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.api.servicecontrol.v1.ServiceController", + "rpcName": 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.api.servicecontrol.v1.ServiceController", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceControllerGrpcTransport(ServiceControllerTransport): """gRPC backend transport for ServiceController. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +360,7 @@ def check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check" not in self._stubs: - self._stubs["check"] = self.grpc_channel.unary_unary( + self._stubs["check"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.ServiceController/Check", request_serializer=service_controller.CheckRequest.serialize, response_deserializer=service_controller.CheckResponse.deserialize, @@ -319,7 +405,7 @@ def report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report" not in self._stubs: - self._stubs["report"] = self.grpc_channel.unary_unary( + self._stubs["report"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.ServiceController/Report", request_serializer=service_controller.ReportRequest.serialize, response_deserializer=service_controller.ReportResponse.deserialize, @@ -327,7 +413,7 @@ def report( return self._stubs["report"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc_asyncio.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc_asyncio.py index 3cfe1b5b0db5..085813b00401 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicecontrol_v1.types import service_controller from .base import DEFAULT_CLIENT_INFO, ServiceControllerTransport from .grpc import ServiceControllerGrpcTransport +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.api.servicecontrol.v1.ServiceController", + "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.api.servicecontrol.v1.ServiceController", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceControllerGrpcAsyncIOTransport(ServiceControllerTransport): """gRPC AsyncIO backend transport for ServiceController. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -284,7 +369,7 @@ def check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check" not in self._stubs: - self._stubs["check"] = self.grpc_channel.unary_unary( + self._stubs["check"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.ServiceController/Check", request_serializer=service_controller.CheckRequest.serialize, response_deserializer=service_controller.CheckResponse.deserialize, @@ -329,7 +414,7 @@ def report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report" not in self._stubs: - self._stubs["report"] = self.grpc_channel.unary_unary( + self._stubs["report"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v1.ServiceController/Report", request_serializer=service_controller.ReportRequest.serialize, response_deserializer=service_controller.ReportResponse.deserialize, @@ -366,7 +451,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/rest.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/rest.py index a446cc14aad6..2a8584187856 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/rest.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v1/services/service_controller/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -85,8 +93,10 @@ def post_report(self, response): def pre_check( self, request: service_controller.CheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service_controller.CheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service_controller.CheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for check Override in a subclass to manipulate the request or metadata @@ -108,8 +118,10 @@ def post_check( def pre_report( self, request: service_controller.ReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service_controller.ReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service_controller.ReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for report Override in a subclass to manipulate the request or metadata @@ -253,7 +265,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Call the check method over HTTP. @@ -263,8 +275,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service_controller.CheckResponse: @@ -276,6 +290,7 @@ def __call__( http_options = ( _BaseServiceControllerRestTransport._BaseCheck._get_http_options() ) + request, metadata = self._interceptor.pre_check(request, metadata) transcoded_request = ( _BaseServiceControllerRestTransport._BaseCheck._get_transcoded_request( @@ -296,6 +311,33 @@ def __call__( ) ) + 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.api.servicecontrol_v1.ServiceControllerClient.Check", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "rpcName": "Check", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceControllerRestTransport._Check._get_response( self._host, @@ -317,7 +359,31 @@ def __call__( pb_resp = service_controller.CheckResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service_controller.CheckResponse.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.api.servicecontrol_v1.ServiceControllerClient.check", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "rpcName": "Check", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Report( @@ -355,7 +421,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Call the report method over HTTP. @@ -366,8 +432,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service_controller.ReportResponse: @@ -379,6 +447,7 @@ def __call__( http_options = ( _BaseServiceControllerRestTransport._BaseReport._get_http_options() ) + request, metadata = self._interceptor.pre_report(request, metadata) transcoded_request = ( _BaseServiceControllerRestTransport._BaseReport._get_transcoded_request( @@ -399,6 +468,33 @@ def __call__( ) ) + 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.api.servicecontrol_v1.ServiceControllerClient.Report", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "rpcName": "Report", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceControllerRestTransport._Report._get_response( self._host, @@ -420,7 +516,31 @@ def __call__( pb_resp = service_controller.ReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service_controller.ReportResponse.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.api.servicecontrol_v1.ServiceControllerClient.report", + extra={ + "serviceName": "google.api.servicecontrol.v1.ServiceController", + "rpcName": "Report", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/gapic_version.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/gapic_version.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/async_client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/async_client.py index 7772d9798ec8..54c9b399741e 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/async_client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServiceControllerTransport from .transports.grpc_asyncio import ServiceControllerGrpcAsyncIOTransport +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 ServiceControllerAsyncClient: """`Service Control API @@ -266,13 +276,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.servicecontrol_v2.ServiceControllerAsyncClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "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.api.servicecontrol.v2.ServiceController", + "credentialsType": None, + }, + ) + async def check( self, request: Optional[Union[service_controller.CheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Private Preview. This feature is only available for approved services. @@ -330,8 +362,10 @@ async def sample_check(): 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, 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: google.cloud.servicecontrol_v2.types.CheckResponse: @@ -377,7 +411,7 @@ async def report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Private Preview. This feature is only available for approved services. @@ -431,8 +465,10 @@ async def sample_report(): 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, 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: google.cloud.servicecontrol_v2.types.ReportResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/client.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/client.py index 63bcc2b0db35..ee3524bcd9c6 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/client.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.rpc import status_pb2 # type: ignore from google.cloud.servicecontrol_v2.types import service_controller @@ -570,6 +580,10 @@ def __init__( # 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( @@ -636,13 +650,36 @@ def __init__( 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.api.servicecontrol_v2.ServiceControllerClient`.", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "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.api.servicecontrol.v2.ServiceController", + "credentialsType": None, + }, + ) + def check( self, request: Optional[Union[service_controller.CheckRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Private Preview. This feature is only available for approved services. @@ -700,8 +737,10 @@ def sample_check(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicecontrol_v2.types.CheckResponse: @@ -747,7 +786,7 @@ def report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Private Preview. This feature is only available for approved services. @@ -801,8 +840,10 @@ def sample_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicecontrol_v2.types.ReportResponse: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc.py index 66f4bfc9b62f..84bcd7e9ae98 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.servicecontrol_v2.types import service_controller from .base import DEFAULT_CLIENT_INFO, ServiceControllerTransport +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.api.servicecontrol.v2.ServiceController", + "rpcName": 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.api.servicecontrol.v2.ServiceController", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceControllerGrpcTransport(ServiceControllerTransport): """gRPC backend transport for ServiceController. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -284,7 +370,7 @@ def check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check" not in self._stubs: - self._stubs["check"] = self.grpc_channel.unary_unary( + self._stubs["check"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v2.ServiceController/Check", request_serializer=service_controller.CheckRequest.serialize, response_deserializer=service_controller.CheckResponse.deserialize, @@ -330,7 +416,7 @@ def report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report" not in self._stubs: - self._stubs["report"] = self.grpc_channel.unary_unary( + self._stubs["report"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v2.ServiceController/Report", request_serializer=service_controller.ReportRequest.serialize, response_deserializer=service_controller.ReportResponse.deserialize, @@ -338,7 +424,7 @@ def report( return self._stubs["report"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc_asyncio.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc_asyncio.py index 09a15f3e0cc5..1eca8584b342 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicecontrol_v2.types import service_controller from .base import DEFAULT_CLIENT_INFO, ServiceControllerTransport from .grpc import ServiceControllerGrpcTransport +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.api.servicecontrol.v2.ServiceController", + "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.api.servicecontrol.v2.ServiceController", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceControllerGrpcAsyncIOTransport(ServiceControllerTransport): """gRPC AsyncIO backend transport for ServiceController. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -294,7 +379,7 @@ def check( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check" not in self._stubs: - self._stubs["check"] = self.grpc_channel.unary_unary( + self._stubs["check"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v2.ServiceController/Check", request_serializer=service_controller.CheckRequest.serialize, response_deserializer=service_controller.CheckResponse.deserialize, @@ -340,7 +425,7 @@ def report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report" not in self._stubs: - self._stubs["report"] = self.grpc_channel.unary_unary( + self._stubs["report"] = self._logged_channel.unary_unary( "/google.api.servicecontrol.v2.ServiceController/Report", request_serializer=service_controller.ReportRequest.serialize, response_deserializer=service_controller.ReportResponse.deserialize, @@ -377,7 +462,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/rest.py b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/rest.py index b24c59b293fc..8b268714a3dd 100644 --- a/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/rest.py +++ b/packages/google-cloud-service-control/google/cloud/servicecontrol_v2/services/service_controller/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -85,8 +93,10 @@ def post_report(self, response): def pre_check( self, request: service_controller.CheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service_controller.CheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service_controller.CheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for check Override in a subclass to manipulate the request or metadata @@ -108,8 +118,10 @@ def post_check( def pre_report( self, request: service_controller.ReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service_controller.ReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service_controller.ReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for report Override in a subclass to manipulate the request or metadata @@ -258,7 +270,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.CheckResponse: r"""Call the check method over HTTP. @@ -268,8 +280,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service_controller.CheckResponse: @@ -281,6 +295,7 @@ def __call__( http_options = ( _BaseServiceControllerRestTransport._BaseCheck._get_http_options() ) + request, metadata = self._interceptor.pre_check(request, metadata) transcoded_request = ( _BaseServiceControllerRestTransport._BaseCheck._get_transcoded_request( @@ -301,6 +316,33 @@ def __call__( ) ) + 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.api.servicecontrol_v2.ServiceControllerClient.Check", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "rpcName": "Check", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceControllerRestTransport._Check._get_response( self._host, @@ -322,7 +364,31 @@ def __call__( pb_resp = service_controller.CheckResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service_controller.CheckResponse.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.api.servicecontrol_v2.ServiceControllerClient.check", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "rpcName": "Check", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Report( @@ -360,7 +426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_controller.ReportResponse: r"""Call the report method over HTTP. @@ -371,8 +437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service_controller.ReportResponse: @@ -386,6 +454,7 @@ def __call__( http_options = ( _BaseServiceControllerRestTransport._BaseReport._get_http_options() ) + request, metadata = self._interceptor.pre_report(request, metadata) transcoded_request = ( _BaseServiceControllerRestTransport._BaseReport._get_transcoded_request( @@ -406,6 +475,33 @@ def __call__( ) ) + 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.api.servicecontrol_v2.ServiceControllerClient.Report", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "rpcName": "Report", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceControllerRestTransport._Report._get_response( self._host, @@ -427,7 +523,31 @@ def __call__( pb_resp = service_controller.ReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service_controller.ReportResponse.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.api.servicecontrol_v2.ServiceControllerClient.report", + extra={ + "serviceName": "google.api.servicecontrol.v2.ServiceController", + "rpcName": "Report", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v1.json b/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v1.json index 55fc34ae7112..aec69298eea8 100644 --- a/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v1.json +++ b/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-control", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.AllocateQuotaResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.AllocateQuotaResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.CheckResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.CheckResponse", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.ReportResponse", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v1.types.ReportResponse", diff --git a/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v2.json b/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v2.json index 3d162977d48a..d3f8d10a4782 100644 --- a/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v2.json +++ b/packages/google-cloud-service-control/samples/generated_samples/snippet_metadata_google.api.servicecontrol.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-control", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v2.types.CheckResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v2.types.CheckResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v2.types.ReportResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicecontrol_v2.types.ReportResponse", diff --git a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py index af10cf1c5fe2..bca133e5588b 100644 --- a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py +++ b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py @@ -1570,6 +1570,7 @@ def test_allocate_quota_rest_bad_request( 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.allocate_quota(request) @@ -1606,6 +1607,7 @@ def test_allocate_quota_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.allocate_quota(request) # Establish that the response is the type that we expect. @@ -1647,6 +1649,7 @@ def test_allocate_quota_rest_interceptors(null_interceptor): 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 = quota_controller.AllocateQuotaResponse.to_json( quota_controller.AllocateQuotaResponse() ) diff --git a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_service_controller.py b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_service_controller.py index 7b956b9019e1..375d4a88266d 100644 --- a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_service_controller.py +++ b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v1/test_service_controller.py @@ -1925,6 +1925,7 @@ def test_check_rest_bad_request(request_type=service_controller.CheckRequest): 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.check(request) @@ -1962,6 +1963,7 @@ def test_check_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.check(request) # Establish that the response is the type that we expect. @@ -2004,6 +2006,7 @@ def test_check_rest_interceptors(null_interceptor): 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 = service_controller.CheckResponse.to_json( service_controller.CheckResponse() ) @@ -2048,6 +2051,7 @@ def test_report_rest_bad_request(request_type=service_controller.ReportRequest): 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.report(request) @@ -2084,6 +2088,7 @@ def test_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.report(request) # Establish that the response is the type that we expect. @@ -2125,6 +2130,7 @@ def test_report_rest_interceptors(null_interceptor): 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 = service_controller.ReportResponse.to_json( service_controller.ReportResponse() ) diff --git a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v2/test_service_controller.py b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v2/test_service_controller.py index e1b67396dfdb..8ca87ebe2385 100644 --- a/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v2/test_service_controller.py +++ b/packages/google-cloud-service-control/tests/unit/gapic/servicecontrol_v2/test_service_controller.py @@ -1888,6 +1888,7 @@ def test_check_rest_bad_request(request_type=service_controller.CheckRequest): 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.check(request) @@ -1921,6 +1922,7 @@ def test_check_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.check(request) # Establish that the response is the type that we expect. @@ -1960,6 +1962,7 @@ def test_check_rest_interceptors(null_interceptor): 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 = service_controller.CheckResponse.to_json( service_controller.CheckResponse() ) @@ -2004,6 +2007,7 @@ def test_report_rest_bad_request(request_type=service_controller.ReportRequest): 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.report(request) @@ -2037,6 +2041,7 @@ def test_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.report(request) # Establish that the response is the type that we expect. @@ -2076,6 +2081,7 @@ def test_report_rest_interceptors(null_interceptor): 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 = service_controller.ReportResponse.to_json( service_controller.ReportResponse() ) diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory/gapic_version.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory/gapic_version.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/gapic_version.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/gapic_version.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/async_client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/async_client.py index e021a9c49545..e787f92a068d 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/async_client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LookupServiceTransport from .transports.grpc_asyncio import LookupServiceGrpcAsyncIOTransport +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 LookupServiceAsyncClient: """Service Directory API for looking up service data at runtime.""" @@ -259,13 +269,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.servicedirectory_v1.LookupServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "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.servicedirectory.v1.LookupService", + "credentialsType": None, + }, + ) + async def resolve_service( self, request: Optional[Union[lookup_service.ResolveServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Returns a [service][google.cloud.servicedirectory.v1.Service] and its associated endpoints. Resolving a service is not @@ -306,8 +338,10 @@ async def sample_resolve_service(): 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, 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: google.cloud.servicedirectory_v1.types.ResolveServiceResponse: @@ -353,7 +387,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -364,8 +398,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -406,7 +442,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -417,8 +453,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/client.py index edf9ed88f702..28468417e9ce 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.cloud.servicedirectory_v1.types import lookup_service, service @@ -625,6 +635,10 @@ def __init__( # 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( @@ -690,13 +704,36 @@ def __init__( 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.servicedirectory_v1.LookupServiceClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "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.servicedirectory.v1.LookupService", + "credentialsType": None, + }, + ) + def resolve_service( self, request: Optional[Union[lookup_service.ResolveServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Returns a [service][google.cloud.servicedirectory.v1.Service] and its associated endpoints. Resolving a service is not @@ -737,8 +774,10 @@ def sample_resolve_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.ResolveServiceResponse: @@ -795,7 +834,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -806,8 +845,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -848,7 +889,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -859,8 +900,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc.py index 44fe4072046f..07f606c9a33c 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1.types import lookup_service from .base import DEFAULT_CLIENT_INFO, LookupServiceTransport +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.servicedirectory.v1.LookupService", + "rpcName": 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.servicedirectory.v1.LookupService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LookupServiceGrpcTransport(LookupServiceTransport): """gRPC backend transport for LookupService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def resolve_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_service" not in self._stubs: - self._stubs["resolve_service"] = self.grpc_channel.unary_unary( + self._stubs["resolve_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.LookupService/ResolveService", request_serializer=lookup_service.ResolveServiceRequest.serialize, response_deserializer=lookup_service.ResolveServiceResponse.deserialize, @@ -266,7 +352,7 @@ def resolve_service( return self._stubs["resolve_service"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -280,7 +366,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -297,7 +383,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc_asyncio.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc_asyncio.py index 6ec0e8455c90..67d19658e3fa 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1.types import lookup_service from .base import DEFAULT_CLIENT_INFO, LookupServiceTransport from .grpc import LookupServiceGrpcTransport +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.servicedirectory.v1.LookupService", + "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.servicedirectory.v1.LookupService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LookupServiceGrpcAsyncIOTransport(LookupServiceTransport): """gRPC AsyncIO backend transport for LookupService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def resolve_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_service" not in self._stubs: - self._stubs["resolve_service"] = self.grpc_channel.unary_unary( + self._stubs["resolve_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.LookupService/ResolveService", request_serializer=lookup_service.ResolveServiceRequest.serialize, response_deserializer=lookup_service.ResolveServiceResponse.deserialize, @@ -300,7 +385,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -318,7 +403,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -335,7 +420,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/rest.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/rest.py index f6039c5035f9..2149ef03d106 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/rest.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/lookup_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_resolve_service(self, response): def pre_resolve_service( self, request: lookup_service.ResolveServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lookup_service.ResolveServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lookup_service.ResolveServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resolve_service Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_resolve_service( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -124,8 +136,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -266,7 +280,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Call the resolve service method over HTTP. @@ -279,8 +293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lookup_service.ResolveServiceResponse: @@ -292,6 +308,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseResolveService._get_http_options() ) + request, metadata = self._interceptor.pre_resolve_service(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseResolveService._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( 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.servicedirectory_v1.LookupServiceClient.ResolveService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "ResolveService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._ResolveService._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = lookup_service.ResolveServiceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resolve_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lookup_service.ResolveServiceResponse.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.servicedirectory_v1.LookupServiceClient.resolve_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "ResolveService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -410,6 +481,33 @@ def __call__( ) ) + 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.servicedirectory_v1.LookupServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._GetLocation._get_response( self._host, @@ -429,6 +527,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.servicedirectory_v1.LookupServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -469,7 +588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -479,8 +598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -489,6 +610,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -499,6 +621,33 @@ def __call__( 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.servicedirectory_v1.LookupServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._ListLocations._get_response( self._host, @@ -518,6 +667,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.servicedirectory_v1.LookupServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.LookupService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/async_client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/async_client.py index 84e1bb5445eb..c841119e6597 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/async_client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport from .transports.grpc_asyncio import RegistrationServiceGrpcAsyncIOTransport +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 RegistrationServiceAsyncClient: """Service Directory API for registering services. It defines the @@ -290,6 +300,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.servicedirectory_v1.RegistrationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "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.servicedirectory.v1.RegistrationService", + "credentialsType": None, + }, + ) + async def create_namespace( self, request: Optional[ @@ -301,7 +333,7 @@ async def create_namespace( namespace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Creates a namespace, and returns the new namespace. @@ -367,8 +399,10 @@ async def sample_create_namespace(): 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, 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -437,7 +471,7 @@ async def list_namespaces( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNamespacesAsyncPager: r"""Lists all namespaces. @@ -483,8 +517,10 @@ async def sample_list_namespaces(): 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, 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListNamespacesAsyncPager: @@ -559,7 +595,7 @@ async def get_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Gets a namespace. @@ -603,8 +639,10 @@ async def sample_get_namespace(): 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, 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -670,7 +708,7 @@ async def update_namespace( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Updates a namespace. @@ -718,8 +756,10 @@ async def sample_update_namespace(): 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, 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -788,7 +828,7 @@ async def delete_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a namespace. This also deletes all services and endpoints in the namespace. @@ -830,8 +870,10 @@ async def sample_delete_namespace(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -887,7 +929,7 @@ async def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Creates a service, and returns the new service. @@ -952,8 +994,10 @@ async def sample_create_service(): 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, 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: google.cloud.servicedirectory_v1.types.Service: @@ -1020,7 +1064,7 @@ async def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists all services belonging to a namespace. @@ -1066,8 +1110,10 @@ async def sample_list_services(): 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, 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListServicesAsyncPager: @@ -1142,7 +1188,7 @@ async def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a service. @@ -1189,8 +1235,10 @@ async def sample_get_service(): 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, 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: google.cloud.servicedirectory_v1.types.Service: @@ -1256,7 +1304,7 @@ async def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Updates a service. @@ -1304,8 +1352,10 @@ async def sample_update_service(): 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, 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: google.cloud.servicedirectory_v1.types.Service: @@ -1374,7 +1424,7 @@ async def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a service. This also deletes all endpoints associated with the service. @@ -1416,8 +1466,10 @@ async def sample_delete_service(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1473,7 +1525,7 @@ async def create_endpoint( endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Creates an endpoint, and returns the new endpoint. @@ -1538,8 +1590,10 @@ async def sample_create_endpoint(): 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, 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -1607,7 +1661,7 @@ async def list_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEndpointsAsyncPager: r"""Lists all endpoints. @@ -1653,8 +1707,10 @@ async def sample_list_endpoints(): 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, 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListEndpointsAsyncPager: @@ -1729,7 +1785,7 @@ async def get_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Gets an endpoint. @@ -1775,8 +1831,10 @@ async def sample_get_endpoint(): 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, 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -1841,7 +1899,7 @@ async def update_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Updates an endpoint. @@ -1889,8 +1947,10 @@ async def sample_update_endpoint(): 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, 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -1958,7 +2018,7 @@ async def delete_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an endpoint. @@ -1999,8 +2059,10 @@ async def sample_delete_endpoint(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2051,7 +2113,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Policy for a resource (namespace or service only). @@ -2089,8 +2151,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2166,7 +2230,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Policy for a resource (namespace or service only). @@ -2204,8 +2268,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2281,7 +2347,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests IAM permissions for a resource (namespace or service only). @@ -2320,8 +2386,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2367,7 +2435,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2378,8 +2446,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2420,7 +2490,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2431,8 +2501,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/client.py index 80b3f4e05ac2..98369b2d67a7 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -678,6 +688,10 @@ def __init__( # 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( @@ -744,6 +758,29 @@ def __init__( 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.servicedirectory_v1.RegistrationServiceClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "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.servicedirectory.v1.RegistrationService", + "credentialsType": None, + }, + ) + def create_namespace( self, request: Optional[ @@ -755,7 +792,7 @@ def create_namespace( namespace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Creates a namespace, and returns the new namespace. @@ -821,8 +858,10 @@ def sample_create_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -888,7 +927,7 @@ def list_namespaces( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNamespacesPager: r"""Lists all namespaces. @@ -934,8 +973,10 @@ def sample_list_namespaces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListNamespacesPager: @@ -1007,7 +1048,7 @@ def get_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Gets a namespace. @@ -1051,8 +1092,10 @@ def sample_get_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -1115,7 +1158,7 @@ def update_namespace( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Updates a namespace. @@ -1163,8 +1206,10 @@ def sample_update_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Namespace: @@ -1230,7 +1275,7 @@ def delete_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a namespace. This also deletes all services and endpoints in the namespace. @@ -1272,8 +1317,10 @@ def sample_delete_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1326,7 +1373,7 @@ def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Creates a service, and returns the new service. @@ -1391,8 +1438,10 @@ def sample_create_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Service: @@ -1456,7 +1505,7 @@ def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesPager: r"""Lists all services belonging to a namespace. @@ -1502,8 +1551,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListServicesPager: @@ -1575,7 +1626,7 @@ def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a service. @@ -1622,8 +1673,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Service: @@ -1686,7 +1739,7 @@ def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Updates a service. @@ -1734,8 +1787,10 @@ def sample_update_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Service: @@ -1801,7 +1856,7 @@ def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a service. This also deletes all endpoints associated with the service. @@ -1843,8 +1898,10 @@ def sample_delete_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1897,7 +1954,7 @@ def create_endpoint( endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Creates an endpoint, and returns the new endpoint. @@ -1962,8 +2019,10 @@ def sample_create_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -2028,7 +2087,7 @@ def list_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEndpointsPager: r"""Lists all endpoints. @@ -2074,8 +2133,10 @@ def sample_list_endpoints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.services.registration_service.pagers.ListEndpointsPager: @@ -2147,7 +2208,7 @@ def get_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Gets an endpoint. @@ -2193,8 +2254,10 @@ def sample_get_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -2256,7 +2319,7 @@ def update_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Updates an endpoint. @@ -2304,8 +2367,10 @@ def sample_update_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1.types.Endpoint: @@ -2370,7 +2435,7 @@ def delete_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an endpoint. @@ -2411,8 +2476,10 @@ def sample_delete_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2460,7 +2527,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Policy for a resource (namespace or service only). @@ -2498,8 +2565,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2574,7 +2643,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Policy for a resource (namespace or service only). @@ -2612,8 +2681,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2688,7 +2759,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests IAM permissions for a resource (namespace or service only). @@ -2727,8 +2798,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2786,7 +2859,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2797,8 +2870,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2839,7 +2914,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2850,8 +2925,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/pagers.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/pagers.py index 6e7dfe425a04..4f668ec08f21 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/pagers.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListNamespacesRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListNamespacesRequest(request) @@ -224,7 +228,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -238,8 +242,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListServicesRequest(request) @@ -298,7 +304,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -312,8 +318,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListServicesRequest(request) @@ -376,7 +384,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -390,8 +398,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListEndpointsRequest(request) @@ -450,7 +460,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -464,8 +474,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListEndpointsRequest(request) diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc.py index 96f4e9f885f0..00e639f33470 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1.types import endpoint from google.cloud.servicedirectory_v1.types import endpoint as gcs_endpoint @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport +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.servicedirectory.v1.RegistrationService", + "rpcName": 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.servicedirectory.v1.RegistrationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistrationServiceGrpcTransport(RegistrationServiceTransport): """gRPC backend transport for RegistrationService. @@ -203,7 +284,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -279,7 +365,7 @@ def create_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_namespace" not in self._stubs: - self._stubs["create_namespace"] = self.grpc_channel.unary_unary( + self._stubs["create_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateNamespace", request_serializer=registration_service.CreateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -308,7 +394,7 @@ def list_namespaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_namespaces" not in self._stubs: - self._stubs["list_namespaces"] = self.grpc_channel.unary_unary( + self._stubs["list_namespaces"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListNamespaces", request_serializer=registration_service.ListNamespacesRequest.serialize, response_deserializer=registration_service.ListNamespacesResponse.deserialize, @@ -334,7 +420,7 @@ def get_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespace" not in self._stubs: - self._stubs["get_namespace"] = self.grpc_channel.unary_unary( + self._stubs["get_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetNamespace", request_serializer=registration_service.GetNamespaceRequest.serialize, response_deserializer=namespace.Namespace.deserialize, @@ -362,7 +448,7 @@ def update_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_namespace" not in self._stubs: - self._stubs["update_namespace"] = self.grpc_channel.unary_unary( + self._stubs["update_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateNamespace", request_serializer=registration_service.UpdateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -389,7 +475,7 @@ def delete_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_namespace" not in self._stubs: - self._stubs["delete_namespace"] = self.grpc_channel.unary_unary( + self._stubs["delete_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteNamespace", request_serializer=registration_service.DeleteNamespaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +501,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateService", request_serializer=registration_service.CreateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -444,7 +530,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListServices", request_serializer=registration_service.ListServicesRequest.serialize, response_deserializer=registration_service.ListServicesResponse.deserialize, @@ -470,7 +556,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetService", request_serializer=registration_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -496,7 +582,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateService", request_serializer=registration_service.UpdateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -523,7 +609,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteService", request_serializer=registration_service.DeleteServiceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -549,7 +635,7 @@ def create_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_endpoint" not in self._stubs: - self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateEndpoint", request_serializer=registration_service.CreateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -578,7 +664,7 @@ def list_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_endpoints" not in self._stubs: - self._stubs["list_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListEndpoints", request_serializer=registration_service.ListEndpointsRequest.serialize, response_deserializer=registration_service.ListEndpointsResponse.deserialize, @@ -604,7 +690,7 @@ def get_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_endpoint" not in self._stubs: - self._stubs["get_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetEndpoint", request_serializer=registration_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, @@ -630,7 +716,7 @@ def update_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_endpoint" not in self._stubs: - self._stubs["update_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateEndpoint", request_serializer=registration_service.UpdateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -656,7 +742,7 @@ def delete_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_endpoint" not in self._stubs: - self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteEndpoint", request_serializer=registration_service.DeleteEndpointRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -683,7 +769,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -710,7 +796,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -740,7 +826,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -748,7 +834,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -762,7 +848,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -779,7 +865,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc_asyncio.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc_asyncio.py index e989b0551ccc..5a7829d1a5fb 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1.types import endpoint from google.cloud.servicedirectory_v1.types import endpoint as gcs_endpoint @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport from .grpc import RegistrationServiceGrpcTransport +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.servicedirectory.v1.RegistrationService", + "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.servicedirectory.v1.RegistrationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistrationServiceGrpcAsyncIOTransport(RegistrationServiceTransport): """gRPC AsyncIO backend transport for RegistrationService. @@ -250,10 +332,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -288,7 +373,7 @@ def create_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_namespace" not in self._stubs: - self._stubs["create_namespace"] = self.grpc_channel.unary_unary( + self._stubs["create_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateNamespace", request_serializer=registration_service.CreateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -317,7 +402,7 @@ def list_namespaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_namespaces" not in self._stubs: - self._stubs["list_namespaces"] = self.grpc_channel.unary_unary( + self._stubs["list_namespaces"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListNamespaces", request_serializer=registration_service.ListNamespacesRequest.serialize, response_deserializer=registration_service.ListNamespacesResponse.deserialize, @@ -345,7 +430,7 @@ def get_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespace" not in self._stubs: - self._stubs["get_namespace"] = self.grpc_channel.unary_unary( + self._stubs["get_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetNamespace", request_serializer=registration_service.GetNamespaceRequest.serialize, response_deserializer=namespace.Namespace.deserialize, @@ -374,7 +459,7 @@ def update_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_namespace" not in self._stubs: - self._stubs["update_namespace"] = self.grpc_channel.unary_unary( + self._stubs["update_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateNamespace", request_serializer=registration_service.UpdateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -403,7 +488,7 @@ def delete_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_namespace" not in self._stubs: - self._stubs["delete_namespace"] = self.grpc_channel.unary_unary( + self._stubs["delete_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteNamespace", request_serializer=registration_service.DeleteNamespaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -431,7 +516,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateService", request_serializer=registration_service.CreateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -460,7 +545,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListServices", request_serializer=registration_service.ListServicesRequest.serialize, response_deserializer=registration_service.ListServicesResponse.deserialize, @@ -486,7 +571,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetService", request_serializer=registration_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -514,7 +599,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateService", request_serializer=registration_service.UpdateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -543,7 +628,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteService", request_serializer=registration_service.DeleteServiceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -571,7 +656,7 @@ def create_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_endpoint" not in self._stubs: - self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/CreateEndpoint", request_serializer=registration_service.CreateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -600,7 +685,7 @@ def list_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_endpoints" not in self._stubs: - self._stubs["list_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/ListEndpoints", request_serializer=registration_service.ListEndpointsRequest.serialize, response_deserializer=registration_service.ListEndpointsResponse.deserialize, @@ -628,7 +713,7 @@ def get_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_endpoint" not in self._stubs: - self._stubs["get_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetEndpoint", request_serializer=registration_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, @@ -656,7 +741,7 @@ def update_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_endpoint" not in self._stubs: - self._stubs["update_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/UpdateEndpoint", request_serializer=registration_service.UpdateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -684,7 +769,7 @@ def delete_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_endpoint" not in self._stubs: - self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/DeleteEndpoint", request_serializer=registration_service.DeleteEndpointRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -711,7 +796,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -738,7 +823,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -768,7 +853,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1.RegistrationService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -886,7 +971,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -904,7 +989,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -921,7 +1006,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/rest.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/rest.py index 1ad938431e6d..a3de71c5bbce 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/rest.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1/services/registration_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -47,6 +47,14 @@ 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, @@ -211,8 +219,11 @@ def post_update_service(self, response): def pre_create_endpoint( self, request: registration_service.CreateEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_endpoint Override in a subclass to manipulate the request or metadata @@ -234,8 +245,11 @@ def post_create_endpoint( def pre_create_namespace( self, request: registration_service.CreateNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_namespace Override in a subclass to manipulate the request or metadata @@ -257,8 +271,11 @@ def post_create_namespace( def pre_create_service( self, request: registration_service.CreateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_service Override in a subclass to manipulate the request or metadata @@ -278,8 +295,11 @@ def post_create_service(self, response: gcs_service.Service) -> gcs_service.Serv def pre_delete_endpoint( self, request: registration_service.DeleteEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_endpoint Override in a subclass to manipulate the request or metadata @@ -290,8 +310,11 @@ def pre_delete_endpoint( def pre_delete_namespace( self, request: registration_service.DeleteNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_namespace Override in a subclass to manipulate the request or metadata @@ -302,8 +325,11 @@ def pre_delete_namespace( def pre_delete_service( self, request: registration_service.DeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -314,8 +340,10 @@ def pre_delete_service( def pre_get_endpoint( self, request: registration_service.GetEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_endpoint Override in a subclass to manipulate the request or metadata @@ -335,8 +363,10 @@ def post_get_endpoint(self, response: endpoint.Endpoint) -> endpoint.Endpoint: def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -356,8 +386,11 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_namespace( self, request: registration_service.GetNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_namespace Override in a subclass to manipulate the request or metadata @@ -377,8 +410,10 @@ def post_get_namespace(self, response: namespace.Namespace) -> namespace.Namespa def pre_get_service( self, request: registration_service.GetServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -398,8 +433,11 @@ def post_get_service(self, response: service.Service) -> service.Service: def pre_list_endpoints( self, request: registration_service.ListEndpointsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListEndpointsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListEndpointsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_endpoints Override in a subclass to manipulate the request or metadata @@ -421,8 +459,11 @@ def post_list_endpoints( def pre_list_namespaces( self, request: registration_service.ListNamespacesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListNamespacesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListNamespacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_namespaces Override in a subclass to manipulate the request or metadata @@ -444,8 +485,11 @@ def post_list_namespaces( def pre_list_services( self, request: registration_service.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -467,8 +511,10 @@ def post_list_services( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -488,8 +534,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -511,8 +560,11 @@ def post_test_iam_permissions( def pre_update_endpoint( self, request: registration_service.UpdateEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_endpoint Override in a subclass to manipulate the request or metadata @@ -534,8 +586,11 @@ def post_update_endpoint( def pre_update_namespace( self, request: registration_service.UpdateNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_namespace Override in a subclass to manipulate the request or metadata @@ -557,8 +612,11 @@ def post_update_namespace( def pre_update_service( self, request: registration_service.UpdateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_service Override in a subclass to manipulate the request or metadata @@ -578,8 +636,10 @@ def post_update_service(self, response: gcs_service.Service) -> gcs_service.Serv def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -601,8 +661,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -758,7 +820,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Call the create endpoint method over HTTP. @@ -769,8 +831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_endpoint.Endpoint: @@ -783,6 +847,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_create_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseCreateEndpoint._get_transcoded_request( http_options, request @@ -797,6 +862,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.CreateEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateEndpoint._get_response( self._host, @@ -818,7 +910,29 @@ def __call__( pb_resp = gcs_endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_endpoint.Endpoint.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.servicedirectory_v1.RegistrationServiceClient.create_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNamespace( @@ -857,7 +971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Call the create namespace method over HTTP. @@ -868,8 +982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_namespace.Namespace: @@ -884,6 +1000,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_create_namespace( request, metadata ) @@ -900,6 +1017,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.CreateNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateNamespace._get_response( self._host, @@ -921,7 +1065,29 @@ def __call__( pb_resp = gcs_namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_namespace.Namespace.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.servicedirectory_v1.RegistrationServiceClient.create_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateService( @@ -960,7 +1126,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Call the create service method over HTTP. @@ -971,8 +1137,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_service.Service: @@ -986,6 +1154,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateService._get_http_options() ) + request, metadata = self._interceptor.pre_create_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseCreateService._get_transcoded_request( http_options, request @@ -1000,6 +1169,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.CreateService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateService._get_response( self._host, @@ -1021,7 +1217,29 @@ def __call__( pb_resp = gcs_service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_service.Service.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.servicedirectory_v1.RegistrationServiceClient.create_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "CreateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEndpoint( @@ -1059,7 +1277,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete endpoint method over HTTP. @@ -1070,13 +1288,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseDeleteEndpoint._get_transcoded_request( http_options, request @@ -1087,6 +1308,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.DeleteEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "DeleteEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteEndpoint._get_response( self._host, @@ -1137,7 +1385,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete namespace method over HTTP. @@ -1148,13 +1396,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_delete_namespace( request, metadata ) @@ -1167,6 +1418,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.DeleteNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "DeleteNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteNamespace._get_response( self._host, @@ -1217,7 +1495,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete service method over HTTP. @@ -1228,13 +1506,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseDeleteService._get_transcoded_request( http_options, request @@ -1245,6 +1526,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.DeleteService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteService._get_response( self._host, @@ -1295,7 +1603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Call the get endpoint method over HTTP. @@ -1308,8 +1616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.endpoint.Endpoint: @@ -1322,6 +1632,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_get_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetEndpoint._get_transcoded_request( http_options, request @@ -1332,6 +1643,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.GetEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetEndpoint._get_response( self._host, @@ -1352,7 +1690,29 @@ def __call__( pb_resp = endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = endpoint.Endpoint.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.servicedirectory_v1.RegistrationServiceClient.get_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1391,7 +1751,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1401,8 +1761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1487,6 +1849,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1501,6 +1864,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1522,7 +1912,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.servicedirectory_v1.RegistrationServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNamespace( @@ -1560,7 +1972,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Call the get namespace method over HTTP. @@ -1571,8 +1983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.namespace.Namespace: @@ -1587,6 +2001,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_get_namespace(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetNamespace._get_transcoded_request( http_options, request @@ -1597,6 +2012,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.GetNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetNamespace._get_response( self._host, @@ -1617,7 +2059,29 @@ def __call__( pb_resp = namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = namespace.Namespace.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.servicedirectory_v1.RegistrationServiceClient.get_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService( @@ -1655,7 +2119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Call the get service method over HTTP. @@ -1669,8 +2133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.Service: @@ -1684,6 +2150,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetService._get_transcoded_request( http_options, request @@ -1694,6 +2161,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.GetService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetService._get_response( self._host, @@ -1714,7 +2208,29 @@ def __call__( pb_resp = service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Service.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.servicedirectory_v1.RegistrationServiceClient.get_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEndpoints( @@ -1752,7 +2268,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListEndpointsResponse: r"""Call the list endpoints method over HTTP. @@ -1763,8 +2279,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListEndpointsResponse: @@ -1776,6 +2294,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_endpoints(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListEndpoints._get_transcoded_request( http_options, request @@ -1786,6 +2305,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.ListEndpoints", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListEndpoints._get_response( self._host, @@ -1806,7 +2352,31 @@ def __call__( pb_resp = registration_service.ListEndpointsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListEndpointsResponse.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.servicedirectory_v1.RegistrationServiceClient.list_endpoints", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNamespaces( @@ -1844,7 +2414,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListNamespacesResponse: r"""Call the list namespaces method over HTTP. @@ -1855,8 +2425,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListNamespacesResponse: @@ -1868,6 +2440,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListNamespaces._get_http_options() ) + request, metadata = self._interceptor.pre_list_namespaces(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListNamespaces._get_transcoded_request( http_options, request @@ -1878,6 +2451,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.ListNamespaces", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListNamespaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListNamespaces._get_response( self._host, @@ -1898,7 +2498,31 @@ def __call__( pb_resp = registration_service.ListNamespacesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_namespaces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListNamespacesResponse.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.servicedirectory_v1.RegistrationServiceClient.list_namespaces", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListNamespaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices( @@ -1936,7 +2560,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListServicesResponse: r"""Call the list services method over HTTP. @@ -1947,8 +2571,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListServicesResponse: @@ -1960,6 +2586,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListServices._get_transcoded_request( http_options, request @@ -1970,6 +2597,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.ListServices", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListServices._get_response( self._host, @@ -1990,7 +2644,31 @@ def __call__( pb_resp = registration_service.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListServicesResponse.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.servicedirectory_v1.RegistrationServiceClient.list_services", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2029,7 +2707,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2039,8 +2717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2125,6 +2805,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2139,6 +2820,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -2160,7 +2868,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.servicedirectory_v1.RegistrationServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2199,7 +2929,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2209,8 +2939,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2220,6 +2952,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2236,6 +2969,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegistrationServiceRestTransport._TestIamPermissions._get_response( @@ -2259,7 +3019,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.servicedirectory_v1.RegistrationServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEndpoint( @@ -2298,7 +3080,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Call the update endpoint method over HTTP. @@ -2309,8 +3091,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_endpoint.Endpoint: @@ -2323,6 +3107,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_update_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseUpdateEndpoint._get_transcoded_request( http_options, request @@ -2337,6 +3122,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.UpdateEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateEndpoint._get_response( self._host, @@ -2358,7 +3170,29 @@ def __call__( pb_resp = gcs_endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_endpoint.Endpoint.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.servicedirectory_v1.RegistrationServiceClient.update_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNamespace( @@ -2397,7 +3231,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Call the update namespace method over HTTP. @@ -2408,8 +3242,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_namespace.Namespace: @@ -2424,6 +3260,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_update_namespace( request, metadata ) @@ -2440,6 +3277,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.UpdateNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateNamespace._get_response( self._host, @@ -2461,7 +3325,29 @@ def __call__( pb_resp = gcs_namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_namespace.Namespace.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.servicedirectory_v1.RegistrationServiceClient.update_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateService( @@ -2500,7 +3386,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Call the update service method over HTTP. @@ -2511,8 +3397,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_service.Service: @@ -2526,6 +3414,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateService._get_http_options() ) + request, metadata = self._interceptor.pre_update_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseUpdateService._get_transcoded_request( http_options, request @@ -2540,6 +3429,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.UpdateService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateService._get_response( self._host, @@ -2561,7 +3477,29 @@ def __call__( pb_resp = gcs_service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_service.Service.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.servicedirectory_v1.RegistrationServiceClient.update_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "UpdateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2763,7 +3701,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2773,8 +3711,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2783,6 +3723,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2793,6 +3734,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetLocation._get_response( self._host, @@ -2812,6 +3780,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.servicedirectory_v1.RegistrationServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2853,7 +3842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2863,8 +3852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2873,6 +3864,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2883,6 +3875,33 @@ def __call__( 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.servicedirectory_v1.RegistrationServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListLocations._get_response( self._host, @@ -2902,6 +3921,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.servicedirectory_v1.RegistrationServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1.RegistrationService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/gapic_version.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/gapic_version.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/async_client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/async_client.py index 14c791c3bc8a..6328d6e35ae1 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/async_client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, LookupServiceTransport from .transports.grpc_asyncio import LookupServiceGrpcAsyncIOTransport +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 LookupServiceAsyncClient: """Service Directory API for looking up service data at runtime.""" @@ -259,13 +269,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.servicedirectory_v1beta1.LookupServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "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.servicedirectory.v1beta1.LookupService", + "credentialsType": None, + }, + ) + async def resolve_service( self, request: Optional[Union[lookup_service.ResolveServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Returns a [service][google.cloud.servicedirectory.v1beta1.Service] and its @@ -307,8 +339,10 @@ async def sample_resolve_service(): 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, 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: google.cloud.servicedirectory_v1beta1.types.ResolveServiceResponse: @@ -354,7 +388,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -365,8 +399,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -407,7 +443,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -418,8 +454,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/client.py index 724a006f8f69..9ac49f0a52cb 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.cloud.servicedirectory_v1beta1.types import lookup_service, service @@ -625,6 +635,10 @@ def __init__( # 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( @@ -690,13 +704,36 @@ def __init__( 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.servicedirectory_v1beta1.LookupServiceClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "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.servicedirectory.v1beta1.LookupService", + "credentialsType": None, + }, + ) + def resolve_service( self, request: Optional[Union[lookup_service.ResolveServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Returns a [service][google.cloud.servicedirectory.v1beta1.Service] and its @@ -738,8 +775,10 @@ def sample_resolve_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.ResolveServiceResponse: @@ -796,7 +835,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -807,8 +846,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -849,7 +890,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -860,8 +901,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc.py index 88da1fdb0600..17873740d749 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1beta1.types import lookup_service from .base import DEFAULT_CLIENT_INFO, LookupServiceTransport +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.servicedirectory.v1beta1.LookupService", + "rpcName": 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.servicedirectory.v1beta1.LookupService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LookupServiceGrpcTransport(LookupServiceTransport): """gRPC backend transport for LookupService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def resolve_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_service" not in self._stubs: - self._stubs["resolve_service"] = self.grpc_channel.unary_unary( + self._stubs["resolve_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.LookupService/ResolveService", request_serializer=lookup_service.ResolveServiceRequest.serialize, response_deserializer=lookup_service.ResolveServiceResponse.deserialize, @@ -267,7 +353,7 @@ def resolve_service( return self._stubs["resolve_service"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -281,7 +367,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -298,7 +384,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc_asyncio.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc_asyncio.py index 2c94bded81f3..10f5694a8228 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1beta1.types import lookup_service from .base import DEFAULT_CLIENT_INFO, LookupServiceTransport from .grpc import LookupServiceGrpcTransport +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.servicedirectory.v1beta1.LookupService", + "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.servicedirectory.v1beta1.LookupService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class LookupServiceGrpcAsyncIOTransport(LookupServiceTransport): """gRPC AsyncIO backend transport for LookupService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def resolve_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_service" not in self._stubs: - self._stubs["resolve_service"] = self.grpc_channel.unary_unary( + self._stubs["resolve_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.LookupService/ResolveService", request_serializer=lookup_service.ResolveServiceRequest.serialize, response_deserializer=lookup_service.ResolveServiceResponse.deserialize, @@ -301,7 +386,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -319,7 +404,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -336,7 +421,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/rest.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/rest.py index 28012f5d0169..b405a482970a 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/rest.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/lookup_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_resolve_service(self, response): def pre_resolve_service( self, request: lookup_service.ResolveServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[lookup_service.ResolveServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + lookup_service.ResolveServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resolve_service Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_resolve_service( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -124,8 +136,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -266,7 +280,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lookup_service.ResolveServiceResponse: r"""Call the resolve service method over HTTP. @@ -279,8 +293,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.lookup_service.ResolveServiceResponse: @@ -292,6 +308,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseResolveService._get_http_options() ) + request, metadata = self._interceptor.pre_resolve_service(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseResolveService._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( 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.servicedirectory_v1beta1.LookupServiceClient.ResolveService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "ResolveService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._ResolveService._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = lookup_service.ResolveServiceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resolve_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lookup_service.ResolveServiceResponse.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.servicedirectory_v1beta1.LookupServiceClient.resolve_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "ResolveService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -410,6 +481,33 @@ def __call__( ) ) + 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.servicedirectory_v1beta1.LookupServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._GetLocation._get_response( self._host, @@ -429,6 +527,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.servicedirectory_v1beta1.LookupServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -469,7 +588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -479,8 +598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -489,6 +610,7 @@ def __call__( http_options = ( _BaseLookupServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLookupServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -499,6 +621,33 @@ def __call__( 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.servicedirectory_v1beta1.LookupServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LookupServiceRestTransport._ListLocations._get_response( self._host, @@ -518,6 +667,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.servicedirectory_v1beta1.LookupServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.LookupService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/async_client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/async_client.py index 5ea36ee74080..61c973a7d345 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/async_client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport from .transports.grpc_asyncio import RegistrationServiceGrpcAsyncIOTransport +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 RegistrationServiceAsyncClient: """Service Directory API for registering services. It defines the @@ -292,6 +302,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.servicedirectory_v1beta1.RegistrationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "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.servicedirectory.v1beta1.RegistrationService", + "credentialsType": None, + }, + ) + async def create_namespace( self, request: Optional[ @@ -303,7 +335,7 @@ async def create_namespace( namespace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Creates a namespace, and returns the new namespace. @@ -369,8 +401,10 @@ async def sample_create_namespace(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -439,7 +473,7 @@ async def list_namespaces( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNamespacesAsyncPager: r"""Lists all namespaces. @@ -485,8 +519,10 @@ async def sample_list_namespaces(): 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, 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListNamespacesAsyncPager: @@ -561,7 +597,7 @@ async def get_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Gets a namespace. @@ -605,8 +641,10 @@ async def sample_get_namespace(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -672,7 +710,7 @@ async def update_namespace( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Updates a namespace. @@ -720,8 +758,10 @@ async def sample_update_namespace(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -790,7 +830,7 @@ async def delete_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a namespace. This also deletes all services and endpoints in the namespace. @@ -832,8 +872,10 @@ async def sample_delete_namespace(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -889,7 +931,7 @@ async def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Creates a service, and returns the new service. @@ -954,8 +996,10 @@ async def sample_create_service(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1022,7 +1066,7 @@ async def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists all services belonging to a namespace. @@ -1068,8 +1112,10 @@ async def sample_list_services(): 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, 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListServicesAsyncPager: @@ -1144,7 +1190,7 @@ async def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a service. @@ -1191,8 +1237,10 @@ async def sample_get_service(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1258,7 +1306,7 @@ async def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Updates a service. @@ -1306,8 +1354,10 @@ async def sample_update_service(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1376,7 +1426,7 @@ async def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a service. This also deletes all endpoints associated with the service. @@ -1418,8 +1468,10 @@ async def sample_delete_service(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1475,7 +1527,7 @@ async def create_endpoint( endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Creates an endpoint, and returns the new endpoint. @@ -1540,8 +1592,10 @@ async def sample_create_endpoint(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -1609,7 +1663,7 @@ async def list_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEndpointsAsyncPager: r"""Lists all endpoints. @@ -1655,8 +1709,10 @@ async def sample_list_endpoints(): 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, 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListEndpointsAsyncPager: @@ -1731,7 +1787,7 @@ async def get_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Gets an endpoint. @@ -1777,8 +1833,10 @@ async def sample_get_endpoint(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -1843,7 +1901,7 @@ async def update_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Updates an endpoint. @@ -1891,8 +1949,10 @@ async def sample_update_endpoint(): 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, 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -1960,7 +2020,7 @@ async def delete_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an endpoint. @@ -2001,8 +2061,10 @@ async def sample_delete_endpoint(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2053,7 +2115,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Policy for a resource @@ -2090,8 +2152,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2167,7 +2231,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Policy for a resource @@ -2204,8 +2268,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -2281,7 +2347,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests IAM permissions for a resource (namespace, service or service workload only). @@ -2320,8 +2386,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2367,7 +2435,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2378,8 +2446,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2420,7 +2490,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2431,8 +2501,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/client.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/client.py index 79c0d8d78e5d..635524c57e5b 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/client.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -680,6 +690,10 @@ def __init__( # 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( @@ -746,6 +760,29 @@ def __init__( 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.servicedirectory_v1beta1.RegistrationServiceClient`.", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "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.servicedirectory.v1beta1.RegistrationService", + "credentialsType": None, + }, + ) + def create_namespace( self, request: Optional[ @@ -757,7 +794,7 @@ def create_namespace( namespace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Creates a namespace, and returns the new namespace. @@ -823,8 +860,10 @@ def sample_create_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -890,7 +929,7 @@ def list_namespaces( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNamespacesPager: r"""Lists all namespaces. @@ -936,8 +975,10 @@ def sample_list_namespaces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListNamespacesPager: @@ -1009,7 +1050,7 @@ def get_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Gets a namespace. @@ -1053,8 +1094,10 @@ def sample_get_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -1117,7 +1160,7 @@ def update_namespace( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Updates a namespace. @@ -1165,8 +1208,10 @@ def sample_update_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Namespace: @@ -1232,7 +1277,7 @@ def delete_namespace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a namespace. This also deletes all services and endpoints in the namespace. @@ -1274,8 +1319,10 @@ def sample_delete_namespace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1328,7 +1375,7 @@ def create_service( service_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Creates a service, and returns the new service. @@ -1393,8 +1440,10 @@ def sample_create_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1458,7 +1507,7 @@ def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesPager: r"""Lists all services belonging to a namespace. @@ -1504,8 +1553,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListServicesPager: @@ -1577,7 +1628,7 @@ def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a service. @@ -1624,8 +1675,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1688,7 +1741,7 @@ def update_service( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Updates a service. @@ -1736,8 +1789,10 @@ def sample_update_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Service: @@ -1803,7 +1858,7 @@ def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a service. This also deletes all endpoints associated with the service. @@ -1845,8 +1900,10 @@ def sample_delete_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1899,7 +1956,7 @@ def create_endpoint( endpoint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Creates an endpoint, and returns the new endpoint. @@ -1964,8 +2021,10 @@ def sample_create_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -2030,7 +2089,7 @@ def list_endpoints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEndpointsPager: r"""Lists all endpoints. @@ -2076,8 +2135,10 @@ def sample_list_endpoints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListEndpointsPager: @@ -2149,7 +2210,7 @@ def get_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Gets an endpoint. @@ -2195,8 +2256,10 @@ def sample_get_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -2258,7 +2321,7 @@ def update_endpoint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Updates an endpoint. @@ -2306,8 +2369,10 @@ def sample_update_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicedirectory_v1beta1.types.Endpoint: @@ -2372,7 +2437,7 @@ def delete_endpoint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an endpoint. @@ -2413,8 +2478,10 @@ def sample_delete_endpoint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2462,7 +2529,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM Policy for a resource @@ -2499,8 +2566,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2575,7 +2644,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM Policy for a resource @@ -2612,8 +2681,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2688,7 +2759,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests IAM permissions for a resource (namespace, service or service workload only). @@ -2727,8 +2798,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2786,7 +2859,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2797,8 +2870,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2839,7 +2914,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2850,8 +2925,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/pagers.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/pagers.py index 21c4f56fc63f..0b797c9cd363 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/pagers.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListNamespacesRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListNamespacesRequest(request) @@ -224,7 +228,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -238,8 +242,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListServicesRequest(request) @@ -298,7 +304,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -312,8 +318,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListServicesRequest(request) @@ -376,7 +384,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -390,8 +398,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = registration_service.ListEndpointsRequest(request) @@ -450,7 +460,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -464,8 +474,10 @@ def __init__( 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, 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`. """ self._method = method self._request = registration_service.ListEndpointsRequest(request) diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc.py index 7fbe6dfa31c2..a864bed555da 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1beta1.types import endpoint as gcs_endpoint from google.cloud.servicedirectory_v1beta1.types import namespace as gcs_namespace @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport +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.servicedirectory.v1beta1.RegistrationService", + "rpcName": 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.servicedirectory.v1beta1.RegistrationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistrationServiceGrpcTransport(RegistrationServiceTransport): """gRPC backend transport for RegistrationService. @@ -204,7 +285,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -280,7 +366,7 @@ def create_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_namespace" not in self._stubs: - self._stubs["create_namespace"] = self.grpc_channel.unary_unary( + self._stubs["create_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateNamespace", request_serializer=registration_service.CreateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -309,7 +395,7 @@ def list_namespaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_namespaces" not in self._stubs: - self._stubs["list_namespaces"] = self.grpc_channel.unary_unary( + self._stubs["list_namespaces"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListNamespaces", request_serializer=registration_service.ListNamespacesRequest.serialize, response_deserializer=registration_service.ListNamespacesResponse.deserialize, @@ -335,7 +421,7 @@ def get_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespace" not in self._stubs: - self._stubs["get_namespace"] = self.grpc_channel.unary_unary( + self._stubs["get_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetNamespace", request_serializer=registration_service.GetNamespaceRequest.serialize, response_deserializer=namespace.Namespace.deserialize, @@ -363,7 +449,7 @@ def update_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_namespace" not in self._stubs: - self._stubs["update_namespace"] = self.grpc_channel.unary_unary( + self._stubs["update_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateNamespace", request_serializer=registration_service.UpdateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -390,7 +476,7 @@ def delete_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_namespace" not in self._stubs: - self._stubs["delete_namespace"] = self.grpc_channel.unary_unary( + self._stubs["delete_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteNamespace", request_serializer=registration_service.DeleteNamespaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -416,7 +502,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateService", request_serializer=registration_service.CreateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -445,7 +531,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListServices", request_serializer=registration_service.ListServicesRequest.serialize, response_deserializer=registration_service.ListServicesResponse.deserialize, @@ -471,7 +557,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetService", request_serializer=registration_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -497,7 +583,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateService", request_serializer=registration_service.UpdateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -524,7 +610,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteService", request_serializer=registration_service.DeleteServiceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -550,7 +636,7 @@ def create_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_endpoint" not in self._stubs: - self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateEndpoint", request_serializer=registration_service.CreateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -579,7 +665,7 @@ def list_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_endpoints" not in self._stubs: - self._stubs["list_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListEndpoints", request_serializer=registration_service.ListEndpointsRequest.serialize, response_deserializer=registration_service.ListEndpointsResponse.deserialize, @@ -605,7 +691,7 @@ def get_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_endpoint" not in self._stubs: - self._stubs["get_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetEndpoint", request_serializer=registration_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, @@ -631,7 +717,7 @@ def update_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_endpoint" not in self._stubs: - self._stubs["update_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateEndpoint", request_serializer=registration_service.UpdateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -657,7 +743,7 @@ def delete_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_endpoint" not in self._stubs: - self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteEndpoint", request_serializer=registration_service.DeleteEndpointRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -683,7 +769,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -709,7 +795,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -739,7 +825,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -747,7 +833,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -761,7 +847,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -778,7 +864,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc_asyncio.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc_asyncio.py index 73875f2f38d6..40376a4488f6 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicedirectory_v1beta1.types import endpoint as gcs_endpoint from google.cloud.servicedirectory_v1beta1.types import namespace as gcs_namespace @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, RegistrationServiceTransport from .grpc import RegistrationServiceGrpcTransport +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.servicedirectory.v1beta1.RegistrationService", + "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.servicedirectory.v1beta1.RegistrationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistrationServiceGrpcAsyncIOTransport(RegistrationServiceTransport): """gRPC AsyncIO backend transport for RegistrationService. @@ -251,10 +333,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -289,7 +374,7 @@ def create_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_namespace" not in self._stubs: - self._stubs["create_namespace"] = self.grpc_channel.unary_unary( + self._stubs["create_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateNamespace", request_serializer=registration_service.CreateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -318,7 +403,7 @@ def list_namespaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_namespaces" not in self._stubs: - self._stubs["list_namespaces"] = self.grpc_channel.unary_unary( + self._stubs["list_namespaces"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListNamespaces", request_serializer=registration_service.ListNamespacesRequest.serialize, response_deserializer=registration_service.ListNamespacesResponse.deserialize, @@ -346,7 +431,7 @@ def get_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespace" not in self._stubs: - self._stubs["get_namespace"] = self.grpc_channel.unary_unary( + self._stubs["get_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetNamespace", request_serializer=registration_service.GetNamespaceRequest.serialize, response_deserializer=namespace.Namespace.deserialize, @@ -375,7 +460,7 @@ def update_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_namespace" not in self._stubs: - self._stubs["update_namespace"] = self.grpc_channel.unary_unary( + self._stubs["update_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateNamespace", request_serializer=registration_service.UpdateNamespaceRequest.serialize, response_deserializer=gcs_namespace.Namespace.deserialize, @@ -404,7 +489,7 @@ def delete_namespace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_namespace" not in self._stubs: - self._stubs["delete_namespace"] = self.grpc_channel.unary_unary( + self._stubs["delete_namespace"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteNamespace", request_serializer=registration_service.DeleteNamespaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -432,7 +517,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateService", request_serializer=registration_service.CreateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -461,7 +546,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListServices", request_serializer=registration_service.ListServicesRequest.serialize, response_deserializer=registration_service.ListServicesResponse.deserialize, @@ -487,7 +572,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetService", request_serializer=registration_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -515,7 +600,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateService", request_serializer=registration_service.UpdateServiceRequest.serialize, response_deserializer=gcs_service.Service.deserialize, @@ -544,7 +629,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteService", request_serializer=registration_service.DeleteServiceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -572,7 +657,7 @@ def create_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_endpoint" not in self._stubs: - self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/CreateEndpoint", request_serializer=registration_service.CreateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -601,7 +686,7 @@ def list_endpoints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_endpoints" not in self._stubs: - self._stubs["list_endpoints"] = self.grpc_channel.unary_unary( + self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/ListEndpoints", request_serializer=registration_service.ListEndpointsRequest.serialize, response_deserializer=registration_service.ListEndpointsResponse.deserialize, @@ -629,7 +714,7 @@ def get_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_endpoint" not in self._stubs: - self._stubs["get_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetEndpoint", request_serializer=registration_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, @@ -657,7 +742,7 @@ def update_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_endpoint" not in self._stubs: - self._stubs["update_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateEndpoint", request_serializer=registration_service.UpdateEndpointRequest.serialize, response_deserializer=gcs_endpoint.Endpoint.deserialize, @@ -685,7 +770,7 @@ def delete_endpoint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_endpoint" not in self._stubs: - self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( + self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteEndpoint", request_serializer=registration_service.DeleteEndpointRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -711,7 +796,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -737,7 +822,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -767,7 +852,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.servicedirectory.v1beta1.RegistrationService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -885,7 +970,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -903,7 +988,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -920,7 +1005,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/rest.py b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/rest.py index 90a21133ef6f..fa074f4446bc 100644 --- a/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/rest.py +++ b/packages/google-cloud-service-directory/google/cloud/servicedirectory_v1beta1/services/registration_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -47,6 +47,14 @@ 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, @@ -211,8 +219,11 @@ def post_update_service(self, response): def pre_create_endpoint( self, request: registration_service.CreateEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_endpoint Override in a subclass to manipulate the request or metadata @@ -234,8 +245,11 @@ def post_create_endpoint( def pre_create_namespace( self, request: registration_service.CreateNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_namespace Override in a subclass to manipulate the request or metadata @@ -257,8 +271,11 @@ def post_create_namespace( def pre_create_service( self, request: registration_service.CreateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.CreateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.CreateServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_service Override in a subclass to manipulate the request or metadata @@ -278,8 +295,11 @@ def post_create_service(self, response: gcs_service.Service) -> gcs_service.Serv def pre_delete_endpoint( self, request: registration_service.DeleteEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_endpoint Override in a subclass to manipulate the request or metadata @@ -290,8 +310,11 @@ def pre_delete_endpoint( def pre_delete_namespace( self, request: registration_service.DeleteNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_namespace Override in a subclass to manipulate the request or metadata @@ -302,8 +325,11 @@ def pre_delete_namespace( def pre_delete_service( self, request: registration_service.DeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.DeleteServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -314,8 +340,10 @@ def pre_delete_service( def pre_get_endpoint( self, request: registration_service.GetEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetEndpointRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_endpoint Override in a subclass to manipulate the request or metadata @@ -335,8 +363,10 @@ def post_get_endpoint(self, response: endpoint.Endpoint) -> endpoint.Endpoint: def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -356,8 +386,11 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_namespace( self, request: registration_service.GetNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_namespace Override in a subclass to manipulate the request or metadata @@ -377,8 +410,10 @@ def post_get_namespace(self, response: namespace.Namespace) -> namespace.Namespa def pre_get_service( self, request: registration_service.GetServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.GetServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -398,8 +433,11 @@ def post_get_service(self, response: service.Service) -> service.Service: def pre_list_endpoints( self, request: registration_service.ListEndpointsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListEndpointsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListEndpointsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_endpoints Override in a subclass to manipulate the request or metadata @@ -421,8 +459,11 @@ def post_list_endpoints( def pre_list_namespaces( self, request: registration_service.ListNamespacesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListNamespacesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListNamespacesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_namespaces Override in a subclass to manipulate the request or metadata @@ -444,8 +485,11 @@ def post_list_namespaces( def pre_list_services( self, request: registration_service.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.ListServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -467,8 +511,10 @@ def post_list_services( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -488,8 +534,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -511,8 +560,11 @@ def post_test_iam_permissions( def pre_update_endpoint( self, request: registration_service.UpdateEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_endpoint Override in a subclass to manipulate the request or metadata @@ -534,8 +586,11 @@ def post_update_endpoint( def pre_update_namespace( self, request: registration_service.UpdateNamespaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateNamespaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateNamespaceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_namespace Override in a subclass to manipulate the request or metadata @@ -557,8 +612,11 @@ def post_update_namespace( def pre_update_service( self, request: registration_service.UpdateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registration_service.UpdateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registration_service.UpdateServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_service Override in a subclass to manipulate the request or metadata @@ -578,8 +636,10 @@ def post_update_service(self, response: gcs_service.Service) -> gcs_service.Serv def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -601,8 +661,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -759,7 +821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Call the create endpoint method over HTTP. @@ -770,8 +832,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_endpoint.Endpoint: @@ -784,6 +848,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_create_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseCreateEndpoint._get_transcoded_request( http_options, request @@ -798,6 +863,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.CreateEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateEndpoint._get_response( self._host, @@ -819,7 +911,29 @@ def __call__( pb_resp = gcs_endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_endpoint.Endpoint.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.servicedirectory_v1beta1.RegistrationServiceClient.create_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateNamespace( @@ -858,7 +972,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Call the create namespace method over HTTP. @@ -869,8 +983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_namespace.Namespace: @@ -885,6 +1001,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_create_namespace( request, metadata ) @@ -901,6 +1018,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.CreateNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateNamespace._get_response( self._host, @@ -922,7 +1066,29 @@ def __call__( pb_resp = gcs_namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_namespace.Namespace.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.servicedirectory_v1beta1.RegistrationServiceClient.create_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateService( @@ -961,7 +1127,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Call the create service method over HTTP. @@ -972,8 +1138,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_service.Service: @@ -987,6 +1155,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseCreateService._get_http_options() ) + request, metadata = self._interceptor.pre_create_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseCreateService._get_transcoded_request( http_options, request @@ -1001,6 +1170,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.CreateService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._CreateService._get_response( self._host, @@ -1022,7 +1218,29 @@ def __call__( pb_resp = gcs_service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_service.Service.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.servicedirectory_v1beta1.RegistrationServiceClient.create_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "CreateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEndpoint( @@ -1060,7 +1278,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete endpoint method over HTTP. @@ -1071,13 +1289,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseDeleteEndpoint._get_transcoded_request( http_options, request @@ -1088,6 +1309,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.DeleteEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "DeleteEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteEndpoint._get_response( self._host, @@ -1138,7 +1386,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete namespace method over HTTP. @@ -1149,13 +1397,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_delete_namespace( request, metadata ) @@ -1168,6 +1419,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.DeleteNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "DeleteNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteNamespace._get_response( self._host, @@ -1218,7 +1496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete service method over HTTP. @@ -1229,13 +1507,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRegistrationServiceRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseDeleteService._get_transcoded_request( http_options, request @@ -1246,6 +1527,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.DeleteService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._DeleteService._get_response( self._host, @@ -1296,7 +1604,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> endpoint.Endpoint: r"""Call the get endpoint method over HTTP. @@ -1309,8 +1617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.endpoint.Endpoint: @@ -1323,6 +1633,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_get_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetEndpoint._get_transcoded_request( http_options, request @@ -1333,6 +1644,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.GetEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetEndpoint._get_response( self._host, @@ -1353,7 +1691,29 @@ def __call__( pb_resp = endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = endpoint.Endpoint.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.servicedirectory_v1beta1.RegistrationServiceClient.get_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1392,7 +1752,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1402,8 +1762,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1488,6 +1850,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1502,6 +1865,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1523,7 +1913,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.servicedirectory_v1beta1.RegistrationServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNamespace( @@ -1561,7 +1973,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> namespace.Namespace: r"""Call the get namespace method over HTTP. @@ -1572,8 +1984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.namespace.Namespace: @@ -1588,6 +2002,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_get_namespace(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetNamespace._get_transcoded_request( http_options, request @@ -1598,6 +2013,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.GetNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetNamespace._get_response( self._host, @@ -1618,7 +2060,29 @@ def __call__( pb_resp = namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = namespace.Namespace.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.servicedirectory_v1beta1.RegistrationServiceClient.get_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService( @@ -1656,7 +2120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Call the get service method over HTTP. @@ -1670,8 +2134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.Service: @@ -1685,6 +2151,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetService._get_transcoded_request( http_options, request @@ -1695,6 +2162,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.GetService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetService._get_response( self._host, @@ -1715,7 +2209,29 @@ def __call__( pb_resp = service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Service.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.servicedirectory_v1beta1.RegistrationServiceClient.get_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEndpoints( @@ -1753,7 +2269,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListEndpointsResponse: r"""Call the list endpoints method over HTTP. @@ -1764,8 +2280,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListEndpointsResponse: @@ -1777,6 +2295,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_endpoints(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListEndpoints._get_transcoded_request( http_options, request @@ -1787,6 +2306,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.ListEndpoints", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListEndpoints._get_response( self._host, @@ -1807,7 +2353,31 @@ def __call__( pb_resp = registration_service.ListEndpointsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListEndpointsResponse.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.servicedirectory_v1beta1.RegistrationServiceClient.list_endpoints", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNamespaces( @@ -1845,7 +2415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListNamespacesResponse: r"""Call the list namespaces method over HTTP. @@ -1856,8 +2426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListNamespacesResponse: @@ -1869,6 +2441,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListNamespaces._get_http_options() ) + request, metadata = self._interceptor.pre_list_namespaces(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListNamespaces._get_transcoded_request( http_options, request @@ -1879,6 +2452,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.ListNamespaces", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListNamespaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListNamespaces._get_response( self._host, @@ -1899,7 +2499,31 @@ def __call__( pb_resp = registration_service.ListNamespacesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_namespaces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListNamespacesResponse.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.servicedirectory_v1beta1.RegistrationServiceClient.list_namespaces", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListNamespaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices( @@ -1937,7 +2561,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registration_service.ListServicesResponse: r"""Call the list services method over HTTP. @@ -1948,8 +2572,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.registration_service.ListServicesResponse: @@ -1961,6 +2587,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListServices._get_transcoded_request( http_options, request @@ -1971,6 +2598,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.ListServices", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListServices._get_response( self._host, @@ -1991,7 +2645,31 @@ def __call__( pb_resp = registration_service.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registration_service.ListServicesResponse.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.servicedirectory_v1beta1.RegistrationServiceClient.list_services", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2030,7 +2708,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2040,8 +2718,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -2126,6 +2806,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2140,6 +2821,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -2161,7 +2869,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.servicedirectory_v1beta1.RegistrationServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2200,7 +2930,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2210,8 +2940,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2221,6 +2953,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2237,6 +2970,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegistrationServiceRestTransport._TestIamPermissions._get_response( @@ -2260,7 +3020,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.servicedirectory_v1beta1.RegistrationServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEndpoint( @@ -2299,7 +3081,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_endpoint.Endpoint: r"""Call the update endpoint method over HTTP. @@ -2310,8 +3092,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_endpoint.Endpoint: @@ -2324,6 +3108,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateEndpoint._get_http_options() ) + request, metadata = self._interceptor.pre_update_endpoint(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseUpdateEndpoint._get_transcoded_request( http_options, request @@ -2338,6 +3123,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.UpdateEndpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateEndpoint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateEndpoint._get_response( self._host, @@ -2359,7 +3171,29 @@ def __call__( pb_resp = gcs_endpoint.Endpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_endpoint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_endpoint.Endpoint.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.servicedirectory_v1beta1.RegistrationServiceClient.update_endpoint", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateEndpoint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNamespace( @@ -2398,7 +3232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_namespace.Namespace: r"""Call the update namespace method over HTTP. @@ -2409,8 +3243,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_namespace.Namespace: @@ -2425,6 +3261,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateNamespace._get_http_options() ) + request, metadata = self._interceptor.pre_update_namespace( request, metadata ) @@ -2441,6 +3278,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.UpdateNamespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateNamespace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateNamespace._get_response( self._host, @@ -2462,7 +3326,29 @@ def __call__( pb_resp = gcs_namespace.Namespace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_namespace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_namespace.Namespace.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.servicedirectory_v1beta1.RegistrationServiceClient.update_namespace", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateNamespace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateService( @@ -2501,7 +3387,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_service.Service: r"""Call the update service method over HTTP. @@ -2512,8 +3398,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_service.Service: @@ -2527,6 +3415,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseUpdateService._get_http_options() ) + request, metadata = self._interceptor.pre_update_service(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseUpdateService._get_transcoded_request( http_options, request @@ -2541,6 +3430,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.UpdateService", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._UpdateService._get_response( self._host, @@ -2562,7 +3478,29 @@ def __call__( pb_resp = gcs_service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_service.Service.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.servicedirectory_v1beta1.RegistrationServiceClient.update_service", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "UpdateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2764,7 +3702,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2774,8 +3712,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2784,6 +3724,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2794,6 +3735,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._GetLocation._get_response( self._host, @@ -2813,6 +3781,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.servicedirectory_v1beta1.RegistrationServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2854,7 +3843,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2864,8 +3853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2874,6 +3865,7 @@ def __call__( http_options = ( _BaseRegistrationServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseRegistrationServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2884,6 +3876,33 @@ def __call__( 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.servicedirectory_v1beta1.RegistrationServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistrationServiceRestTransport._ListLocations._get_response( self._host, @@ -2903,6 +3922,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.servicedirectory_v1beta1.RegistrationServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicedirectory.v1beta1.RegistrationService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1.json b/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1.json index a48e9618b4c9..bb916a8e137a 100644 --- a/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1.json +++ b/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-directory", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.ResolveServiceResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.ResolveServiceResponse", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_endpoint" @@ -808,7 +808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_endpoint" @@ -886,7 +886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_namespace" @@ -963,7 +963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_namespace" @@ -1041,7 +1041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_service" @@ -1118,7 +1118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_service" @@ -1196,7 +1196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -1276,7 +1276,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -1353,7 +1353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1429,7 +1429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1510,7 +1510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -1590,7 +1590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -1671,7 +1671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", @@ -1751,7 +1751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", @@ -1832,7 +1832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListEndpointsAsyncPager", @@ -1912,7 +1912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListEndpointsPager", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListNamespacesAsyncPager", @@ -2073,7 +2073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListNamespacesPager", @@ -2154,7 +2154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListServicesAsyncPager", @@ -2234,7 +2234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.services.registration_service.pagers.ListServicesPager", @@ -2311,7 +2311,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2387,7 +2387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2464,7 +2464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2540,7 +2540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2625,7 +2625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -2709,7 +2709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Endpoint", @@ -2794,7 +2794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -2878,7 +2878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Namespace", @@ -2963,7 +2963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", @@ -3047,7 +3047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1.types.Service", diff --git a/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1beta1.json b/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1beta1.json index 5a1f604f643e..bbc7749e9905 100644 --- a/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1beta1.json +++ b/packages/google-cloud-service-directory/samples/generated_samples/snippet_metadata_google.cloud.servicedirectory.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-directory", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.ResolveServiceResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.ResolveServiceResponse", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_endpoint" @@ -808,7 +808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_endpoint" @@ -886,7 +886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_namespace" @@ -963,7 +963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_namespace" @@ -1041,7 +1041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_service" @@ -1118,7 +1118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_service" @@ -1196,7 +1196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -1276,7 +1276,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -1353,7 +1353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1429,7 +1429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1510,7 +1510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -1590,7 +1590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -1671,7 +1671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", @@ -1751,7 +1751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", @@ -1832,7 +1832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListEndpointsAsyncPager", @@ -1912,7 +1912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListEndpointsPager", @@ -1993,7 +1993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListNamespacesAsyncPager", @@ -2073,7 +2073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListNamespacesPager", @@ -2154,7 +2154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListServicesAsyncPager", @@ -2234,7 +2234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.services.registration_service.pagers.ListServicesPager", @@ -2311,7 +2311,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2387,7 +2387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2464,7 +2464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2540,7 +2540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2625,7 +2625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -2709,7 +2709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Endpoint", @@ -2794,7 +2794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -2878,7 +2878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Namespace", @@ -2963,7 +2963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", @@ -3047,7 +3047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicedirectory_v1beta1.types.Service", diff --git a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_lookup_service.py b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_lookup_service.py index fa3669913756..8fec4ddf8e0e 100644 --- a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_lookup_service.py +++ b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_lookup_service.py @@ -1396,6 +1396,7 @@ def test_resolve_service_rest_required_fields( response_value._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.resolve_service(request) @@ -1609,6 +1610,7 @@ def test_resolve_service_rest_bad_request( 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.resolve_service(request) @@ -1644,6 +1646,7 @@ def test_resolve_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resolve_service(request) # Establish that the response is the type that we expect. @@ -1683,6 +1686,7 @@ def test_resolve_service_rest_interceptors(null_interceptor): 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 = lookup_service.ResolveServiceResponse.to_json( lookup_service.ResolveServiceResponse() ) @@ -1729,6 +1733,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -1759,6 +1764,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -1787,6 +1793,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -1817,6 +1824,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_registration_service.py b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_registration_service.py index 162d3dcc492a..1bfd38a6e12c 100644 --- a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_registration_service.py +++ b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1/test_registration_service.py @@ -7607,6 +7607,7 @@ def test_create_namespace_rest_required_fields( response_value._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_namespace(request) @@ -7669,6 +7670,7 @@ def test_create_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -7810,6 +7812,7 @@ def test_list_namespaces_rest_required_fields( response_value._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_namespaces(request) @@ -7865,6 +7868,7 @@ def test_list_namespaces_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespaces(**mock_args) @@ -8058,6 +8062,7 @@ def test_get_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8105,6 +8110,7 @@ def test_get_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -8235,6 +8241,7 @@ def test_update_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8293,6 +8300,7 @@ def test_update_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -8424,6 +8432,7 @@ def test_delete_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8469,6 +8478,7 @@ def test_delete_namespace_rest_flattened(): 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"} client.delete_namespace(**mock_args) @@ -8609,6 +8619,7 @@ def test_create_service_rest_required_fields( response_value._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_service(request) @@ -8673,6 +8684,7 @@ def test_create_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -8815,6 +8827,7 @@ def test_list_services_rest_required_fields( response_value._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_services(request) @@ -8872,6 +8885,7 @@ def test_list_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_services(**mock_args) @@ -9068,6 +9082,7 @@ def test_get_service_rest_required_fields( response_value._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_service(request) @@ -9115,6 +9130,7 @@ def test_get_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -9244,6 +9260,7 @@ def test_update_service_rest_required_fields( response_value._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_service(request) @@ -9302,6 +9319,7 @@ def test_update_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -9431,6 +9449,7 @@ def test_delete_service_rest_required_fields( response_value._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_service(request) @@ -9476,6 +9495,7 @@ def test_delete_service_rest_flattened(): 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"} client.delete_service(**mock_args) @@ -9617,6 +9637,7 @@ def test_create_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -9681,6 +9702,7 @@ def test_create_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -9823,6 +9845,7 @@ def test_list_endpoints_rest_required_fields( response_value._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_endpoints(request) @@ -9880,6 +9903,7 @@ def test_list_endpoints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoints(**mock_args) @@ -10076,6 +10100,7 @@ def test_get_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10123,6 +10148,7 @@ def test_get_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -10252,6 +10278,7 @@ def test_update_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10310,6 +10337,7 @@ def test_update_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -10439,6 +10467,7 @@ def test_delete_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10484,6 +10513,7 @@ def test_delete_endpoint_rest_flattened(): 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"} client.delete_endpoint(**mock_args) @@ -10614,6 +10644,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -10732,6 +10763,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -10866,6 +10898,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -11915,6 +11948,7 @@ def test_create_namespace_rest_bad_request( 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_namespace(request) @@ -12019,6 +12053,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12060,6 +12095,7 @@ def test_create_namespace_rest_interceptors(null_interceptor): 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 = gcs_namespace.Namespace.to_json(gcs_namespace.Namespace()) req.return_value.content = return_value @@ -12104,6 +12140,7 @@ def test_list_namespaces_rest_bad_request( 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_namespaces(request) @@ -12139,6 +12176,7 @@ def test_list_namespaces_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespaces(request) # Establish that the response is the type that we expect. @@ -12179,6 +12217,7 @@ def test_list_namespaces_rest_interceptors(null_interceptor): 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 = registration_service.ListNamespacesResponse.to_json( registration_service.ListNamespacesResponse() ) @@ -12225,6 +12264,7 @@ def test_get_namespace_rest_bad_request( 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_namespace(request) @@ -12261,6 +12301,7 @@ def test_get_namespace_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12302,6 +12343,7 @@ def test_get_namespace_rest_interceptors(null_interceptor): 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 = namespace.Namespace.to_json(namespace.Namespace()) req.return_value.content = return_value @@ -12348,6 +12390,7 @@ def test_update_namespace_rest_bad_request( 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_namespace(request) @@ -12458,6 +12501,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12499,6 +12543,7 @@ def test_update_namespace_rest_interceptors(null_interceptor): 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 = gcs_namespace.Namespace.to_json(gcs_namespace.Namespace()) req.return_value.content = return_value @@ -12543,6 +12588,7 @@ def test_delete_namespace_rest_bad_request( 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_namespace(request) @@ -12573,6 +12619,7 @@ def test_delete_namespace_rest_call_success(request_type): 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_namespace(request) # Establish that the response is the type that we expect. @@ -12609,6 +12656,7 @@ def test_delete_namespace_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteNamespaceRequest() metadata = [ @@ -12649,6 +12697,7 @@ def test_create_service_rest_bad_request( 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_service(request) @@ -12767,6 +12816,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -12808,6 +12858,7 @@ def test_create_service_rest_interceptors(null_interceptor): 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 = gcs_service.Service.to_json(gcs_service.Service()) req.return_value.content = return_value @@ -12852,6 +12903,7 @@ def test_list_services_rest_bad_request( 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_services(request) @@ -12887,6 +12939,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_services(request) # Establish that the response is the type that we expect. @@ -12927,6 +12980,7 @@ def test_list_services_rest_interceptors(null_interceptor): 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 = registration_service.ListServicesResponse.to_json( registration_service.ListServicesResponse() ) @@ -12975,6 +13029,7 @@ def test_get_service_rest_bad_request( 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_service(request) @@ -13013,6 +13068,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -13054,6 +13110,7 @@ def test_get_service_rest_interceptors(null_interceptor): 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 = service.Service.to_json(service.Service()) req.return_value.content = return_value @@ -13102,6 +13159,7 @@ def test_update_service_rest_bad_request( 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_service(request) @@ -13224,6 +13282,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -13265,6 +13324,7 @@ def test_update_service_rest_interceptors(null_interceptor): 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 = gcs_service.Service.to_json(gcs_service.Service()) req.return_value.content = return_value @@ -13311,6 +13371,7 @@ def test_delete_service_rest_bad_request( 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_service(request) @@ -13343,6 +13404,7 @@ def test_delete_service_rest_call_success(request_type): 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_service(request) # Establish that the response is the type that we expect. @@ -13379,6 +13441,7 @@ def test_delete_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteServiceRequest() metadata = [ @@ -13421,6 +13484,7 @@ def test_create_endpoint_rest_bad_request( 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_endpoint(request) @@ -13537,6 +13601,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -13581,6 +13646,7 @@ def test_create_endpoint_rest_interceptors(null_interceptor): 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 = gcs_endpoint.Endpoint.to_json(gcs_endpoint.Endpoint()) req.return_value.content = return_value @@ -13627,6 +13693,7 @@ def test_list_endpoints_rest_bad_request( 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_endpoints(request) @@ -13664,6 +13731,7 @@ def test_list_endpoints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoints(request) # Establish that the response is the type that we expect. @@ -13704,6 +13772,7 @@ def test_list_endpoints_rest_interceptors(null_interceptor): 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 = registration_service.ListEndpointsResponse.to_json( registration_service.ListEndpointsResponse() ) @@ -13752,6 +13821,7 @@ def test_get_endpoint_rest_bad_request( 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_endpoint(request) @@ -13793,6 +13863,7 @@ def test_get_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -13837,6 +13908,7 @@ def test_get_endpoint_rest_interceptors(null_interceptor): 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 = endpoint.Endpoint.to_json(endpoint.Endpoint()) req.return_value.content = return_value @@ -13885,6 +13957,7 @@ def test_update_endpoint_rest_bad_request( 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_endpoint(request) @@ -14003,6 +14076,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -14047,6 +14121,7 @@ def test_update_endpoint_rest_interceptors(null_interceptor): 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 = gcs_endpoint.Endpoint.to_json(gcs_endpoint.Endpoint()) req.return_value.content = return_value @@ -14093,6 +14168,7 @@ def test_delete_endpoint_rest_bad_request( 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_endpoint(request) @@ -14125,6 +14201,7 @@ def test_delete_endpoint_rest_call_success(request_type): 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_endpoint(request) # Establish that the response is the type that we expect. @@ -14161,6 +14238,7 @@ def test_delete_endpoint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteEndpointRequest() metadata = [ @@ -14201,6 +14279,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -14234,6 +14313,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -14273,6 +14353,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -14317,6 +14398,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -14350,6 +14432,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -14389,6 +14472,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -14433,6 +14517,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -14465,6 +14550,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -14503,6 +14589,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -14549,6 +14636,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -14579,6 +14667,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -14607,6 +14696,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -14637,6 +14727,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_lookup_service.py b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_lookup_service.py index 5f4c5141d8f8..bdd834a45ef6 100644 --- a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_lookup_service.py +++ b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_lookup_service.py @@ -1396,6 +1396,7 @@ def test_resolve_service_rest_required_fields( response_value._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.resolve_service(request) @@ -1609,6 +1610,7 @@ def test_resolve_service_rest_bad_request( 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.resolve_service(request) @@ -1644,6 +1646,7 @@ def test_resolve_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resolve_service(request) # Establish that the response is the type that we expect. @@ -1683,6 +1686,7 @@ def test_resolve_service_rest_interceptors(null_interceptor): 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 = lookup_service.ResolveServiceResponse.to_json( lookup_service.ResolveServiceResponse() ) @@ -1729,6 +1733,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -1759,6 +1764,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -1787,6 +1793,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -1817,6 +1824,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_registration_service.py b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_registration_service.py index 46bba089e25a..1f1e3668f7cf 100644 --- a/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_registration_service.py +++ b/packages/google-cloud-service-directory/tests/unit/gapic/servicedirectory_v1beta1/test_registration_service.py @@ -7608,6 +7608,7 @@ def test_create_namespace_rest_required_fields( response_value._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_namespace(request) @@ -7670,6 +7671,7 @@ def test_create_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -7812,6 +7814,7 @@ def test_list_namespaces_rest_required_fields( response_value._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_namespaces(request) @@ -7867,6 +7870,7 @@ def test_list_namespaces_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespaces(**mock_args) @@ -8061,6 +8065,7 @@ def test_get_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8108,6 +8113,7 @@ def test_get_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -8239,6 +8245,7 @@ def test_update_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8297,6 +8304,7 @@ def test_update_namespace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespace(**mock_args) @@ -8428,6 +8436,7 @@ def test_delete_namespace_rest_required_fields( response_value._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_namespace(request) @@ -8473,6 +8482,7 @@ def test_delete_namespace_rest_flattened(): 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"} client.delete_namespace(**mock_args) @@ -8614,6 +8624,7 @@ def test_create_service_rest_required_fields( response_value._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_service(request) @@ -8678,6 +8689,7 @@ def test_create_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -8820,6 +8832,7 @@ def test_list_services_rest_required_fields( response_value._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_services(request) @@ -8877,6 +8890,7 @@ def test_list_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_services(**mock_args) @@ -9073,6 +9087,7 @@ def test_get_service_rest_required_fields( response_value._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_service(request) @@ -9120,6 +9135,7 @@ def test_get_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -9249,6 +9265,7 @@ def test_update_service_rest_required_fields( response_value._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_service(request) @@ -9307,6 +9324,7 @@ def test_update_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_service(**mock_args) @@ -9436,6 +9454,7 @@ def test_delete_service_rest_required_fields( response_value._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_service(request) @@ -9481,6 +9500,7 @@ def test_delete_service_rest_flattened(): 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"} client.delete_service(**mock_args) @@ -9622,6 +9642,7 @@ def test_create_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -9686,6 +9707,7 @@ def test_create_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -9828,6 +9850,7 @@ def test_list_endpoints_rest_required_fields( response_value._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_endpoints(request) @@ -9885,6 +9908,7 @@ def test_list_endpoints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoints(**mock_args) @@ -10081,6 +10105,7 @@ def test_get_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10128,6 +10153,7 @@ def test_get_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -10257,6 +10283,7 @@ def test_update_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10315,6 +10342,7 @@ def test_update_endpoint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_endpoint(**mock_args) @@ -10444,6 +10472,7 @@ def test_delete_endpoint_rest_required_fields( response_value._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_endpoint(request) @@ -10489,6 +10518,7 @@ def test_delete_endpoint_rest_flattened(): 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"} client.delete_endpoint(**mock_args) @@ -10619,6 +10649,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -10737,6 +10768,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -10871,6 +10903,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -11920,6 +11953,7 @@ def test_create_namespace_rest_bad_request( 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_namespace(request) @@ -12030,6 +12064,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12071,6 +12106,7 @@ def test_create_namespace_rest_interceptors(null_interceptor): 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 = gcs_namespace.Namespace.to_json(gcs_namespace.Namespace()) req.return_value.content = return_value @@ -12115,6 +12151,7 @@ def test_list_namespaces_rest_bad_request( 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_namespaces(request) @@ -12150,6 +12187,7 @@ def test_list_namespaces_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespaces(request) # Establish that the response is the type that we expect. @@ -12190,6 +12228,7 @@ def test_list_namespaces_rest_interceptors(null_interceptor): 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 = registration_service.ListNamespacesResponse.to_json( registration_service.ListNamespacesResponse() ) @@ -12236,6 +12275,7 @@ def test_get_namespace_rest_bad_request( 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_namespace(request) @@ -12272,6 +12312,7 @@ def test_get_namespace_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12313,6 +12354,7 @@ def test_get_namespace_rest_interceptors(null_interceptor): 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 = namespace.Namespace.to_json(namespace.Namespace()) req.return_value.content = return_value @@ -12359,6 +12401,7 @@ def test_update_namespace_rest_bad_request( 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_namespace(request) @@ -12471,6 +12514,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespace(request) # Establish that the response is the type that we expect. @@ -12512,6 +12556,7 @@ def test_update_namespace_rest_interceptors(null_interceptor): 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 = gcs_namespace.Namespace.to_json(gcs_namespace.Namespace()) req.return_value.content = return_value @@ -12556,6 +12601,7 @@ def test_delete_namespace_rest_bad_request( 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_namespace(request) @@ -12586,6 +12632,7 @@ def test_delete_namespace_rest_call_success(request_type): 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_namespace(request) # Establish that the response is the type that we expect. @@ -12622,6 +12669,7 @@ def test_delete_namespace_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteNamespaceRequest() metadata = [ @@ -12662,6 +12710,7 @@ def test_create_service_rest_bad_request( 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_service(request) @@ -12784,6 +12833,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -12825,6 +12875,7 @@ def test_create_service_rest_interceptors(null_interceptor): 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 = gcs_service.Service.to_json(gcs_service.Service()) req.return_value.content = return_value @@ -12869,6 +12920,7 @@ def test_list_services_rest_bad_request( 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_services(request) @@ -12904,6 +12956,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_services(request) # Establish that the response is the type that we expect. @@ -12944,6 +12997,7 @@ def test_list_services_rest_interceptors(null_interceptor): 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 = registration_service.ListServicesResponse.to_json( registration_service.ListServicesResponse() ) @@ -12992,6 +13046,7 @@ def test_get_service_rest_bad_request( 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_service(request) @@ -13030,6 +13085,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -13071,6 +13127,7 @@ def test_get_service_rest_interceptors(null_interceptor): 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 = service.Service.to_json(service.Service()) req.return_value.content = return_value @@ -13119,6 +13176,7 @@ def test_update_service_rest_bad_request( 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_service(request) @@ -13245,6 +13303,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -13286,6 +13345,7 @@ def test_update_service_rest_interceptors(null_interceptor): 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 = gcs_service.Service.to_json(gcs_service.Service()) req.return_value.content = return_value @@ -13332,6 +13392,7 @@ def test_delete_service_rest_bad_request( 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_service(request) @@ -13364,6 +13425,7 @@ def test_delete_service_rest_call_success(request_type): 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_service(request) # Establish that the response is the type that we expect. @@ -13400,6 +13462,7 @@ def test_delete_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteServiceRequest() metadata = [ @@ -13442,6 +13505,7 @@ def test_create_endpoint_rest_bad_request( 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_endpoint(request) @@ -13560,6 +13624,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -13604,6 +13669,7 @@ def test_create_endpoint_rest_interceptors(null_interceptor): 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 = gcs_endpoint.Endpoint.to_json(gcs_endpoint.Endpoint()) req.return_value.content = return_value @@ -13650,6 +13716,7 @@ def test_list_endpoints_rest_bad_request( 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_endpoints(request) @@ -13687,6 +13754,7 @@ def test_list_endpoints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoints(request) # Establish that the response is the type that we expect. @@ -13727,6 +13795,7 @@ def test_list_endpoints_rest_interceptors(null_interceptor): 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 = registration_service.ListEndpointsResponse.to_json( registration_service.ListEndpointsResponse() ) @@ -13775,6 +13844,7 @@ def test_get_endpoint_rest_bad_request( 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_endpoint(request) @@ -13816,6 +13886,7 @@ def test_get_endpoint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -13860,6 +13931,7 @@ def test_get_endpoint_rest_interceptors(null_interceptor): 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 = endpoint.Endpoint.to_json(endpoint.Endpoint()) req.return_value.content = return_value @@ -13908,6 +13980,7 @@ def test_update_endpoint_rest_bad_request( 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_endpoint(request) @@ -14028,6 +14101,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_endpoint(request) # Establish that the response is the type that we expect. @@ -14072,6 +14146,7 @@ def test_update_endpoint_rest_interceptors(null_interceptor): 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 = gcs_endpoint.Endpoint.to_json(gcs_endpoint.Endpoint()) req.return_value.content = return_value @@ -14118,6 +14193,7 @@ def test_delete_endpoint_rest_bad_request( 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_endpoint(request) @@ -14150,6 +14226,7 @@ def test_delete_endpoint_rest_call_success(request_type): 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_endpoint(request) # Establish that the response is the type that we expect. @@ -14186,6 +14263,7 @@ def test_delete_endpoint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registration_service.DeleteEndpointRequest() metadata = [ @@ -14226,6 +14304,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -14259,6 +14338,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -14298,6 +14378,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -14342,6 +14423,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -14375,6 +14457,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -14414,6 +14497,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -14458,6 +14542,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -14490,6 +14575,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -14528,6 +14614,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -14574,6 +14661,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -14604,6 +14692,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -14632,6 +14721,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -14662,6 +14752,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage/gapic_version.py b/packages/google-cloud-service-usage/google/cloud/service_usage/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage/gapic_version.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/gapic_version.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/gapic_version.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/async_client.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/async_client.py index 0dc276eaff29..e2a575cb1ce2 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/async_client.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServiceUsageTransport from .transports.grpc_asyncio import ServiceUsageGrpcAsyncIOTransport +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 ServiceUsageAsyncClient: """Enables services that service consumers want to use on Google Cloud @@ -260,13 +270,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.serviceusage_v1.ServiceUsageAsyncClient`.", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "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.api.serviceusage.v1.ServiceUsage", + "credentialsType": None, + }, + ) + async def enable_service( self, request: Optional[Union[serviceusage.EnableServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enable a service so that it can be used with a project. @@ -306,8 +338,10 @@ async def sample_enable_service(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -365,7 +399,7 @@ async def disable_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause @@ -411,8 +445,10 @@ async def sample_disable_service(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -470,7 +506,7 @@ async def get_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Service: r"""Returns the service configuration and enabled state for a given service. @@ -506,8 +542,10 @@ async def sample_get_service(): 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, 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: google.cloud.service_usage_v1.types.Service: @@ -553,7 +591,7 @@ async def list_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesAsyncPager: r"""List all services available to the specified project, and the current state of those services with respect to the project. The @@ -602,8 +640,10 @@ async def sample_list_services(): 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, 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: google.cloud.service_usage_v1.services.service_usage.pagers.ListServicesAsyncPager: @@ -662,7 +702,7 @@ async def batch_enable_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and @@ -704,8 +744,10 @@ async def sample_batch_enable_services(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -763,7 +805,7 @@ async def batch_get_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serviceusage.BatchGetServicesResponse: r"""Returns the service configurations and enabled states for a given list of services. @@ -799,8 +841,10 @@ async def sample_batch_get_services(): 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, 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: google.cloud.service_usage_v1.types.BatchGetServicesResponse: @@ -844,7 +888,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -855,8 +899,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -897,7 +943,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -908,8 +954,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/client.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/client.py index 0e8fb1858e94..c6f5f25d2a96 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/client.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -581,6 +591,10 @@ def __init__( # 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( @@ -643,13 +657,36 @@ def __init__( 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.api.serviceusage_v1.ServiceUsageClient`.", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "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.api.serviceusage.v1.ServiceUsage", + "credentialsType": None, + }, + ) + def enable_service( self, request: Optional[Union[serviceusage.EnableServiceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Enable a service so that it can be used with a project. @@ -689,8 +726,10 @@ def sample_enable_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -746,7 +785,7 @@ def disable_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause @@ -792,8 +831,10 @@ def sample_disable_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -849,7 +890,7 @@ def get_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Service: r"""Returns the service configuration and enabled state for a given service. @@ -885,8 +926,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.service_usage_v1.types.Service: @@ -930,7 +973,7 @@ def list_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesPager: r"""List all services available to the specified project, and the current state of those services with respect to the project. The @@ -979,8 +1022,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.service_usage_v1.services.service_usage.pagers.ListServicesPager: @@ -1037,7 +1082,7 @@ def batch_enable_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and @@ -1079,8 +1124,10 @@ def sample_batch_enable_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1136,7 +1183,7 @@ def batch_get_services( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serviceusage.BatchGetServicesResponse: r"""Returns the service configurations and enabled states for a given list of services. @@ -1172,8 +1219,10 @@ def sample_batch_get_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.service_usage_v1.types.BatchGetServicesResponse: @@ -1228,7 +1277,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1239,8 +1288,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1281,7 +1332,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1292,8 +1343,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/pagers.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/pagers.py index 13f30e9c1886..e6a59db62ca4 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/pagers.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = serviceusage.ListServicesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = serviceusage.ListServicesRequest(request) diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc.py index 7117f77b93d7..b221afc26fce 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.service_usage_v1.types import resources, serviceusage from .base import DEFAULT_CLIENT_INFO, ServiceUsageTransport +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.api.serviceusage.v1.ServiceUsage", + "rpcName": 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.api.serviceusage.v1.ServiceUsage", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceUsageGrpcTransport(ServiceUsageTransport): """gRPC backend transport for ServiceUsage. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def enable_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_service" not in self._stubs: - self._stubs["enable_service"] = self.grpc_channel.unary_unary( + self._stubs["enable_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/EnableService", request_serializer=serviceusage.EnableServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -308,7 +396,7 @@ def disable_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_service" not in self._stubs: - self._stubs["disable_service"] = self.grpc_channel.unary_unary( + self._stubs["disable_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/DisableService", request_serializer=serviceusage.DisableServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -335,7 +423,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/GetService", request_serializer=serviceusage.GetServiceRequest.serialize, response_deserializer=resources.Service.deserialize, @@ -376,7 +464,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/ListServices", request_serializer=serviceusage.ListServicesRequest.serialize, response_deserializer=serviceusage.ListServicesResponse.deserialize, @@ -405,7 +493,7 @@ def batch_enable_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_enable_services" not in self._stubs: - self._stubs["batch_enable_services"] = self.grpc_channel.unary_unary( + self._stubs["batch_enable_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/BatchEnableServices", request_serializer=serviceusage.BatchEnableServicesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +522,7 @@ def batch_get_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_services" not in self._stubs: - self._stubs["batch_get_services"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/BatchGetServices", request_serializer=serviceusage.BatchGetServicesRequest.serialize, response_deserializer=serviceusage.BatchGetServicesResponse.deserialize, @@ -442,7 +530,7 @@ def batch_get_services( return self._stubs["batch_get_services"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -454,7 +542,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -473,7 +561,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc_asyncio.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc_asyncio.py index 37b2fb9ca01c..0590e3c3039e 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.service_usage_v1.types import resources, serviceusage from .base import DEFAULT_CLIENT_INFO, ServiceUsageTransport from .grpc import ServiceUsageGrpcTransport +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.api.serviceusage.v1.ServiceUsage", + "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.api.serviceusage.v1.ServiceUsage", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceUsageGrpcAsyncIOTransport(ServiceUsageTransport): """gRPC AsyncIO backend transport for ServiceUsage. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def enable_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_service" not in self._stubs: - self._stubs["enable_service"] = self.grpc_channel.unary_unary( + self._stubs["enable_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/EnableService", request_serializer=serviceusage.EnableServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -322,7 +407,7 @@ def disable_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "disable_service" not in self._stubs: - self._stubs["disable_service"] = self.grpc_channel.unary_unary( + self._stubs["disable_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/DisableService", request_serializer=serviceusage.DisableServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -349,7 +434,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/GetService", request_serializer=serviceusage.GetServiceRequest.serialize, response_deserializer=resources.Service.deserialize, @@ -390,7 +475,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/ListServices", request_serializer=serviceusage.ListServicesRequest.serialize, response_deserializer=serviceusage.ListServicesResponse.deserialize, @@ -421,7 +506,7 @@ def batch_enable_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_enable_services" not in self._stubs: - self._stubs["batch_enable_services"] = self.grpc_channel.unary_unary( + self._stubs["batch_enable_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/BatchEnableServices", request_serializer=serviceusage.BatchEnableServicesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def batch_get_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_services" not in self._stubs: - self._stubs["batch_get_services"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_services"] = self._logged_channel.unary_unary( "/google.api.serviceusage.v1.ServiceUsage/BatchGetServices", request_serializer=serviceusage.BatchGetServicesRequest.serialize, response_deserializer=serviceusage.BatchGetServicesResponse.deserialize, @@ -509,7 +594,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -525,7 +610,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -544,7 +629,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/rest.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/rest.py index a9d28c6a34c2..b34d14403909 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/rest.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -118,8 +126,10 @@ def post_list_services(self, response): def pre_batch_enable_services( self, request: serviceusage.BatchEnableServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.BatchEnableServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serviceusage.BatchEnableServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_enable_services Override in a subclass to manipulate the request or metadata @@ -141,8 +151,10 @@ def post_batch_enable_services( def pre_batch_get_services( self, request: serviceusage.BatchGetServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.BatchGetServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serviceusage.BatchGetServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_get_services Override in a subclass to manipulate the request or metadata @@ -164,8 +176,10 @@ def post_batch_get_services( def pre_disable_service( self, request: serviceusage.DisableServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.DisableServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serviceusage.DisableServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_service Override in a subclass to manipulate the request or metadata @@ -187,8 +201,10 @@ def post_disable_service( def pre_enable_service( self, request: serviceusage.EnableServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.EnableServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serviceusage.EnableServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_service Override in a subclass to manipulate the request or metadata @@ -210,8 +226,8 @@ def post_enable_service( def pre_get_service( self, request: serviceusage.GetServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.GetServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[serviceusage.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -231,8 +247,10 @@ def post_get_service(self, response: resources.Service) -> resources.Service: def pre_list_services( self, request: serviceusage.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[serviceusage.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + serviceusage.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -254,8 +272,10 @@ def post_list_services( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -277,8 +297,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -465,7 +487,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch enable services method over HTTP. @@ -475,8 +497,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -489,6 +513,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseBatchEnableServices._get_http_options() ) + request, metadata = self._interceptor.pre_batch_enable_services( request, metadata ) @@ -505,6 +530,33 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageClient.BatchEnableServices", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "BatchEnableServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._BatchEnableServices._get_response( self._host, @@ -524,7 +576,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_enable_services(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.api.serviceusage_v1.ServiceUsageClient.batch_enable_services", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "BatchEnableServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchGetServices( @@ -561,7 +635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serviceusage.BatchGetServicesResponse: r"""Call the batch get services method over HTTP. @@ -571,8 +645,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serviceusage.BatchGetServicesResponse: @@ -582,6 +658,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseBatchGetServices._get_http_options() ) + request, metadata = self._interceptor.pre_batch_get_services( request, metadata ) @@ -594,6 +671,33 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageClient.BatchGetServices", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "BatchGetServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._BatchGetServices._get_response( self._host, @@ -614,7 +718,31 @@ def __call__( pb_resp = serviceusage.BatchGetServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_get_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = serviceusage.BatchGetServicesResponse.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.api.serviceusage_v1.ServiceUsageClient.batch_get_services", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "BatchGetServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableService( @@ -652,7 +780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the disable service method over HTTP. @@ -662,8 +790,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -676,6 +806,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseDisableService._get_http_options() ) + request, metadata = self._interceptor.pre_disable_service(request, metadata) transcoded_request = _BaseServiceUsageRestTransport._BaseDisableService._get_transcoded_request( http_options, request @@ -690,6 +821,33 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageClient.DisableService", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "DisableService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._DisableService._get_response( self._host, @@ -709,7 +867,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_service(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.api.serviceusage_v1.ServiceUsageClient.disable_service", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "DisableService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableService( @@ -747,7 +927,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the enable service method over HTTP. @@ -757,8 +937,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -771,6 +953,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseEnableService._get_http_options() ) + request, metadata = self._interceptor.pre_enable_service(request, metadata) transcoded_request = _BaseServiceUsageRestTransport._BaseEnableService._get_transcoded_request( http_options, request @@ -785,6 +968,33 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageClient.EnableService", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "EnableService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._EnableService._get_response( self._host, @@ -804,7 +1014,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_service(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.api.serviceusage_v1.ServiceUsageClient.enable_service", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "EnableService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService( @@ -841,7 +1073,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Service: r"""Call the get service method over HTTP. @@ -851,8 +1083,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Service: @@ -864,6 +1098,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = ( _BaseServiceUsageRestTransport._BaseGetService._get_transcoded_request( @@ -878,6 +1113,33 @@ def __call__( ) ) + 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.api.serviceusage_v1.ServiceUsageClient.GetService", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._GetService._get_response( self._host, @@ -898,7 +1160,29 @@ def __call__( pb_resp = resources.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Service.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.api.serviceusage_v1.ServiceUsageClient.get_service", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices( @@ -935,7 +1219,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> serviceusage.ListServicesResponse: r"""Call the list services method over HTTP. @@ -945,8 +1229,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.serviceusage.ListServicesResponse: @@ -956,6 +1242,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = _BaseServiceUsageRestTransport._BaseListServices._get_transcoded_request( http_options, request @@ -968,6 +1255,33 @@ def __call__( ) ) + 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.api.serviceusage_v1.ServiceUsageClient.ListServices", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._ListServices._get_response( self._host, @@ -988,7 +1302,31 @@ def __call__( pb_resp = serviceusage.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = serviceusage.ListServicesResponse.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.api.serviceusage_v1.ServiceUsageClient.list_services", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1081,7 +1419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1091,8 +1429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1101,6 +1441,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseServiceUsageRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1113,6 +1454,33 @@ def __call__( ) ) + 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.api.serviceusage_v1.ServiceUsageClient.GetOperation", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._GetOperation._get_response( self._host, @@ -1132,6 +1500,27 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageAsyncClient.GetOperation", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1172,7 +1561,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1182,8 +1571,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1192,6 +1583,7 @@ def __call__( http_options = ( _BaseServiceUsageRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseServiceUsageRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1202,6 +1594,33 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageClient.ListOperations", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceUsageRestTransport._ListOperations._get_response( self._host, @@ -1221,6 +1640,27 @@ def __call__( 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.api.serviceusage_v1.ServiceUsageAsyncClient.ListOperations", + extra={ + "serviceName": "google.api.serviceusage.v1.ServiceUsage", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-usage/samples/generated_samples/snippet_metadata_google.api.serviceusage.v1.json b/packages/google-cloud-service-usage/samples/generated_samples/snippet_metadata_google.api.serviceusage.v1.json index ed52e7aa53a9..7c0c44f2ca72 100644 --- a/packages/google-cloud-service-usage/samples/generated_samples/snippet_metadata_google.api.serviceusage.v1.json +++ b/packages/google-cloud-service-usage/samples/generated_samples/snippet_metadata_google.api.serviceusage.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-usage", - "version": "1.11.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.types.BatchGetServicesResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.types.BatchGetServicesResponse", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -502,7 +502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -655,7 +655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.types.Service", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.types.Service", @@ -808,7 +808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.services.service_usage.pagers.ListServicesAsyncPager", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.service_usage_v1.services.service_usage.pagers.ListServicesPager", diff --git a/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py b/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py index 1393e986d6d3..c4404635d277 100644 --- a/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py +++ b/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py @@ -3473,6 +3473,7 @@ def test_enable_service_rest_bad_request( 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.enable_service(request) @@ -3503,6 +3504,7 @@ def test_enable_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_service(request) # Establish that the response is the type that we expect. @@ -3544,6 +3546,7 @@ def test_enable_service_rest_interceptors(null_interceptor): 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 @@ -3588,6 +3591,7 @@ def test_disable_service_rest_bad_request( 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.disable_service(request) @@ -3618,6 +3622,7 @@ def test_disable_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_service(request) # Establish that the response is the type that we expect. @@ -3659,6 +3664,7 @@ def test_disable_service_rest_interceptors(null_interceptor): 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 @@ -3701,6 +3707,7 @@ def test_get_service_rest_bad_request(request_type=serviceusage.GetServiceReques 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_service(request) @@ -3738,6 +3745,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_service(request) # Establish that the response is the type that we expect. @@ -3778,6 +3786,7 @@ def test_get_service_rest_interceptors(null_interceptor): 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 = resources.Service.to_json(resources.Service()) req.return_value.content = return_value @@ -3820,6 +3829,7 @@ def test_list_services_rest_bad_request(request_type=serviceusage.ListServicesRe 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_services(request) @@ -3855,6 +3865,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_services(request) # Establish that the response is the type that we expect. @@ -3895,6 +3906,7 @@ def test_list_services_rest_interceptors(null_interceptor): 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 = serviceusage.ListServicesResponse.to_json( serviceusage.ListServicesResponse() ) @@ -3941,6 +3953,7 @@ def test_batch_enable_services_rest_bad_request( 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.batch_enable_services(request) @@ -3971,6 +3984,7 @@ def test_batch_enable_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_enable_services(request) # Establish that the response is the type that we expect. @@ -4012,6 +4026,7 @@ def test_batch_enable_services_rest_interceptors(null_interceptor): 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 @@ -4056,6 +4071,7 @@ def test_batch_get_services_rest_bad_request( 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.batch_get_services(request) @@ -4089,6 +4105,7 @@ def test_batch_get_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_get_services(request) # Establish that the response is the type that we expect. @@ -4128,6 +4145,7 @@ def test_batch_get_services_rest_interceptors(null_interceptor): 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 = serviceusage.BatchGetServicesResponse.to_json( serviceusage.BatchGetServicesResponse() ) @@ -4174,6 +4192,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4204,6 +4223,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -4232,6 +4252,7 @@ def test_list_operations_rest_bad_request( 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) @@ -4262,6 +4283,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/async_client.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/async_client.py index 3faeeb4717ca..0dd492dee7d4 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/async_client.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServiceHealthTransport from .transports.grpc_asyncio import ServiceHealthGrpcAsyncIOTransport +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 ServiceHealthAsyncClient: """Request service health events relevant to your Google Cloud @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.servicehealth_v1.ServiceHealthAsyncClient`.", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "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.servicehealth.v1.ServiceHealth", + "credentialsType": None, + }, + ) + async def list_events( self, request: Optional[Union[event_resources.ListEventsRequest, dict]] = None, @@ -276,7 +308,7 @@ async def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsAsyncPager: r"""Lists events under a given project and location. @@ -327,8 +359,10 @@ async def sample_list_events(): 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, 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListEventsAsyncPager: @@ -403,7 +437,7 @@ async def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.Event: r"""Retrieves a resource containing information about an event. @@ -453,8 +487,10 @@ async def sample_get_event(): 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, 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: google.cloud.servicehealth_v1.types.Event: @@ -520,7 +556,7 @@ async def list_organization_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrganizationEventsAsyncPager: r"""Lists organization events under a given organization and location. @@ -574,8 +610,10 @@ async def sample_list_organization_events(): 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, 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationEventsAsyncPager: @@ -652,7 +690,7 @@ async def get_organization_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationEvent: r"""Retrieves a resource containing information about an event affecting an organization . @@ -704,8 +742,10 @@ async def sample_get_organization_event(): 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, 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: google.cloud.servicehealth_v1.types.OrganizationEvent: @@ -771,7 +811,7 @@ async def list_organization_impacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrganizationImpactsAsyncPager: r"""Lists assets impacted by organization events under a given organization and location. @@ -822,8 +862,10 @@ async def sample_list_organization_impacts(): 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, 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationImpactsAsyncPager: @@ -900,7 +942,7 @@ async def get_organization_impact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationImpact: r"""Retrieves a resource containing information about impact to an asset under an organization affected by a @@ -955,8 +997,10 @@ async def sample_get_organization_impact(): 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, 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: google.cloud.servicehealth_v1.types.OrganizationImpact: @@ -1018,7 +1062,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1029,8 +1073,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1071,7 +1117,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1082,8 +1128,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/client.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/client.py index 7ff044750179..1ef4b82e265e 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/client.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -625,6 +635,10 @@ def __init__( # 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( @@ -690,6 +704,29 @@ def __init__( 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.servicehealth_v1.ServiceHealthClient`.", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "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.servicehealth.v1.ServiceHealth", + "credentialsType": None, + }, + ) + def list_events( self, request: Optional[Union[event_resources.ListEventsRequest, dict]] = None, @@ -697,7 +734,7 @@ def list_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEventsPager: r"""Lists events under a given project and location. @@ -748,8 +785,10 @@ def sample_list_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListEventsPager: @@ -821,7 +860,7 @@ def get_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.Event: r"""Retrieves a resource containing information about an event. @@ -871,8 +910,10 @@ def sample_get_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.types.Event: @@ -935,7 +976,7 @@ def list_organization_events( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrganizationEventsPager: r"""Lists organization events under a given organization and location. @@ -989,8 +1030,10 @@ def sample_list_organization_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationEventsPager: @@ -1064,7 +1107,7 @@ def get_organization_event( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationEvent: r"""Retrieves a resource containing information about an event affecting an organization . @@ -1116,8 +1159,10 @@ def sample_get_organization_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.types.OrganizationEvent: @@ -1180,7 +1225,7 @@ def list_organization_impacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrganizationImpactsPager: r"""Lists assets impacted by organization events under a given organization and location. @@ -1231,8 +1276,10 @@ def sample_list_organization_impacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationImpactsPager: @@ -1308,7 +1355,7 @@ def get_organization_impact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationImpact: r"""Retrieves a resource containing information about impact to an asset under an organization affected by a @@ -1363,8 +1410,10 @@ def sample_get_organization_impact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.servicehealth_v1.types.OrganizationImpact: @@ -1436,7 +1485,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1447,8 +1496,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1489,7 +1540,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1500,8 +1551,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/pagers.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/pagers.py index 998150defe4e..0d4f1b754eb9 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/pagers.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = event_resources.ListEventsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = event_resources.ListEventsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = event_resources.ListOrganizationEventsRequest(request) @@ -295,7 +301,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -309,8 +315,10 @@ def __init__( 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, 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`. """ self._method = method self._request = event_resources.ListOrganizationEventsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = event_resources.ListOrganizationImpactsRequest(request) @@ -451,7 +461,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -465,8 +475,10 @@ def __init__( 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, 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`. """ self._method = method self._request = event_resources.ListOrganizationImpactsRequest(request) diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc.py index fa6eba56bea5..74b29fc3fcde 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.servicehealth_v1.types import event_resources from .base import DEFAULT_CLIENT_INFO, ServiceHealthTransport +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.servicehealth.v1.ServiceHealth", + "rpcName": 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.servicehealth.v1.ServiceHealth", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceHealthGrpcTransport(ServiceHealthTransport): """gRPC backend transport for ServiceHealth. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListEvents", request_serializer=event_resources.ListEventsRequest.serialize, response_deserializer=event_resources.ListEventsResponse.deserialize, @@ -284,7 +370,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetEvent", request_serializer=event_resources.GetEventRequest.serialize, response_deserializer=event_resources.Event.deserialize, @@ -314,7 +400,7 @@ def list_organization_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_organization_events" not in self._stubs: - self._stubs["list_organization_events"] = self.grpc_channel.unary_unary( + self._stubs["list_organization_events"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListOrganizationEvents", request_serializer=event_resources.ListOrganizationEventsRequest.serialize, response_deserializer=event_resources.ListOrganizationEventsResponse.deserialize, @@ -343,7 +429,7 @@ def get_organization_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_event" not in self._stubs: - self._stubs["get_organization_event"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_event"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetOrganizationEvent", request_serializer=event_resources.GetOrganizationEventRequest.serialize, response_deserializer=event_resources.OrganizationEvent.deserialize, @@ -373,7 +459,7 @@ def list_organization_impacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_organization_impacts" not in self._stubs: - self._stubs["list_organization_impacts"] = self.grpc_channel.unary_unary( + self._stubs["list_organization_impacts"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListOrganizationImpacts", request_serializer=event_resources.ListOrganizationImpactsRequest.serialize, response_deserializer=event_resources.ListOrganizationImpactsResponse.deserialize, @@ -404,7 +490,7 @@ def get_organization_impact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_impact" not in self._stubs: - self._stubs["get_organization_impact"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_impact"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetOrganizationImpact", request_serializer=event_resources.GetOrganizationImpactRequest.serialize, response_deserializer=event_resources.OrganizationImpact.deserialize, @@ -412,7 +498,7 @@ def get_organization_impact( return self._stubs["get_organization_impact"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -426,7 +512,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -443,7 +529,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc_asyncio.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc_asyncio.py index f151d7165b22..da47b264dd07 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc_asyncio.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.servicehealth_v1.types import event_resources from .base import DEFAULT_CLIENT_INFO, ServiceHealthTransport from .grpc import ServiceHealthGrpcTransport +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.servicehealth.v1.ServiceHealth", + "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.servicehealth.v1.ServiceHealth", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceHealthGrpcAsyncIOTransport(ServiceHealthTransport): """gRPC AsyncIO backend transport for ServiceHealth. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def list_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_events" not in self._stubs: - self._stubs["list_events"] = self.grpc_channel.unary_unary( + self._stubs["list_events"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListEvents", request_serializer=event_resources.ListEventsRequest.serialize, response_deserializer=event_resources.ListEventsResponse.deserialize, @@ -293,7 +378,7 @@ def get_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event" not in self._stubs: - self._stubs["get_event"] = self.grpc_channel.unary_unary( + self._stubs["get_event"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetEvent", request_serializer=event_resources.GetEventRequest.serialize, response_deserializer=event_resources.Event.deserialize, @@ -323,7 +408,7 @@ def list_organization_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_organization_events" not in self._stubs: - self._stubs["list_organization_events"] = self.grpc_channel.unary_unary( + self._stubs["list_organization_events"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListOrganizationEvents", request_serializer=event_resources.ListOrganizationEventsRequest.serialize, response_deserializer=event_resources.ListOrganizationEventsResponse.deserialize, @@ -353,7 +438,7 @@ def get_organization_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_event" not in self._stubs: - self._stubs["get_organization_event"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_event"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetOrganizationEvent", request_serializer=event_resources.GetOrganizationEventRequest.serialize, response_deserializer=event_resources.OrganizationEvent.deserialize, @@ -383,7 +468,7 @@ def list_organization_impacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_organization_impacts" not in self._stubs: - self._stubs["list_organization_impacts"] = self.grpc_channel.unary_unary( + self._stubs["list_organization_impacts"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/ListOrganizationImpacts", request_serializer=event_resources.ListOrganizationImpactsRequest.serialize, response_deserializer=event_resources.ListOrganizationImpactsResponse.deserialize, @@ -414,7 +499,7 @@ def get_organization_impact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization_impact" not in self._stubs: - self._stubs["get_organization_impact"] = self.grpc_channel.unary_unary( + self._stubs["get_organization_impact"] = self._logged_channel.unary_unary( "/google.cloud.servicehealth.v1.ServiceHealth/GetOrganizationImpact", request_serializer=event_resources.GetOrganizationImpactRequest.serialize, response_deserializer=event_resources.OrganizationImpact.deserialize, @@ -526,7 +611,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -544,7 +629,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -561,7 +646,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/rest.py b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/rest.py index 9df308f1d754..62da0c9ec79c 100644 --- a/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/rest.py +++ b/packages/google-cloud-servicehealth/google/cloud/servicehealth_v1/services/service_health/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -118,8 +126,10 @@ def post_list_organization_impacts(self, response): def pre_get_event( self, request: event_resources.GetEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_resources.GetEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_resources.GetEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event Override in a subclass to manipulate the request or metadata @@ -139,8 +149,11 @@ def post_get_event(self, response: event_resources.Event) -> event_resources.Eve def pre_get_organization_event( self, request: event_resources.GetOrganizationEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_resources.GetOrganizationEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_resources.GetOrganizationEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_organization_event Override in a subclass to manipulate the request or metadata @@ -162,8 +175,11 @@ def post_get_organization_event( def pre_get_organization_impact( self, request: event_resources.GetOrganizationImpactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_resources.GetOrganizationImpactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_resources.GetOrganizationImpactRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_organization_impact Override in a subclass to manipulate the request or metadata @@ -185,8 +201,10 @@ def post_get_organization_impact( def pre_list_events( self, request: event_resources.ListEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_resources.ListEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_resources.ListEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_events Override in a subclass to manipulate the request or metadata @@ -208,9 +226,10 @@ def post_list_events( def pre_list_organization_events( self, request: event_resources.ListOrganizationEventsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - event_resources.ListOrganizationEventsRequest, Sequence[Tuple[str, str]] + event_resources.ListOrganizationEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_organization_events @@ -233,9 +252,10 @@ def post_list_organization_events( def pre_list_organization_impacts( self, request: event_resources.ListOrganizationImpactsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - event_resources.ListOrganizationImpactsRequest, Sequence[Tuple[str, str]] + event_resources.ListOrganizationImpactsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_organization_impacts @@ -258,8 +278,10 @@ def post_list_organization_impacts( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -281,8 +303,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -423,7 +447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.Event: r"""Call the get event method over HTTP. @@ -433,8 +457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.Event: @@ -449,6 +475,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseGetEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_event(request, metadata) transcoded_request = ( _BaseServiceHealthRestTransport._BaseGetEvent._get_transcoded_request( @@ -463,6 +490,33 @@ def __call__( ) ) + 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.servicehealth_v1.ServiceHealthClient.GetEvent", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._GetEvent._get_response( self._host, @@ -483,7 +537,29 @@ def __call__( pb_resp = event_resources.Event.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_resources.Event.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.servicehealth_v1.ServiceHealthClient.get_event", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganizationEvent( @@ -520,7 +596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationEvent: r"""Call the get organization event method over HTTP. @@ -531,8 +607,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.OrganizationEvent: @@ -547,6 +625,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseGetOrganizationEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization_event( request, metadata ) @@ -559,6 +638,33 @@ def __call__( 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.servicehealth_v1.ServiceHealthClient.GetOrganizationEvent", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetOrganizationEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._GetOrganizationEvent._get_response( self._host, @@ -579,7 +685,31 @@ def __call__( pb_resp = event_resources.OrganizationEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_resources.OrganizationEvent.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.servicehealth_v1.ServiceHealthClient.get_organization_event", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetOrganizationEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganizationImpact( @@ -617,7 +747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.OrganizationImpact: r"""Call the get organization impact method over HTTP. @@ -628,8 +758,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.OrganizationImpact: @@ -643,6 +775,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseGetOrganizationImpact._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization_impact( request, metadata ) @@ -655,6 +788,33 @@ def __call__( 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.servicehealth_v1.ServiceHealthClient.GetOrganizationImpact", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetOrganizationImpact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._GetOrganizationImpact._get_response( self._host, @@ -675,7 +835,31 @@ def __call__( pb_resp = event_resources.OrganizationImpact.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization_impact(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_resources.OrganizationImpact.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.servicehealth_v1.ServiceHealthClient.get_organization_impact", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetOrganizationImpact", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEvents( @@ -712,7 +896,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.ListEventsResponse: r"""Call the list events method over HTTP. @@ -723,8 +907,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.ListEventsResponse: @@ -736,6 +922,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseListEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_events(request, metadata) transcoded_request = ( _BaseServiceHealthRestTransport._BaseListEvents._get_transcoded_request( @@ -750,6 +937,33 @@ def __call__( ) ) + 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.servicehealth_v1.ServiceHealthClient.ListEvents", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._ListEvents._get_response( self._host, @@ -770,7 +984,31 @@ def __call__( pb_resp = event_resources.ListEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_resources.ListEventsResponse.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.servicehealth_v1.ServiceHealthClient.list_events", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOrganizationEvents( @@ -808,7 +1046,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.ListOrganizationEventsResponse: r"""Call the list organization events method over HTTP. @@ -819,8 +1057,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.ListOrganizationEventsResponse: @@ -832,6 +1072,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseListOrganizationEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_organization_events( request, metadata ) @@ -844,6 +1085,33 @@ def __call__( 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.servicehealth_v1.ServiceHealthClient.ListOrganizationEvents", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListOrganizationEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._ListOrganizationEvents._get_response( self._host, @@ -864,7 +1132,31 @@ def __call__( pb_resp = event_resources.ListOrganizationEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_organization_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + event_resources.ListOrganizationEventsResponse.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.servicehealth_v1.ServiceHealthClient.list_organization_events", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListOrganizationEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOrganizationImpacts( @@ -902,7 +1194,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_resources.ListOrganizationImpactsResponse: r"""Call the list organization impacts method over HTTP. @@ -913,8 +1205,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event_resources.ListOrganizationImpactsResponse: @@ -926,6 +1220,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseListOrganizationImpacts._get_http_options() ) + request, metadata = self._interceptor.pre_list_organization_impacts( request, metadata ) @@ -938,6 +1233,33 @@ def __call__( 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.servicehealth_v1.ServiceHealthClient.ListOrganizationImpacts", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListOrganizationImpacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServiceHealthRestTransport._ListOrganizationImpacts._get_response( @@ -960,7 +1282,33 @@ def __call__( pb_resp = event_resources.ListOrganizationImpactsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_organization_impacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + event_resources.ListOrganizationImpactsResponse.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.servicehealth_v1.ServiceHealthClient.list_organization_impacts", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListOrganizationImpacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1062,7 +1410,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1072,8 +1420,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1082,6 +1432,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseServiceHealthRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1094,6 +1445,33 @@ def __call__( ) ) + 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.servicehealth_v1.ServiceHealthClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._GetLocation._get_response( self._host, @@ -1113,6 +1491,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.servicehealth_v1.ServiceHealthAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1153,7 +1552,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1163,8 +1562,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1173,6 +1574,7 @@ def __call__( http_options = ( _BaseServiceHealthRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseServiceHealthRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1183,6 +1585,33 @@ def __call__( 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.servicehealth_v1.ServiceHealthClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceHealthRestTransport._ListLocations._get_response( self._host, @@ -1202,6 +1631,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.servicehealth_v1.ServiceHealthAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.servicehealth.v1.ServiceHealth", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-servicehealth/samples/generated_samples/snippet_metadata_google.cloud.servicehealth.v1.json b/packages/google-cloud-servicehealth/samples/generated_samples/snippet_metadata_google.cloud.servicehealth.v1.json index 22600c1e9d56..8ec1ea7b2c3b 100644 --- a/packages/google-cloud-servicehealth/samples/generated_samples/snippet_metadata_google.cloud.servicehealth.v1.json +++ b/packages/google-cloud-servicehealth/samples/generated_samples/snippet_metadata_google.cloud.servicehealth.v1.json @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.Event", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.Event", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.OrganizationEvent", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.OrganizationEvent", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.OrganizationImpact", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.types.OrganizationImpact", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListEventsAsyncPager", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListEventsPager", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationEventsAsyncPager", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationEventsPager", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationImpactsAsyncPager", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicehealth_v1.services.service_health.pagers.ListOrganizationImpactsPager", diff --git a/packages/google-cloud-servicehealth/tests/unit/gapic/servicehealth_v1/test_service_health.py b/packages/google-cloud-servicehealth/tests/unit/gapic/servicehealth_v1/test_service_health.py index 4c607ce0622d..7fe6d1436862 100644 --- a/packages/google-cloud-servicehealth/tests/unit/gapic/servicehealth_v1/test_service_health.py +++ b/packages/google-cloud-servicehealth/tests/unit/gapic/servicehealth_v1/test_service_health.py @@ -3893,6 +3893,7 @@ def test_list_events_rest_required_fields( response_value._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_events(request) @@ -3948,6 +3949,7 @@ def test_list_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_events(**mock_args) @@ -4139,6 +4141,7 @@ def test_get_event_rest_required_fields(request_type=event_resources.GetEventReq response_value._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_event(request) @@ -4184,6 +4187,7 @@ def test_get_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_event(**mock_args) @@ -4330,6 +4334,7 @@ def test_list_organization_events_rest_required_fields( response_value._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_organization_events(request) @@ -4385,6 +4390,7 @@ def test_list_organization_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_events(**mock_args) @@ -4584,6 +4590,7 @@ def test_get_organization_event_rest_required_fields( response_value._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_organization_event(request) @@ -4631,6 +4638,7 @@ def test_get_organization_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_event(**mock_args) @@ -4777,6 +4785,7 @@ def test_list_organization_impacts_rest_required_fields( response_value._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_organization_impacts(request) @@ -4831,6 +4840,7 @@ def test_list_organization_impacts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_impacts(**mock_args) @@ -5030,6 +5040,7 @@ def test_get_organization_impact_rest_required_fields( response_value._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_organization_impact(request) @@ -5077,6 +5088,7 @@ def test_get_organization_impact_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization_impact(**mock_args) @@ -5575,6 +5587,7 @@ def test_list_events_rest_bad_request(request_type=event_resources.ListEventsReq 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_events(request) @@ -5611,6 +5624,7 @@ def test_list_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_events(request) # Establish that the response is the type that we expect. @@ -5652,6 +5666,7 @@ def test_list_events_rest_interceptors(null_interceptor): 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 = event_resources.ListEventsResponse.to_json( event_resources.ListEventsResponse() ) @@ -5696,6 +5711,7 @@ def test_get_event_rest_bad_request(request_type=event_resources.GetEventRequest 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_event(request) @@ -5739,6 +5755,7 @@ def test_get_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_event(request) # Establish that the response is the type that we expect. @@ -5790,6 +5807,7 @@ def test_get_event_rest_interceptors(null_interceptor): 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 = event_resources.Event.to_json(event_resources.Event()) req.return_value.content = return_value @@ -5834,6 +5852,7 @@ def test_list_organization_events_rest_bad_request( 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_organization_events(request) @@ -5870,6 +5889,7 @@ def test_list_organization_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_events(request) # Establish that the response is the type that we expect. @@ -5911,6 +5931,7 @@ def test_list_organization_events_rest_interceptors(null_interceptor): 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 = event_resources.ListOrganizationEventsResponse.to_json( event_resources.ListOrganizationEventsResponse() ) @@ -5959,6 +5980,7 @@ def test_get_organization_event_rest_bad_request( 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_organization_event(request) @@ -6003,6 +6025,7 @@ def test_get_organization_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_event(request) # Establish that the response is the type that we expect. @@ -6056,6 +6079,7 @@ def test_get_organization_event_rest_interceptors(null_interceptor): 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 = event_resources.OrganizationEvent.to_json( event_resources.OrganizationEvent() ) @@ -6102,6 +6126,7 @@ def test_list_organization_impacts_rest_bad_request( 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_organization_impacts(request) @@ -6138,6 +6163,7 @@ def test_list_organization_impacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_impacts(request) # Establish that the response is the type that we expect. @@ -6179,6 +6205,7 @@ def test_list_organization_impacts_rest_interceptors(null_interceptor): 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 = event_resources.ListOrganizationImpactsResponse.to_json( event_resources.ListOrganizationImpactsResponse() ) @@ -6227,6 +6254,7 @@ def test_get_organization_impact_rest_bad_request( 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_organization_impact(request) @@ -6265,6 +6293,7 @@ def test_get_organization_impact_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization_impact(request) # Establish that the response is the type that we expect. @@ -6306,6 +6335,7 @@ def test_get_organization_impact_rest_interceptors(null_interceptor): 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 = event_resources.OrganizationImpact.to_json( event_resources.OrganizationImpact() ) @@ -6352,6 +6382,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -6382,6 +6413,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -6410,6 +6442,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -6440,6 +6473,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) diff --git a/packages/google-cloud-shell/google/cloud/shell/gapic_version.py b/packages/google-cloud-shell/google/cloud/shell/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-shell/google/cloud/shell/gapic_version.py +++ b/packages/google-cloud-shell/google/cloud/shell/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/gapic_version.py b/packages/google-cloud-shell/google/cloud/shell_v1/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/gapic_version.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/async_client.py b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/async_client.py index be5655ec1677..fc0d66a41d15 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/async_client.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudShellServiceTransport from .transports.grpc_asyncio import CloudShellServiceGrpcAsyncIOTransport +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 CloudShellServiceAsyncClient: """API for interacting with Google Cloud Shell. Each user of @@ -271,6 +281,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.shell_v1.CloudShellServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "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.shell.v1.CloudShellService", + "credentialsType": None, + }, + ) + async def get_environment( self, request: Optional[Union[cloudshell.GetEnvironmentRequest, dict]] = None, @@ -278,7 +310,7 @@ async def get_environment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudshell.Environment: r"""Gets an environment. Returns NOT_FOUND if the environment does not exist. @@ -324,8 +356,10 @@ async def sample_get_environment(): 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, 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: google.cloud.shell_v1.types.Environment: @@ -391,7 +425,7 @@ async def start_environment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts an existing environment, allowing clients to connect to it. The returned operation will contain an @@ -438,8 +472,10 @@ async def sample_start_environment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -496,7 +532,7 @@ async def authorize_environment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Sends OAuth credentials to a running environment on behalf of a user. When this completes, the environment @@ -540,8 +576,10 @@ async def sample_authorize_environment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -597,7 +635,7 @@ async def add_public_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via @@ -640,8 +678,10 @@ async def sample_add_public_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -699,7 +739,7 @@ async def remove_public_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Removes a public SSH key from an environment. Clients will no longer be able to connect to the environment using the @@ -742,8 +782,10 @@ async def sample_remove_public_key(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/client.py b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/client.py index 5ed9d4c04661..a7231277e4a6 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/client.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -588,6 +598,10 @@ def __init__( # 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( @@ -654,6 +668,29 @@ def __init__( 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.shell_v1.CloudShellServiceClient`.", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "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.shell.v1.CloudShellService", + "credentialsType": None, + }, + ) + def get_environment( self, request: Optional[Union[cloudshell.GetEnvironmentRequest, dict]] = None, @@ -661,7 +698,7 @@ def get_environment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudshell.Environment: r"""Gets an environment. Returns NOT_FOUND if the environment does not exist. @@ -707,8 +744,10 @@ def sample_get_environment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.shell_v1.types.Environment: @@ -771,7 +810,7 @@ def start_environment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts an existing environment, allowing clients to connect to it. The returned operation will contain an @@ -818,8 +857,10 @@ def sample_start_environment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -874,7 +915,7 @@ def authorize_environment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Sends OAuth credentials to a running environment on behalf of a user. When this completes, the environment @@ -918,8 +959,10 @@ def sample_authorize_environment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -973,7 +1016,7 @@ def add_public_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via @@ -1016,8 +1059,10 @@ def sample_add_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1073,7 +1118,7 @@ def remove_public_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Removes a public SSH key from an environment. Clients will no longer be able to connect to the environment using the @@ -1116,8 +1161,10 @@ def sample_remove_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py index 8caabea94b2e..0d0c1ba86245 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.shell_v1.types import cloudshell from .base import DEFAULT_CLIENT_INFO, CloudShellServiceTransport +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.shell.v1.CloudShellService", + "rpcName": 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.shell.v1.CloudShellService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudShellServiceGrpcTransport(CloudShellServiceTransport): """gRPC backend transport for CloudShellService. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -252,7 +338,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/GetEnvironment", request_serializer=cloudshell.GetEnvironmentRequest.serialize, response_deserializer=cloudshell.Environment.deserialize, @@ -310,7 +398,7 @@ def start_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_environment" not in self._stubs: - self._stubs["start_environment"] = self.grpc_channel.unary_unary( + self._stubs["start_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/StartEnvironment", request_serializer=cloudshell.StartEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -340,7 +428,7 @@ def authorize_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "authorize_environment" not in self._stubs: - self._stubs["authorize_environment"] = self.grpc_channel.unary_unary( + self._stubs["authorize_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/AuthorizeEnvironment", request_serializer=cloudshell.AuthorizeEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -369,7 +457,7 @@ def add_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_public_key" not in self._stubs: - self._stubs["add_public_key"] = self.grpc_channel.unary_unary( + self._stubs["add_public_key"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/AddPublicKey", request_serializer=cloudshell.AddPublicKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +486,7 @@ def remove_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_public_key" not in self._stubs: - self._stubs["remove_public_key"] = self.grpc_channel.unary_unary( + self._stubs["remove_public_key"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/RemovePublicKey", request_serializer=cloudshell.RemovePublicKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +494,7 @@ def remove_public_key( return self._stubs["remove_public_key"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc_asyncio.py b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc_asyncio.py index bef25b353360..4249d34de3c1 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.shell_v1.types import cloudshell from .base import DEFAULT_CLIENT_INFO, CloudShellServiceTransport from .grpc import CloudShellServiceGrpcTransport +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.shell.v1.CloudShellService", + "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.shell.v1.CloudShellService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudShellServiceGrpcAsyncIOTransport(CloudShellServiceTransport): """gRPC AsyncIO backend transport for CloudShellService. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/GetEnvironment", request_serializer=cloudshell.GetEnvironmentRequest.serialize, response_deserializer=cloudshell.Environment.deserialize, @@ -324,7 +409,7 @@ def start_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_environment" not in self._stubs: - self._stubs["start_environment"] = self.grpc_channel.unary_unary( + self._stubs["start_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/StartEnvironment", request_serializer=cloudshell.StartEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -356,7 +441,7 @@ def authorize_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "authorize_environment" not in self._stubs: - self._stubs["authorize_environment"] = self.grpc_channel.unary_unary( + self._stubs["authorize_environment"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/AuthorizeEnvironment", request_serializer=cloudshell.AuthorizeEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def add_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_public_key" not in self._stubs: - self._stubs["add_public_key"] = self.grpc_channel.unary_unary( + self._stubs["add_public_key"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/AddPublicKey", request_serializer=cloudshell.AddPublicKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -418,7 +503,7 @@ def remove_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_public_key" not in self._stubs: - self._stubs["remove_public_key"] = self.grpc_channel.unary_unary( + self._stubs["remove_public_key"] = self._logged_channel.unary_unary( "/google.cloud.shell.v1.CloudShellService/RemovePublicKey", request_serializer=cloudshell.RemovePublicKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -471,7 +556,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/rest.py b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/rest.py index d4beecf3b210..022b79a4030a 100644 --- a/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/rest.py +++ b/packages/google-cloud-shell/google/cloud/shell_v1/services/cloud_shell_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -110,8 +118,8 @@ def post_start_environment(self, response): def pre_add_public_key( self, request: cloudshell.AddPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudshell.AddPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudshell.AddPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for add_public_key Override in a subclass to manipulate the request or metadata @@ -133,8 +141,10 @@ def post_add_public_key( def pre_authorize_environment( self, request: cloudshell.AuthorizeEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudshell.AuthorizeEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudshell.AuthorizeEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for authorize_environment Override in a subclass to manipulate the request or metadata @@ -156,8 +166,10 @@ def post_authorize_environment( def pre_get_environment( self, request: cloudshell.GetEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudshell.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudshell.GetEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_environment Override in a subclass to manipulate the request or metadata @@ -179,8 +191,10 @@ def post_get_environment( def pre_remove_public_key( self, request: cloudshell.RemovePublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudshell.RemovePublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudshell.RemovePublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_public_key Override in a subclass to manipulate the request or metadata @@ -202,8 +216,10 @@ def post_remove_public_key( def pre_start_environment( self, request: cloudshell.StartEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudshell.StartEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudshell.StartEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for start_environment Override in a subclass to manipulate the request or metadata @@ -379,7 +395,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the add public key method over HTTP. @@ -390,8 +406,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -404,6 +422,7 @@ def __call__( http_options = ( _BaseCloudShellServiceRestTransport._BaseAddPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_add_public_key(request, metadata) transcoded_request = _BaseCloudShellServiceRestTransport._BaseAddPublicKey._get_transcoded_request( http_options, request @@ -418,6 +437,33 @@ def __call__( 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.shell_v1.CloudShellServiceClient.AddPublicKey", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "AddPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudShellServiceRestTransport._AddPublicKey._get_response( self._host, @@ -437,7 +483,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_public_key(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.shell_v1.CloudShellServiceClient.add_public_key", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "AddPublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AuthorizeEnvironment( @@ -476,7 +544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the authorize environment method over HTTP. @@ -487,8 +555,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -501,6 +571,7 @@ def __call__( http_options = ( _BaseCloudShellServiceRestTransport._BaseAuthorizeEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_authorize_environment( request, metadata ) @@ -517,6 +588,33 @@ def __call__( 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.shell_v1.CloudShellServiceClient.AuthorizeEnvironment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "AuthorizeEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CloudShellServiceRestTransport._AuthorizeEnvironment._get_response( @@ -538,7 +636,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_authorize_environment(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.shell_v1.CloudShellServiceClient.authorize_environment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "AuthorizeEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnvironment( @@ -576,7 +696,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudshell.Environment: r"""Call the get environment method over HTTP. @@ -587,8 +707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloudshell.Environment: @@ -606,6 +728,7 @@ def __call__( http_options = ( _BaseCloudShellServiceRestTransport._BaseGetEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment(request, metadata) transcoded_request = _BaseCloudShellServiceRestTransport._BaseGetEnvironment._get_transcoded_request( http_options, request @@ -616,6 +739,33 @@ def __call__( 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.shell_v1.CloudShellServiceClient.GetEnvironment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "GetEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudShellServiceRestTransport._GetEnvironment._get_response( self._host, @@ -636,7 +786,29 @@ def __call__( pb_resp = cloudshell.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudshell.Environment.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.shell_v1.CloudShellServiceClient.get_environment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "GetEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemovePublicKey( @@ -675,7 +847,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the remove public key method over HTTP. @@ -686,8 +858,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -700,6 +874,7 @@ def __call__( http_options = ( _BaseCloudShellServiceRestTransport._BaseRemovePublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_remove_public_key( request, metadata ) @@ -716,6 +891,33 @@ def __call__( 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.shell_v1.CloudShellServiceClient.RemovePublicKey", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "RemovePublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudShellServiceRestTransport._RemovePublicKey._get_response( self._host, @@ -735,7 +937,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_public_key(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.shell_v1.CloudShellServiceClient.remove_public_key", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "RemovePublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartEnvironment( @@ -774,7 +998,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start environment method over HTTP. @@ -785,8 +1009,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -799,6 +1025,7 @@ def __call__( http_options = ( _BaseCloudShellServiceRestTransport._BaseStartEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_start_environment( request, metadata ) @@ -815,6 +1042,33 @@ def __call__( 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.shell_v1.CloudShellServiceClient.StartEnvironment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "StartEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudShellServiceRestTransport._StartEnvironment._get_response( self._host, @@ -834,7 +1088,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_environment(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.shell_v1.CloudShellServiceClient.start_environment", + extra={ + "serviceName": "google.cloud.shell.v1.CloudShellService", + "rpcName": "StartEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-shell/samples/generated_samples/snippet_metadata_google.cloud.shell.v1.json b/packages/google-cloud-shell/samples/generated_samples/snippet_metadata_google.cloud.shell.v1.json index 2bcb3c21ff58..e58b3321f1fb 100644 --- a/packages/google-cloud-shell/samples/generated_samples/snippet_metadata_google.cloud.shell.v1.json +++ b/packages/google-cloud-shell/samples/generated_samples/snippet_metadata_google.cloud.shell.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-shell", - "version": "1.10.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -353,7 +353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.shell_v1.types.Environment", @@ -433,7 +433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.shell_v1.types.Environment", @@ -510,7 +510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -663,7 +663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-shell/tests/unit/gapic/shell_v1/test_cloud_shell_service.py b/packages/google-cloud-shell/tests/unit/gapic/shell_v1/test_cloud_shell_service.py index 3bab1647e9f0..aafb460afeac 100644 --- a/packages/google-cloud-shell/tests/unit/gapic/shell_v1/test_cloud_shell_service.py +++ b/packages/google-cloud-shell/tests/unit/gapic/shell_v1/test_cloud_shell_service.py @@ -2594,6 +2594,7 @@ def test_get_environment_rest_required_fields( response_value._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_environment(request) @@ -2639,6 +2640,7 @@ def test_get_environment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_environment(**mock_args) @@ -3235,6 +3237,7 @@ def test_get_environment_rest_bad_request( 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_environment(request) @@ -3278,6 +3281,7 @@ def test_get_environment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_environment(request) # Establish that the response is the type that we expect. @@ -3326,6 +3330,7 @@ def test_get_environment_rest_interceptors(null_interceptor): 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 = cloudshell.Environment.to_json(cloudshell.Environment()) req.return_value.content = return_value @@ -3370,6 +3375,7 @@ def test_start_environment_rest_bad_request( 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.start_environment(request) @@ -3400,6 +3406,7 @@ def test_start_environment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.start_environment(request) # Establish that the response is the type that we expect. @@ -3441,6 +3448,7 @@ def test_start_environment_rest_interceptors(null_interceptor): 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 @@ -3485,6 +3493,7 @@ def test_authorize_environment_rest_bad_request( 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.authorize_environment(request) @@ -3515,6 +3524,7 @@ def test_authorize_environment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.authorize_environment(request) # Establish that the response is the type that we expect. @@ -3556,6 +3566,7 @@ def test_authorize_environment_rest_interceptors(null_interceptor): 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 @@ -3598,6 +3609,7 @@ def test_add_public_key_rest_bad_request(request_type=cloudshell.AddPublicKeyReq 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.add_public_key(request) @@ -3628,6 +3640,7 @@ def test_add_public_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.add_public_key(request) # Establish that the response is the type that we expect. @@ -3667,6 +3680,7 @@ def test_add_public_key_rest_interceptors(null_interceptor): 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 @@ -3711,6 +3725,7 @@ def test_remove_public_key_rest_bad_request( 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.remove_public_key(request) @@ -3741,6 +3756,7 @@ def test_remove_public_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.remove_public_key(request) # Establish that the response is the type that we expect. @@ -3782,6 +3798,7 @@ def test_remove_public_key_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-speech/google/cloud/speech/gapic_version.py b/packages/google-cloud-speech/google/cloud/speech/gapic_version.py index 97acdfe8394d..558c8aab67c5 100644 --- a/packages/google-cloud-speech/google/cloud/speech/gapic_version.py +++ b/packages/google-cloud-speech/google/cloud/speech/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.28.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/gapic_version.py b/packages/google-cloud-speech/google/cloud/speech_v1/gapic_version.py index 97acdfe8394d..558c8aab67c5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/gapic_version.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.28.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/async_client.py index a3d303b034aa..8f6c802e3b85 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AdaptationTransport from .transports.grpc_asyncio import AdaptationGrpcAsyncIOTransport +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 AdaptationAsyncClient: """Service that implements Google Cloud Speech Adaptation API.""" @@ -253,6 +263,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.speech_v1.AdaptationAsyncClient`.", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "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.speech.v1.Adaptation", + "credentialsType": None, + }, + ) + async def create_phrase_set( self, request: Optional[ @@ -264,7 +296,7 @@ async def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items @@ -341,8 +373,10 @@ async def sample_create_phrase_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, 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: google.cloud.speech_v1.types.PhraseSet: @@ -410,7 +444,7 @@ async def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Get a phrase set. @@ -464,8 +498,10 @@ async def sample_get_phrase_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, 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: google.cloud.speech_v1.types.PhraseSet: @@ -529,7 +565,7 @@ async def list_phrase_set( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetAsyncPager: r"""List phrase sets. @@ -584,8 +620,10 @@ async def sample_list_phrase_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, 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: google.cloud.speech_v1.services.adaptation.pagers.ListPhraseSetAsyncPager: @@ -663,7 +701,7 @@ async def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Update a phrase set. @@ -723,8 +761,10 @@ async def sample_update_phrase_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, 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: google.cloud.speech_v1.types.PhraseSet: @@ -792,7 +832,7 @@ async def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a phrase set. @@ -834,8 +874,10 @@ async def sample_delete_phrase_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -891,7 +933,7 @@ async def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Create a custom class. @@ -965,8 +1007,10 @@ async def sample_create_custom_class(): 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, 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: google.cloud.speech_v1.types.CustomClass: @@ -1038,7 +1082,7 @@ async def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Get a custom class. @@ -1084,8 +1128,10 @@ async def sample_get_custom_class(): 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, 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: google.cloud.speech_v1.types.CustomClass: @@ -1153,7 +1199,7 @@ async def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesAsyncPager: r"""List custom classes. @@ -1208,8 +1254,10 @@ async def sample_list_custom_classes(): 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, 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: google.cloud.speech_v1.services.adaptation.pagers.ListCustomClassesAsyncPager: @@ -1287,7 +1335,7 @@ async def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Update a custom class. @@ -1347,8 +1395,10 @@ async def sample_update_custom_class(): 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, 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: google.cloud.speech_v1.types.CustomClass: @@ -1420,7 +1470,7 @@ async def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a custom class. @@ -1471,8 +1521,10 @@ async def sample_delete_custom_class(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1523,7 +1575,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1534,8 +1586,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1576,7 +1630,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1587,8 +1641,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/client.py index 1e7970ccd4ae..17e211aa853c 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -601,6 +611,10 @@ def __init__( # 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( @@ -663,6 +677,29 @@ def __init__( 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.speech_v1.AdaptationClient`.", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "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.speech.v1.Adaptation", + "credentialsType": None, + }, + ) + def create_phrase_set( self, request: Optional[ @@ -674,7 +711,7 @@ def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items @@ -751,8 +788,10 @@ def sample_create_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.PhraseSet: @@ -817,7 +856,7 @@ def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Get a phrase set. @@ -871,8 +910,10 @@ def sample_get_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.PhraseSet: @@ -933,7 +974,7 @@ def list_phrase_set( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetPager: r"""List phrase sets. @@ -988,8 +1029,10 @@ def sample_list_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.services.adaptation.pagers.ListPhraseSetPager: @@ -1064,7 +1107,7 @@ def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Update a phrase set. @@ -1124,8 +1167,10 @@ def sample_update_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.PhraseSet: @@ -1190,7 +1235,7 @@ def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a phrase set. @@ -1232,8 +1277,10 @@ def sample_delete_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1286,7 +1333,7 @@ def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Create a custom class. @@ -1360,8 +1407,10 @@ def sample_create_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.CustomClass: @@ -1430,7 +1479,7 @@ def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Get a custom class. @@ -1476,8 +1525,10 @@ def sample_get_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.CustomClass: @@ -1542,7 +1593,7 @@ def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesPager: r"""List custom classes. @@ -1597,8 +1648,10 @@ def sample_list_custom_classes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.services.adaptation.pagers.ListCustomClassesPager: @@ -1673,7 +1726,7 @@ def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Update a custom class. @@ -1733,8 +1786,10 @@ def sample_update_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.CustomClass: @@ -1803,7 +1858,7 @@ def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a custom class. @@ -1854,8 +1909,10 @@ def sample_delete_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1916,7 +1973,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1927,8 +1984,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1969,7 +2028,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1980,8 +2039,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/pagers.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/pagers.py index 33c5fcc03ac7..a9967de18782 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/pagers.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech_adaptation.ListPhraseSetRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech_adaptation.ListPhraseSetRequest(request) @@ -221,7 +225,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -235,8 +239,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech_adaptation.ListCustomClassesRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech_adaptation.ListCustomClassesRequest(request) diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc.py index c4e65114cf3e..d306d504dcc2 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.speech_v1.types import cloud_speech_adaptation, resource from .base import DEFAULT_CLIENT_INFO, AdaptationTransport +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.speech.v1.Adaptation", + "rpcName": 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.speech.v1.Adaptation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdaptationGrpcTransport(AdaptationTransport): """gRPC backend transport for Adaptation. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/CreatePhraseSet", request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -284,7 +370,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/GetPhraseSet", request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -313,7 +399,7 @@ def list_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_set" not in self._stubs: - self._stubs["list_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/ListPhraseSet", request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize, response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize, @@ -339,7 +425,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/UpdatePhraseSet", request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -365,7 +451,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/DeletePhraseSet", request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -393,7 +479,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/CreateCustomClass", request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -421,7 +507,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/GetCustomClass", request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -450,7 +536,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/ListCustomClasses", request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize, @@ -478,7 +564,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/UpdateCustomClass", request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -504,7 +590,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/DeleteCustomClass", request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -512,7 +598,7 @@ def delete_custom_class( return self._stubs["delete_custom_class"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -524,7 +610,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -543,7 +629,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py index 32c2ee4c75f2..08416693b9e8 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.speech_v1.types import cloud_speech_adaptation, resource from .base import DEFAULT_CLIENT_INFO, AdaptationTransport from .grpc import AdaptationGrpcTransport +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.speech.v1.Adaptation", + "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.speech.v1.Adaptation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdaptationGrpcAsyncIOTransport(AdaptationTransport): """gRPC AsyncIO backend transport for Adaptation. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/CreatePhraseSet", request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -296,7 +381,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/GetPhraseSet", request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -325,7 +410,7 @@ def list_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_set" not in self._stubs: - self._stubs["list_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/ListPhraseSet", request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize, response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize, @@ -353,7 +438,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/UpdatePhraseSet", request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -381,7 +466,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/DeletePhraseSet", request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -410,7 +495,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/CreateCustomClass", request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -438,7 +523,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/GetCustomClass", request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -467,7 +552,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/ListCustomClasses", request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize, @@ -496,7 +581,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/UpdateCustomClass", request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -524,7 +609,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Adaptation/DeleteCustomClass", request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -602,7 +687,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -618,7 +703,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -637,7 +722,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/rest.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/rest.py index d5a06d183592..d3a80f8116b5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/rest.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/adaptation/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -143,9 +151,10 @@ def post_update_phrase_set(self, response): def pre_create_custom_class( self, request: cloud_speech_adaptation.CreateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.CreateCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.CreateCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_custom_class @@ -168,9 +177,10 @@ def post_create_custom_class( def pre_create_phrase_set( self, request: cloud_speech_adaptation.CreatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.CreatePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.CreatePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_phrase_set @@ -193,9 +203,10 @@ def post_create_phrase_set( def pre_delete_custom_class( self, request: cloud_speech_adaptation.DeleteCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.DeleteCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.DeleteCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_custom_class @@ -207,9 +218,10 @@ def pre_delete_custom_class( def pre_delete_phrase_set( self, request: cloud_speech_adaptation.DeletePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.DeletePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.DeletePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_phrase_set @@ -221,9 +233,10 @@ def pre_delete_phrase_set( def pre_get_custom_class( self, request: cloud_speech_adaptation.GetCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.GetCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.GetCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_custom_class @@ -246,8 +259,11 @@ def post_get_custom_class( def pre_get_phrase_set( self, request: cloud_speech_adaptation.GetPhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech_adaptation.GetPhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech_adaptation.GetPhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_phrase_set Override in a subclass to manipulate the request or metadata @@ -267,9 +283,10 @@ def post_get_phrase_set(self, response: resource.PhraseSet) -> resource.PhraseSe def pre_list_custom_classes( self, request: cloud_speech_adaptation.ListCustomClassesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.ListCustomClassesRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.ListCustomClassesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_custom_classes @@ -292,8 +309,11 @@ def post_list_custom_classes( def pre_list_phrase_set( self, request: cloud_speech_adaptation.ListPhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech_adaptation.ListPhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech_adaptation.ListPhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_phrase_set Override in a subclass to manipulate the request or metadata @@ -315,9 +335,10 @@ def post_list_phrase_set( def pre_update_custom_class( self, request: cloud_speech_adaptation.UpdateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.UpdateCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.UpdateCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_custom_class @@ -340,9 +361,10 @@ def post_update_custom_class( def pre_update_phrase_set( self, request: cloud_speech_adaptation.UpdatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.UpdatePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.UpdatePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_phrase_set @@ -365,8 +387,10 @@ def post_update_phrase_set( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -388,8 +412,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -530,7 +556,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the create custom class method over HTTP. @@ -541,8 +567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -559,6 +587,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseCreateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_class( request, metadata ) @@ -575,6 +604,33 @@ def __call__( 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.speech_v1.AdaptationClient.CreateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "CreateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._CreateCustomClass._get_response( self._host, @@ -596,7 +652,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1.AdaptationClient.create_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "CreateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePhraseSet( @@ -634,7 +712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the create phrase set method over HTTP. @@ -645,8 +723,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -659,6 +739,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseCreatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_phrase_set( request, metadata ) @@ -675,6 +756,33 @@ def __call__( 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.speech_v1.AdaptationClient.CreatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "CreatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._CreatePhraseSet._get_response( self._host, @@ -696,7 +804,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1.AdaptationClient.create_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "CreatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCustomClass( @@ -733,7 +863,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete custom class method over HTTP. @@ -744,13 +874,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAdaptationRestTransport._BaseDeleteCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_delete_custom_class( request, metadata ) @@ -763,6 +896,33 @@ def __call__( 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.speech_v1.AdaptationClient.DeleteCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "DeleteCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._DeleteCustomClass._get_response( self._host, @@ -812,7 +972,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete phrase set method over HTTP. @@ -823,13 +983,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAdaptationRestTransport._BaseDeletePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_phrase_set( request, metadata ) @@ -842,6 +1005,33 @@ def __call__( 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.speech_v1.AdaptationClient.DeletePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "DeletePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._DeletePhraseSet._get_response( self._host, @@ -891,7 +1081,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the get custom class method over HTTP. @@ -902,8 +1092,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -920,6 +1112,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_class( request, metadata ) @@ -934,6 +1127,33 @@ def __call__( ) ) + 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.speech_v1.AdaptationClient.GetCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetCustomClass._get_response( self._host, @@ -954,7 +1174,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1.AdaptationClient.get_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPhraseSet( @@ -991,7 +1233,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the get phrase set method over HTTP. @@ -1002,8 +1244,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -1016,6 +1260,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetPhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_phrase_set(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseGetPhraseSet._get_transcoded_request( @@ -1030,6 +1275,33 @@ def __call__( ) ) + 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.speech_v1.AdaptationClient.GetPhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetPhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetPhraseSet._get_response( self._host, @@ -1050,7 +1322,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1.AdaptationClient.get_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetPhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomClasses( @@ -1087,7 +1381,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech_adaptation.ListCustomClassesResponse: r"""Call the list custom classes method over HTTP. @@ -1098,8 +1392,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech_adaptation.ListCustomClassesResponse: @@ -1111,6 +1407,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListCustomClasses._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_classes( request, metadata ) @@ -1123,6 +1420,33 @@ def __call__( 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.speech_v1.AdaptationClient.ListCustomClasses", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListCustomClasses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListCustomClasses._get_response( self._host, @@ -1143,7 +1467,33 @@ def __call__( pb_resp = cloud_speech_adaptation.ListCustomClassesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_classes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_speech_adaptation.ListCustomClassesResponse.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.speech_v1.AdaptationClient.list_custom_classes", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListCustomClasses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPhraseSet( @@ -1180,7 +1530,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech_adaptation.ListPhraseSetResponse: r"""Call the list phrase set method over HTTP. @@ -1191,8 +1541,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech_adaptation.ListPhraseSetResponse: @@ -1204,6 +1556,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListPhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_phrase_set(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseListPhraseSet._get_transcoded_request( @@ -1218,6 +1571,33 @@ def __call__( ) ) + 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.speech_v1.AdaptationClient.ListPhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListPhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListPhraseSet._get_response( self._host, @@ -1238,7 +1618,31 @@ def __call__( pb_resp = cloud_speech_adaptation.ListPhraseSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_speech_adaptation.ListPhraseSetResponse.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.speech_v1.AdaptationClient.list_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListPhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomClass( @@ -1276,7 +1680,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the update custom class method over HTTP. @@ -1287,8 +1691,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -1305,6 +1711,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseUpdateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_class( request, metadata ) @@ -1321,6 +1728,33 @@ def __call__( 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.speech_v1.AdaptationClient.UpdateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "UpdateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._UpdateCustomClass._get_response( self._host, @@ -1342,7 +1776,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1.AdaptationClient.update_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "UpdateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePhraseSet( @@ -1380,7 +1836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the update phrase set method over HTTP. @@ -1391,8 +1847,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -1405,6 +1863,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseUpdatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_phrase_set( request, metadata ) @@ -1421,6 +1880,33 @@ def __call__( 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.speech_v1.AdaptationClient.UpdatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "UpdatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._UpdatePhraseSet._get_response( self._host, @@ -1442,7 +1928,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1.AdaptationClient.update_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "UpdatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1575,7 +2083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1585,8 +2093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1595,6 +2105,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseGetOperation._get_transcoded_request( @@ -1609,6 +2120,33 @@ def __call__( ) ) + 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.speech_v1.AdaptationClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetOperation._get_response( self._host, @@ -1628,6 +2166,27 @@ def __call__( 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.speech_v1.AdaptationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1668,7 +2227,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1678,8 +2237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1688,6 +2249,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAdaptationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1700,6 +2262,33 @@ def __call__( ) ) + 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.speech_v1.AdaptationClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListOperations._get_response( self._host, @@ -1719,6 +2308,27 @@ def __call__( 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.speech_v1.AdaptationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1.Adaptation", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py index d8a56779733f..65763b2f720f 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport +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 SpeechAsyncClient: """Service that implements Google Cloud Speech API.""" @@ -254,6 +264,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.speech_v1.SpeechAsyncClient`.", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "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.speech.v1.Speech", + "credentialsType": None, + }, + ) + async def recognize( self, request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None, @@ -262,7 +294,7 @@ async def recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous speech recognition: receive results after all audio has been sent and processed. @@ -322,8 +354,10 @@ async def sample_recognize(): 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, 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: google.cloud.speech_v1.types.RecognizeResponse: @@ -382,7 +416,7 @@ async def long_running_recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an @@ -450,8 +484,10 @@ async def sample_long_running_recognize(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -523,7 +559,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -581,8 +617,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]: @@ -675,7 +713,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -686,8 +724,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -728,7 +768,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -739,8 +779,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py index e688dc4f1f6f..1287454192b1 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -605,6 +615,10 @@ def __init__( # 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( @@ -667,6 +681,29 @@ def __init__( 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.speech_v1.SpeechClient`.", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "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.speech.v1.Speech", + "credentialsType": None, + }, + ) + def recognize( self, request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None, @@ -675,7 +712,7 @@ def recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous speech recognition: receive results after all audio has been sent and processed. @@ -735,8 +772,10 @@ def sample_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1.types.RecognizeResponse: @@ -792,7 +831,7 @@ def long_running_recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an @@ -860,8 +899,10 @@ def sample_long_running_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -928,7 +969,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[cloud_speech.StreamingRecognizeResponse]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -986,8 +1027,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]: @@ -1091,7 +1134,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1102,8 +1145,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1144,7 +1189,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1155,8 +1200,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py index 485bee0180f5..237e027cb777 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.speech_v1.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport +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.speech.v1.Speech", + "rpcName": 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.speech.v1.Speech", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcTransport(SpeechTransport): """gRPC backend transport for Speech. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -301,7 +389,7 @@ def long_running_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "long_running_recognize" not in self._stubs: - self._stubs["long_running_recognize"] = self.grpc_channel.unary_unary( + self._stubs["long_running_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Speech/LongRunningRecognize", request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +420,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v1.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -340,7 +428,7 @@ def streaming_recognize( return self._stubs["streaming_recognize"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -352,7 +440,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -371,7 +459,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py index 380e3e4ffc4e..ced2778da862 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.speech_v1.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport from .grpc import SpeechGrpcTransport +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.speech.v1.Speech", + "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.speech.v1.Speech", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcAsyncIOTransport(SpeechTransport): """gRPC AsyncIO backend transport for Speech. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -315,7 +400,7 @@ def long_running_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "long_running_recognize" not in self._stubs: - self._stubs["long_running_recognize"] = self.grpc_channel.unary_unary( + self._stubs["long_running_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1.Speech/LongRunningRecognize", request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -346,7 +431,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v1.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -409,7 +494,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -425,7 +510,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -444,7 +529,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/rest.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/rest.py index 4d78ada7e76e..ba8a8052d06f 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/rest.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,8 +94,11 @@ def post_recognize(self, response): def pre_long_running_recognize( self, request: cloud_speech.LongRunningRecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.LongRunningRecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.LongRunningRecognizeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for long_running_recognize Override in a subclass to manipulate the request or metadata @@ -109,8 +120,8 @@ def post_long_running_recognize( def pre_recognize( self, request: cloud_speech.RecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for recognize Override in a subclass to manipulate the request or metadata @@ -132,8 +143,10 @@ def post_recognize( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -155,8 +168,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -338,7 +353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the long running recognize method over HTTP. @@ -349,8 +364,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -363,6 +380,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseLongRunningRecognize._get_http_options() ) + request, metadata = self._interceptor.pre_long_running_recognize( request, metadata ) @@ -379,6 +397,33 @@ def __call__( 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.speech_v1.SpeechClient.LongRunningRecognize", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "LongRunningRecognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._LongRunningRecognize._get_response( self._host, @@ -398,7 +443,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_long_running_recognize(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.speech_v1.SpeechClient.long_running_recognize", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "LongRunningRecognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Recognize(_BaseSpeechRestTransport._BaseRecognize, SpeechRestStub): @@ -434,7 +501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Call the recognize method over HTTP. @@ -445,8 +512,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.RecognizeResponse: @@ -457,6 +526,7 @@ def __call__( """ http_options = _BaseSpeechRestTransport._BaseRecognize._get_http_options() + request, metadata = self._interceptor.pre_recognize(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseRecognize._get_transcoded_request( @@ -475,6 +545,33 @@ def __call__( ) ) + 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.speech_v1.SpeechClient.Recognize", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "Recognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._Recognize._get_response( self._host, @@ -496,7 +593,29 @@ def __call__( pb_resp = cloud_speech.RecognizeResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_recognize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.RecognizeResponse.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.speech_v1.SpeechClient.recognize", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "Recognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingRecognize( @@ -511,7 +630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingRecognize is not available over REST transport" @@ -580,7 +699,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -590,8 +709,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -600,6 +721,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetOperation._get_transcoded_request( @@ -614,6 +736,33 @@ def __call__( ) ) + 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.speech_v1.SpeechClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetOperation._get_response( self._host, @@ -633,6 +782,27 @@ def __call__( 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.speech_v1.SpeechAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -671,7 +841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -681,8 +851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -691,6 +863,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseListOperations._get_transcoded_request( @@ -705,6 +878,33 @@ def __call__( ) ) + 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.speech_v1.SpeechClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListOperations._get_response( self._host, @@ -724,6 +924,27 @@ def __call__( 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.speech_v1.SpeechAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1.Speech", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/gapic_version.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/gapic_version.py index 97acdfe8394d..558c8aab67c5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.28.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py index afa4497da155..b330c3fb8f01 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AdaptationTransport from .transports.grpc_asyncio import AdaptationGrpcAsyncIOTransport +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 AdaptationAsyncClient: """Service that implements Google Cloud Speech Adaptation API.""" @@ -253,6 +263,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.speech_v1p1beta1.AdaptationAsyncClient`.", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "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.speech.v1p1beta1.Adaptation", + "credentialsType": None, + }, + ) + async def create_phrase_set( self, request: Optional[ @@ -264,7 +296,7 @@ async def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items @@ -341,8 +373,10 @@ async def sample_create_phrase_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, 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -410,7 +444,7 @@ async def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Get a phrase set. @@ -464,8 +498,10 @@ async def sample_get_phrase_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, 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -529,7 +565,7 @@ async def list_phrase_set( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetAsyncPager: r"""List phrase sets. @@ -584,8 +620,10 @@ async def sample_list_phrase_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, 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: google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetAsyncPager: @@ -663,7 +701,7 @@ async def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Update a phrase set. @@ -723,8 +761,10 @@ async def sample_update_phrase_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, 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -792,7 +832,7 @@ async def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a phrase set. @@ -834,8 +874,10 @@ async def sample_delete_phrase_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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -891,7 +933,7 @@ async def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Create a custom class. @@ -965,8 +1007,10 @@ async def sample_create_custom_class(): 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, 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1038,7 +1082,7 @@ async def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Get a custom class. @@ -1084,8 +1128,10 @@ async def sample_get_custom_class(): 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, 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1153,7 +1199,7 @@ async def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesAsyncPager: r"""List custom classes. @@ -1208,8 +1254,10 @@ async def sample_list_custom_classes(): 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, 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: google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesAsyncPager: @@ -1287,7 +1335,7 @@ async def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Update a custom class. @@ -1347,8 +1395,10 @@ async def sample_update_custom_class(): 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, 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1420,7 +1470,7 @@ async def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a custom class. @@ -1471,8 +1521,10 @@ async def sample_delete_custom_class(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1523,7 +1575,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1534,8 +1586,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1576,7 +1630,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1587,8 +1641,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py index 08bb5084ace2..53cce6750d1c 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -601,6 +611,10 @@ def __init__( # 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( @@ -663,6 +677,29 @@ def __init__( 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.speech_v1p1beta1.AdaptationClient`.", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "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.speech.v1p1beta1.Adaptation", + "credentialsType": None, + }, + ) + def create_phrase_set( self, request: Optional[ @@ -674,7 +711,7 @@ def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items @@ -751,8 +788,10 @@ def sample_create_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -817,7 +856,7 @@ def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Get a phrase set. @@ -871,8 +910,10 @@ def sample_get_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -933,7 +974,7 @@ def list_phrase_set( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetPager: r"""List phrase sets. @@ -988,8 +1029,10 @@ def sample_list_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetPager: @@ -1064,7 +1107,7 @@ def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Update a phrase set. @@ -1124,8 +1167,10 @@ def sample_update_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.PhraseSet: @@ -1190,7 +1235,7 @@ def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a phrase set. @@ -1232,8 +1277,10 @@ def sample_delete_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1286,7 +1333,7 @@ def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Create a custom class. @@ -1360,8 +1407,10 @@ def sample_create_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1430,7 +1479,7 @@ def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Get a custom class. @@ -1476,8 +1525,10 @@ def sample_get_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1542,7 +1593,7 @@ def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesPager: r"""List custom classes. @@ -1597,8 +1648,10 @@ def sample_list_custom_classes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesPager: @@ -1673,7 +1726,7 @@ def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Update a custom class. @@ -1733,8 +1786,10 @@ def sample_update_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.CustomClass: @@ -1803,7 +1858,7 @@ def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a custom class. @@ -1854,8 +1909,10 @@ def sample_delete_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1916,7 +1973,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1927,8 +1984,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1969,7 +2028,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1980,8 +2039,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py index 5d69cc0dd8d1..644dee680c5e 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech_adaptation.ListPhraseSetRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech_adaptation.ListPhraseSetRequest(request) @@ -221,7 +225,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -235,8 +239,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech_adaptation.ListCustomClassesRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech_adaptation.ListCustomClassesRequest(request) diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py index f7738b4a8b64..59fa30a87596 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource from .base import DEFAULT_CLIENT_INFO, AdaptationTransport +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.speech.v1p1beta1.Adaptation", + "rpcName": 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.speech.v1p1beta1.Adaptation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdaptationGrpcTransport(AdaptationTransport): """gRPC backend transport for Adaptation. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/CreatePhraseSet", request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -284,7 +370,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/GetPhraseSet", request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -313,7 +399,7 @@ def list_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_set" not in self._stubs: - self._stubs["list_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/ListPhraseSet", request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize, response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize, @@ -339,7 +425,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/UpdatePhraseSet", request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -365,7 +451,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/DeletePhraseSet", request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -393,7 +479,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/CreateCustomClass", request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -421,7 +507,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/GetCustomClass", request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -450,7 +536,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/ListCustomClasses", request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize, @@ -478,7 +564,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/UpdateCustomClass", request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -504,7 +590,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/DeleteCustomClass", request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -512,7 +598,7 @@ def delete_custom_class( return self._stubs["delete_custom_class"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -524,7 +610,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -543,7 +629,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py index 562b3f06d538..fac9ebd0ea1f 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource from .base import DEFAULT_CLIENT_INFO, AdaptationTransport from .grpc import AdaptationGrpcTransport +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.speech.v1p1beta1.Adaptation", + "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.speech.v1p1beta1.Adaptation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdaptationGrpcAsyncIOTransport(AdaptationTransport): """gRPC AsyncIO backend transport for Adaptation. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/CreatePhraseSet", request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -296,7 +381,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/GetPhraseSet", request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -325,7 +410,7 @@ def list_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_set" not in self._stubs: - self._stubs["list_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/ListPhraseSet", request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize, response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize, @@ -353,7 +438,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/UpdatePhraseSet", request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize, response_deserializer=resource.PhraseSet.deserialize, @@ -381,7 +466,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/DeletePhraseSet", request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -410,7 +495,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/CreateCustomClass", request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -438,7 +523,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/GetCustomClass", request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -467,7 +552,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/ListCustomClasses", request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize, @@ -496,7 +581,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/UpdateCustomClass", request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize, response_deserializer=resource.CustomClass.deserialize, @@ -524,7 +609,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Adaptation/DeleteCustomClass", request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -602,7 +687,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -618,7 +703,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -637,7 +722,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py index b336587d695f..e93345887d20 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -143,9 +151,10 @@ def post_update_phrase_set(self, response): def pre_create_custom_class( self, request: cloud_speech_adaptation.CreateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.CreateCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.CreateCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_custom_class @@ -168,9 +177,10 @@ def post_create_custom_class( def pre_create_phrase_set( self, request: cloud_speech_adaptation.CreatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.CreatePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.CreatePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_phrase_set @@ -193,9 +203,10 @@ def post_create_phrase_set( def pre_delete_custom_class( self, request: cloud_speech_adaptation.DeleteCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.DeleteCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.DeleteCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_custom_class @@ -207,9 +218,10 @@ def pre_delete_custom_class( def pre_delete_phrase_set( self, request: cloud_speech_adaptation.DeletePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.DeletePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.DeletePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_phrase_set @@ -221,9 +233,10 @@ def pre_delete_phrase_set( def pre_get_custom_class( self, request: cloud_speech_adaptation.GetCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.GetCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.GetCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_custom_class @@ -246,8 +259,11 @@ def post_get_custom_class( def pre_get_phrase_set( self, request: cloud_speech_adaptation.GetPhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech_adaptation.GetPhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech_adaptation.GetPhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_phrase_set Override in a subclass to manipulate the request or metadata @@ -267,9 +283,10 @@ def post_get_phrase_set(self, response: resource.PhraseSet) -> resource.PhraseSe def pre_list_custom_classes( self, request: cloud_speech_adaptation.ListCustomClassesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.ListCustomClassesRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.ListCustomClassesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_custom_classes @@ -292,8 +309,11 @@ def post_list_custom_classes( def pre_list_phrase_set( self, request: cloud_speech_adaptation.ListPhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech_adaptation.ListPhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech_adaptation.ListPhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_phrase_set Override in a subclass to manipulate the request or metadata @@ -315,9 +335,10 @@ def post_list_phrase_set( def pre_update_custom_class( self, request: cloud_speech_adaptation.UpdateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.UpdateCustomClassRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.UpdateCustomClassRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_custom_class @@ -340,9 +361,10 @@ def post_update_custom_class( def pre_update_phrase_set( self, request: cloud_speech_adaptation.UpdatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_speech_adaptation.UpdatePhraseSetRequest, Sequence[Tuple[str, str]] + cloud_speech_adaptation.UpdatePhraseSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_phrase_set @@ -365,8 +387,10 @@ def post_update_phrase_set( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -388,8 +412,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -530,7 +556,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the create custom class method over HTTP. @@ -541,8 +567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -559,6 +587,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseCreateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_class( request, metadata ) @@ -575,6 +604,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.CreateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "CreateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._CreateCustomClass._get_response( self._host, @@ -596,7 +652,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1p1beta1.AdaptationClient.create_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "CreateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePhraseSet( @@ -634,7 +712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the create phrase set method over HTTP. @@ -645,8 +723,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -659,6 +739,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseCreatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_phrase_set( request, metadata ) @@ -675,6 +756,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.CreatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "CreatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._CreatePhraseSet._get_response( self._host, @@ -696,7 +804,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1p1beta1.AdaptationClient.create_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "CreatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCustomClass( @@ -733,7 +863,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete custom class method over HTTP. @@ -744,13 +874,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAdaptationRestTransport._BaseDeleteCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_delete_custom_class( request, metadata ) @@ -763,6 +896,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.DeleteCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "DeleteCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._DeleteCustomClass._get_response( self._host, @@ -812,7 +972,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete phrase set method over HTTP. @@ -823,13 +983,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseAdaptationRestTransport._BaseDeletePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_phrase_set( request, metadata ) @@ -842,6 +1005,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.DeletePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "DeletePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._DeletePhraseSet._get_response( self._host, @@ -891,7 +1081,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the get custom class method over HTTP. @@ -902,8 +1092,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -920,6 +1112,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_class( request, metadata ) @@ -934,6 +1127,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.AdaptationClient.GetCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetCustomClass._get_response( self._host, @@ -954,7 +1174,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1p1beta1.AdaptationClient.get_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPhraseSet( @@ -991,7 +1233,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the get phrase set method over HTTP. @@ -1002,8 +1244,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -1016,6 +1260,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetPhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_phrase_set(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseGetPhraseSet._get_transcoded_request( @@ -1030,6 +1275,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.AdaptationClient.GetPhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetPhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetPhraseSet._get_response( self._host, @@ -1050,7 +1322,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1p1beta1.AdaptationClient.get_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetPhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomClasses( @@ -1087,7 +1381,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech_adaptation.ListCustomClassesResponse: r"""Call the list custom classes method over HTTP. @@ -1098,8 +1392,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech_adaptation.ListCustomClassesResponse: @@ -1111,6 +1407,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListCustomClasses._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_classes( request, metadata ) @@ -1123,6 +1420,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.ListCustomClasses", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListCustomClasses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListCustomClasses._get_response( self._host, @@ -1143,7 +1467,33 @@ def __call__( pb_resp = cloud_speech_adaptation.ListCustomClassesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_classes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_speech_adaptation.ListCustomClassesResponse.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.speech_v1p1beta1.AdaptationClient.list_custom_classes", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListCustomClasses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPhraseSet( @@ -1180,7 +1530,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech_adaptation.ListPhraseSetResponse: r"""Call the list phrase set method over HTTP. @@ -1191,8 +1541,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech_adaptation.ListPhraseSetResponse: @@ -1204,6 +1556,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListPhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_list_phrase_set(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseListPhraseSet._get_transcoded_request( @@ -1218,6 +1571,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.AdaptationClient.ListPhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListPhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListPhraseSet._get_response( self._host, @@ -1238,7 +1618,31 @@ def __call__( pb_resp = cloud_speech_adaptation.ListPhraseSetResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_speech_adaptation.ListPhraseSetResponse.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.speech_v1p1beta1.AdaptationClient.list_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListPhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomClass( @@ -1276,7 +1680,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.CustomClass: r"""Call the update custom class method over HTTP. @@ -1287,8 +1691,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.CustomClass: @@ -1305,6 +1711,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseUpdateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_class( request, metadata ) @@ -1321,6 +1728,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.UpdateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "UpdateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._UpdateCustomClass._get_response( self._host, @@ -1342,7 +1776,29 @@ def __call__( pb_resp = resource.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.CustomClass.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.speech_v1p1beta1.AdaptationClient.update_custom_class", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "UpdateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePhraseSet( @@ -1380,7 +1836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.PhraseSet: r"""Call the update phrase set method over HTTP. @@ -1391,8 +1847,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource.PhraseSet: @@ -1405,6 +1863,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseUpdatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_phrase_set( request, metadata ) @@ -1421,6 +1880,33 @@ def __call__( 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.speech_v1p1beta1.AdaptationClient.UpdatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "UpdatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._UpdatePhraseSet._get_response( self._host, @@ -1442,7 +1928,29 @@ def __call__( pb_resp = resource.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.PhraseSet.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.speech_v1p1beta1.AdaptationClient.update_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "UpdatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1575,7 +2083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1585,8 +2093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1595,6 +2105,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAdaptationRestTransport._BaseGetOperation._get_transcoded_request( @@ -1609,6 +2120,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.AdaptationClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._GetOperation._get_response( self._host, @@ -1628,6 +2166,27 @@ def __call__( 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.speech_v1p1beta1.AdaptationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1668,7 +2227,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1678,8 +2237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1688,6 +2249,7 @@ def __call__( http_options = ( _BaseAdaptationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAdaptationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1700,6 +2262,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.AdaptationClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdaptationRestTransport._ListOperations._get_response( self._host, @@ -1719,6 +2308,27 @@ def __call__( 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.speech_v1p1beta1.AdaptationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Adaptation", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py index 8b4ff7a47805..034c9f016797 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport +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 SpeechAsyncClient: """Service that implements Google Cloud Speech API.""" @@ -254,6 +264,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.speech_v1p1beta1.SpeechAsyncClient`.", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "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.speech.v1p1beta1.Speech", + "credentialsType": None, + }, + ) + async def recognize( self, request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None, @@ -262,7 +294,7 @@ async def recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous speech recognition: receive results after all audio has been sent and processed. @@ -322,8 +354,10 @@ async def sample_recognize(): 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, 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: google.cloud.speech_v1p1beta1.types.RecognizeResponse: @@ -382,7 +416,7 @@ async def long_running_recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an @@ -450,8 +484,10 @@ async def sample_long_running_recognize(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -523,7 +559,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -581,8 +617,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]: @@ -675,7 +713,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -686,8 +724,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -728,7 +768,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -739,8 +779,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py index 254d9b2e3afb..cd539b827f07 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -605,6 +615,10 @@ def __init__( # 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( @@ -667,6 +681,29 @@ def __init__( 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.speech_v1p1beta1.SpeechClient`.", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "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.speech.v1p1beta1.Speech", + "credentialsType": None, + }, + ) + def recognize( self, request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None, @@ -675,7 +712,7 @@ def recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous speech recognition: receive results after all audio has been sent and processed. @@ -735,8 +772,10 @@ def sample_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v1p1beta1.types.RecognizeResponse: @@ -792,7 +831,7 @@ def long_running_recognize( audio: Optional[cloud_speech.RecognitionAudio] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an @@ -860,8 +899,10 @@ def sample_long_running_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -928,7 +969,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[cloud_speech.StreamingRecognizeResponse]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -986,8 +1027,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]: @@ -1091,7 +1134,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1102,8 +1145,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1144,7 +1189,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1155,8 +1200,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py index 0682fca9edb9..dce2091cd9d8 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.speech_v1p1beta1.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport +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.speech.v1p1beta1.Speech", + "rpcName": 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.speech.v1p1beta1.Speech", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcTransport(SpeechTransport): """gRPC backend transport for Speech. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -245,7 +331,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -301,7 +389,7 @@ def long_running_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "long_running_recognize" not in self._stubs: - self._stubs["long_running_recognize"] = self.grpc_channel.unary_unary( + self._stubs["long_running_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Speech/LongRunningRecognize", request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +420,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v1p1beta1.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -340,7 +428,7 @@ def streaming_recognize( return self._stubs["streaming_recognize"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -352,7 +440,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -371,7 +459,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py index de13827089c4..d690f2d6e301 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.speech_v1p1beta1.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport from .grpc import SpeechGrpcTransport +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.speech.v1p1beta1.Speech", + "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.speech.v1p1beta1.Speech", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcAsyncIOTransport(SpeechTransport): """gRPC AsyncIO backend transport for Speech. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +339,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -315,7 +400,7 @@ def long_running_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "long_running_recognize" not in self._stubs: - self._stubs["long_running_recognize"] = self.grpc_channel.unary_unary( + self._stubs["long_running_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v1p1beta1.Speech/LongRunningRecognize", request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -346,7 +431,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v1p1beta1.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -409,7 +494,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -425,7 +510,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -444,7 +529,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py index 6c723b5ab93a..029dfd9b7aa1 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,8 +94,11 @@ def post_recognize(self, response): def pre_long_running_recognize( self, request: cloud_speech.LongRunningRecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.LongRunningRecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.LongRunningRecognizeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for long_running_recognize Override in a subclass to manipulate the request or metadata @@ -109,8 +120,8 @@ def post_long_running_recognize( def pre_recognize( self, request: cloud_speech.RecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for recognize Override in a subclass to manipulate the request or metadata @@ -132,8 +143,10 @@ def post_recognize( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -155,8 +168,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -338,7 +353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the long running recognize method over HTTP. @@ -349,8 +364,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -363,6 +380,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseLongRunningRecognize._get_http_options() ) + request, metadata = self._interceptor.pre_long_running_recognize( request, metadata ) @@ -379,6 +397,33 @@ def __call__( 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.speech_v1p1beta1.SpeechClient.LongRunningRecognize", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "LongRunningRecognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._LongRunningRecognize._get_response( self._host, @@ -398,7 +443,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_long_running_recognize(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.speech_v1p1beta1.SpeechClient.long_running_recognize", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "LongRunningRecognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Recognize(_BaseSpeechRestTransport._BaseRecognize, SpeechRestStub): @@ -434,7 +501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Call the recognize method over HTTP. @@ -445,8 +512,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.RecognizeResponse: @@ -457,6 +526,7 @@ def __call__( """ http_options = _BaseSpeechRestTransport._BaseRecognize._get_http_options() + request, metadata = self._interceptor.pre_recognize(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseRecognize._get_transcoded_request( @@ -475,6 +545,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.SpeechClient.Recognize", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "Recognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._Recognize._get_response( self._host, @@ -496,7 +593,29 @@ def __call__( pb_resp = cloud_speech.RecognizeResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_recognize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.RecognizeResponse.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.speech_v1p1beta1.SpeechClient.recognize", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "Recognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingRecognize( @@ -511,7 +630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingRecognize is not available over REST transport" @@ -580,7 +699,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -590,8 +709,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -600,6 +721,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetOperation._get_transcoded_request( @@ -614,6 +736,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.SpeechClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetOperation._get_response( self._host, @@ -633,6 +782,27 @@ def __call__( 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.speech_v1p1beta1.SpeechAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -671,7 +841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -681,8 +851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -691,6 +863,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseListOperations._get_transcoded_request( @@ -705,6 +878,33 @@ def __call__( ) ) + 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.speech_v1p1beta1.SpeechClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListOperations._get_response( self._host, @@ -724,6 +924,27 @@ def __call__( 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.speech_v1p1beta1.SpeechAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v1p1beta1.Speech", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/gapic_version.py b/packages/google-cloud-speech/google/cloud/speech_v2/gapic_version.py index 97acdfe8394d..558c8aab67c5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/gapic_version.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.28.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/async_client.py index 311521d62192..e7d72d45a461 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport +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 SpeechAsyncClient: """Enables speech transcription and resource management.""" @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.speech_v2.SpeechAsyncClient`.", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "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.speech.v2.Speech", + "credentialsType": None, + }, + ) + async def create_recognizer( self, request: Optional[Union[cloud_speech.CreateRecognizerRequest, dict]] = None, @@ -276,7 +308,7 @@ async def create_recognizer( recognizer_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -341,8 +373,10 @@ async def sample_create_recognizer(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -419,7 +453,7 @@ async def list_recognizers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecognizersAsyncPager: r"""Lists Recognizers. @@ -466,8 +500,10 @@ async def sample_list_recognizers(): 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, 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: google.cloud.speech_v2.services.speech.pagers.ListRecognizersAsyncPager: @@ -543,7 +579,7 @@ async def get_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Recognizer: r"""Returns the requested [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with @@ -592,8 +628,10 @@ async def sample_get_recognizer(): 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, 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: google.cloud.speech_v2.types.Recognizer: @@ -655,7 +693,7 @@ async def update_recognizer( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -714,8 +752,10 @@ async def sample_update_recognizer(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -792,7 +832,7 @@ async def delete_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -841,8 +881,10 @@ async def sample_delete_recognizer(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -915,7 +957,7 @@ async def undelete_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -965,8 +1007,10 @@ async def sample_undelete_recognizer(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1043,7 +1087,7 @@ async def recognize( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous Speech recognition: receive results after all audio has been sent and processed. @@ -1154,8 +1198,10 @@ async def sample_recognize(): 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, 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: google.cloud.speech_v2.types.RecognizeResponse: @@ -1228,7 +1274,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -1300,8 +1346,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.speech_v2.types.StreamingRecognizeResponse]: @@ -1398,7 +1446,7 @@ async def batch_recognize( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running @@ -1492,8 +1540,10 @@ async def sample_batch_recognize(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1574,7 +1624,7 @@ async def get_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Returns the requested [Config][google.cloud.speech.v2.Config]. @@ -1621,8 +1671,10 @@ async def sample_get_config(): 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, 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: google.cloud.speech_v2.types.Config: @@ -1686,7 +1738,7 @@ async def update_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Updates the [Config][google.cloud.speech.v2.Config]. @@ -1738,8 +1790,10 @@ async def sample_update_config(): 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, 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: google.cloud.speech_v2.types.Config: @@ -1808,7 +1862,7 @@ async def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -1873,8 +1927,10 @@ async def sample_create_custom_class(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1951,7 +2007,7 @@ async def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesAsyncPager: r"""Lists CustomClasses. @@ -1998,8 +2054,10 @@ async def sample_list_custom_classes(): 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, 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: google.cloud.speech_v2.services.speech.pagers.ListCustomClassesAsyncPager: @@ -2075,7 +2133,7 @@ async def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.CustomClass: r"""Returns the requested [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2122,8 +2180,10 @@ async def sample_get_custom_class(): 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, 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: google.cloud.speech_v2.types.CustomClass: @@ -2189,7 +2249,7 @@ async def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2248,8 +2308,10 @@ async def sample_update_custom_class(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2326,7 +2388,7 @@ async def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2375,8 +2437,10 @@ async def sample_delete_custom_class(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2449,7 +2513,7 @@ async def undelete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2499,8 +2563,10 @@ async def sample_undelete_custom_class(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2575,7 +2641,7 @@ async def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -2640,8 +2706,10 @@ async def sample_create_phrase_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, 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: google.api_core.operation_async.AsyncOperation: @@ -2717,7 +2785,7 @@ async def list_phrase_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetsAsyncPager: r"""Lists PhraseSets. @@ -2764,8 +2832,10 @@ async def sample_list_phrase_sets(): 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, 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: google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsAsyncPager: @@ -2841,7 +2911,7 @@ async def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.PhraseSet: r"""Returns the requested [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -2888,8 +2958,10 @@ async def sample_get_phrase_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, 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: google.cloud.speech_v2.types.PhraseSet: @@ -2954,7 +3026,7 @@ async def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3013,8 +3085,10 @@ async def sample_update_phrase_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, 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: google.api_core.operation_async.AsyncOperation: @@ -3090,7 +3164,7 @@ async def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3139,8 +3213,10 @@ async def sample_delete_phrase_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, 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: google.api_core.operation_async.AsyncOperation: @@ -3212,7 +3288,7 @@ async def undelete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3261,8 +3337,10 @@ async def sample_undelete_phrase_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, 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: google.api_core.operation_async.AsyncOperation: @@ -3333,7 +3411,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3344,8 +3422,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3386,7 +3466,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3397,8 +3477,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3439,7 +3521,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3455,8 +3537,10 @@ async def delete_operation( 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, 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: None """ @@ -3493,7 +3577,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3508,8 +3592,10 @@ async def cancel_operation( 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, 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: None """ @@ -3546,7 +3632,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3557,8 +3643,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -3599,7 +3687,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3610,8 +3698,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/client.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/client.py index 9ea0edd5f38b..002d11b2d881 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.location import locations_pb2 # type: ignore @@ -701,6 +711,10 @@ def __init__( # 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( @@ -763,6 +777,29 @@ def __init__( 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.speech_v2.SpeechClient`.", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "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.speech.v2.Speech", + "credentialsType": None, + }, + ) + def create_recognizer( self, request: Optional[Union[cloud_speech.CreateRecognizerRequest, dict]] = None, @@ -772,7 +809,7 @@ def create_recognizer( recognizer_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -837,8 +874,10 @@ def sample_create_recognizer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -912,7 +951,7 @@ def list_recognizers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecognizersPager: r"""Lists Recognizers. @@ -959,8 +998,10 @@ def sample_list_recognizers(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.services.speech.pagers.ListRecognizersPager: @@ -1033,7 +1074,7 @@ def get_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Recognizer: r"""Returns the requested [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with @@ -1082,8 +1123,10 @@ def sample_get_recognizer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.Recognizer: @@ -1142,7 +1185,7 @@ def update_recognizer( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -1201,8 +1244,10 @@ def sample_update_recognizer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1276,7 +1321,7 @@ def delete_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -1325,8 +1370,10 @@ def sample_delete_recognizer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1396,7 +1443,7 @@ def undelete_recognizer( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer]. @@ -1446,8 +1493,10 @@ def sample_undelete_recognizer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1521,7 +1570,7 @@ def recognize( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Performs synchronous Speech recognition: receive results after all audio has been sent and processed. @@ -1632,8 +1681,10 @@ def sample_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.RecognizeResponse: @@ -1701,7 +1752,7 @@ def streaming_recognize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[cloud_speech.StreamingRecognizeResponse]: r"""Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only @@ -1773,8 +1824,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.speech_v2.types.StreamingRecognizeResponse]: @@ -1869,7 +1922,7 @@ def batch_recognize( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running @@ -1963,8 +2016,10 @@ def sample_batch_recognize(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2042,7 +2097,7 @@ def get_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Returns the requested [Config][google.cloud.speech.v2.Config]. @@ -2089,8 +2144,10 @@ def sample_get_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.Config: @@ -2151,7 +2208,7 @@ def update_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Updates the [Config][google.cloud.speech.v2.Config]. @@ -2203,8 +2260,10 @@ def sample_update_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.Config: @@ -2270,7 +2329,7 @@ def create_custom_class( custom_class_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2335,8 +2394,10 @@ def sample_create_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2410,7 +2471,7 @@ def list_custom_classes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomClassesPager: r"""Lists CustomClasses. @@ -2457,8 +2518,10 @@ def sample_list_custom_classes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.services.speech.pagers.ListCustomClassesPager: @@ -2531,7 +2594,7 @@ def get_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.CustomClass: r"""Returns the requested [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2578,8 +2641,10 @@ def sample_get_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.CustomClass: @@ -2642,7 +2707,7 @@ def update_custom_class( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2701,8 +2766,10 @@ def sample_update_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2776,7 +2843,7 @@ def delete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2825,8 +2892,10 @@ def sample_delete_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2896,7 +2965,7 @@ def undelete_custom_class( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass]. @@ -2946,8 +3015,10 @@ def sample_undelete_custom_class(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3019,7 +3090,7 @@ def create_phrase_set( phrase_set_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3084,8 +3155,10 @@ def sample_create_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3158,7 +3231,7 @@ def list_phrase_sets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPhraseSetsPager: r"""Lists PhraseSets. @@ -3205,8 +3278,10 @@ def sample_list_phrase_sets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsPager: @@ -3279,7 +3354,7 @@ def get_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.PhraseSet: r"""Returns the requested [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3326,8 +3401,10 @@ def sample_get_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.speech_v2.types.PhraseSet: @@ -3389,7 +3466,7 @@ def update_phrase_set( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3448,8 +3525,10 @@ def sample_update_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3522,7 +3601,7 @@ def delete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3571,8 +3650,10 @@ def sample_delete_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3641,7 +3722,7 @@ def undelete_phrase_set( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. @@ -3690,8 +3771,10 @@ def sample_undelete_phrase_set(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3772,7 +3855,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3783,8 +3866,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3825,7 +3910,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3836,8 +3921,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3878,7 +3965,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -3894,8 +3981,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3932,7 +4021,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -3947,8 +4036,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -3985,7 +4076,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3996,8 +4087,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -4038,7 +4131,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4049,8 +4142,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/pagers.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/pagers.py index 750389f2c9f6..3f35b97b6c0f 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/pagers.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech.ListRecognizersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech.ListRecognizersRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech.ListCustomClassesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech.ListCustomClassesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_speech.ListPhraseSetsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_speech.ListPhraseSetsRequest(request) diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc.py index eb9b062982cc..c688a618d0a6 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.speech_v2.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport +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.speech.v2.Speech", + "rpcName": 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.speech.v2.Speech", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcTransport(SpeechTransport): """gRPC backend transport for Speech. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def create_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_recognizer" not in self._stubs: - self._stubs["create_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["create_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreateRecognizer", request_serializer=cloud_speech.CreateRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -298,7 +386,7 @@ def list_recognizers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recognizers" not in self._stubs: - self._stubs["list_recognizers"] = self.grpc_channel.unary_unary( + self._stubs["list_recognizers"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListRecognizers", request_serializer=cloud_speech.ListRecognizersRequest.serialize, response_deserializer=cloud_speech.ListRecognizersResponse.deserialize, @@ -327,7 +415,7 @@ def get_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recognizer" not in self._stubs: - self._stubs["get_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["get_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetRecognizer", request_serializer=cloud_speech.GetRecognizerRequest.serialize, response_deserializer=cloud_speech.Recognizer.deserialize, @@ -353,7 +441,7 @@ def update_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recognizer" not in self._stubs: - self._stubs["update_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["update_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateRecognizer", request_serializer=cloud_speech.UpdateRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_recognizer" not in self._stubs: - self._stubs["delete_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["delete_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeleteRecognizer", request_serializer=cloud_speech.DeleteRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def undelete_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_recognizer" not in self._stubs: - self._stubs["undelete_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["undelete_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeleteRecognizer", request_serializer=cloud_speech.UndeleteRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -432,7 +520,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -463,7 +551,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v2.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -492,7 +580,7 @@ def batch_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_recognize" not in self._stubs: - self._stubs["batch_recognize"] = self.grpc_channel.unary_unary( + self._stubs["batch_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/BatchRecognize", request_serializer=cloud_speech.BatchRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -518,7 +606,7 @@ def get_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_config" not in self._stubs: - self._stubs["get_config"] = self.grpc_channel.unary_unary( + self._stubs["get_config"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetConfig", request_serializer=cloud_speech.GetConfigRequest.serialize, response_deserializer=cloud_speech.Config.deserialize, @@ -544,7 +632,7 @@ def update_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_config" not in self._stubs: - self._stubs["update_config"] = self.grpc_channel.unary_unary( + self._stubs["update_config"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateConfig", request_serializer=cloud_speech.UpdateConfigRequest.serialize, response_deserializer=cloud_speech.Config.deserialize, @@ -570,7 +658,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreateCustomClass", request_serializer=cloud_speech.CreateCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -598,7 +686,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListCustomClasses", request_serializer=cloud_speech.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech.ListCustomClassesResponse.deserialize, @@ -625,7 +713,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetCustomClass", request_serializer=cloud_speech.GetCustomClassRequest.serialize, response_deserializer=cloud_speech.CustomClass.deserialize, @@ -651,7 +739,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateCustomClass", request_serializer=cloud_speech.UpdateCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -677,7 +765,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeleteCustomClass", request_serializer=cloud_speech.DeleteCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -703,7 +791,7 @@ def undelete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_custom_class" not in self._stubs: - self._stubs["undelete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["undelete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeleteCustomClass", request_serializer=cloud_speech.UndeleteCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -729,7 +817,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreatePhraseSet", request_serializer=cloud_speech.CreatePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -757,7 +845,7 @@ def list_phrase_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_sets" not in self._stubs: - self._stubs["list_phrase_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_sets"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListPhraseSets", request_serializer=cloud_speech.ListPhraseSetsRequest.serialize, response_deserializer=cloud_speech.ListPhraseSetsResponse.deserialize, @@ -784,7 +872,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetPhraseSet", request_serializer=cloud_speech.GetPhraseSetRequest.serialize, response_deserializer=cloud_speech.PhraseSet.deserialize, @@ -810,7 +898,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdatePhraseSet", request_serializer=cloud_speech.UpdatePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -836,7 +924,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeletePhraseSet", request_serializer=cloud_speech.DeletePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -862,7 +950,7 @@ def undelete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_phrase_set" not in self._stubs: - self._stubs["undelete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["undelete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeletePhraseSet", request_serializer=cloud_speech.UndeletePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -870,7 +958,7 @@ def undelete_phrase_set( return self._stubs["undelete_phrase_set"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -882,7 +970,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -899,7 +987,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -916,7 +1004,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -935,7 +1023,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -954,7 +1042,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -971,7 +1059,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc_asyncio.py index e31f1bf70a52..bc595a0f3621 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.speech_v2.types import cloud_speech from .base import DEFAULT_CLIENT_INFO, SpeechTransport from .grpc import SpeechGrpcTransport +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.speech.v2.Speech", + "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.speech.v2.Speech", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpeechGrpcAsyncIOTransport(SpeechTransport): """gRPC AsyncIO backend transport for Speech. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def create_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_recognizer" not in self._stubs: - self._stubs["create_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["create_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreateRecognizer", request_serializer=cloud_speech.CreateRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -311,7 +396,7 @@ def list_recognizers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recognizers" not in self._stubs: - self._stubs["list_recognizers"] = self.grpc_channel.unary_unary( + self._stubs["list_recognizers"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListRecognizers", request_serializer=cloud_speech.ListRecognizersRequest.serialize, response_deserializer=cloud_speech.ListRecognizersResponse.deserialize, @@ -342,7 +427,7 @@ def get_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recognizer" not in self._stubs: - self._stubs["get_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["get_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetRecognizer", request_serializer=cloud_speech.GetRecognizerRequest.serialize, response_deserializer=cloud_speech.Recognizer.deserialize, @@ -370,7 +455,7 @@ def update_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recognizer" not in self._stubs: - self._stubs["update_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["update_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateRecognizer", request_serializer=cloud_speech.UpdateRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -398,7 +483,7 @@ def delete_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_recognizer" not in self._stubs: - self._stubs["delete_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["delete_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeleteRecognizer", request_serializer=cloud_speech.DeleteRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -426,7 +511,7 @@ def undelete_recognizer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_recognizer" not in self._stubs: - self._stubs["undelete_recognizer"] = self.grpc_channel.unary_unary( + self._stubs["undelete_recognizer"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeleteRecognizer", request_serializer=cloud_speech.UndeleteRecognizerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -455,7 +540,7 @@ def recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "recognize" not in self._stubs: - self._stubs["recognize"] = self.grpc_channel.unary_unary( + self._stubs["recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/Recognize", request_serializer=cloud_speech.RecognizeRequest.serialize, response_deserializer=cloud_speech.RecognizeResponse.deserialize, @@ -486,7 +571,7 @@ def streaming_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_recognize" not in self._stubs: - self._stubs["streaming_recognize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_recognize"] = self._logged_channel.stream_stream( "/google.cloud.speech.v2.Speech/StreamingRecognize", request_serializer=cloud_speech.StreamingRecognizeRequest.serialize, response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize, @@ -517,7 +602,7 @@ def batch_recognize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_recognize" not in self._stubs: - self._stubs["batch_recognize"] = self.grpc_channel.unary_unary( + self._stubs["batch_recognize"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/BatchRecognize", request_serializer=cloud_speech.BatchRecognizeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +628,7 @@ def get_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_config" not in self._stubs: - self._stubs["get_config"] = self.grpc_channel.unary_unary( + self._stubs["get_config"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetConfig", request_serializer=cloud_speech.GetConfigRequest.serialize, response_deserializer=cloud_speech.Config.deserialize, @@ -569,7 +654,7 @@ def update_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_config" not in self._stubs: - self._stubs["update_config"] = self.grpc_channel.unary_unary( + self._stubs["update_config"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateConfig", request_serializer=cloud_speech.UpdateConfigRequest.serialize, response_deserializer=cloud_speech.Config.deserialize, @@ -597,7 +682,7 @@ def create_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_class" not in self._stubs: - self._stubs["create_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreateCustomClass", request_serializer=cloud_speech.CreateCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -626,7 +711,7 @@ def list_custom_classes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_classes" not in self._stubs: - self._stubs["list_custom_classes"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_classes"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListCustomClasses", request_serializer=cloud_speech.ListCustomClassesRequest.serialize, response_deserializer=cloud_speech.ListCustomClassesResponse.deserialize, @@ -655,7 +740,7 @@ def get_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_class" not in self._stubs: - self._stubs["get_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetCustomClass", request_serializer=cloud_speech.GetCustomClassRequest.serialize, response_deserializer=cloud_speech.CustomClass.deserialize, @@ -683,7 +768,7 @@ def update_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_class" not in self._stubs: - self._stubs["update_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdateCustomClass", request_serializer=cloud_speech.UpdateCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -711,7 +796,7 @@ def delete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_custom_class" not in self._stubs: - self._stubs["delete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["delete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeleteCustomClass", request_serializer=cloud_speech.DeleteCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -739,7 +824,7 @@ def undelete_custom_class( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_custom_class" not in self._stubs: - self._stubs["undelete_custom_class"] = self.grpc_channel.unary_unary( + self._stubs["undelete_custom_class"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeleteCustomClass", request_serializer=cloud_speech.UndeleteCustomClassRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +852,7 @@ def create_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_phrase_set" not in self._stubs: - self._stubs["create_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["create_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/CreatePhraseSet", request_serializer=cloud_speech.CreatePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -796,7 +881,7 @@ def list_phrase_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_phrase_sets" not in self._stubs: - self._stubs["list_phrase_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_phrase_sets"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/ListPhraseSets", request_serializer=cloud_speech.ListPhraseSetsRequest.serialize, response_deserializer=cloud_speech.ListPhraseSetsResponse.deserialize, @@ -825,7 +910,7 @@ def get_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_phrase_set" not in self._stubs: - self._stubs["get_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["get_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/GetPhraseSet", request_serializer=cloud_speech.GetPhraseSetRequest.serialize, response_deserializer=cloud_speech.PhraseSet.deserialize, @@ -853,7 +938,7 @@ def update_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_phrase_set" not in self._stubs: - self._stubs["update_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["update_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UpdatePhraseSet", request_serializer=cloud_speech.UpdatePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -881,7 +966,7 @@ def delete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_phrase_set" not in self._stubs: - self._stubs["delete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/DeletePhraseSet", request_serializer=cloud_speech.DeletePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -909,7 +994,7 @@ def undelete_phrase_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_phrase_set" not in self._stubs: - self._stubs["undelete_phrase_set"] = self.grpc_channel.unary_unary( + self._stubs["undelete_phrase_set"] = self._logged_channel.unary_unary( "/google.cloud.speech.v2.Speech/UndeletePhraseSet", request_serializer=cloud_speech.UndeletePhraseSetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1072,7 +1157,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1088,7 +1173,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1105,7 +1190,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1122,7 +1207,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1141,7 +1226,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1160,7 +1245,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1177,7 +1262,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/rest.py b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/rest.py index a382d415d307..2ea8621cdcf5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/rest.py +++ b/packages/google-cloud-speech/google/cloud/speech_v2/services/speech/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -247,8 +255,10 @@ def post_update_recognizer(self, response): def pre_batch_recognize( self, request: cloud_speech.BatchRecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.BatchRecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.BatchRecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_recognize Override in a subclass to manipulate the request or metadata @@ -270,8 +280,10 @@ def post_batch_recognize( def pre_create_custom_class( self, request: cloud_speech.CreateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.CreateCustomClassRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.CreateCustomClassRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_custom_class Override in a subclass to manipulate the request or metadata @@ -293,8 +305,10 @@ def post_create_custom_class( def pre_create_phrase_set( self, request: cloud_speech.CreatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.CreatePhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.CreatePhraseSetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_phrase_set Override in a subclass to manipulate the request or metadata @@ -316,8 +330,10 @@ def post_create_phrase_set( def pre_create_recognizer( self, request: cloud_speech.CreateRecognizerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.CreateRecognizerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.CreateRecognizerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_recognizer Override in a subclass to manipulate the request or metadata @@ -339,8 +355,10 @@ def post_create_recognizer( def pre_delete_custom_class( self, request: cloud_speech.DeleteCustomClassRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.DeleteCustomClassRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.DeleteCustomClassRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_custom_class Override in a subclass to manipulate the request or metadata @@ -362,8 +380,10 @@ def post_delete_custom_class( def pre_delete_phrase_set( self, request: cloud_speech.DeletePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.DeletePhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.DeletePhraseSetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_phrase_set Override in a subclass to manipulate the request or metadata @@ -385,8 +405,10 @@ def post_delete_phrase_set( def pre_delete_recognizer( self, request: cloud_speech.DeleteRecognizerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.DeleteRecognizerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.DeleteRecognizerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_recognizer Override in a subclass to manipulate the request or metadata @@ -408,8 +430,8 @@ def post_delete_recognizer( def pre_get_config( self, request: cloud_speech.GetConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.GetConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_speech.GetConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_config Override in a subclass to manipulate the request or metadata @@ -429,8 +451,10 @@ def post_get_config(self, response: cloud_speech.Config) -> cloud_speech.Config: def pre_get_custom_class( self, request: cloud_speech.GetCustomClassRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.GetCustomClassRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.GetCustomClassRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_custom_class Override in a subclass to manipulate the request or metadata @@ -452,8 +476,10 @@ def post_get_custom_class( def pre_get_phrase_set( self, request: cloud_speech.GetPhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.GetPhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.GetPhraseSetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_phrase_set Override in a subclass to manipulate the request or metadata @@ -475,8 +501,10 @@ def post_get_phrase_set( def pre_get_recognizer( self, request: cloud_speech.GetRecognizerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.GetRecognizerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.GetRecognizerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_recognizer Override in a subclass to manipulate the request or metadata @@ -498,8 +526,10 @@ def post_get_recognizer( def pre_list_custom_classes( self, request: cloud_speech.ListCustomClassesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.ListCustomClassesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.ListCustomClassesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_custom_classes Override in a subclass to manipulate the request or metadata @@ -521,8 +551,10 @@ def post_list_custom_classes( def pre_list_phrase_sets( self, request: cloud_speech.ListPhraseSetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.ListPhraseSetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.ListPhraseSetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_phrase_sets Override in a subclass to manipulate the request or metadata @@ -544,8 +576,10 @@ def post_list_phrase_sets( def pre_list_recognizers( self, request: cloud_speech.ListRecognizersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.ListRecognizersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.ListRecognizersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_recognizers Override in a subclass to manipulate the request or metadata @@ -567,8 +601,8 @@ def post_list_recognizers( def pre_recognize( self, request: cloud_speech.RecognizeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for recognize Override in a subclass to manipulate the request or metadata @@ -590,8 +624,10 @@ def post_recognize( def pre_undelete_custom_class( self, request: cloud_speech.UndeleteCustomClassRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UndeleteCustomClassRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UndeleteCustomClassRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undelete_custom_class Override in a subclass to manipulate the request or metadata @@ -613,8 +649,10 @@ def post_undelete_custom_class( def pre_undelete_phrase_set( self, request: cloud_speech.UndeletePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UndeletePhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UndeletePhraseSetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undelete_phrase_set Override in a subclass to manipulate the request or metadata @@ -636,8 +674,10 @@ def post_undelete_phrase_set( def pre_undelete_recognizer( self, request: cloud_speech.UndeleteRecognizerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UndeleteRecognizerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UndeleteRecognizerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undelete_recognizer Override in a subclass to manipulate the request or metadata @@ -659,8 +699,10 @@ def post_undelete_recognizer( def pre_update_config( self, request: cloud_speech.UpdateConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UpdateConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UpdateConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_config Override in a subclass to manipulate the request or metadata @@ -680,8 +722,10 @@ def post_update_config(self, response: cloud_speech.Config) -> cloud_speech.Conf def pre_update_custom_class( self, request: cloud_speech.UpdateCustomClassRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UpdateCustomClassRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UpdateCustomClassRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_custom_class Override in a subclass to manipulate the request or metadata @@ -703,8 +747,10 @@ def post_update_custom_class( def pre_update_phrase_set( self, request: cloud_speech.UpdatePhraseSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UpdatePhraseSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UpdatePhraseSetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_phrase_set Override in a subclass to manipulate the request or metadata @@ -726,8 +772,10 @@ def post_update_phrase_set( def pre_update_recognizer( self, request: cloud_speech.UpdateRecognizerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_speech.UpdateRecognizerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_speech.UpdateRecognizerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_recognizer Override in a subclass to manipulate the request or metadata @@ -749,8 +797,10 @@ def post_update_recognizer( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -772,8 +822,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -795,8 +847,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -816,8 +870,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -837,8 +893,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -860,8 +918,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1054,7 +1114,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch recognize method over HTTP. @@ -1066,8 +1126,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1080,6 +1142,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseBatchRecognize._get_http_options() ) + request, metadata = self._interceptor.pre_batch_recognize(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseBatchRecognize._get_transcoded_request( @@ -1098,6 +1161,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.BatchRecognize", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "BatchRecognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._BatchRecognize._get_response( self._host, @@ -1117,7 +1207,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_recognize(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.speech_v2.SpeechClient.batch_recognize", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "BatchRecognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCustomClass( @@ -1155,7 +1267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create custom class method over HTTP. @@ -1167,8 +1279,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1181,6 +1295,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseCreateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_class( request, metadata ) @@ -1203,6 +1318,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.CreateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._CreateCustomClass._get_response( self._host, @@ -1222,7 +1364,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_class(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.speech_v2.SpeechClient.create_custom_class", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePhraseSet( @@ -1260,7 +1424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create phrase set method over HTTP. @@ -1272,8 +1436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1286,6 +1452,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseCreatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_phrase_set( request, metadata ) @@ -1306,6 +1473,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.CreatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._CreatePhraseSet._get_response( self._host, @@ -1325,7 +1519,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_phrase_set(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.speech_v2.SpeechClient.create_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRecognizer( @@ -1363,7 +1579,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create recognizer method over HTTP. @@ -1375,8 +1591,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1389,6 +1607,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseCreateRecognizer._get_http_options() ) + request, metadata = self._interceptor.pre_create_recognizer( request, metadata ) @@ -1411,6 +1630,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.CreateRecognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreateRecognizer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._CreateRecognizer._get_response( self._host, @@ -1430,7 +1676,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_recognizer(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.speech_v2.SpeechClient.create_recognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CreateRecognizer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCustomClass( @@ -1467,7 +1735,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete custom class method over HTTP. @@ -1479,8 +1747,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1493,6 +1763,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseDeleteCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_delete_custom_class( request, metadata ) @@ -1509,6 +1780,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.DeleteCustomClass", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeleteCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._DeleteCustomClass._get_response( self._host, @@ -1527,7 +1825,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_custom_class(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.speech_v2.SpeechClient.delete_custom_class", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeleteCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePhraseSet( @@ -1564,7 +1884,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete phrase set method over HTTP. @@ -1576,8 +1896,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1590,6 +1912,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseDeletePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_phrase_set( request, metadata ) @@ -1606,6 +1929,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.DeletePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeletePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._DeletePhraseSet._get_response( self._host, @@ -1624,7 +1974,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_phrase_set(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.speech_v2.SpeechClient.delete_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeletePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRecognizer( @@ -1661,7 +2033,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete recognizer method over HTTP. @@ -1673,8 +2045,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1687,6 +2061,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseDeleteRecognizer._get_http_options() ) + request, metadata = self._interceptor.pre_delete_recognizer( request, metadata ) @@ -1703,6 +2078,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.DeleteRecognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeleteRecognizer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._DeleteRecognizer._get_response( self._host, @@ -1721,7 +2123,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_recognizer(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.speech_v2.SpeechClient.delete_recognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeleteRecognizer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConfig(_BaseSpeechRestTransport._BaseGetConfig, SpeechRestStub): @@ -1756,7 +2180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Call the get config method over HTTP. @@ -1768,8 +2192,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.Config: @@ -1781,6 +2207,7 @@ def __call__( """ http_options = _BaseSpeechRestTransport._BaseGetConfig._get_http_options() + request, metadata = self._interceptor.pre_get_config(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetConfig._get_transcoded_request( @@ -1795,6 +2222,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetConfig", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetConfig._get_response( self._host, @@ -1815,7 +2269,29 @@ def __call__( pb_resp = cloud_speech.Config.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.Config.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.speech_v2.SpeechClient.get_config", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCustomClass(_BaseSpeechRestTransport._BaseGetCustomClass, SpeechRestStub): @@ -1850,7 +2326,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.CustomClass: r"""Call the get custom class method over HTTP. @@ -1862,8 +2338,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.CustomClass: @@ -1879,6 +2357,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_class( request, metadata ) @@ -1895,6 +2374,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetCustomClass", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetCustomClass._get_response( self._host, @@ -1915,7 +2421,29 @@ def __call__( pb_resp = cloud_speech.CustomClass.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_class(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.CustomClass.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.speech_v2.SpeechClient.get_custom_class", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPhraseSet(_BaseSpeechRestTransport._BaseGetPhraseSet, SpeechRestStub): @@ -1950,7 +2478,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.PhraseSet: r"""Call the get phrase set method over HTTP. @@ -1962,8 +2490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.PhraseSet: @@ -1978,6 +2508,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetPhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_phrase_set(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetPhraseSet._get_transcoded_request( @@ -1992,6 +2523,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetPhraseSet", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetPhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetPhraseSet._get_response( self._host, @@ -2012,7 +2570,29 @@ def __call__( pb_resp = cloud_speech.PhraseSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_phrase_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.PhraseSet.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.speech_v2.SpeechClient.get_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetPhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecognizer(_BaseSpeechRestTransport._BaseGetRecognizer, SpeechRestStub): @@ -2047,7 +2627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Recognizer: r"""Call the get recognizer method over HTTP. @@ -2059,8 +2639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.Recognizer: @@ -2072,6 +2654,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetRecognizer._get_http_options() ) + request, metadata = self._interceptor.pre_get_recognizer(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetRecognizer._get_transcoded_request( @@ -2086,6 +2669,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetRecognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetRecognizer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetRecognizer._get_response( self._host, @@ -2106,7 +2716,29 @@ def __call__( pb_resp = cloud_speech.Recognizer.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recognizer(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.Recognizer.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.speech_v2.SpeechClient.get_recognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetRecognizer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomClasses( @@ -2143,7 +2775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.ListCustomClassesResponse: r"""Call the list custom classes method over HTTP. @@ -2155,8 +2787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.ListCustomClassesResponse: @@ -2169,6 +2803,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListCustomClasses._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_classes( request, metadata ) @@ -2185,6 +2820,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.ListCustomClasses", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListCustomClasses", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListCustomClasses._get_response( self._host, @@ -2205,7 +2867,31 @@ def __call__( pb_resp = cloud_speech.ListCustomClassesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_classes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.ListCustomClassesResponse.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.speech_v2.SpeechClient.list_custom_classes", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListCustomClasses", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPhraseSets(_BaseSpeechRestTransport._BaseListPhraseSets, SpeechRestStub): @@ -2240,7 +2926,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.ListPhraseSetsResponse: r"""Call the list phrase sets method over HTTP. @@ -2252,8 +2938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.ListPhraseSetsResponse: @@ -2266,6 +2954,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListPhraseSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_phrase_sets( request, metadata ) @@ -2282,6 +2971,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.ListPhraseSets", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListPhraseSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListPhraseSets._get_response( self._host, @@ -2302,7 +3018,31 @@ def __call__( pb_resp = cloud_speech.ListPhraseSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_phrase_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.ListPhraseSetsResponse.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.speech_v2.SpeechClient.list_phrase_sets", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListPhraseSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecognizers( @@ -2339,7 +3079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.ListRecognizersResponse: r"""Call the list recognizers method over HTTP. @@ -2351,8 +3091,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.ListRecognizersResponse: @@ -2365,6 +3107,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListRecognizers._get_http_options() ) + request, metadata = self._interceptor.pre_list_recognizers( request, metadata ) @@ -2381,6 +3124,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.ListRecognizers", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListRecognizers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListRecognizers._get_response( self._host, @@ -2401,7 +3171,31 @@ def __call__( pb_resp = cloud_speech.ListRecognizersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recognizers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.ListRecognizersResponse.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.speech_v2.SpeechClient.list_recognizers", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListRecognizers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Recognize(_BaseSpeechRestTransport._BaseRecognize, SpeechRestStub): @@ -2437,7 +3231,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.RecognizeResponse: r"""Call the recognize method over HTTP. @@ -2453,8 +3247,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.RecognizeResponse: @@ -2465,6 +3261,7 @@ def __call__( """ http_options = _BaseSpeechRestTransport._BaseRecognize._get_http_options() + request, metadata = self._interceptor.pre_recognize(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseRecognize._get_transcoded_request( @@ -2483,6 +3280,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.Recognize", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "Recognize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._Recognize._get_response( self._host, @@ -2504,7 +3328,29 @@ def __call__( pb_resp = cloud_speech.RecognizeResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_recognize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.RecognizeResponse.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.speech_v2.SpeechClient.recognize", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "Recognize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingRecognize( @@ -2519,7 +3365,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingRecognize is not available over REST transport" @@ -2560,7 +3406,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete custom class method over HTTP. @@ -2572,8 +3418,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2586,6 +3434,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUndeleteCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_custom_class( request, metadata ) @@ -2602,6 +3451,33 @@ def __call__( 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.speech_v2.SpeechClient.UndeleteCustomClass", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeleteCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UndeleteCustomClass._get_response( self._host, @@ -2621,7 +3497,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_custom_class(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.speech_v2.SpeechClient.undelete_custom_class", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeleteCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeletePhraseSet( @@ -2659,7 +3557,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete phrase set method over HTTP. @@ -2671,8 +3569,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2685,6 +3585,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUndeletePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_phrase_set( request, metadata ) @@ -2707,6 +3608,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UndeletePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeletePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UndeletePhraseSet._get_response( self._host, @@ -2726,7 +3654,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_phrase_set(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.speech_v2.SpeechClient.undelete_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeletePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteRecognizer( @@ -2764,7 +3714,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete recognizer method over HTTP. @@ -2776,8 +3726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2790,6 +3742,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUndeleteRecognizer._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_recognizer( request, metadata ) @@ -2810,6 +3763,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UndeleteRecognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeleteRecognizer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UndeleteRecognizer._get_response( self._host, @@ -2829,7 +3809,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_recognizer(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.speech_v2.SpeechClient.undelete_recognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UndeleteRecognizer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConfig(_BaseSpeechRestTransport._BaseUpdateConfig, SpeechRestStub): @@ -2865,7 +3867,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_speech.Config: r"""Call the update config method over HTTP. @@ -2877,8 +3879,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_speech.Config: @@ -2892,6 +3896,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUpdateConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_config(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseUpdateConfig._get_transcoded_request( @@ -2910,6 +3915,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UpdateConfig", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UpdateConfig._get_response( self._host, @@ -2931,7 +3963,29 @@ def __call__( pb_resp = cloud_speech.Config.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_speech.Config.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.speech_v2.SpeechClient.update_config", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomClass( @@ -2969,7 +4023,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update custom class method over HTTP. @@ -2981,8 +4035,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2995,6 +4051,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUpdateCustomClass._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_class( request, metadata ) @@ -3017,6 +4074,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UpdateCustomClass", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateCustomClass", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UpdateCustomClass._get_response( self._host, @@ -3036,7 +4120,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_class(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.speech_v2.SpeechClient.update_custom_class", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateCustomClass", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePhraseSet( @@ -3074,7 +4180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update phrase set method over HTTP. @@ -3086,8 +4192,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3100,6 +4208,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUpdatePhraseSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_phrase_set( request, metadata ) @@ -3120,6 +4229,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UpdatePhraseSet", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdatePhraseSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UpdatePhraseSet._get_response( self._host, @@ -3139,7 +4275,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_phrase_set(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.speech_v2.SpeechClient.update_phrase_set", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdatePhraseSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRecognizer( @@ -3177,7 +4335,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update recognizer method over HTTP. @@ -3189,8 +4347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3203,6 +4363,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseUpdateRecognizer._get_http_options() ) + request, metadata = self._interceptor.pre_update_recognizer( request, metadata ) @@ -3225,6 +4386,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.UpdateRecognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateRecognizer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._UpdateRecognizer._get_response( self._host, @@ -3244,7 +4432,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_recognizer(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.speech_v2.SpeechClient.update_recognizer", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "UpdateRecognizer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3476,7 +4686,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3486,14 +4696,17 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. """ http_options = _BaseSpeechRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetLocation._get_transcoded_request( @@ -3508,6 +4721,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetLocation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetLocation._get_response( self._host, @@ -3527,6 +4767,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.speech_v2.SpeechAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3565,7 +4826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3575,8 +4836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -3585,6 +4848,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseListLocations._get_transcoded_request( @@ -3599,6 +4863,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.ListLocations", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListLocations._get_response( self._host, @@ -3618,6 +4909,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.speech_v2.SpeechAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3659,7 +4971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3669,13 +4981,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSpeechRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3696,6 +5011,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.CancelOperation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._CancelOperation._get_response( self._host, @@ -3752,7 +5094,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3762,13 +5104,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseSpeechRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3785,6 +5130,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._DeleteOperation._get_response( self._host, @@ -3838,7 +5210,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3848,8 +5220,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -3858,6 +5232,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseGetOperation._get_transcoded_request( @@ -3872,6 +5247,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._GetOperation._get_response( self._host, @@ -3891,6 +5293,27 @@ def __call__( 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.speech_v2.SpeechAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3929,7 +5352,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3939,8 +5362,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3949,6 +5374,7 @@ def __call__( http_options = ( _BaseSpeechRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSpeechRestTransport._BaseListOperations._get_transcoded_request( @@ -3963,6 +5389,33 @@ def __call__( ) ) + 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.speech_v2.SpeechClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpeechRestTransport._ListOperations._get_response( self._host, @@ -3982,6 +5435,27 @@ def __call__( 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.speech_v2.SpeechAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.speech.v2.Speech", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1.json b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1.json index 824b69ea3d27..93236a91bf54 100644 --- a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1.json +++ b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-speech", - "version": "2.28.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_custom_class" @@ -478,7 +478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_custom_class" @@ -556,7 +556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_phrase_set" @@ -633,7 +633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_phrase_set" @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -791,7 +791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -952,7 +952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.services.adaptation.pagers.ListCustomClassesAsyncPager", @@ -1113,7 +1113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.services.adaptation.pagers.ListCustomClassesPager", @@ -1194,7 +1194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.services.adaptation.pagers.ListPhraseSetAsyncPager", @@ -1274,7 +1274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.services.adaptation.pagers.ListPhraseSetPager", @@ -1359,7 +1359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -1443,7 +1443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.CustomClass", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -1612,7 +1612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.PhraseSet", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1781,7 +1781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.RecognizeResponse", @@ -1950,7 +1950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1.types.RecognizeResponse", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]", @@ -2103,7 +2103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]", diff --git a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1p1beta1.json b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1p1beta1.json index fe69e15276ff..3b43da242b1d 100644 --- a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1p1beta1.json +++ b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-speech", - "version": "2.28.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_custom_class" @@ -478,7 +478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_custom_class" @@ -556,7 +556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_phrase_set" @@ -633,7 +633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_phrase_set" @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -791,7 +791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -952,7 +952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesAsyncPager", @@ -1113,7 +1113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesPager", @@ -1194,7 +1194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetAsyncPager", @@ -1274,7 +1274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetPager", @@ -1359,7 +1359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -1443,7 +1443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.CustomClass", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -1612,7 +1612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.PhraseSet", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1781,7 +1781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.RecognizeResponse", @@ -1950,7 +1950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v1p1beta1.types.RecognizeResponse", @@ -2027,7 +2027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]", @@ -2103,7 +2103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]", diff --git a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v2.json b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v2.json index b826c4192543..dc8cd78439ea 100644 --- a/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v2.json +++ b/packages/google-cloud-speech/samples/generated_samples/snippet_metadata_google.cloud.speech.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-speech", - "version": "2.28.1" + "version": "0.1.0" }, "snippets": [ { @@ -59,7 +59,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -151,7 +151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -240,7 +240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -328,7 +328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -417,7 +417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -505,7 +505,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -594,7 +594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -682,7 +682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -843,7 +843,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -924,7 +924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1004,7 +1004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1165,7 +1165,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Config", @@ -1326,7 +1326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Config", @@ -1407,7 +1407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.CustomClass", @@ -1487,7 +1487,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.CustomClass", @@ -1568,7 +1568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.PhraseSet", @@ -1648,7 +1648,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.PhraseSet", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Recognizer", @@ -1809,7 +1809,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Recognizer", @@ -1890,7 +1890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListCustomClassesAsyncPager", @@ -1970,7 +1970,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListCustomClassesPager", @@ -2051,7 +2051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsAsyncPager", @@ -2131,7 +2131,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsPager", @@ -2212,7 +2212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListRecognizersAsyncPager", @@ -2292,7 +2292,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.services.speech.pagers.ListRecognizersPager", @@ -2389,7 +2389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.RecognizeResponse", @@ -2485,7 +2485,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.RecognizeResponse", @@ -2562,7 +2562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v2.types.StreamingRecognizeResponse]", @@ -2638,7 +2638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.speech_v2.types.StreamingRecognizeResponse]", @@ -2719,7 +2719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2799,7 +2799,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2880,7 +2880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2960,7 +2960,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3041,7 +3041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3121,7 +3121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3206,7 +3206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Config", @@ -3290,7 +3290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.speech_v2.types.Config", @@ -3375,7 +3375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3459,7 +3459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3544,7 +3544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3628,7 +3628,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3713,7 +3713,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3797,7 +3797,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_adaptation.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_adaptation.py index 87143fb8a00d..feed5ad09d1f 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_adaptation.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_adaptation.py @@ -4936,6 +4936,7 @@ def test_create_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -4992,6 +4993,7 @@ def test_create_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5124,6 +5126,7 @@ def test_get_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5171,6 +5174,7 @@ def test_get_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5310,6 +5314,7 @@ def test_list_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5363,6 +5368,7 @@ def test_list_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5556,6 +5562,7 @@ def test_update_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5606,6 +5613,7 @@ def test_update_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5737,6 +5745,7 @@ def test_delete_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5782,6 +5791,7 @@ def test_delete_phrase_set_rest_flattened(): 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"} client.delete_phrase_set(**mock_args) @@ -5921,6 +5931,7 @@ def test_create_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -5977,6 +5988,7 @@ def test_create_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6112,6 +6124,7 @@ def test_get_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6159,6 +6172,7 @@ def test_get_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6303,6 +6317,7 @@ def test_list_custom_classes_rest_required_fields( response_value._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_custom_classes(request) @@ -6358,6 +6373,7 @@ def test_list_custom_classes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_classes(**mock_args) @@ -6555,6 +6571,7 @@ def test_update_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6605,6 +6622,7 @@ def test_update_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6738,6 +6756,7 @@ def test_delete_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6783,6 +6802,7 @@ def test_delete_custom_class_rest_flattened(): 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"} client.delete_custom_class(**mock_args) @@ -7466,6 +7486,7 @@ def test_create_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7502,6 +7523,7 @@ def test_create_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7543,6 +7565,7 @@ def test_create_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -7587,6 +7610,7 @@ def test_get_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7623,6 +7647,7 @@ def test_get_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7664,6 +7689,7 @@ def test_get_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -7708,6 +7734,7 @@ def test_list_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7743,6 +7770,7 @@ def test_list_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7783,6 +7811,7 @@ def test_list_phrase_set_rest_interceptors(null_interceptor): 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 = cloud_speech_adaptation.ListPhraseSetResponse.to_json( cloud_speech_adaptation.ListPhraseSetResponse() ) @@ -7831,6 +7860,7 @@ def test_update_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7943,6 +7973,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7984,6 +8015,7 @@ def test_update_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -8028,6 +8060,7 @@ def test_delete_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -8058,6 +8091,7 @@ def test_delete_phrase_set_rest_call_success(request_type): 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_phrase_set(request) # Establish that the response is the type that we expect. @@ -8094,6 +8128,7 @@ def test_delete_phrase_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloud_speech_adaptation.DeletePhraseSetRequest() metadata = [ @@ -8134,6 +8169,7 @@ def test_create_custom_class_rest_bad_request( 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_custom_class(request) @@ -8170,6 +8206,7 @@ def test_create_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8211,6 +8248,7 @@ def test_create_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8255,6 +8293,7 @@ def test_get_custom_class_rest_bad_request( 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_custom_class(request) @@ -8291,6 +8330,7 @@ def test_get_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8332,6 +8372,7 @@ def test_get_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8376,6 +8417,7 @@ def test_list_custom_classes_rest_bad_request( 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_custom_classes(request) @@ -8413,6 +8455,7 @@ def test_list_custom_classes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_classes(request) # Establish that the response is the type that we expect. @@ -8453,6 +8496,7 @@ def test_list_custom_classes_rest_interceptors(null_interceptor): 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 = cloud_speech_adaptation.ListCustomClassesResponse.to_json( cloud_speech_adaptation.ListCustomClassesResponse() ) @@ -8503,6 +8547,7 @@ def test_update_custom_class_rest_bad_request( 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_custom_class(request) @@ -8617,6 +8662,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8658,6 +8704,7 @@ def test_update_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8702,6 +8749,7 @@ def test_delete_custom_class_rest_bad_request( 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_custom_class(request) @@ -8732,6 +8780,7 @@ def test_delete_custom_class_rest_call_success(request_type): 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_custom_class(request) # Establish that the response is the type that we expect. @@ -8768,6 +8817,7 @@ def test_delete_custom_class_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloud_speech_adaptation.DeleteCustomClassRequest() metadata = [ @@ -8808,6 +8858,7 @@ def test_get_operation_rest_bad_request( 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) @@ -8838,6 +8889,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -8866,6 +8918,7 @@ def test_list_operations_rest_bad_request( 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) @@ -8896,6 +8949,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py index 0664ea6223b3..501d0da596bd 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py @@ -1835,6 +1835,7 @@ def test_recognize_rest_required_fields(request_type=cloud_speech.RecognizeReque response_value._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.recognize(request) @@ -1891,6 +1892,7 @@ def test_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.recognize(**mock_args) @@ -2025,6 +2027,7 @@ def test_long_running_recognize_rest_required_fields( response_value._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.long_running_recognize(request) @@ -2079,6 +2082,7 @@ def test_long_running_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.long_running_recognize(**mock_args) @@ -2377,6 +2381,7 @@ def test_recognize_rest_bad_request(request_type=cloud_speech.RecognizeRequest): 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.recognize(request) @@ -2412,6 +2417,7 @@ def test_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.recognize(request) # Establish that the response is the type that we expect. @@ -2448,6 +2454,7 @@ def test_recognize_rest_interceptors(null_interceptor): 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 = cloud_speech.RecognizeResponse.to_json( cloud_speech.RecognizeResponse() ) @@ -2494,6 +2501,7 @@ def test_long_running_recognize_rest_bad_request( 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.long_running_recognize(request) @@ -2524,6 +2532,7 @@ def test_long_running_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.long_running_recognize(request) # Establish that the response is the type that we expect. @@ -2563,6 +2572,7 @@ def test_long_running_recognize_rest_interceptors(null_interceptor): 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 @@ -2619,6 +2629,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2649,6 +2660,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2677,6 +2689,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2707,6 +2720,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py index 5d0533b4f01f..1ffdbfe29c25 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py @@ -4936,6 +4936,7 @@ def test_create_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -4992,6 +4993,7 @@ def test_create_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5125,6 +5127,7 @@ def test_get_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5172,6 +5175,7 @@ def test_get_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5312,6 +5316,7 @@ def test_list_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5365,6 +5370,7 @@ def test_list_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5559,6 +5565,7 @@ def test_update_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5609,6 +5616,7 @@ def test_update_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -5740,6 +5748,7 @@ def test_delete_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -5785,6 +5794,7 @@ def test_delete_phrase_set_rest_flattened(): 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"} client.delete_phrase_set(**mock_args) @@ -5925,6 +5935,7 @@ def test_create_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -5981,6 +5992,7 @@ def test_create_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6116,6 +6128,7 @@ def test_get_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6163,6 +6176,7 @@ def test_get_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6307,6 +6321,7 @@ def test_list_custom_classes_rest_required_fields( response_value._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_custom_classes(request) @@ -6362,6 +6377,7 @@ def test_list_custom_classes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_classes(**mock_args) @@ -6559,6 +6575,7 @@ def test_update_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6609,6 +6626,7 @@ def test_update_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -6742,6 +6760,7 @@ def test_delete_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -6787,6 +6806,7 @@ def test_delete_custom_class_rest_flattened(): 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"} client.delete_custom_class(**mock_args) @@ -7470,6 +7490,7 @@ def test_create_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7506,6 +7527,7 @@ def test_create_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7547,6 +7569,7 @@ def test_create_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -7591,6 +7614,7 @@ def test_get_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7627,6 +7651,7 @@ def test_get_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7668,6 +7693,7 @@ def test_get_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -7712,6 +7738,7 @@ def test_list_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7747,6 +7774,7 @@ def test_list_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7787,6 +7815,7 @@ def test_list_phrase_set_rest_interceptors(null_interceptor): 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 = cloud_speech_adaptation.ListPhraseSetResponse.to_json( cloud_speech_adaptation.ListPhraseSetResponse() ) @@ -7835,6 +7864,7 @@ def test_update_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -7947,6 +7977,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -7988,6 +8019,7 @@ def test_update_phrase_set_rest_interceptors(null_interceptor): 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 = resource.PhraseSet.to_json(resource.PhraseSet()) req.return_value.content = return_value @@ -8032,6 +8064,7 @@ def test_delete_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -8062,6 +8095,7 @@ def test_delete_phrase_set_rest_call_success(request_type): 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_phrase_set(request) # Establish that the response is the type that we expect. @@ -8098,6 +8132,7 @@ def test_delete_phrase_set_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloud_speech_adaptation.DeletePhraseSetRequest() metadata = [ @@ -8138,6 +8173,7 @@ def test_create_custom_class_rest_bad_request( 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_custom_class(request) @@ -8174,6 +8210,7 @@ def test_create_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8215,6 +8252,7 @@ def test_create_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8259,6 +8297,7 @@ def test_get_custom_class_rest_bad_request( 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_custom_class(request) @@ -8295,6 +8334,7 @@ def test_get_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8336,6 +8376,7 @@ def test_get_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8380,6 +8421,7 @@ def test_list_custom_classes_rest_bad_request( 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_custom_classes(request) @@ -8417,6 +8459,7 @@ def test_list_custom_classes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_classes(request) # Establish that the response is the type that we expect. @@ -8457,6 +8500,7 @@ def test_list_custom_classes_rest_interceptors(null_interceptor): 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 = cloud_speech_adaptation.ListCustomClassesResponse.to_json( cloud_speech_adaptation.ListCustomClassesResponse() ) @@ -8507,6 +8551,7 @@ def test_update_custom_class_rest_bad_request( 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_custom_class(request) @@ -8621,6 +8666,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -8662,6 +8708,7 @@ def test_update_custom_class_rest_interceptors(null_interceptor): 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 = resource.CustomClass.to_json(resource.CustomClass()) req.return_value.content = return_value @@ -8706,6 +8753,7 @@ def test_delete_custom_class_rest_bad_request( 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_custom_class(request) @@ -8736,6 +8784,7 @@ def test_delete_custom_class_rest_call_success(request_type): 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_custom_class(request) # Establish that the response is the type that we expect. @@ -8772,6 +8821,7 @@ def test_delete_custom_class_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloud_speech_adaptation.DeleteCustomClassRequest() metadata = [ @@ -8812,6 +8862,7 @@ def test_get_operation_rest_bad_request( 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) @@ -8842,6 +8893,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -8870,6 +8922,7 @@ def test_list_operations_rest_bad_request( 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) @@ -8900,6 +8953,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py index 6aeadbc3964c..adbe6c874018 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py @@ -1835,6 +1835,7 @@ def test_recognize_rest_required_fields(request_type=cloud_speech.RecognizeReque response_value._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.recognize(request) @@ -1891,6 +1892,7 @@ def test_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.recognize(**mock_args) @@ -2025,6 +2027,7 @@ def test_long_running_recognize_rest_required_fields( response_value._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.long_running_recognize(request) @@ -2079,6 +2082,7 @@ def test_long_running_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.long_running_recognize(**mock_args) @@ -2377,6 +2381,7 @@ def test_recognize_rest_bad_request(request_type=cloud_speech.RecognizeRequest): 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.recognize(request) @@ -2412,6 +2417,7 @@ def test_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.recognize(request) # Establish that the response is the type that we expect. @@ -2448,6 +2454,7 @@ def test_recognize_rest_interceptors(null_interceptor): 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 = cloud_speech.RecognizeResponse.to_json( cloud_speech.RecognizeResponse() ) @@ -2494,6 +2501,7 @@ def test_long_running_recognize_rest_bad_request( 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.long_running_recognize(request) @@ -2524,6 +2532,7 @@ def test_long_running_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.long_running_recognize(request) # Establish that the response is the type that we expect. @@ -2563,6 +2572,7 @@ def test_long_running_recognize_rest_interceptors(null_interceptor): 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 @@ -2619,6 +2629,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2649,6 +2660,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2677,6 +2689,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2707,6 +2720,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v2/test_speech.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v2/test_speech.py index 9bb2fcf81cc5..a432786ad9c0 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v2/test_speech.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v2/test_speech.py @@ -9510,6 +9510,7 @@ def test_create_recognizer_rest_required_fields( response_value._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_recognizer(request) @@ -9568,6 +9569,7 @@ def test_create_recognizer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recognizer(**mock_args) @@ -9711,6 +9713,7 @@ def test_list_recognizers_rest_required_fields( response_value._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_recognizers(request) @@ -9765,6 +9768,7 @@ def test_list_recognizers_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recognizers(**mock_args) @@ -9959,6 +9963,7 @@ def test_get_recognizer_rest_required_fields( response_value._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_recognizer(request) @@ -10006,6 +10011,7 @@ def test_get_recognizer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recognizer(**mock_args) @@ -10143,6 +10149,7 @@ def test_update_recognizer_rest_required_fields( response_value._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_recognizer(request) @@ -10199,6 +10206,7 @@ def test_update_recognizer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recognizer(**mock_args) @@ -10342,6 +10350,7 @@ def test_delete_recognizer_rest_required_fields( response_value._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_recognizer(request) @@ -10396,6 +10405,7 @@ def test_delete_recognizer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recognizer(**mock_args) @@ -10533,6 +10543,7 @@ def test_undelete_recognizer_rest_required_fields( response_value._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.undelete_recognizer(request) @@ -10578,6 +10589,7 @@ def test_undelete_recognizer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_recognizer(**mock_args) @@ -10708,6 +10720,7 @@ def test_recognize_rest_required_fields(request_type=cloud_speech.RecognizeReque response_value._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.recognize(request) @@ -10757,6 +10770,7 @@ def test_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.recognize(**mock_args) @@ -10905,6 +10919,7 @@ def test_batch_recognize_rest_required_fields( response_value._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.batch_recognize(request) @@ -10953,6 +10968,7 @@ def test_batch_recognize_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_recognize(**mock_args) @@ -11085,6 +11101,7 @@ def test_get_config_rest_required_fields(request_type=cloud_speech.GetConfigRequ response_value._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_config(request) @@ -11130,6 +11147,7 @@ def test_get_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_config(**mock_args) @@ -11258,6 +11276,7 @@ def test_update_config_rest_required_fields( response_value._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_config(request) @@ -11306,6 +11325,7 @@ def test_update_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_config(**mock_args) @@ -11451,6 +11471,7 @@ def test_create_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -11509,6 +11530,7 @@ def test_create_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -11654,6 +11676,7 @@ def test_list_custom_classes_rest_required_fields( response_value._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_custom_classes(request) @@ -11708,6 +11731,7 @@ def test_list_custom_classes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_classes(**mock_args) @@ -11904,6 +11928,7 @@ def test_get_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -11951,6 +11976,7 @@ def test_get_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -12090,6 +12116,7 @@ def test_update_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -12146,6 +12173,7 @@ def test_update_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -12291,6 +12319,7 @@ def test_delete_custom_class_rest_required_fields( response_value._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_custom_class(request) @@ -12345,6 +12374,7 @@ def test_delete_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_custom_class(**mock_args) @@ -12483,6 +12513,7 @@ def test_undelete_custom_class_rest_required_fields( response_value._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.undelete_custom_class(request) @@ -12528,6 +12559,7 @@ def test_undelete_custom_class_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_custom_class(**mock_args) @@ -12670,6 +12702,7 @@ def test_create_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -12728,6 +12761,7 @@ def test_create_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -12870,6 +12904,7 @@ def test_list_phrase_sets_rest_required_fields( response_value._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_phrase_sets(request) @@ -12924,6 +12959,7 @@ def test_list_phrase_sets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_sets(**mock_args) @@ -13117,6 +13153,7 @@ def test_get_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -13164,6 +13201,7 @@ def test_get_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -13300,6 +13338,7 @@ def test_update_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -13356,6 +13395,7 @@ def test_update_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -13499,6 +13539,7 @@ def test_delete_phrase_set_rest_required_fields( response_value._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_phrase_set(request) @@ -13553,6 +13594,7 @@ def test_delete_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_phrase_set(**mock_args) @@ -13689,6 +13731,7 @@ def test_undelete_phrase_set_rest_required_fields( response_value._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.undelete_phrase_set(request) @@ -13734,6 +13777,7 @@ def test_undelete_phrase_set_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_phrase_set(**mock_args) @@ -15030,6 +15074,7 @@ def test_create_recognizer_rest_bad_request( 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_recognizer(request) @@ -15220,6 +15265,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_recognizer(request) # Establish that the response is the type that we expect. @@ -15259,6 +15305,7 @@ def test_create_recognizer_rest_interceptors(null_interceptor): 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 @@ -15303,6 +15350,7 @@ def test_list_recognizers_rest_bad_request( 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_recognizers(request) @@ -15338,6 +15386,7 @@ def test_list_recognizers_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recognizers(request) # Establish that the response is the type that we expect. @@ -15376,6 +15425,7 @@ def test_list_recognizers_rest_interceptors(null_interceptor): 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 = cloud_speech.ListRecognizersResponse.to_json( cloud_speech.ListRecognizersResponse() ) @@ -15422,6 +15472,7 @@ def test_get_recognizer_rest_bad_request( 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_recognizer(request) @@ -15466,6 +15517,7 @@ def test_get_recognizer_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recognizer(request) # Establish that the response is the type that we expect. @@ -15513,6 +15565,7 @@ def test_get_recognizer_rest_interceptors(null_interceptor): 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 = cloud_speech.Recognizer.to_json(cloud_speech.Recognizer()) req.return_value.content = return_value @@ -15559,6 +15612,7 @@ def test_update_recognizer_rest_bad_request( 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_recognizer(request) @@ -15751,6 +15805,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_recognizer(request) # Establish that the response is the type that we expect. @@ -15790,6 +15845,7 @@ def test_update_recognizer_rest_interceptors(null_interceptor): 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 @@ -15834,6 +15890,7 @@ def test_delete_recognizer_rest_bad_request( 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_recognizer(request) @@ -15864,6 +15921,7 @@ def test_delete_recognizer_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recognizer(request) # Establish that the response is the type that we expect. @@ -15903,6 +15961,7 @@ def test_delete_recognizer_rest_interceptors(null_interceptor): 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 @@ -15947,6 +16006,7 @@ def test_undelete_recognizer_rest_bad_request( 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.undelete_recognizer(request) @@ -15977,6 +16037,7 @@ def test_undelete_recognizer_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_recognizer(request) # Establish that the response is the type that we expect. @@ -16016,6 +16077,7 @@ def test_undelete_recognizer_rest_interceptors(null_interceptor): 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 @@ -16060,6 +16122,7 @@ def test_recognize_rest_bad_request(request_type=cloud_speech.RecognizeRequest): 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.recognize(request) @@ -16095,6 +16158,7 @@ def test_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.recognize(request) # Establish that the response is the type that we expect. @@ -16130,6 +16194,7 @@ def test_recognize_rest_interceptors(null_interceptor): 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 = cloud_speech.RecognizeResponse.to_json( cloud_speech.RecognizeResponse() ) @@ -16190,6 +16255,7 @@ def test_batch_recognize_rest_bad_request( 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.batch_recognize(request) @@ -16222,6 +16288,7 @@ def test_batch_recognize_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_recognize(request) # Establish that the response is the type that we expect. @@ -16261,6 +16328,7 @@ def test_batch_recognize_rest_interceptors(null_interceptor): 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 @@ -16303,6 +16371,7 @@ def test_get_config_rest_bad_request(request_type=cloud_speech.GetConfigRequest) 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_config(request) @@ -16339,6 +16408,7 @@ def test_get_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_config(request) # Establish that the response is the type that we expect. @@ -16376,6 +16446,7 @@ def test_get_config_rest_interceptors(null_interceptor): 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 = cloud_speech.Config.to_json(cloud_speech.Config()) req.return_value.content = return_value @@ -16418,6 +16489,7 @@ def test_update_config_rest_bad_request(request_type=cloud_speech.UpdateConfigRe 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_config(request) @@ -16526,6 +16598,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_config(request) # Establish that the response is the type that we expect. @@ -16565,6 +16638,7 @@ def test_update_config_rest_interceptors(null_interceptor): 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 = cloud_speech.Config.to_json(cloud_speech.Config()) req.return_value.content = return_value @@ -16609,6 +16683,7 @@ def test_create_custom_class_rest_bad_request( 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_custom_class(request) @@ -16722,6 +16797,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -16761,6 +16837,7 @@ def test_create_custom_class_rest_interceptors(null_interceptor): 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 @@ -16805,6 +16882,7 @@ def test_list_custom_classes_rest_bad_request( 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_custom_classes(request) @@ -16840,6 +16918,7 @@ def test_list_custom_classes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_classes(request) # Establish that the response is the type that we expect. @@ -16878,6 +16957,7 @@ def test_list_custom_classes_rest_interceptors(null_interceptor): 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 = cloud_speech.ListCustomClassesResponse.to_json( cloud_speech.ListCustomClassesResponse() ) @@ -16924,6 +17004,7 @@ def test_get_custom_class_rest_bad_request( 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_custom_class(request) @@ -16966,6 +17047,7 @@ def test_get_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -17011,6 +17093,7 @@ def test_get_custom_class_rest_interceptors(null_interceptor): 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 = cloud_speech.CustomClass.to_json(cloud_speech.CustomClass()) req.return_value.content = return_value @@ -17059,6 +17142,7 @@ def test_update_custom_class_rest_bad_request( 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_custom_class(request) @@ -17176,6 +17260,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -17215,6 +17300,7 @@ def test_update_custom_class_rest_interceptors(null_interceptor): 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 @@ -17259,6 +17345,7 @@ def test_delete_custom_class_rest_bad_request( 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_custom_class(request) @@ -17289,6 +17376,7 @@ def test_delete_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_custom_class(request) # Establish that the response is the type that we expect. @@ -17328,6 +17416,7 @@ def test_delete_custom_class_rest_interceptors(null_interceptor): 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 @@ -17372,6 +17461,7 @@ def test_undelete_custom_class_rest_bad_request( 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.undelete_custom_class(request) @@ -17402,6 +17492,7 @@ def test_undelete_custom_class_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_custom_class(request) # Establish that the response is the type that we expect. @@ -17441,6 +17532,7 @@ def test_undelete_custom_class_rest_interceptors(null_interceptor): 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 @@ -17485,6 +17577,7 @@ def test_create_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -17599,6 +17692,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -17638,6 +17732,7 @@ def test_create_phrase_set_rest_interceptors(null_interceptor): 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 @@ -17682,6 +17777,7 @@ def test_list_phrase_sets_rest_bad_request( 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_phrase_sets(request) @@ -17717,6 +17813,7 @@ def test_list_phrase_sets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_sets(request) # Establish that the response is the type that we expect. @@ -17755,6 +17852,7 @@ def test_list_phrase_sets_rest_interceptors(null_interceptor): 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 = cloud_speech.ListPhraseSetsResponse.to_json( cloud_speech.ListPhraseSetsResponse() ) @@ -17799,6 +17897,7 @@ def test_get_phrase_set_rest_bad_request(request_type=cloud_speech.GetPhraseSetR 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_phrase_set(request) @@ -17842,6 +17941,7 @@ def test_get_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -17888,6 +17988,7 @@ def test_get_phrase_set_rest_interceptors(null_interceptor): 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 = cloud_speech.PhraseSet.to_json(cloud_speech.PhraseSet()) req.return_value.content = return_value @@ -17934,6 +18035,7 @@ def test_update_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -18050,6 +18152,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -18089,6 +18192,7 @@ def test_update_phrase_set_rest_interceptors(null_interceptor): 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 @@ -18133,6 +18237,7 @@ def test_delete_phrase_set_rest_bad_request( 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_phrase_set(request) @@ -18163,6 +18268,7 @@ def test_delete_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_phrase_set(request) # Establish that the response is the type that we expect. @@ -18202,6 +18308,7 @@ def test_delete_phrase_set_rest_interceptors(null_interceptor): 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 @@ -18246,6 +18353,7 @@ def test_undelete_phrase_set_rest_bad_request( 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.undelete_phrase_set(request) @@ -18276,6 +18384,7 @@ def test_undelete_phrase_set_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_phrase_set(request) # Establish that the response is the type that we expect. @@ -18315,6 +18424,7 @@ def test_undelete_phrase_set_rest_interceptors(null_interceptor): 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 @@ -18359,6 +18469,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -18389,6 +18500,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -18417,6 +18529,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -18447,6 +18560,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -18477,6 +18591,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -18507,6 +18622,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -18537,6 +18653,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -18567,6 +18684,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -18597,6 +18715,7 @@ def test_get_operation_rest_bad_request( 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) @@ -18627,6 +18746,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -18657,6 +18777,7 @@ def test_list_operations_rest_bad_request( 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) @@ -18687,6 +18808,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control/gapic_version.py b/packages/google-cloud-storage-control/google/cloud/storage_control/gapic_version.py index 659b65ba02d3..558c8aab67c5 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control/gapic_version.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.1.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/gapic_version.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/gapic_version.py index 659b65ba02d3..558c8aab67c5 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/gapic_version.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.1.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/async_client.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/async_client.py index fd504444b965..13a25436490b 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/async_client.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StorageControlTransport from .transports.grpc_asyncio import StorageControlGrpcAsyncIOTransport +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 StorageControlAsyncClient: """StorageControl service includes selected control plane @@ -270,6 +280,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.storage.control_v2.StorageControlAsyncClient`.", + extra={ + "serviceName": "google.storage.control.v2.StorageControl", + "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.storage.control.v2.StorageControl", + "credentialsType": None, + }, + ) + async def create_folder( self, request: Optional[Union[storage_control.CreateFolderRequest, dict]] = None, @@ -279,7 +311,7 @@ async def create_folder( folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.Folder: r"""Creates a new folder. This operation is only applicable to a hierarchical namespace enabled bucket. @@ -348,8 +380,10 @@ async def sample_create_folder(): 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, 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: google.cloud.storage_control_v2.types.Folder: @@ -424,7 +458,7 @@ async def delete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes an empty folder. This operation is only applicable to a hierarchical namespace enabled @@ -468,8 +502,10 @@ async def sample_delete_folder(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -532,7 +568,7 @@ async def get_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.Folder: r"""Returns metadata for the specified folder. This operation is only applicable to a hierarchical namespace @@ -579,8 +615,10 @@ async def sample_get_folder(): 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, 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: google.cloud.storage_control_v2.types.Folder: @@ -653,7 +691,7 @@ async def list_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFoldersAsyncPager: r"""Retrieves a list of folders. This operation is only applicable to a hierarchical namespace enabled bucket. @@ -701,8 +739,10 @@ async def sample_list_folders(): 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, 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: google.cloud.storage_control_v2.services.storage_control.pagers.ListFoldersAsyncPager: @@ -784,7 +824,7 @@ async def rename_folder( destination_folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Renames a source folder to a destination folder. This operation is only applicable to a hierarchical namespace @@ -844,8 +884,10 @@ async def sample_rename_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -929,7 +971,7 @@ async def get_storage_layout( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.StorageLayout: r"""Returns the storage layout configuration for a given bucket. @@ -974,8 +1016,10 @@ async def sample_get_storage_layout(): 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, 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: google.cloud.storage_control_v2.types.StorageLayout: @@ -1051,7 +1095,7 @@ async def create_managed_folder( managed_folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.ManagedFolder: r"""Creates a new managed folder. @@ -1114,8 +1158,10 @@ async def sample_create_managed_folder(): 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, 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: google.cloud.storage_control_v2.types.ManagedFolder: @@ -1189,7 +1235,7 @@ async def delete_managed_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes an empty managed folder. @@ -1230,8 +1276,10 @@ async def sample_delete_managed_folder(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1294,7 +1342,7 @@ async def get_managed_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.ManagedFolder: r"""Returns metadata for the specified managed folder. @@ -1337,8 +1385,10 @@ async def sample_get_managed_folder(): 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, 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: google.cloud.storage_control_v2.types.ManagedFolder: @@ -1410,7 +1460,7 @@ async def list_managed_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagedFoldersAsyncPager: r"""Retrieves a list of managed folders for a given bucket. @@ -1456,8 +1506,10 @@ async def sample_list_managed_folders(): 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, 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: google.cloud.storage_control_v2.services.storage_control.pagers.ListManagedFoldersAsyncPager: diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/client.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/client.py index 1ea52fb48261..ada9fb8ed0a8 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/client.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -625,6 +635,10 @@ def __init__( # 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( @@ -690,6 +704,29 @@ def __init__( 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.storage.control_v2.StorageControlClient`.", + extra={ + "serviceName": "google.storage.control.v2.StorageControl", + "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.storage.control.v2.StorageControl", + "credentialsType": None, + }, + ) + def create_folder( self, request: Optional[Union[storage_control.CreateFolderRequest, dict]] = None, @@ -699,7 +736,7 @@ def create_folder( folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.Folder: r"""Creates a new folder. This operation is only applicable to a hierarchical namespace enabled bucket. @@ -768,8 +805,10 @@ def sample_create_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.types.Folder: @@ -841,7 +880,7 @@ def delete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes an empty folder. This operation is only applicable to a hierarchical namespace enabled @@ -885,8 +924,10 @@ def sample_delete_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -946,7 +987,7 @@ def get_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.Folder: r"""Returns metadata for the specified folder. This operation is only applicable to a hierarchical namespace @@ -993,8 +1034,10 @@ def sample_get_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.types.Folder: @@ -1064,7 +1107,7 @@ def list_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFoldersPager: r"""Retrieves a list of folders. This operation is only applicable to a hierarchical namespace enabled bucket. @@ -1112,8 +1155,10 @@ def sample_list_folders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.services.storage_control.pagers.ListFoldersPager: @@ -1192,7 +1237,7 @@ def rename_folder( destination_folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Renames a source folder to a destination folder. This operation is only applicable to a hierarchical namespace @@ -1252,8 +1297,10 @@ def sample_rename_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1334,7 +1381,7 @@ def get_storage_layout( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.StorageLayout: r"""Returns the storage layout configuration for a given bucket. @@ -1379,8 +1426,10 @@ def sample_get_storage_layout(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.types.StorageLayout: @@ -1453,7 +1502,7 @@ def create_managed_folder( managed_folder_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.ManagedFolder: r"""Creates a new managed folder. @@ -1516,8 +1565,10 @@ def sample_create_managed_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.types.ManagedFolder: @@ -1588,7 +1639,7 @@ def delete_managed_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Permanently deletes an empty managed folder. @@ -1629,8 +1680,10 @@ def sample_delete_managed_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1690,7 +1743,7 @@ def get_managed_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storage_control.ManagedFolder: r"""Returns metadata for the specified managed folder. @@ -1733,8 +1786,10 @@ def sample_get_managed_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.types.ManagedFolder: @@ -1803,7 +1858,7 @@ def list_managed_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagedFoldersPager: r"""Retrieves a list of managed folders for a given bucket. @@ -1849,8 +1904,10 @@ def sample_list_managed_folders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_control_v2.services.storage_control.pagers.ListManagedFoldersPager: diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/pagers.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/pagers.py index 435abc3e1304..38eb5f06eacd 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/pagers.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = storage_control.ListFoldersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = storage_control.ListFoldersRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = storage_control.ListManagedFoldersRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = storage_control.ListManagedFoldersRequest(request) diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc.py index 42ab6fb26761..9d79f56814d6 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.storage_control_v2.types import storage_control from .base import DEFAULT_CLIENT_INFO, StorageControlTransport +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.storage.control.v2.StorageControl", + "rpcName": 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.storage.control.v2.StorageControl", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageControlGrpcTransport(StorageControlTransport): """gRPC backend transport for StorageControl. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def create_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_folder" not in self._stubs: - self._stubs["create_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/CreateFolder", request_serializer=storage_control.CreateFolderRequest.serialize, response_deserializer=storage_control.Folder.deserialize, @@ -300,7 +388,7 @@ def delete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_folder" not in self._stubs: - self._stubs["delete_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/DeleteFolder", request_serializer=storage_control.DeleteFolderRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -328,7 +416,7 @@ def get_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_folder" not in self._stubs: - self._stubs["get_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetFolder", request_serializer=storage_control.GetFolderRequest.serialize, response_deserializer=storage_control.Folder.deserialize, @@ -357,7 +445,7 @@ def list_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_folders" not in self._stubs: - self._stubs["list_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_folders"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/ListFolders", request_serializer=storage_control.ListFoldersRequest.serialize, response_deserializer=storage_control.ListFoldersResponse.deserialize, @@ -387,7 +475,7 @@ def rename_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_folder" not in self._stubs: - self._stubs["rename_folder"] = self.grpc_channel.unary_unary( + self._stubs["rename_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/RenameFolder", request_serializer=storage_control.RenameFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +504,7 @@ def get_storage_layout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_storage_layout" not in self._stubs: - self._stubs["get_storage_layout"] = self.grpc_channel.unary_unary( + self._stubs["get_storage_layout"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetStorageLayout", request_serializer=storage_control.GetStorageLayoutRequest.serialize, response_deserializer=storage_control.StorageLayout.deserialize, @@ -444,7 +532,7 @@ def create_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_managed_folder" not in self._stubs: - self._stubs["create_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/CreateManagedFolder", request_serializer=storage_control.CreateManagedFolderRequest.serialize, response_deserializer=storage_control.ManagedFolder.deserialize, @@ -470,7 +558,7 @@ def delete_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_managed_folder" not in self._stubs: - self._stubs["delete_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/DeleteManagedFolder", request_serializer=storage_control.DeleteManagedFolderRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -498,7 +586,7 @@ def get_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_managed_folder" not in self._stubs: - self._stubs["get_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetManagedFolder", request_serializer=storage_control.GetManagedFolderRequest.serialize, response_deserializer=storage_control.ManagedFolder.deserialize, @@ -528,7 +616,7 @@ def list_managed_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_managed_folders" not in self._stubs: - self._stubs["list_managed_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_managed_folders"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/ListManagedFolders", request_serializer=storage_control.ListManagedFoldersRequest.serialize, response_deserializer=storage_control.ListManagedFoldersResponse.deserialize, @@ -536,7 +624,7 @@ def list_managed_folders( return self._stubs["list_managed_folders"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc_asyncio.py b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc_asyncio.py index c8d8d1c99937..6a4d6dfa3dd9 100644 --- a/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc_asyncio.py +++ b/packages/google-cloud-storage-control/google/cloud/storage_control_v2/services/storage_control/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.storage_control_v2.types import storage_control from .base import DEFAULT_CLIENT_INFO, StorageControlTransport from .grpc import StorageControlGrpcTransport +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.storage.control.v2.StorageControl", + "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.storage.control.v2.StorageControl", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageControlGrpcAsyncIOTransport(StorageControlTransport): """gRPC AsyncIO backend transport for StorageControl. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def create_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_folder" not in self._stubs: - self._stubs["create_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/CreateFolder", request_serializer=storage_control.CreateFolderRequest.serialize, response_deserializer=storage_control.Folder.deserialize, @@ -312,7 +397,7 @@ def delete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_folder" not in self._stubs: - self._stubs["delete_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/DeleteFolder", request_serializer=storage_control.DeleteFolderRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -342,7 +427,7 @@ def get_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_folder" not in self._stubs: - self._stubs["get_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetFolder", request_serializer=storage_control.GetFolderRequest.serialize, response_deserializer=storage_control.Folder.deserialize, @@ -372,7 +457,7 @@ def list_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_folders" not in self._stubs: - self._stubs["list_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_folders"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/ListFolders", request_serializer=storage_control.ListFoldersRequest.serialize, response_deserializer=storage_control.ListFoldersResponse.deserialize, @@ -404,7 +489,7 @@ def rename_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_folder" not in self._stubs: - self._stubs["rename_folder"] = self.grpc_channel.unary_unary( + self._stubs["rename_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/RenameFolder", request_serializer=storage_control.RenameFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +519,7 @@ def get_storage_layout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_storage_layout" not in self._stubs: - self._stubs["get_storage_layout"] = self.grpc_channel.unary_unary( + self._stubs["get_storage_layout"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetStorageLayout", request_serializer=storage_control.GetStorageLayoutRequest.serialize, response_deserializer=storage_control.StorageLayout.deserialize, @@ -463,7 +548,7 @@ def create_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_managed_folder" not in self._stubs: - self._stubs["create_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/CreateManagedFolder", request_serializer=storage_control.CreateManagedFolderRequest.serialize, response_deserializer=storage_control.ManagedFolder.deserialize, @@ -491,7 +576,7 @@ def delete_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_managed_folder" not in self._stubs: - self._stubs["delete_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/DeleteManagedFolder", request_serializer=storage_control.DeleteManagedFolderRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -520,7 +605,7 @@ def get_managed_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_managed_folder" not in self._stubs: - self._stubs["get_managed_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_managed_folder"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/GetManagedFolder", request_serializer=storage_control.GetManagedFolderRequest.serialize, response_deserializer=storage_control.ManagedFolder.deserialize, @@ -550,7 +635,7 @@ def list_managed_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_managed_folders" not in self._stubs: - self._stubs["list_managed_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_managed_folders"] = self._logged_channel.unary_unary( "/google.storage.control.v2.StorageControl/ListManagedFolders", request_serializer=storage_control.ListManagedFoldersRequest.serialize, response_deserializer=storage_control.ListManagedFoldersResponse.deserialize, @@ -696,7 +781,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-storage-control/samples/generated_samples/snippet_metadata_google.storage.control.v2.json b/packages/google-cloud-storage-control/samples/generated_samples/snippet_metadata_google.storage.control.v2.json index ff1c1124044d..13ffe2cf1f9d 100644 --- a/packages/google-cloud-storage-control/samples/generated_samples/snippet_metadata_google.storage.control.v2.json +++ b/packages/google-cloud-storage-control/samples/generated_samples/snippet_metadata_google.storage.control.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-storage-control", - "version": "1.1.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.Folder", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.Folder", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.ManagedFolder", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.ManagedFolder", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_folder" @@ -478,7 +478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_folder" @@ -556,7 +556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_managed_folder" @@ -633,7 +633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_managed_folder" @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.Folder", @@ -791,7 +791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.Folder", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.ManagedFolder", @@ -952,7 +952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.ManagedFolder", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.StorageLayout", @@ -1113,7 +1113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.types.StorageLayout", @@ -1194,7 +1194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.services.storage_control.pagers.ListFoldersAsyncPager", @@ -1274,7 +1274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.services.storage_control.pagers.ListFoldersPager", @@ -1355,7 +1355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.services.storage_control.pagers.ListManagedFoldersAsyncPager", @@ -1435,7 +1435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_control_v2.services.storage_control.pagers.ListManagedFoldersPager", @@ -1520,7 +1520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1604,7 +1604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer/gapic_version.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer/gapic_version.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/gapic_version.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/gapic_version.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/async_client.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/async_client.py index a72bce6ef697..50510ff4b4a6 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/async_client.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StorageTransferServiceTransport from .transports.grpc_asyncio import StorageTransferServiceGrpcAsyncIOTransport +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 StorageTransferServiceAsyncClient: """Storage Transfer Service and its protos. @@ -272,13 +282,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.storagetransfer_v1.StorageTransferServiceAsyncClient`.", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "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.storagetransfer.v1.StorageTransferService", + "credentialsType": None, + }, + ) + async def get_google_service_account( self, request: Optional[Union[transfer.GetGoogleServiceAccountRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.GoogleServiceAccount: r"""Returns the Google service account that is used by Storage Transfer Service to access buckets in the @@ -324,8 +356,10 @@ async def sample_get_google_service_account(): 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, 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: google.cloud.storage_transfer_v1.types.GoogleServiceAccount: @@ -371,7 +405,7 @@ async def create_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Creates a transfer job that runs periodically. @@ -406,8 +440,10 @@ async def sample_create_transfer_job(): 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, 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -448,7 +484,7 @@ async def update_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Updates a transfer job. Updating a job's transfer spec does not affect transfer operations that are running already. @@ -495,8 +531,10 @@ async def sample_update_transfer_job(): 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, 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -543,7 +581,7 @@ async def get_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Gets a transfer job. @@ -580,8 +618,10 @@ async def sample_get_transfer_job(): 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, 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -628,7 +668,7 @@ async def list_transfer_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferJobsAsyncPager: r"""Lists transfer jobs. @@ -667,8 +707,10 @@ async def sample_list_transfer_jobs(): 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, 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: google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListTransferJobsAsyncPager: @@ -722,7 +764,7 @@ async def pause_transfer_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Pauses a transfer operation. @@ -756,8 +798,10 @@ async def sample_pause_transfer_operation(): 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, 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -794,7 +838,7 @@ async def resume_transfer_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Resumes a transfer operation that is paused. @@ -828,8 +872,10 @@ async def sample_resume_transfer_operation(): 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, 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -866,7 +912,7 @@ async def run_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a new operation for the specified transfer job. A ``TransferJob`` has a maximum of one active @@ -910,8 +956,10 @@ async def sample_run_transfer_job(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -975,7 +1023,7 @@ async def delete_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a transfer job. Deleting a transfer job sets its status to @@ -1011,8 +1059,10 @@ async def sample_delete_transfer_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1052,7 +1102,7 @@ async def create_agent_pool( agent_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Creates an agent pool resource. @@ -1128,8 +1178,10 @@ async def sample_create_agent_pool(): 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, 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1195,7 +1247,7 @@ async def update_agent_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Updates an existing agent pool resource. @@ -1265,8 +1317,10 @@ async def sample_update_agent_pool(): 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, 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1329,7 +1383,7 @@ async def get_agent_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Gets an agent pool. @@ -1373,8 +1427,10 @@ async def sample_get_agent_pool(): 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, 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1433,7 +1489,7 @@ async def list_agent_pools( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAgentPoolsAsyncPager: r"""Lists agent pools. @@ -1477,8 +1533,10 @@ async def sample_list_agent_pools(): 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, 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: google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListAgentPoolsAsyncPager: @@ -1555,7 +1613,7 @@ async def delete_agent_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an agent pool. @@ -1596,8 +1654,10 @@ async def sample_delete_agent_pool(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1648,7 +1708,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1659,8 +1719,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1701,7 +1763,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1712,8 +1774,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1754,7 +1818,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1769,8 +1833,10 @@ async def cancel_operation( 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, 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: None """ diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/client.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/client.py index 89c39cc81cc5..f69774ff217a 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/client.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -591,6 +601,10 @@ def __init__( # 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( @@ -657,13 +671,36 @@ def __init__( 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.storagetransfer_v1.StorageTransferServiceClient`.", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "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.storagetransfer.v1.StorageTransferService", + "credentialsType": None, + }, + ) + def get_google_service_account( self, request: Optional[Union[transfer.GetGoogleServiceAccountRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.GoogleServiceAccount: r"""Returns the Google service account that is used by Storage Transfer Service to access buckets in the @@ -709,8 +746,10 @@ def sample_get_google_service_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.GoogleServiceAccount: @@ -756,7 +795,7 @@ def create_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Creates a transfer job that runs periodically. @@ -791,8 +830,10 @@ def sample_create_transfer_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -831,7 +872,7 @@ def update_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Updates a transfer job. Updating a job's transfer spec does not affect transfer operations that are running already. @@ -878,8 +919,10 @@ def sample_update_transfer_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -924,7 +967,7 @@ def get_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Gets a transfer job. @@ -961,8 +1004,10 @@ def sample_get_transfer_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.TransferJob: @@ -1007,7 +1052,7 @@ def list_transfer_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferJobsPager: r"""Lists transfer jobs. @@ -1046,8 +1091,10 @@ def sample_list_transfer_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListTransferJobsPager: @@ -1099,7 +1146,7 @@ def pause_transfer_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Pauses a transfer operation. @@ -1133,8 +1180,10 @@ def sample_pause_transfer_operation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1169,7 +1218,7 @@ def resume_transfer_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Resumes a transfer operation that is paused. @@ -1203,8 +1252,10 @@ def sample_resume_transfer_operation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1241,7 +1292,7 @@ def run_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a new operation for the specified transfer job. A ``TransferJob`` has a maximum of one active @@ -1285,8 +1336,10 @@ def sample_run_transfer_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1348,7 +1401,7 @@ def delete_transfer_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a transfer job. Deleting a transfer job sets its status to @@ -1384,8 +1437,10 @@ def sample_delete_transfer_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1423,7 +1478,7 @@ def create_agent_pool( agent_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Creates an agent pool resource. @@ -1499,8 +1554,10 @@ def sample_create_agent_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1563,7 +1620,7 @@ def update_agent_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Updates an existing agent pool resource. @@ -1633,8 +1690,10 @@ def sample_update_agent_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1694,7 +1753,7 @@ def get_agent_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Gets an agent pool. @@ -1738,8 +1797,10 @@ def sample_get_agent_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.types.AgentPool: @@ -1795,7 +1856,7 @@ def list_agent_pools( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAgentPoolsPager: r"""Lists agent pools. @@ -1839,8 +1900,10 @@ def sample_list_agent_pools(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListAgentPoolsPager: @@ -1914,7 +1977,7 @@ def delete_agent_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an agent pool. @@ -1955,8 +2018,10 @@ def sample_delete_agent_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2017,7 +2082,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2028,8 +2093,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2070,7 +2137,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2081,8 +2148,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2123,7 +2192,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2138,8 +2207,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/pagers.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/pagers.py index 5fb1a425d97e..e85d32d94117 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/pagers.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = transfer.ListTransferJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = transfer.ListTransferJobsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = transfer.ListAgentPoolsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = transfer.ListAgentPoolsRequest(request) diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc.py index 884b56d7461d..b39546670033 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.storage_transfer_v1.types import transfer, transfer_types from .base import DEFAULT_CLIENT_INFO, StorageTransferServiceTransport +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.storagetransfer.v1.StorageTransferService", + "rpcName": 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.storagetransfer.v1.StorageTransferService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageTransferServiceGrpcTransport(StorageTransferServiceTransport): """gRPC backend transport for StorageTransferService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -283,7 +371,9 @@ def get_google_service_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_google_service_account" not in self._stubs: - self._stubs["get_google_service_account"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_google_service_account" + ] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetGoogleServiceAccount", request_serializer=transfer.GetGoogleServiceAccountRequest.serialize, response_deserializer=transfer_types.GoogleServiceAccount.deserialize, @@ -309,7 +399,7 @@ def create_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_transfer_job" not in self._stubs: - self._stubs["create_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["create_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/CreateTransferJob", request_serializer=transfer.CreateTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -345,7 +435,7 @@ def update_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_transfer_job" not in self._stubs: - self._stubs["update_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["update_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/UpdateTransferJob", request_serializer=transfer.UpdateTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -371,7 +461,7 @@ def get_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_job" not in self._stubs: - self._stubs["get_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetTransferJob", request_serializer=transfer.GetTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -399,7 +489,7 @@ def list_transfer_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_jobs" not in self._stubs: - self._stubs["list_transfer_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_jobs"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ListTransferJobs", request_serializer=transfer.ListTransferJobsRequest.serialize, response_deserializer=transfer.ListTransferJobsResponse.deserialize, @@ -425,7 +515,7 @@ def pause_transfer_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_transfer_operation" not in self._stubs: - self._stubs["pause_transfer_operation"] = self.grpc_channel.unary_unary( + self._stubs["pause_transfer_operation"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/PauseTransferOperation", request_serializer=transfer.PauseTransferOperationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -451,7 +541,7 @@ def resume_transfer_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_transfer_operation" not in self._stubs: - self._stubs["resume_transfer_operation"] = self.grpc_channel.unary_unary( + self._stubs["resume_transfer_operation"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ResumeTransferOperation", request_serializer=transfer.ResumeTransferOperationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -480,7 +570,7 @@ def run_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_transfer_job" not in self._stubs: - self._stubs["run_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["run_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/RunTransferJob", request_serializer=transfer.RunTransferJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -508,7 +598,7 @@ def delete_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_job" not in self._stubs: - self._stubs["delete_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/DeleteTransferJob", request_serializer=transfer.DeleteTransferJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -534,7 +624,7 @@ def create_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_agent_pool" not in self._stubs: - self._stubs["create_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/CreateAgentPool", request_serializer=transfer.CreateAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -560,7 +650,7 @@ def update_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_agent_pool" not in self._stubs: - self._stubs["update_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/UpdateAgentPool", request_serializer=transfer.UpdateAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -586,7 +676,7 @@ def get_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent_pool" not in self._stubs: - self._stubs["get_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetAgentPool", request_serializer=transfer.GetAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -612,7 +702,7 @@ def list_agent_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_agent_pools" not in self._stubs: - self._stubs["list_agent_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_agent_pools"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ListAgentPools", request_serializer=transfer.ListAgentPoolsRequest.serialize, response_deserializer=transfer.ListAgentPoolsResponse.deserialize, @@ -638,7 +728,7 @@ def delete_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent_pool" not in self._stubs: - self._stubs["delete_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/DeleteAgentPool", request_serializer=transfer.DeleteAgentPoolRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -646,7 +736,7 @@ def delete_agent_pool( return self._stubs["delete_agent_pool"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -658,7 +748,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -675,7 +765,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -694,7 +784,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc_asyncio.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc_asyncio.py index 07fd990ed5d6..6cf0ae337953 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.storage_transfer_v1.types import transfer, transfer_types from .base import DEFAULT_CLIENT_INFO, StorageTransferServiceTransport from .grpc import StorageTransferServiceGrpcTransport +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.storagetransfer.v1.StorageTransferService", + "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.storagetransfer.v1.StorageTransferService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageTransferServiceGrpcAsyncIOTransport(StorageTransferServiceTransport): """gRPC AsyncIO backend transport for StorageTransferService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -294,7 +379,9 @@ def get_google_service_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_google_service_account" not in self._stubs: - self._stubs["get_google_service_account"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_google_service_account" + ] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetGoogleServiceAccount", request_serializer=transfer.GetGoogleServiceAccountRequest.serialize, response_deserializer=transfer_types.GoogleServiceAccount.deserialize, @@ -322,7 +409,7 @@ def create_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_transfer_job" not in self._stubs: - self._stubs["create_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["create_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/CreateTransferJob", request_serializer=transfer.CreateTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -360,7 +447,7 @@ def update_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_transfer_job" not in self._stubs: - self._stubs["update_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["update_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/UpdateTransferJob", request_serializer=transfer.UpdateTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -388,7 +475,7 @@ def get_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_job" not in self._stubs: - self._stubs["get_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetTransferJob", request_serializer=transfer.GetTransferJobRequest.serialize, response_deserializer=transfer_types.TransferJob.deserialize, @@ -416,7 +503,7 @@ def list_transfer_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_jobs" not in self._stubs: - self._stubs["list_transfer_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_jobs"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ListTransferJobs", request_serializer=transfer.ListTransferJobsRequest.serialize, response_deserializer=transfer.ListTransferJobsResponse.deserialize, @@ -442,7 +529,7 @@ def pause_transfer_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_transfer_operation" not in self._stubs: - self._stubs["pause_transfer_operation"] = self.grpc_channel.unary_unary( + self._stubs["pause_transfer_operation"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/PauseTransferOperation", request_serializer=transfer.PauseTransferOperationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -470,7 +557,7 @@ def resume_transfer_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_transfer_operation" not in self._stubs: - self._stubs["resume_transfer_operation"] = self.grpc_channel.unary_unary( + self._stubs["resume_transfer_operation"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ResumeTransferOperation", request_serializer=transfer.ResumeTransferOperationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -501,7 +588,7 @@ def run_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_transfer_job" not in self._stubs: - self._stubs["run_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["run_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/RunTransferJob", request_serializer=transfer.RunTransferJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -529,7 +616,7 @@ def delete_transfer_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_job" not in self._stubs: - self._stubs["delete_transfer_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_job"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/DeleteTransferJob", request_serializer=transfer.DeleteTransferJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -557,7 +644,7 @@ def create_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_agent_pool" not in self._stubs: - self._stubs["create_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/CreateAgentPool", request_serializer=transfer.CreateAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -585,7 +672,7 @@ def update_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_agent_pool" not in self._stubs: - self._stubs["update_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/UpdateAgentPool", request_serializer=transfer.UpdateAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -611,7 +698,7 @@ def get_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent_pool" not in self._stubs: - self._stubs["get_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/GetAgentPool", request_serializer=transfer.GetAgentPoolRequest.serialize, response_deserializer=transfer_types.AgentPool.deserialize, @@ -639,7 +726,7 @@ def list_agent_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_agent_pools" not in self._stubs: - self._stubs["list_agent_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_agent_pools"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/ListAgentPools", request_serializer=transfer.ListAgentPoolsRequest.serialize, response_deserializer=transfer.ListAgentPoolsResponse.deserialize, @@ -665,7 +752,7 @@ def delete_agent_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent_pool" not in self._stubs: - self._stubs["delete_agent_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent_pool"] = self._logged_channel.unary_unary( "/google.storagetransfer.v1.StorageTransferService/DeleteAgentPool", request_serializer=transfer.DeleteAgentPoolRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -768,7 +855,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -784,7 +871,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -801,7 +888,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -820,7 +907,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/rest.py b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/rest.py index ba7b240edfb3..5c1ae349882c 100644 --- a/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/rest.py +++ b/packages/google-cloud-storage-transfer/google/cloud/storage_transfer_v1/services/storage_transfer_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -167,8 +175,10 @@ def post_update_transfer_job(self, response): def pre_create_agent_pool( self, request: transfer.CreateAgentPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.CreateAgentPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.CreateAgentPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_agent_pool Override in a subclass to manipulate the request or metadata @@ -190,8 +200,10 @@ def post_create_agent_pool( def pre_create_transfer_job( self, request: transfer.CreateTransferJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.CreateTransferJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.CreateTransferJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_transfer_job Override in a subclass to manipulate the request or metadata @@ -213,8 +225,10 @@ def post_create_transfer_job( def pre_delete_agent_pool( self, request: transfer.DeleteAgentPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.DeleteAgentPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.DeleteAgentPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_agent_pool Override in a subclass to manipulate the request or metadata @@ -225,8 +239,10 @@ def pre_delete_agent_pool( def pre_delete_transfer_job( self, request: transfer.DeleteTransferJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.DeleteTransferJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.DeleteTransferJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_transfer_job Override in a subclass to manipulate the request or metadata @@ -235,8 +251,10 @@ def pre_delete_transfer_job( return request, metadata def pre_get_agent_pool( - self, request: transfer.GetAgentPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[transfer.GetAgentPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: transfer.GetAgentPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[transfer.GetAgentPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_agent_pool Override in a subclass to manipulate the request or metadata @@ -258,8 +276,10 @@ def post_get_agent_pool( def pre_get_google_service_account( self, request: transfer.GetGoogleServiceAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.GetGoogleServiceAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.GetGoogleServiceAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_google_service_account Override in a subclass to manipulate the request or metadata @@ -281,8 +301,8 @@ def post_get_google_service_account( def pre_get_transfer_job( self, request: transfer.GetTransferJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.GetTransferJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[transfer.GetTransferJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_transfer_job Override in a subclass to manipulate the request or metadata @@ -304,8 +324,8 @@ def post_get_transfer_job( def pre_list_agent_pools( self, request: transfer.ListAgentPoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.ListAgentPoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[transfer.ListAgentPoolsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_agent_pools Override in a subclass to manipulate the request or metadata @@ -327,8 +347,10 @@ def post_list_agent_pools( def pre_list_transfer_jobs( self, request: transfer.ListTransferJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.ListTransferJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.ListTransferJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transfer_jobs Override in a subclass to manipulate the request or metadata @@ -350,8 +372,10 @@ def post_list_transfer_jobs( def pre_pause_transfer_operation( self, request: transfer.PauseTransferOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.PauseTransferOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.PauseTransferOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for pause_transfer_operation Override in a subclass to manipulate the request or metadata @@ -362,8 +386,10 @@ def pre_pause_transfer_operation( def pre_resume_transfer_operation( self, request: transfer.ResumeTransferOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.ResumeTransferOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.ResumeTransferOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resume_transfer_operation Override in a subclass to manipulate the request or metadata @@ -374,8 +400,8 @@ def pre_resume_transfer_operation( def pre_run_transfer_job( self, request: transfer.RunTransferJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.RunTransferJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[transfer.RunTransferJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_transfer_job Override in a subclass to manipulate the request or metadata @@ -397,8 +423,10 @@ def post_run_transfer_job( def pre_update_agent_pool( self, request: transfer.UpdateAgentPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.UpdateAgentPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.UpdateAgentPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_agent_pool Override in a subclass to manipulate the request or metadata @@ -420,8 +448,10 @@ def post_update_agent_pool( def pre_update_transfer_job( self, request: transfer.UpdateTransferJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[transfer.UpdateTransferJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + transfer.UpdateTransferJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_transfer_job Override in a subclass to manipulate the request or metadata @@ -443,8 +473,10 @@ def post_update_transfer_job( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -464,8 +496,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -487,8 +521,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -680,7 +716,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Call the create agent pool method over HTTP. @@ -691,8 +727,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.AgentPool: @@ -702,6 +740,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseCreateAgentPool._get_http_options() ) + request, metadata = self._interceptor.pre_create_agent_pool( request, metadata ) @@ -718,6 +757,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.CreateAgentPool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "CreateAgentPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._CreateAgentPool._get_response( @@ -741,7 +807,29 @@ def __call__( pb_resp = transfer_types.AgentPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_agent_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.AgentPool.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.storagetransfer_v1.StorageTransferServiceClient.create_agent_pool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "CreateAgentPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTransferJob( @@ -780,7 +868,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Call the create transfer job method over HTTP. @@ -790,8 +878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.TransferJob: @@ -804,6 +894,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseCreateTransferJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_transfer_job( request, metadata ) @@ -820,6 +911,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.CreateTransferJob", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "CreateTransferJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._CreateTransferJob._get_response( @@ -843,7 +961,29 @@ def __call__( pb_resp = transfer_types.TransferJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_transfer_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.TransferJob.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.storagetransfer_v1.StorageTransferServiceClient.create_transfer_job", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "CreateTransferJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAgentPool( @@ -881,7 +1021,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete agent pool method over HTTP. @@ -892,13 +1032,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageTransferServiceRestTransport._BaseDeleteAgentPool._get_http_options() ) + request, metadata = self._interceptor.pre_delete_agent_pool( request, metadata ) @@ -911,6 +1054,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.DeleteAgentPool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "DeleteAgentPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._DeleteAgentPool._get_response( @@ -963,7 +1133,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete transfer job method over HTTP. @@ -973,13 +1143,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageTransferServiceRestTransport._BaseDeleteTransferJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_transfer_job( request, metadata ) @@ -992,6 +1165,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.DeleteTransferJob", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "DeleteTransferJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._DeleteTransferJob._get_response( @@ -1044,7 +1244,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Call the get agent pool method over HTTP. @@ -1055,8 +1255,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.AgentPool: @@ -1066,6 +1268,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseGetAgentPool._get_http_options() ) + request, metadata = self._interceptor.pre_get_agent_pool(request, metadata) transcoded_request = _BaseStorageTransferServiceRestTransport._BaseGetAgentPool._get_transcoded_request( http_options, request @@ -1076,6 +1279,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.GetAgentPool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetAgentPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageTransferServiceRestTransport._GetAgentPool._get_response( self._host, @@ -1096,7 +1326,29 @@ def __call__( pb_resp = transfer_types.AgentPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_agent_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.AgentPool.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.storagetransfer_v1.StorageTransferServiceClient.get_agent_pool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetAgentPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGoogleServiceAccount( @@ -1134,7 +1386,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.GoogleServiceAccount: r"""Call the get google service account method over HTTP. @@ -1146,8 +1398,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.GoogleServiceAccount: @@ -1157,6 +1411,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseGetGoogleServiceAccount._get_http_options() ) + request, metadata = self._interceptor.pre_get_google_service_account( request, metadata ) @@ -1169,6 +1424,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.GetGoogleServiceAccount", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetGoogleServiceAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageTransferServiceRestTransport._GetGoogleServiceAccount._get_response( self._host, @@ -1189,7 +1471,31 @@ def __call__( pb_resp = transfer_types.GoogleServiceAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_google_service_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.GoogleServiceAccount.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.storagetransfer_v1.StorageTransferServiceClient.get_google_service_account", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetGoogleServiceAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTransferJob( @@ -1227,7 +1533,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Call the get transfer job method over HTTP. @@ -1237,8 +1543,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.TransferJob: @@ -1251,6 +1559,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseGetTransferJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_transfer_job( request, metadata ) @@ -1263,6 +1572,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.GetTransferJob", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetTransferJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._GetTransferJob._get_response( @@ -1285,7 +1621,29 @@ def __call__( pb_resp = transfer_types.TransferJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transfer_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.TransferJob.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.storagetransfer_v1.StorageTransferServiceClient.get_transfer_job", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetTransferJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAgentPools( @@ -1323,7 +1681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.ListAgentPoolsResponse: r"""Call the list agent pools method over HTTP. @@ -1333,8 +1691,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer.ListAgentPoolsResponse: @@ -1344,6 +1704,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseListAgentPools._get_http_options() ) + request, metadata = self._interceptor.pre_list_agent_pools( request, metadata ) @@ -1356,6 +1717,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.ListAgentPools", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListAgentPools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._ListAgentPools._get_response( @@ -1378,7 +1766,29 @@ def __call__( pb_resp = transfer.ListAgentPoolsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_agent_pools(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.ListAgentPoolsResponse.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.storagetransfer_v1.StorageTransferServiceClient.list_agent_pools", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListAgentPools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTransferJobs( @@ -1416,7 +1826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.ListTransferJobsResponse: r"""Call the list transfer jobs method over HTTP. @@ -1428,8 +1838,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer.ListTransferJobsResponse: @@ -1439,6 +1851,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseListTransferJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_transfer_jobs( request, metadata ) @@ -1451,6 +1864,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.ListTransferJobs", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListTransferJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._ListTransferJobs._get_response( @@ -1473,7 +1913,31 @@ def __call__( pb_resp = transfer.ListTransferJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transfer_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.ListTransferJobsResponse.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.storagetransfer_v1.StorageTransferServiceClient.list_transfer_jobs", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListTransferJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseTransferOperation( @@ -1512,7 +1976,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the pause transfer operation method over HTTP. @@ -1523,13 +1987,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageTransferServiceRestTransport._BasePauseTransferOperation._get_http_options() ) + request, metadata = self._interceptor.pre_pause_transfer_operation( request, metadata ) @@ -1546,6 +2013,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.PauseTransferOperation", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "PauseTransferOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageTransferServiceRestTransport._PauseTransferOperation._get_response( self._host, @@ -1598,7 +2092,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the resume transfer operation method over HTTP. @@ -1609,13 +2103,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageTransferServiceRestTransport._BaseResumeTransferOperation._get_http_options() ) + request, metadata = self._interceptor.pre_resume_transfer_operation( request, metadata ) @@ -1632,6 +2129,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.ResumeTransferOperation", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ResumeTransferOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageTransferServiceRestTransport._ResumeTransferOperation._get_response( self._host, @@ -1684,7 +2208,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run transfer job method over HTTP. @@ -1694,8 +2218,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1708,6 +2234,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseRunTransferJob._get_http_options() ) + request, metadata = self._interceptor.pre_run_transfer_job( request, metadata ) @@ -1724,6 +2251,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.RunTransferJob", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "RunTransferJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._RunTransferJob._get_response( @@ -1745,7 +2299,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_transfer_job(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.storagetransfer_v1.StorageTransferServiceClient.run_transfer_job", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "RunTransferJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAgentPool( @@ -1784,7 +2360,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.AgentPool: r"""Call the update agent pool method over HTTP. @@ -1795,8 +2371,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.AgentPool: @@ -1806,6 +2384,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseUpdateAgentPool._get_http_options() ) + request, metadata = self._interceptor.pre_update_agent_pool( request, metadata ) @@ -1822,6 +2401,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.UpdateAgentPool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "UpdateAgentPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._UpdateAgentPool._get_response( @@ -1845,7 +2451,29 @@ def __call__( pb_resp = transfer_types.AgentPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_agent_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.AgentPool.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.storagetransfer_v1.StorageTransferServiceClient.update_agent_pool", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "UpdateAgentPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTransferJob( @@ -1884,7 +2512,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer_types.TransferJob: r"""Call the update transfer job method over HTTP. @@ -1894,8 +2522,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.transfer_types.TransferJob: @@ -1908,6 +2538,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseUpdateTransferJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_transfer_job( request, metadata ) @@ -1924,6 +2555,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.UpdateTransferJob", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "UpdateTransferJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._UpdateTransferJob._get_response( @@ -1947,7 +2605,29 @@ def __call__( pb_resp = transfer_types.TransferJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_transfer_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer_types.TransferJob.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.storagetransfer_v1.StorageTransferServiceClient.update_transfer_job", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "UpdateTransferJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2106,7 +2786,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2116,13 +2796,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageTransferServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2139,6 +2822,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.CancelOperation", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._CancelOperation._get_response( @@ -2198,7 +2908,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2208,8 +2918,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2218,6 +2930,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStorageTransferServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2228,6 +2941,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.GetOperation", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageTransferServiceRestTransport._GetOperation._get_response( self._host, @@ -2247,6 +2987,27 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2288,7 +3049,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2298,8 +3059,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2308,6 +3071,7 @@ def __call__( http_options = ( _BaseStorageTransferServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStorageTransferServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2318,6 +3082,33 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceClient.ListOperations", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( StorageTransferServiceRestTransport._ListOperations._get_response( @@ -2339,6 +3130,27 @@ def __call__( 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.storagetransfer_v1.StorageTransferServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.storagetransfer.v1.StorageTransferService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-storage-transfer/samples/generated_samples/snippet_metadata_google.storagetransfer.v1.json b/packages/google-cloud-storage-transfer/samples/generated_samples/snippet_metadata_google.storagetransfer.v1.json index b781e19fcb84..99925243876a 100644 --- a/packages/google-cloud-storage-transfer/samples/generated_samples/snippet_metadata_google.storagetransfer.v1.json +++ b/packages/google-cloud-storage-transfer/samples/generated_samples/snippet_metadata_google.storagetransfer.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-storage-transfer", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent_pool" @@ -454,7 +454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent_pool" @@ -528,7 +528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_job" @@ -601,7 +601,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_job" @@ -679,7 +679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -759,7 +759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -836,7 +836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.GoogleServiceAccount", @@ -912,7 +912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.GoogleServiceAccount", @@ -989,7 +989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", @@ -1065,7 +1065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", @@ -1146,7 +1146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListAgentPoolsAsyncPager", @@ -1226,7 +1226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListAgentPoolsPager", @@ -1303,7 +1303,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListTransferJobsAsyncPager", @@ -1379,7 +1379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.services.storage_transfer_service.pagers.ListTransferJobsPager", @@ -1456,7 +1456,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "pause_transfer_operation" @@ -1529,7 +1529,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "pause_transfer_operation" @@ -1603,7 +1603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "resume_transfer_operation" @@ -1676,7 +1676,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "resume_transfer_operation" @@ -1750,7 +1750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1826,7 +1826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1911,7 +1911,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -1995,7 +1995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.AgentPool", @@ -2072,7 +2072,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", @@ -2148,7 +2148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storage_transfer_v1.types.TransferJob", diff --git a/packages/google-cloud-storage-transfer/tests/unit/gapic/storage_transfer_v1/test_storage_transfer_service.py b/packages/google-cloud-storage-transfer/tests/unit/gapic/storage_transfer_v1/test_storage_transfer_service.py index f9553d3f8bf9..761e0faf5122 100644 --- a/packages/google-cloud-storage-transfer/tests/unit/gapic/storage_transfer_v1/test_storage_transfer_service.py +++ b/packages/google-cloud-storage-transfer/tests/unit/gapic/storage_transfer_v1/test_storage_transfer_service.py @@ -5527,6 +5527,7 @@ def test_get_google_service_account_rest_required_fields( response_value._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_google_service_account(request) @@ -5646,6 +5647,7 @@ def test_create_transfer_job_rest_required_fields( response_value._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_transfer_job(request) @@ -5774,6 +5776,7 @@ def test_update_transfer_job_rest_required_fields( response_value._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_transfer_job(request) @@ -5913,6 +5916,7 @@ def test_get_transfer_job_rest_required_fields( response_value._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_transfer_job(request) @@ -6061,6 +6065,7 @@ def test_list_transfer_jobs_rest_required_fields( response_value._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_transfer_jobs(request) @@ -6259,6 +6264,7 @@ def test_pause_transfer_operation_rest_required_fields( response_value._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.pause_transfer_operation(request) @@ -6381,6 +6387,7 @@ def test_resume_transfer_operation_rest_required_fields( response_value._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.resume_transfer_operation(request) @@ -6508,6 +6515,7 @@ def test_run_transfer_job_rest_required_fields( response_value._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.run_transfer_job(request) @@ -6645,6 +6653,7 @@ def test_delete_transfer_job_rest_required_fields( response_value._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_transfer_job(request) @@ -6790,6 +6799,7 @@ def test_create_agent_pool_rest_required_fields( response_value._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_agent_pool(request) @@ -6852,6 +6862,7 @@ def test_create_agent_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_agent_pool(**mock_args) @@ -6983,6 +6994,7 @@ def test_update_agent_pool_rest_required_fields( response_value._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_agent_pool(request) @@ -7029,6 +7041,7 @@ def test_update_agent_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_agent_pool(**mock_args) @@ -7158,6 +7171,7 @@ def test_get_agent_pool_rest_required_fields(request_type=transfer.GetAgentPoolR response_value._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_agent_pool(request) @@ -7203,6 +7217,7 @@ def test_get_agent_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_agent_pool(**mock_args) @@ -7342,6 +7357,7 @@ def test_list_agent_pools_rest_required_fields( response_value._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_agent_pools(request) @@ -7396,6 +7412,7 @@ def test_list_agent_pools_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_agent_pools(**mock_args) @@ -7585,6 +7602,7 @@ def test_delete_agent_pool_rest_required_fields( response_value._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_agent_pool(request) @@ -7628,6 +7646,7 @@ def test_delete_agent_pool_rest_flattened(): 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"} client.delete_agent_pool(**mock_args) @@ -8516,6 +8535,7 @@ def test_get_google_service_account_rest_bad_request( 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_google_service_account(request) @@ -8552,6 +8572,7 @@ def test_get_google_service_account_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_google_service_account(request) # Establish that the response is the type that we expect. @@ -8595,6 +8616,7 @@ def test_get_google_service_account_rest_interceptors(null_interceptor): 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 = transfer_types.GoogleServiceAccount.to_json( transfer_types.GoogleServiceAccount() ) @@ -8641,6 +8663,7 @@ def test_create_transfer_job_rest_bad_request( 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_transfer_job(request) @@ -8865,6 +8888,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_transfer_job(request) # Establish that the response is the type that we expect. @@ -8909,6 +8933,7 @@ def test_create_transfer_job_rest_interceptors(null_interceptor): 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 = transfer_types.TransferJob.to_json(transfer_types.TransferJob()) req.return_value.content = return_value @@ -8953,6 +8978,7 @@ def test_update_transfer_job_rest_bad_request( 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_transfer_job(request) @@ -8992,6 +9018,7 @@ def test_update_transfer_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_transfer_job(request) # Establish that the response is the type that we expect. @@ -9036,6 +9063,7 @@ def test_update_transfer_job_rest_interceptors(null_interceptor): 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 = transfer_types.TransferJob.to_json(transfer_types.TransferJob()) req.return_value.content = return_value @@ -9078,6 +9106,7 @@ def test_get_transfer_job_rest_bad_request(request_type=transfer.GetTransferJobR 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_transfer_job(request) @@ -9117,6 +9146,7 @@ def test_get_transfer_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_transfer_job(request) # Establish that the response is the type that we expect. @@ -9159,6 +9189,7 @@ def test_get_transfer_job_rest_interceptors(null_interceptor): 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 = transfer_types.TransferJob.to_json(transfer_types.TransferJob()) req.return_value.content = return_value @@ -9203,6 +9234,7 @@ def test_list_transfer_jobs_rest_bad_request( 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_transfer_jobs(request) @@ -9238,6 +9270,7 @@ def test_list_transfer_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_transfer_jobs(request) # Establish that the response is the type that we expect. @@ -9278,6 +9311,7 @@ def test_list_transfer_jobs_rest_interceptors(null_interceptor): 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 = transfer.ListTransferJobsResponse.to_json( transfer.ListTransferJobsResponse() ) @@ -9324,6 +9358,7 @@ def test_pause_transfer_operation_rest_bad_request( 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.pause_transfer_operation(request) @@ -9354,6 +9389,7 @@ def test_pause_transfer_operation_rest_call_success(request_type): 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.pause_transfer_operation(request) # Establish that the response is the type that we expect. @@ -9390,6 +9426,7 @@ def test_pause_transfer_operation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = transfer.PauseTransferOperationRequest() metadata = [ @@ -9430,6 +9467,7 @@ def test_resume_transfer_operation_rest_bad_request( 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.resume_transfer_operation(request) @@ -9460,6 +9498,7 @@ def test_resume_transfer_operation_rest_call_success(request_type): 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.resume_transfer_operation(request) # Establish that the response is the type that we expect. @@ -9497,6 +9536,7 @@ def test_resume_transfer_operation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = transfer.ResumeTransferOperationRequest() metadata = [ @@ -9535,6 +9575,7 @@ def test_run_transfer_job_rest_bad_request(request_type=transfer.RunTransferJobR 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.run_transfer_job(request) @@ -9565,6 +9606,7 @@ def test_run_transfer_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.run_transfer_job(request) # Establish that the response is the type that we expect. @@ -9604,6 +9646,7 @@ def test_run_transfer_job_rest_interceptors(null_interceptor): 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 @@ -9648,6 +9691,7 @@ def test_delete_transfer_job_rest_bad_request( 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_transfer_job(request) @@ -9678,6 +9722,7 @@ def test_delete_transfer_job_rest_call_success(request_type): 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_transfer_job(request) # Establish that the response is the type that we expect. @@ -9714,6 +9759,7 @@ def test_delete_transfer_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = transfer.DeleteTransferJobRequest() metadata = [ @@ -9754,6 +9800,7 @@ def test_create_agent_pool_rest_bad_request( 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_agent_pool(request) @@ -9864,6 +9911,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_agent_pool(request) # Establish that the response is the type that we expect. @@ -9906,6 +9954,7 @@ def test_create_agent_pool_rest_interceptors(null_interceptor): 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 = transfer_types.AgentPool.to_json(transfer_types.AgentPool()) req.return_value.content = return_value @@ -9950,6 +9999,7 @@ def test_update_agent_pool_rest_bad_request( 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_agent_pool(request) @@ -10060,6 +10110,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_agent_pool(request) # Establish that the response is the type that we expect. @@ -10102,6 +10153,7 @@ def test_update_agent_pool_rest_interceptors(null_interceptor): 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 = transfer_types.AgentPool.to_json(transfer_types.AgentPool()) req.return_value.content = return_value @@ -10144,6 +10196,7 @@ def test_get_agent_pool_rest_bad_request(request_type=transfer.GetAgentPoolReque 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_agent_pool(request) @@ -10181,6 +10234,7 @@ def test_get_agent_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_agent_pool(request) # Establish that the response is the type that we expect. @@ -10221,6 +10275,7 @@ def test_get_agent_pool_rest_interceptors(null_interceptor): 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 = transfer_types.AgentPool.to_json(transfer_types.AgentPool()) req.return_value.content = return_value @@ -10263,6 +10318,7 @@ def test_list_agent_pools_rest_bad_request(request_type=transfer.ListAgentPoolsR 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_agent_pools(request) @@ -10298,6 +10354,7 @@ def test_list_agent_pools_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_agent_pools(request) # Establish that the response is the type that we expect. @@ -10336,6 +10393,7 @@ def test_list_agent_pools_rest_interceptors(null_interceptor): 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 = transfer.ListAgentPoolsResponse.to_json( transfer.ListAgentPoolsResponse() ) @@ -10382,6 +10440,7 @@ def test_delete_agent_pool_rest_bad_request( 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_agent_pool(request) @@ -10412,6 +10471,7 @@ def test_delete_agent_pool_rest_call_success(request_type): 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_agent_pool(request) # Establish that the response is the type that we expect. @@ -10448,6 +10508,7 @@ def test_delete_agent_pool_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = transfer.DeleteAgentPoolRequest() metadata = [ @@ -10488,6 +10549,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -10518,6 +10580,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -10546,6 +10609,7 @@ def test_get_operation_rest_bad_request( 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) @@ -10576,6 +10640,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -10604,6 +10669,7 @@ def test_list_operations_rest_bad_request( 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) @@ -10634,6 +10700,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py index 17bbab4c1877..558c8aab67c5 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py index 17bbab4c1877..558c8aab67c5 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/async_client.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/async_client.py index fa930748e838..10dd72b40ed8 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/async_client.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, StorageInsightsTransport from .transports.grpc_asyncio import StorageInsightsGrpcAsyncIOTransport +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 StorageInsightsAsyncClient: """Service describing handlers for resources""" @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.storageinsights_v1.StorageInsightsAsyncClient`.", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "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.storageinsights.v1.StorageInsights", + "credentialsType": None, + }, + ) + async def list_report_configs( self, request: Optional[Union[storageinsights.ListReportConfigsRequest, dict]] = None, @@ -276,7 +308,7 @@ async def list_report_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReportConfigsAsyncPager: r"""Lists ReportConfigs in a given project and location. @@ -321,8 +353,10 @@ async def sample_list_report_configs(): 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, 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: google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportConfigsAsyncPager: @@ -397,7 +431,7 @@ async def get_report_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Gets details of a single ReportConfig. @@ -438,8 +472,10 @@ async def sample_get_report_config(): 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, 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -507,7 +543,7 @@ async def create_report_config( report_config: Optional[storageinsights.ReportConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Creates a new ReportConfig in a given project and location. @@ -554,8 +590,10 @@ async def sample_create_report_config(): 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, 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -625,7 +663,7 @@ async def update_report_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Updates the parameters of a single ReportConfig. @@ -676,8 +714,10 @@ async def sample_update_report_config(): 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, 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -748,7 +788,7 @@ async def delete_report_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a single ReportConfig. @@ -786,8 +826,10 @@ async def sample_delete_report_config(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -839,7 +881,7 @@ async def list_report_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReportDetailsAsyncPager: r"""Lists ReportDetails in a given project and location. @@ -884,8 +926,10 @@ async def sample_list_report_details(): 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, 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: google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportDetailsAsyncPager: @@ -960,7 +1004,7 @@ async def get_report_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportDetail: r"""Gets details of a single ReportDetail. @@ -1001,8 +1045,10 @@ async def sample_get_report_detail(): 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, 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: google.cloud.storageinsights_v1.types.ReportDetail: @@ -1064,7 +1110,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1075,8 +1121,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1117,7 +1165,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1128,8 +1176,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1170,7 +1220,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1186,8 +1236,10 @@ async def delete_operation( 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, 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: None """ @@ -1224,7 +1276,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1239,8 +1291,10 @@ async def cancel_operation( 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, 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: None """ @@ -1277,7 +1331,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1288,8 +1342,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1330,7 +1386,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1341,8 +1397,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/client.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/client.py index bcbc2b9c4fed..5e50b7d68a86 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/client.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -611,6 +621,10 @@ def __init__( # 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( @@ -676,6 +690,29 @@ def __init__( 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.storageinsights_v1.StorageInsightsClient`.", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "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.storageinsights.v1.StorageInsights", + "credentialsType": None, + }, + ) + def list_report_configs( self, request: Optional[Union[storageinsights.ListReportConfigsRequest, dict]] = None, @@ -683,7 +720,7 @@ def list_report_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReportConfigsPager: r"""Lists ReportConfigs in a given project and location. @@ -728,8 +765,10 @@ def sample_list_report_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportConfigsPager: @@ -801,7 +840,7 @@ def get_report_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Gets details of a single ReportConfig. @@ -842,8 +881,10 @@ def sample_get_report_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -908,7 +949,7 @@ def create_report_config( report_config: Optional[storageinsights.ReportConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Creates a new ReportConfig in a given project and location. @@ -955,8 +996,10 @@ def sample_create_report_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -1023,7 +1066,7 @@ def update_report_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Updates the parameters of a single ReportConfig. @@ -1074,8 +1117,10 @@ def sample_update_report_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.types.ReportConfig: @@ -1143,7 +1188,7 @@ def delete_report_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a single ReportConfig. @@ -1181,8 +1226,10 @@ def sample_delete_report_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1231,7 +1278,7 @@ def list_report_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReportDetailsPager: r"""Lists ReportDetails in a given project and location. @@ -1276,8 +1323,10 @@ def sample_list_report_details(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportDetailsPager: @@ -1349,7 +1398,7 @@ def get_report_detail( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportDetail: r"""Gets details of a single ReportDetail. @@ -1390,8 +1439,10 @@ def sample_get_report_detail(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.storageinsights_v1.types.ReportDetail: @@ -1463,7 +1514,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1474,8 +1525,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1516,7 +1569,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1527,8 +1580,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1569,7 +1624,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1585,8 +1640,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1623,7 +1680,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1638,8 +1695,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1676,7 +1735,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1687,8 +1746,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1729,7 +1790,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1740,8 +1801,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/pagers.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/pagers.py index 112050d87d87..b4239af12378 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/pagers.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = storageinsights.ListReportConfigsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = storageinsights.ListReportConfigsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = storageinsights.ListReportDetailsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = storageinsights.ListReportDetailsRequest(request) diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc.py index 2605cecca291..4949788c9795 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.storageinsights_v1.types import storageinsights from .base import DEFAULT_CLIENT_INFO, StorageInsightsTransport +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.storageinsights.v1.StorageInsights", + "rpcName": 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.storageinsights.v1.StorageInsights", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageInsightsGrpcTransport(StorageInsightsTransport): """gRPC backend transport for StorageInsights. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def list_report_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_configs" not in self._stubs: - self._stubs["list_report_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_report_configs"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/ListReportConfigs", request_serializer=storageinsights.ListReportConfigsRequest.serialize, response_deserializer=storageinsights.ListReportConfigsResponse.deserialize, @@ -287,7 +373,7 @@ def get_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_config" not in self._stubs: - self._stubs["get_report_config"] = self.grpc_channel.unary_unary( + self._stubs["get_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/GetReportConfig", request_serializer=storageinsights.GetReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -316,7 +402,7 @@ def create_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_report_config" not in self._stubs: - self._stubs["create_report_config"] = self.grpc_channel.unary_unary( + self._stubs["create_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/CreateReportConfig", request_serializer=storageinsights.CreateReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -344,7 +430,7 @@ def update_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_report_config" not in self._stubs: - self._stubs["update_report_config"] = self.grpc_channel.unary_unary( + self._stubs["update_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/UpdateReportConfig", request_serializer=storageinsights.UpdateReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -370,7 +456,7 @@ def delete_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_report_config" not in self._stubs: - self._stubs["delete_report_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/DeleteReportConfig", request_serializer=storageinsights.DeleteReportConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -399,7 +485,7 @@ def list_report_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_details" not in self._stubs: - self._stubs["list_report_details"] = self.grpc_channel.unary_unary( + self._stubs["list_report_details"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/ListReportDetails", request_serializer=storageinsights.ListReportDetailsRequest.serialize, response_deserializer=storageinsights.ListReportDetailsResponse.deserialize, @@ -427,7 +513,7 @@ def get_report_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_detail" not in self._stubs: - self._stubs["get_report_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_report_detail"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/GetReportDetail", request_serializer=storageinsights.GetReportDetailRequest.serialize, response_deserializer=storageinsights.ReportDetail.deserialize, @@ -435,7 +521,7 @@ def get_report_detail( return self._stubs["get_report_detail"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -447,7 +533,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -464,7 +550,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -481,7 +567,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -500,7 +586,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -519,7 +605,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -536,7 +622,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc_asyncio.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc_asyncio.py index 36e01e4df1f5..f2e848effe72 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc_asyncio.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.storageinsights_v1.types import storageinsights from .base import DEFAULT_CLIENT_INFO, StorageInsightsTransport from .grpc import StorageInsightsGrpcTransport +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.storageinsights.v1.StorageInsights", + "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.storageinsights.v1.StorageInsights", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class StorageInsightsGrpcAsyncIOTransport(StorageInsightsTransport): """gRPC AsyncIO backend transport for StorageInsights. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def list_report_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_configs" not in self._stubs: - self._stubs["list_report_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_report_configs"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/ListReportConfigs", request_serializer=storageinsights.ListReportConfigsRequest.serialize, response_deserializer=storageinsights.ListReportConfigsResponse.deserialize, @@ -296,7 +381,7 @@ def get_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_config" not in self._stubs: - self._stubs["get_report_config"] = self.grpc_channel.unary_unary( + self._stubs["get_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/GetReportConfig", request_serializer=storageinsights.GetReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -326,7 +411,7 @@ def create_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_report_config" not in self._stubs: - self._stubs["create_report_config"] = self.grpc_channel.unary_unary( + self._stubs["create_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/CreateReportConfig", request_serializer=storageinsights.CreateReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -355,7 +440,7 @@ def update_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_report_config" not in self._stubs: - self._stubs["update_report_config"] = self.grpc_channel.unary_unary( + self._stubs["update_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/UpdateReportConfig", request_serializer=storageinsights.UpdateReportConfigRequest.serialize, response_deserializer=storageinsights.ReportConfig.deserialize, @@ -383,7 +468,7 @@ def delete_report_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_report_config" not in self._stubs: - self._stubs["delete_report_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_report_config"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/DeleteReportConfig", request_serializer=storageinsights.DeleteReportConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -412,7 +497,7 @@ def list_report_details( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_details" not in self._stubs: - self._stubs["list_report_details"] = self.grpc_channel.unary_unary( + self._stubs["list_report_details"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/ListReportDetails", request_serializer=storageinsights.ListReportDetailsRequest.serialize, response_deserializer=storageinsights.ListReportDetailsResponse.deserialize, @@ -441,7 +526,7 @@ def get_report_detail( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_detail" not in self._stubs: - self._stubs["get_report_detail"] = self.grpc_channel.unary_unary( + self._stubs["get_report_detail"] = self._logged_channel.unary_unary( "/google.cloud.storageinsights.v1.StorageInsights/GetReportDetail", request_serializer=storageinsights.GetReportDetailRequest.serialize, response_deserializer=storageinsights.ReportDetail.deserialize, @@ -560,7 +645,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -576,7 +661,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -593,7 +678,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -610,7 +695,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -629,7 +714,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -648,7 +733,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -665,7 +750,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/rest.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/rest.py index b512a8f7b0fa..23202b6116e9 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/rest.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/services/storage_insights/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -124,8 +132,11 @@ def post_update_report_config(self, response): def pre_create_report_config( self, request: storageinsights.CreateReportConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.CreateReportConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.CreateReportConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_report_config Override in a subclass to manipulate the request or metadata @@ -147,8 +158,11 @@ def post_create_report_config( def pre_delete_report_config( self, request: storageinsights.DeleteReportConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.DeleteReportConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.DeleteReportConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_report_config Override in a subclass to manipulate the request or metadata @@ -159,8 +173,10 @@ def pre_delete_report_config( def pre_get_report_config( self, request: storageinsights.GetReportConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.GetReportConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.GetReportConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_report_config Override in a subclass to manipulate the request or metadata @@ -182,8 +198,10 @@ def post_get_report_config( def pre_get_report_detail( self, request: storageinsights.GetReportDetailRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.GetReportDetailRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.GetReportDetailRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_report_detail Override in a subclass to manipulate the request or metadata @@ -205,8 +223,11 @@ def post_get_report_detail( def pre_list_report_configs( self, request: storageinsights.ListReportConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.ListReportConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.ListReportConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_report_configs Override in a subclass to manipulate the request or metadata @@ -228,8 +249,11 @@ def post_list_report_configs( def pre_list_report_details( self, request: storageinsights.ListReportDetailsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.ListReportDetailsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.ListReportDetailsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_report_details Override in a subclass to manipulate the request or metadata @@ -251,8 +275,11 @@ def post_list_report_details( def pre_update_report_config( self, request: storageinsights.UpdateReportConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[storageinsights.UpdateReportConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + storageinsights.UpdateReportConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_report_config Override in a subclass to manipulate the request or metadata @@ -274,8 +301,10 @@ def post_update_report_config( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -297,8 +326,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -320,8 +351,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -341,8 +374,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -362,8 +397,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -385,8 +422,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -528,7 +567,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Call the create report config method over HTTP. @@ -538,8 +577,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ReportConfig: @@ -555,6 +596,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseCreateReportConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_report_config( request, metadata ) @@ -571,6 +613,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.CreateReportConfig", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "CreateReportConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._CreateReportConfig._get_response( self._host, @@ -592,7 +661,29 @@ def __call__( pb_resp = storageinsights.ReportConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_report_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = storageinsights.ReportConfig.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.storageinsights_v1.StorageInsightsClient.create_report_config", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "CreateReportConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteReportConfig( @@ -630,7 +721,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete report config method over HTTP. @@ -640,13 +731,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageInsightsRestTransport._BaseDeleteReportConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_report_config( request, metadata ) @@ -659,6 +753,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.DeleteReportConfig", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "DeleteReportConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._DeleteReportConfig._get_response( self._host, @@ -708,7 +829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Call the get report config method over HTTP. @@ -718,8 +839,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ReportConfig: @@ -735,6 +858,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseGetReportConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_report_config( request, metadata ) @@ -747,6 +871,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.GetReportConfig", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetReportConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._GetReportConfig._get_response( self._host, @@ -767,7 +918,29 @@ def __call__( pb_resp = storageinsights.ReportConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_report_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = storageinsights.ReportConfig.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.storageinsights_v1.StorageInsightsClient.get_report_config", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetReportConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReportDetail( @@ -804,7 +977,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportDetail: r"""Call the get report detail method over HTTP. @@ -814,8 +987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ReportDetail: @@ -829,6 +1004,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseGetReportDetail._get_http_options() ) + request, metadata = self._interceptor.pre_get_report_detail( request, metadata ) @@ -841,6 +1017,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.GetReportDetail", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetReportDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._GetReportDetail._get_response( self._host, @@ -861,7 +1064,29 @@ def __call__( pb_resp = storageinsights.ReportDetail.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_report_detail(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = storageinsights.ReportDetail.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.storageinsights_v1.StorageInsightsClient.get_report_detail", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetReportDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReportConfigs( @@ -899,7 +1124,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ListReportConfigsResponse: r"""Call the list report configs method over HTTP. @@ -910,8 +1135,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ListReportConfigsResponse: @@ -923,6 +1150,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseListReportConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_report_configs( request, metadata ) @@ -935,6 +1163,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.ListReportConfigs", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListReportConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._ListReportConfigs._get_response( self._host, @@ -955,7 +1210,31 @@ def __call__( pb_resp = storageinsights.ListReportConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_report_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + storageinsights.ListReportConfigsResponse.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.storageinsights_v1.StorageInsightsClient.list_report_configs", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListReportConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReportDetails( @@ -993,7 +1272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ListReportDetailsResponse: r"""Call the list report details method over HTTP. @@ -1004,8 +1283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ListReportDetailsResponse: @@ -1017,6 +1298,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseListReportDetails._get_http_options() ) + request, metadata = self._interceptor.pre_list_report_details( request, metadata ) @@ -1029,6 +1311,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.ListReportDetails", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListReportDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._ListReportDetails._get_response( self._host, @@ -1049,7 +1358,31 @@ def __call__( pb_resp = storageinsights.ListReportDetailsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_report_details(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + storageinsights.ListReportDetailsResponse.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.storageinsights_v1.StorageInsightsClient.list_report_details", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListReportDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateReportConfig( @@ -1088,7 +1421,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> storageinsights.ReportConfig: r"""Call the update report config method over HTTP. @@ -1098,8 +1431,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.storageinsights.ReportConfig: @@ -1115,6 +1450,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseUpdateReportConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_report_config( request, metadata ) @@ -1131,6 +1467,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.UpdateReportConfig", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "UpdateReportConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._UpdateReportConfig._get_response( self._host, @@ -1152,7 +1515,29 @@ def __call__( pb_resp = storageinsights.ReportConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_report_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = storageinsights.ReportConfig.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.storageinsights_v1.StorageInsightsClient.update_report_config", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "UpdateReportConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1263,7 +1648,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1273,8 +1658,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1283,6 +1670,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseStorageInsightsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1293,6 +1681,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.GetLocation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._GetLocation._get_response( self._host, @@ -1312,6 +1727,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.storageinsights_v1.StorageInsightsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1352,7 +1788,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1362,8 +1798,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1372,6 +1810,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseStorageInsightsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1382,6 +1821,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.ListLocations", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._ListLocations._get_response( self._host, @@ -1401,6 +1867,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.storageinsights_v1.StorageInsightsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1442,7 +1929,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1452,13 +1939,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageInsightsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1475,6 +1965,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._CancelOperation._get_response( self._host, @@ -1531,7 +2048,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1541,13 +2058,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseStorageInsightsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1560,6 +2080,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._DeleteOperation._get_response( self._host, @@ -1615,7 +2162,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1625,8 +2172,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1635,6 +2184,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseStorageInsightsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1645,6 +2195,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.GetOperation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._GetOperation._get_response( self._host, @@ -1664,6 +2241,27 @@ def __call__( 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.storageinsights_v1.StorageInsightsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1704,7 +2302,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1714,8 +2312,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1724,6 +2324,7 @@ def __call__( http_options = ( _BaseStorageInsightsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseStorageInsightsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1734,6 +2335,33 @@ def __call__( 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.storageinsights_v1.StorageInsightsClient.ListOperations", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StorageInsightsRestTransport._ListOperations._get_response( self._host, @@ -1753,6 +2381,27 @@ def __call__( 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.storageinsights_v1.StorageInsightsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.storageinsights.v1.StorageInsights", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json b/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json index 5ba148047f85..3852bb62c126 100644 --- a/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json +++ b/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-storageinsights", - "version": "0.1.12" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_report_config" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_report_config" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportDetail", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportDetail", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportConfigsAsyncPager", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportConfigsPager", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportDetailsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.services.storage_insights.pagers.ListReportDetailsPager", @@ -1019,7 +1019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.storageinsights_v1.types.ReportConfig", diff --git a/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py b/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py index 360ca36c69b3..96e98ca7624f 100644 --- a/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py +++ b/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py @@ -4050,6 +4050,7 @@ def test_list_report_configs_rest_required_fields( response_value._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_report_configs(request) @@ -4105,6 +4106,7 @@ def test_list_report_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_configs(**mock_args) @@ -4301,6 +4303,7 @@ def test_get_report_config_rest_required_fields( response_value._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_report_config(request) @@ -4348,6 +4351,7 @@ def test_get_report_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_config(**mock_args) @@ -4486,6 +4490,7 @@ def test_create_report_config_rest_required_fields( response_value._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_report_config(request) @@ -4540,6 +4545,7 @@ def test_create_report_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_config(**mock_args) @@ -4679,6 +4685,7 @@ def test_update_report_config_rest_required_fields( response_value._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_report_config(request) @@ -4742,6 +4749,7 @@ def test_update_report_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_config(**mock_args) @@ -4882,6 +4890,7 @@ def test_delete_report_config_rest_required_fields( response_value._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_report_config(request) @@ -4935,6 +4944,7 @@ def test_delete_report_config_rest_flattened(): 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"} client.delete_report_config(**mock_args) @@ -5079,6 +5089,7 @@ def test_list_report_details_rest_required_fields( response_value._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_report_details(request) @@ -5136,6 +5147,7 @@ def test_list_report_details_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_details(**mock_args) @@ -5334,6 +5346,7 @@ def test_get_report_detail_rest_required_fields( response_value._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_report_detail(request) @@ -5381,6 +5394,7 @@ def test_get_report_detail_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_report_detail(**mock_args) @@ -5925,6 +5939,7 @@ def test_list_report_configs_rest_bad_request( 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_report_configs(request) @@ -5961,6 +5976,7 @@ def test_list_report_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_configs(request) # Establish that the response is the type that we expect. @@ -6002,6 +6018,7 @@ def test_list_report_configs_rest_interceptors(null_interceptor): 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 = storageinsights.ListReportConfigsResponse.to_json( storageinsights.ListReportConfigsResponse() ) @@ -6048,6 +6065,7 @@ def test_get_report_config_rest_bad_request( 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_report_config(request) @@ -6084,6 +6102,7 @@ def test_get_report_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_config(request) # Establish that the response is the type that we expect. @@ -6125,6 +6144,7 @@ def test_get_report_config_rest_interceptors(null_interceptor): 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 = storageinsights.ReportConfig.to_json( storageinsights.ReportConfig() ) @@ -6171,6 +6191,7 @@ def test_create_report_config_rest_bad_request( 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_report_config(request) @@ -6300,6 +6321,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_config(request) # Establish that the response is the type that we expect. @@ -6341,6 +6363,7 @@ def test_create_report_config_rest_interceptors(null_interceptor): 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 = storageinsights.ReportConfig.to_json( storageinsights.ReportConfig() ) @@ -6391,6 +6414,7 @@ def test_update_report_config_rest_bad_request( 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_report_config(request) @@ -6524,6 +6548,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_config(request) # Establish that the response is the type that we expect. @@ -6565,6 +6590,7 @@ def test_update_report_config_rest_interceptors(null_interceptor): 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 = storageinsights.ReportConfig.to_json( storageinsights.ReportConfig() ) @@ -6611,6 +6637,7 @@ def test_delete_report_config_rest_bad_request( 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_report_config(request) @@ -6641,6 +6668,7 @@ def test_delete_report_config_rest_call_success(request_type): 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_report_config(request) # Establish that the response is the type that we expect. @@ -6677,6 +6705,7 @@ def test_delete_report_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = storageinsights.DeleteReportConfigRequest() metadata = [ @@ -6719,6 +6748,7 @@ def test_list_report_details_rest_bad_request( 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_report_details(request) @@ -6757,6 +6787,7 @@ def test_list_report_details_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_details(request) # Establish that the response is the type that we expect. @@ -6798,6 +6829,7 @@ def test_list_report_details_rest_interceptors(null_interceptor): 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 = storageinsights.ListReportDetailsResponse.to_json( storageinsights.ListReportDetailsResponse() ) @@ -6846,6 +6878,7 @@ def test_get_report_detail_rest_bad_request( 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_report_detail(request) @@ -6885,6 +6918,7 @@ def test_get_report_detail_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_report_detail(request) # Establish that the response is the type that we expect. @@ -6927,6 +6961,7 @@ def test_get_report_detail_rest_interceptors(null_interceptor): 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 = storageinsights.ReportDetail.to_json( storageinsights.ReportDetail() ) @@ -6973,6 +7008,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -7003,6 +7039,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -7031,6 +7068,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -7061,6 +7099,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -7091,6 +7130,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -7121,6 +7161,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -7151,6 +7192,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -7181,6 +7223,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -7211,6 +7254,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7241,6 +7285,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -7271,6 +7316,7 @@ def test_list_operations_rest_bad_request( 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) @@ -7301,6 +7347,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-support/google/cloud/support/gapic_version.py b/packages/google-cloud-support/google/cloud/support/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-support/google/cloud/support/gapic_version.py +++ b/packages/google-cloud-support/google/cloud/support/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py b/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py +++ b/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/async_client.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/async_client.py index 5f657a9b63e6..945bef1b4e85 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/async_client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CaseAttachmentServiceTransport from .transports.grpc_asyncio import CaseAttachmentServiceGrpcAsyncIOTransport +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 CaseAttachmentServiceAsyncClient: """A service to manage file attachment for Google Cloud support @@ -266,6 +276,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.support_v2.CaseAttachmentServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CaseAttachmentService", + "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.support.v2.CaseAttachmentService", + "credentialsType": None, + }, + ) + async def list_attachments( self, request: Optional[ @@ -275,7 +307,7 @@ async def list_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttachmentsAsyncPager: r"""Retrieve all attachments associated with a support case. @@ -322,8 +354,10 @@ async def sample_list_attachments(): 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, 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: google.cloud.support_v2.services.case_attachment_service.pagers.ListAttachmentsAsyncPager: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/client.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/client.py index c392aab7bbee..e7968dbc8d6e 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.support_v2.services.case_attachment_service import pagers from google.cloud.support_v2.types import attachment, attachment_service @@ -603,6 +613,10 @@ def __init__( # 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( @@ -669,6 +683,29 @@ def __init__( 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.support_v2.CaseAttachmentServiceClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CaseAttachmentService", + "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.support.v2.CaseAttachmentService", + "credentialsType": None, + }, + ) + def list_attachments( self, request: Optional[ @@ -678,7 +715,7 @@ def list_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttachmentsPager: r"""Retrieve all attachments associated with a support case. @@ -725,8 +762,10 @@ def sample_list_attachments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.services.case_attachment_service.pagers.ListAttachmentsPager: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/pagers.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/pagers.py index c541559f0b61..7ff852d41da4 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/pagers.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = attachment_service.ListAttachmentsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = attachment_service.ListAttachmentsRequest(request) diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc.py index ba81ef1506f3..b2b9e4dc5353 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.support_v2.types import attachment_service from .base import DEFAULT_CLIENT_INFO, CaseAttachmentServiceTransport +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.support.v2.CaseAttachmentService", + "rpcName": 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.support.v2.CaseAttachmentService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CaseAttachmentServiceGrpcTransport(CaseAttachmentServiceTransport): """gRPC backend transport for CaseAttachmentService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def list_attachments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attachments" not in self._stubs: - self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + self._stubs["list_attachments"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseAttachmentService/ListAttachments", request_serializer=attachment_service.ListAttachmentsRequest.serialize, response_deserializer=attachment_service.ListAttachmentsResponse.deserialize, @@ -266,7 +352,7 @@ def list_attachments( return self._stubs["list_attachments"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc_asyncio.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc_asyncio.py index f07fb20085c6..ed338ac46fcb 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.support_v2.types import attachment_service from .base import DEFAULT_CLIENT_INFO, CaseAttachmentServiceTransport from .grpc import CaseAttachmentServiceGrpcTransport +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.support.v2.CaseAttachmentService", + "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.support.v2.CaseAttachmentService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CaseAttachmentServiceGrpcAsyncIOTransport(CaseAttachmentServiceTransport): """gRPC AsyncIO backend transport for CaseAttachmentService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def list_attachments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attachments" not in self._stubs: - self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + self._stubs["list_attachments"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseAttachmentService/ListAttachments", request_serializer=attachment_service.ListAttachmentsRequest.serialize, response_deserializer=attachment_service.ListAttachmentsResponse.deserialize, @@ -298,7 +383,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/rest.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/rest.py index d96a5bd63ec0..3bb0550c6fe9 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/rest.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_attachment_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,11 @@ def post_list_attachments(self, response): def pre_list_attachments( self, request: attachment_service.ListAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment_service.ListAttachmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment_service.ListAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_attachments Override in a subclass to manipulate the request or metadata @@ -220,7 +231,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> attachment_service.ListAttachmentsResponse: r"""Call the list attachments method over HTTP. @@ -231,8 +242,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.attachment_service.ListAttachmentsResponse: @@ -244,6 +257,7 @@ def __call__( http_options = ( _BaseCaseAttachmentServiceRestTransport._BaseListAttachments._get_http_options() ) + request, metadata = self._interceptor.pre_list_attachments( request, metadata ) @@ -256,6 +270,33 @@ def __call__( 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.support_v2.CaseAttachmentServiceClient.ListAttachments", + extra={ + "serviceName": "google.cloud.support.v2.CaseAttachmentService", + "rpcName": "ListAttachments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CaseAttachmentServiceRestTransport._ListAttachments._get_response( @@ -278,7 +319,31 @@ def __call__( pb_resp = attachment_service.ListAttachmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attachments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + attachment_service.ListAttachmentsResponse.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.support_v2.CaseAttachmentServiceClient.list_attachments", + extra={ + "serviceName": "google.cloud.support.v2.CaseAttachmentService", + "rpcName": "ListAttachments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/async_client.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/async_client.py index e95129a5e2d5..8ec3acc9d19f 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/async_client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CaseServiceTransport from .transports.grpc_asyncio import CaseServiceGrpcAsyncIOTransport +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 CaseServiceAsyncClient: """A service to manage Google Cloud support cases.""" @@ -256,6 +266,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.support_v2.CaseServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "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.support.v2.CaseService", + "credentialsType": None, + }, + ) + async def get_case( self, request: Optional[Union[case_service.GetCaseRequest, dict]] = None, @@ -263,7 +295,7 @@ async def get_case( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Retrieve the specified case. @@ -307,8 +339,10 @@ async def sample_get_case(): 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, 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: google.cloud.support_v2.types.Case: @@ -365,7 +399,7 @@ async def list_cases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCasesAsyncPager: r"""Retrieve all cases under the specified parent. @@ -415,8 +449,10 @@ async def sample_list_cases(): 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, 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: google.cloud.support_v2.services.case_service.pagers.ListCasesAsyncPager: @@ -490,7 +526,7 @@ async def search_cases( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCasesAsyncPager: r"""Search cases using the specified query. @@ -527,8 +563,10 @@ async def sample_search_cases(): 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, 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: google.cloud.support_v2.services.case_service.pagers.SearchCasesAsyncPager: @@ -590,7 +628,7 @@ async def create_case( case: Optional[gcs_case.Case] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Create a new case and associate it with the given Google Cloud Resource. The case object must have the following fields set: @@ -643,8 +681,10 @@ async def sample_create_case(): 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, 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: google.cloud.support_v2.types.Case: @@ -706,7 +746,7 @@ async def update_case( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Update the specified case. Only a subset of fields can be updated. @@ -764,8 +804,10 @@ async def sample_update_case(): 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, 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: google.cloud.support_v2.types.Case: @@ -827,7 +869,7 @@ async def escalate_case( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Escalate a case. Escalating a case will initiate the Google Cloud Support escalation management process. @@ -871,8 +913,10 @@ async def sample_escalate_case(): 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, 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: google.cloud.support_v2.types.Case: @@ -916,7 +960,7 @@ async def close_case( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Close the specified case. @@ -953,8 +997,10 @@ async def sample_close_case(): 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, 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: google.cloud.support_v2.types.Case: @@ -1000,7 +1046,7 @@ async def search_case_classifications( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCaseClassificationsAsyncPager: r"""Retrieve valid classifications to be used when creating a support case. The classications are @@ -1041,8 +1087,10 @@ async def sample_search_case_classifications(): 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, 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: google.cloud.support_v2.services.case_service.pagers.SearchCaseClassificationsAsyncPager: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/client.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/client.py index de3b6c199a9e..e65a7f2d32fe 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -577,6 +587,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.support_v2.CaseServiceClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "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.support.v2.CaseService", + "credentialsType": None, + }, + ) + def get_case( self, request: Optional[Union[case_service.GetCaseRequest, dict]] = None, @@ -646,7 +683,7 @@ def get_case( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Retrieve the specified case. @@ -690,8 +727,10 @@ def sample_get_case(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Case: @@ -747,7 +786,7 @@ def list_cases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCasesPager: r"""Retrieve all cases under the specified parent. @@ -797,8 +836,10 @@ def sample_list_cases(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.services.case_service.pagers.ListCasesPager: @@ -869,7 +910,7 @@ def search_cases( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCasesPager: r"""Search cases using the specified query. @@ -906,8 +947,10 @@ def sample_search_cases(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.services.case_service.pagers.SearchCasesPager: @@ -967,7 +1010,7 @@ def create_case( case: Optional[gcs_case.Case] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Create a new case and associate it with the given Google Cloud Resource. The case object must have the following fields set: @@ -1020,8 +1063,10 @@ def sample_create_case(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Case: @@ -1080,7 +1125,7 @@ def update_case( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Update the specified case. Only a subset of fields can be updated. @@ -1138,8 +1183,10 @@ def sample_update_case(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Case: @@ -1198,7 +1245,7 @@ def escalate_case( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Escalate a case. Escalating a case will initiate the Google Cloud Support escalation management process. @@ -1242,8 +1289,10 @@ def sample_escalate_case(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Case: @@ -1285,7 +1334,7 @@ def close_case( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Close the specified case. @@ -1322,8 +1371,10 @@ def sample_close_case(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Case: @@ -1367,7 +1418,7 @@ def search_case_classifications( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCaseClassificationsPager: r"""Retrieve valid classifications to be used when creating a support case. The classications are @@ -1408,8 +1459,10 @@ def sample_search_case_classifications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.services.case_service.pagers.SearchCaseClassificationsPager: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/pagers.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/pagers.py index 41912eb8b7c1..ba6ff6f173ad 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/pagers.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = case_service.ListCasesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = case_service.ListCasesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = case_service.SearchCasesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = case_service.SearchCasesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = case_service.SearchCaseClassificationsRequest(request) @@ -447,7 +457,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -461,8 +471,10 @@ def __init__( 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, 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`. """ self._method = method self._request = case_service.SearchCaseClassificationsRequest(request) diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc.py index 844e30bc07fb..5b20e7eb6f1a 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,7 +23,10 @@ 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.support_v2.types import case from google.cloud.support_v2.types import case as gcs_case @@ -28,6 +34,81 @@ from .base import DEFAULT_CLIENT_INFO, CaseServiceTransport +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.support.v2.CaseService", + "rpcName": 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.support.v2.CaseService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CaseServiceGrpcTransport(CaseServiceTransport): """gRPC backend transport for CaseService. @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -253,7 +339,7 @@ def get_case(self) -> Callable[[case_service.GetCaseRequest], case.Case]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_case" not in self._stubs: - self._stubs["get_case"] = self.grpc_channel.unary_unary( + self._stubs["get_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/GetCase", request_serializer=case_service.GetCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -284,7 +370,7 @@ def list_cases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cases" not in self._stubs: - self._stubs["list_cases"] = self.grpc_channel.unary_unary( + self._stubs["list_cases"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/ListCases", request_serializer=case_service.ListCasesRequest.serialize, response_deserializer=case_service.ListCasesResponse.deserialize, @@ -310,7 +396,7 @@ def search_cases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_cases" not in self._stubs: - self._stubs["search_cases"] = self.grpc_channel.unary_unary( + self._stubs["search_cases"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/SearchCases", request_serializer=case_service.SearchCasesRequest.serialize, response_deserializer=case_service.SearchCasesResponse.deserialize, @@ -337,7 +423,7 @@ def create_case(self) -> Callable[[case_service.CreateCaseRequest], gcs_case.Cas # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_case" not in self._stubs: - self._stubs["create_case"] = self.grpc_channel.unary_unary( + self._stubs["create_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/CreateCase", request_serializer=case_service.CreateCaseRequest.serialize, response_deserializer=gcs_case.Case.deserialize, @@ -362,7 +448,7 @@ def update_case(self) -> Callable[[case_service.UpdateCaseRequest], gcs_case.Cas # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_case" not in self._stubs: - self._stubs["update_case"] = self.grpc_channel.unary_unary( + self._stubs["update_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/UpdateCase", request_serializer=case_service.UpdateCaseRequest.serialize, response_deserializer=gcs_case.Case.deserialize, @@ -393,7 +479,7 @@ def escalate_case(self) -> Callable[[case_service.EscalateCaseRequest], case.Cas # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "escalate_case" not in self._stubs: - self._stubs["escalate_case"] = self.grpc_channel.unary_unary( + self._stubs["escalate_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/EscalateCase", request_serializer=case_service.EscalateCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -417,7 +503,7 @@ def close_case(self) -> Callable[[case_service.CloseCaseRequest], case.Case]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "close_case" not in self._stubs: - self._stubs["close_case"] = self.grpc_channel.unary_unary( + self._stubs["close_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/CloseCase", request_serializer=case_service.CloseCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -450,7 +536,9 @@ def search_case_classifications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_case_classifications" not in self._stubs: - self._stubs["search_case_classifications"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_case_classifications" + ] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/SearchCaseClassifications", request_serializer=case_service.SearchCaseClassificationsRequest.serialize, response_deserializer=case_service.SearchCaseClassificationsResponse.deserialize, @@ -458,7 +546,7 @@ def search_case_classifications( return self._stubs["search_case_classifications"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc_asyncio.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc_asyncio.py index 5acb869ea85f..41876c876091 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,8 +25,11 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.support_v2.types import case from google.cloud.support_v2.types import case as gcs_case @@ -32,6 +38,82 @@ from .base import DEFAULT_CLIENT_INFO, CaseServiceTransport from .grpc import CaseServiceGrpcTransport +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.support.v2.CaseService", + "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.support.v2.CaseService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CaseServiceGrpcAsyncIOTransport(CaseServiceTransport): """gRPC AsyncIO backend transport for CaseService. @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def get_case(self) -> Callable[[case_service.GetCaseRequest], Awaitable[case.Cas # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_case" not in self._stubs: - self._stubs["get_case"] = self.grpc_channel.unary_unary( + self._stubs["get_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/GetCase", request_serializer=case_service.GetCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -294,7 +379,7 @@ def list_cases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cases" not in self._stubs: - self._stubs["list_cases"] = self.grpc_channel.unary_unary( + self._stubs["list_cases"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/ListCases", request_serializer=case_service.ListCasesRequest.serialize, response_deserializer=case_service.ListCasesResponse.deserialize, @@ -322,7 +407,7 @@ def search_cases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_cases" not in self._stubs: - self._stubs["search_cases"] = self.grpc_channel.unary_unary( + self._stubs["search_cases"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/SearchCases", request_serializer=case_service.SearchCasesRequest.serialize, response_deserializer=case_service.SearchCasesResponse.deserialize, @@ -351,7 +436,7 @@ def create_case( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_case" not in self._stubs: - self._stubs["create_case"] = self.grpc_channel.unary_unary( + self._stubs["create_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/CreateCase", request_serializer=case_service.CreateCaseRequest.serialize, response_deserializer=gcs_case.Case.deserialize, @@ -378,7 +463,7 @@ def update_case( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_case" not in self._stubs: - self._stubs["update_case"] = self.grpc_channel.unary_unary( + self._stubs["update_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/UpdateCase", request_serializer=case_service.UpdateCaseRequest.serialize, response_deserializer=gcs_case.Case.deserialize, @@ -411,7 +496,7 @@ def escalate_case( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "escalate_case" not in self._stubs: - self._stubs["escalate_case"] = self.grpc_channel.unary_unary( + self._stubs["escalate_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/EscalateCase", request_serializer=case_service.EscalateCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -437,7 +522,7 @@ def close_case( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "close_case" not in self._stubs: - self._stubs["close_case"] = self.grpc_channel.unary_unary( + self._stubs["close_case"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/CloseCase", request_serializer=case_service.CloseCaseRequest.serialize, response_deserializer=case.Case.deserialize, @@ -470,7 +555,9 @@ def search_case_classifications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_case_classifications" not in self._stubs: - self._stubs["search_case_classifications"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_case_classifications" + ] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CaseService/SearchCaseClassifications", request_serializer=case_service.SearchCaseClassificationsRequest.serialize, response_deserializer=case_service.SearchCaseClassificationsResponse.deserialize, @@ -564,7 +651,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/rest.py b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/rest.py index 10b384a41cf1..17896bc70dce 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/rest.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/case_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -135,8 +143,8 @@ def post_update_case(self, response): def pre_close_case( self, request: case_service.CloseCaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.CloseCaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[case_service.CloseCaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for close_case Override in a subclass to manipulate the request or metadata @@ -156,8 +164,8 @@ def post_close_case(self, response: case.Case) -> case.Case: def pre_create_case( self, request: case_service.CreateCaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.CreateCaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[case_service.CreateCaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_case Override in a subclass to manipulate the request or metadata @@ -177,8 +185,10 @@ def post_create_case(self, response: gcs_case.Case) -> gcs_case.Case: def pre_escalate_case( self, request: case_service.EscalateCaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.EscalateCaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + case_service.EscalateCaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for escalate_case Override in a subclass to manipulate the request or metadata @@ -196,8 +206,10 @@ def post_escalate_case(self, response: case.Case) -> case.Case: return response def pre_get_case( - self, request: case_service.GetCaseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[case_service.GetCaseRequest, Sequence[Tuple[str, str]]]: + self, + request: case_service.GetCaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[case_service.GetCaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_case Override in a subclass to manipulate the request or metadata @@ -217,8 +229,8 @@ def post_get_case(self, response: case.Case) -> case.Case: def pre_list_cases( self, request: case_service.ListCasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.ListCasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[case_service.ListCasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_cases Override in a subclass to manipulate the request or metadata @@ -240,9 +252,10 @@ def post_list_cases( def pre_search_case_classifications( self, request: case_service.SearchCaseClassificationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - case_service.SearchCaseClassificationsRequest, Sequence[Tuple[str, str]] + case_service.SearchCaseClassificationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_case_classifications @@ -265,8 +278,10 @@ def post_search_case_classifications( def pre_search_cases( self, request: case_service.SearchCasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.SearchCasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + case_service.SearchCasesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_cases Override in a subclass to manipulate the request or metadata @@ -288,8 +303,8 @@ def post_search_cases( def pre_update_case( self, request: case_service.UpdateCaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[case_service.UpdateCaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[case_service.UpdateCaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_case Override in a subclass to manipulate the request or metadata @@ -426,7 +441,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Call the close case method over HTTP. @@ -437,8 +452,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case.Case: @@ -448,6 +465,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseCloseCase._get_http_options() ) + request, metadata = self._interceptor.pre_close_case(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseCloseCase._get_transcoded_request( @@ -466,6 +484,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.CloseCase", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "CloseCase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._CloseCase._get_response( self._host, @@ -487,7 +532,29 @@ def __call__( pb_resp = case.Case.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_close_case(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = case.Case.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.support_v2.CaseServiceClient.close_case", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "CloseCase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCase( @@ -525,7 +592,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Call the create case method over HTTP. @@ -536,8 +603,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_case.Case: @@ -547,6 +616,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseCreateCase._get_http_options() ) + request, metadata = self._interceptor.pre_create_case(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseCreateCase._get_transcoded_request( @@ -565,6 +635,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.CreateCase", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "CreateCase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._CreateCase._get_response( self._host, @@ -586,7 +683,29 @@ def __call__( pb_resp = gcs_case.Case.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_case(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_case.Case.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.support_v2.CaseServiceClient.create_case", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "CreateCase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EscalateCase( @@ -624,7 +743,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Call the escalate case method over HTTP. @@ -635,8 +754,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case.Case: @@ -646,6 +767,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseEscalateCase._get_http_options() ) + request, metadata = self._interceptor.pre_escalate_case(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseEscalateCase._get_transcoded_request( @@ -666,6 +788,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.EscalateCase", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "EscalateCase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._EscalateCase._get_response( self._host, @@ -687,7 +836,29 @@ def __call__( pb_resp = case.Case.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_escalate_case(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = case.Case.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.support_v2.CaseServiceClient.escalate_case", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "EscalateCase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCase(_BaseCaseServiceRestTransport._BaseGetCase, CaseServiceRestStub): @@ -722,7 +893,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case.Case: r"""Call the get case method over HTTP. @@ -733,8 +904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case.Case: @@ -744,6 +917,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseGetCase._get_http_options() ) + request, metadata = self._interceptor.pre_get_case(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseGetCase._get_transcoded_request( @@ -758,6 +932,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.GetCase", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "GetCase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._GetCase._get_response( self._host, @@ -778,7 +979,29 @@ def __call__( pb_resp = case.Case.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_case(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = case.Case.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.support_v2.CaseServiceClient.get_case", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "GetCase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCases(_BaseCaseServiceRestTransport._BaseListCases, CaseServiceRestStub): @@ -813,7 +1036,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case_service.ListCasesResponse: r"""Call the list cases method over HTTP. @@ -824,8 +1047,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case_service.ListCasesResponse: @@ -837,6 +1062,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseListCases._get_http_options() ) + request, metadata = self._interceptor.pre_list_cases(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseListCases._get_transcoded_request( @@ -851,6 +1077,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.ListCases", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "ListCases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._ListCases._get_response( self._host, @@ -871,7 +1124,29 @@ def __call__( pb_resp = case_service.ListCasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = case_service.ListCasesResponse.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.support_v2.CaseServiceClient.list_cases", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "ListCases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchCaseClassifications( @@ -909,7 +1184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case_service.SearchCaseClassificationsResponse: r"""Call the search case classifications method over HTTP. @@ -921,8 +1196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case_service.SearchCaseClassificationsResponse: @@ -934,6 +1211,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseSearchCaseClassifications._get_http_options() ) + request, metadata = self._interceptor.pre_search_case_classifications( request, metadata ) @@ -946,6 +1224,33 @@ def __call__( 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.support_v2.CaseServiceClient.SearchCaseClassifications", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "SearchCaseClassifications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CaseServiceRestTransport._SearchCaseClassifications._get_response( @@ -968,7 +1273,31 @@ def __call__( pb_resp = case_service.SearchCaseClassificationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_case_classifications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + case_service.SearchCaseClassificationsResponse.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.support_v2.CaseServiceClient.search_case_classifications", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "SearchCaseClassifications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchCases( @@ -1005,7 +1334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> case_service.SearchCasesResponse: r"""Call the search cases method over HTTP. @@ -1016,8 +1345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.case_service.SearchCasesResponse: @@ -1029,6 +1360,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseSearchCases._get_http_options() ) + request, metadata = self._interceptor.pre_search_cases(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseSearchCases._get_transcoded_request( @@ -1043,6 +1375,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.SearchCases", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "SearchCases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._SearchCases._get_response( self._host, @@ -1063,7 +1422,31 @@ def __call__( pb_resp = case_service.SearchCasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_cases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = case_service.SearchCasesResponse.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.support_v2.CaseServiceClient.search_cases", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "SearchCases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCase( @@ -1101,7 +1484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_case.Case: r"""Call the update case method over HTTP. @@ -1112,8 +1495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_case.Case: @@ -1123,6 +1508,7 @@ def __call__( http_options = ( _BaseCaseServiceRestTransport._BaseUpdateCase._get_http_options() ) + request, metadata = self._interceptor.pre_update_case(request, metadata) transcoded_request = ( _BaseCaseServiceRestTransport._BaseUpdateCase._get_transcoded_request( @@ -1141,6 +1527,33 @@ def __call__( ) ) + 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.support_v2.CaseServiceClient.UpdateCase", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "UpdateCase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CaseServiceRestTransport._UpdateCase._get_response( self._host, @@ -1162,7 +1575,29 @@ def __call__( pb_resp = gcs_case.Case.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_case(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_case.Case.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.support_v2.CaseServiceClient.update_case", + extra={ + "serviceName": "google.cloud.support.v2.CaseService", + "rpcName": "UpdateCase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/async_client.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/async_client.py index 55c550482af4..7bc8f94ec975 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/async_client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CommentServiceTransport from .transports.grpc_asyncio import CommentServiceGrpcAsyncIOTransport +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 CommentServiceAsyncClient: """A service to manage comments on cases.""" @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.support_v2.CommentServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "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.support.v2.CommentService", + "credentialsType": None, + }, + ) + async def list_comments( self, request: Optional[Union[comment_service.ListCommentsRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_comments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCommentsAsyncPager: r"""Retrieve all Comments associated with the Case object. @@ -315,8 +347,10 @@ async def sample_list_comments(): 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, 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: google.cloud.support_v2.services.comment_service.pagers.ListCommentsAsyncPager: @@ -392,7 +426,7 @@ async def create_comment( comment: Optional[gcs_comment.Comment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_comment.Comment: r"""Add a new comment to the specified Case. The comment object must have the following fields set: @@ -445,8 +479,10 @@ async def sample_create_comment(): 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, 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: google.cloud.support_v2.types.Comment: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/client.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/client.py index 4d7b00198664..af614117b3ec 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/client.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import timestamp_pb2 # type: ignore from google.cloud.support_v2.services.comment_service import pagers @@ -600,6 +610,10 @@ def __init__( # 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( @@ -665,6 +679,29 @@ def __init__( 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.support_v2.CommentServiceClient`.", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "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.support.v2.CommentService", + "credentialsType": None, + }, + ) + def list_comments( self, request: Optional[Union[comment_service.ListCommentsRequest, dict]] = None, @@ -672,7 +709,7 @@ def list_comments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCommentsPager: r"""Retrieve all Comments associated with the Case object. @@ -719,8 +756,10 @@ def sample_list_comments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.services.comment_service.pagers.ListCommentsPager: @@ -793,7 +832,7 @@ def create_comment( comment: Optional[gcs_comment.Comment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_comment.Comment: r"""Add a new comment to the specified Case. The comment object must have the following fields set: @@ -846,8 +885,10 @@ def sample_create_comment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.support_v2.types.Comment: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/pagers.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/pagers.py index b38abdf3e951..da29f6ce4465 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/pagers.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = comment_service.ListCommentsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = comment_service.ListCommentsRequest(request) diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc.py index 8127f50a5f90..9cb39c65550d 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,13 +23,91 @@ 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.support_v2.types import comment as gcs_comment from google.cloud.support_v2.types import comment_service from .base import DEFAULT_CLIENT_INFO, CommentServiceTransport +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.support.v2.CommentService", + "rpcName": 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.support.v2.CommentService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CommentServiceGrpcTransport(CommentServiceTransport): """gRPC backend transport for CommentService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def list_comments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_comments" not in self._stubs: - self._stubs["list_comments"] = self.grpc_channel.unary_unary( + self._stubs["list_comments"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CommentService/ListComments", request_serializer=comment_service.ListCommentsRequest.serialize, response_deserializer=comment_service.ListCommentsResponse.deserialize, @@ -285,7 +371,7 @@ def create_comment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_comment" not in self._stubs: - self._stubs["create_comment"] = self.grpc_channel.unary_unary( + self._stubs["create_comment"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CommentService/CreateComment", request_serializer=comment_service.CreateCommentRequest.serialize, response_deserializer=gcs_comment.Comment.deserialize, @@ -293,7 +379,7 @@ def create_comment( return self._stubs["create_comment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc_asyncio.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc_asyncio.py index 6c4a8fc54284..7a0c271705f8 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,8 +25,11 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.support_v2.types import comment as gcs_comment from google.cloud.support_v2.types import comment_service @@ -31,6 +37,82 @@ from .base import DEFAULT_CLIENT_INFO, CommentServiceTransport from .grpc import CommentServiceGrpcTransport +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.support.v2.CommentService", + "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.support.v2.CommentService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CommentServiceGrpcAsyncIOTransport(CommentServiceTransport): """gRPC AsyncIO backend transport for CommentService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def list_comments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_comments" not in self._stubs: - self._stubs["list_comments"] = self.grpc_channel.unary_unary( + self._stubs["list_comments"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CommentService/ListComments", request_serializer=comment_service.ListCommentsRequest.serialize, response_deserializer=comment_service.ListCommentsResponse.deserialize, @@ -296,7 +381,7 @@ def create_comment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_comment" not in self._stubs: - self._stubs["create_comment"] = self.grpc_channel.unary_unary( + self._stubs["create_comment"] = self._logged_channel.unary_unary( "/google.cloud.support.v2.CommentService/CreateComment", request_serializer=comment_service.CreateCommentRequest.serialize, response_deserializer=gcs_comment.Comment.deserialize, @@ -333,7 +418,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/rest.py b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/rest.py index b2c1f115ed8c..d7baf5eb80a4 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/rest.py +++ b/packages/google-cloud-support/google/cloud/support_v2/services/comment_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,8 +94,10 @@ def post_list_comments(self, response): def pre_create_comment( self, request: comment_service.CreateCommentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[comment_service.CreateCommentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + comment_service.CreateCommentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_comment Override in a subclass to manipulate the request or metadata @@ -107,8 +117,10 @@ def post_create_comment(self, response: gcs_comment.Comment) -> gcs_comment.Comm def pre_list_comments( self, request: comment_service.ListCommentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[comment_service.ListCommentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + comment_service.ListCommentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_comments Override in a subclass to manipulate the request or metadata @@ -249,7 +261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcs_comment.Comment: r"""Call the create comment method over HTTP. @@ -260,8 +272,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcs_comment.Comment: @@ -273,6 +287,7 @@ def __call__( http_options = ( _BaseCommentServiceRestTransport._BaseCreateComment._get_http_options() ) + request, metadata = self._interceptor.pre_create_comment(request, metadata) transcoded_request = _BaseCommentServiceRestTransport._BaseCreateComment._get_transcoded_request( http_options, request @@ -287,6 +302,33 @@ def __call__( 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.support_v2.CommentServiceClient.CreateComment", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "rpcName": "CreateComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CommentServiceRestTransport._CreateComment._get_response( self._host, @@ -308,7 +350,29 @@ def __call__( pb_resp = gcs_comment.Comment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_comment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcs_comment.Comment.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.support_v2.CommentServiceClient.create_comment", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "rpcName": "CreateComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListComments( @@ -345,7 +409,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> comment_service.ListCommentsResponse: r"""Call the list comments method over HTTP. @@ -356,8 +420,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.comment_service.ListCommentsResponse: @@ -369,6 +435,7 @@ def __call__( http_options = ( _BaseCommentServiceRestTransport._BaseListComments._get_http_options() ) + request, metadata = self._interceptor.pre_list_comments(request, metadata) transcoded_request = _BaseCommentServiceRestTransport._BaseListComments._get_transcoded_request( http_options, request @@ -379,6 +446,33 @@ def __call__( 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.support_v2.CommentServiceClient.ListComments", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "rpcName": "ListComments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CommentServiceRestTransport._ListComments._get_response( self._host, @@ -399,7 +493,31 @@ def __call__( pb_resp = comment_service.ListCommentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_comments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = comment_service.ListCommentsResponse.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.support_v2.CommentServiceClient.list_comments", + extra={ + "serviceName": "google.cloud.support.v2.CommentService", + "rpcName": "ListComments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json b/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json index 81f47465bfaa..0e2ed2a1f18f 100644 --- a/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json +++ b/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-support", - "version": "0.1.11" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_attachment_service.pagers.ListAttachmentsAsyncPager", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_attachment_service.pagers.ListAttachmentsPager", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -365,7 +365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -526,7 +526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -602,7 +602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -683,7 +683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -844,7 +844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.ListCasesAsyncPager", @@ -924,7 +924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.ListCasesPager", @@ -1001,7 +1001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.SearchCaseClassificationsAsyncPager", @@ -1077,7 +1077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.SearchCaseClassificationsPager", @@ -1154,7 +1154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.SearchCasesAsyncPager", @@ -1230,7 +1230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.case_service.pagers.SearchCasesPager", @@ -1315,7 +1315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -1399,7 +1399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Case", @@ -1484,7 +1484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Comment", @@ -1568,7 +1568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.types.Comment", @@ -1649,7 +1649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.comment_service.pagers.ListCommentsAsyncPager", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.support_v2.services.comment_service.pagers.ListCommentsPager", diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py index a8ed63374d35..2ca6bc4f4560 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py @@ -1755,6 +1755,7 @@ def test_list_attachments_rest_required_fields( response_value._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_attachments(request) @@ -1808,6 +1809,7 @@ def test_list_attachments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_attachments(**mock_args) @@ -2095,6 +2097,7 @@ def test_list_attachments_rest_bad_request( 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_attachments(request) @@ -2130,6 +2133,7 @@ def test_list_attachments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_attachments(request) # Establish that the response is the type that we expect. @@ -2170,6 +2174,7 @@ def test_list_attachments_rest_interceptors(null_interceptor): 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 = attachment_service.ListAttachmentsResponse.to_json( attachment_service.ListAttachmentsResponse() ) diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py index 0d315ef7a9d4..be2dc8ce045f 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py @@ -4128,6 +4128,7 @@ def test_get_case_rest_required_fields(request_type=case_service.GetCaseRequest) response_value._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_case(request) @@ -4173,6 +4174,7 @@ def test_get_case_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_case(**mock_args) @@ -4308,6 +4310,7 @@ def test_list_cases_rest_required_fields(request_type=case_service.ListCasesRequ response_value._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_cases(request) @@ -4362,6 +4365,7 @@ def test_list_cases_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cases(**mock_args) @@ -4648,6 +4652,7 @@ def test_create_case_rest_required_fields(request_type=case_service.CreateCaseRe response_value._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_case(request) @@ -4702,6 +4707,7 @@ def test_create_case_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_case(**mock_args) @@ -4828,6 +4834,7 @@ def test_update_case_rest_required_fields(request_type=case_service.UpdateCaseRe response_value._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_case(request) @@ -4874,6 +4881,7 @@ def test_update_case_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_case(**mock_args) @@ -5005,6 +5013,7 @@ def test_escalate_case_rest_required_fields( response_value._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.escalate_case(request) @@ -5123,6 +5132,7 @@ def test_close_case_rest_required_fields(request_type=case_service.CloseCaseRequ response_value._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.close_case(request) @@ -5828,6 +5838,7 @@ def test_get_case_rest_bad_request(request_type=case_service.GetCaseRequest): 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_case(request) @@ -5873,6 +5884,7 @@ def test_get_case_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_case(request) # Establish that the response is the type that we expect. @@ -5921,6 +5933,7 @@ def test_get_case_rest_interceptors(null_interceptor): 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 = case.Case.to_json(case.Case()) req.return_value.content = return_value @@ -5963,6 +5976,7 @@ def test_list_cases_rest_bad_request(request_type=case_service.ListCasesRequest) 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_cases(request) @@ -5998,6 +6012,7 @@ def test_list_cases_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cases(request) # Establish that the response is the type that we expect. @@ -6036,6 +6051,7 @@ def test_list_cases_rest_interceptors(null_interceptor): 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 = case_service.ListCasesResponse.to_json( case_service.ListCasesResponse() ) @@ -6080,6 +6096,7 @@ def test_search_cases_rest_bad_request(request_type=case_service.SearchCasesRequ 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.search_cases(request) @@ -6115,6 +6132,7 @@ def test_search_cases_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_cases(request) # Establish that the response is the type that we expect. @@ -6155,6 +6173,7 @@ def test_search_cases_rest_interceptors(null_interceptor): 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 = case_service.SearchCasesResponse.to_json( case_service.SearchCasesResponse() ) @@ -6199,6 +6218,7 @@ def test_create_case_rest_bad_request(request_type=case_service.CreateCaseReques 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_case(request) @@ -6335,6 +6355,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_case(request) # Establish that the response is the type that we expect. @@ -6383,6 +6404,7 @@ def test_create_case_rest_interceptors(null_interceptor): 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 = gcs_case.Case.to_json(gcs_case.Case()) req.return_value.content = return_value @@ -6425,6 +6447,7 @@ def test_update_case_rest_bad_request(request_type=case_service.UpdateCaseReques 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_case(request) @@ -6561,6 +6584,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_case(request) # Establish that the response is the type that we expect. @@ -6609,6 +6633,7 @@ def test_update_case_rest_interceptors(null_interceptor): 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 = gcs_case.Case.to_json(gcs_case.Case()) req.return_value.content = return_value @@ -6651,6 +6676,7 @@ def test_escalate_case_rest_bad_request(request_type=case_service.EscalateCaseRe 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.escalate_case(request) @@ -6696,6 +6722,7 @@ def test_escalate_case_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.escalate_case(request) # Establish that the response is the type that we expect. @@ -6746,6 +6773,7 @@ def test_escalate_case_rest_interceptors(null_interceptor): 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 = case.Case.to_json(case.Case()) req.return_value.content = return_value @@ -6788,6 +6816,7 @@ def test_close_case_rest_bad_request(request_type=case_service.CloseCaseRequest) 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.close_case(request) @@ -6833,6 +6862,7 @@ def test_close_case_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.close_case(request) # Establish that the response is the type that we expect. @@ -6881,6 +6911,7 @@ def test_close_case_rest_interceptors(null_interceptor): 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 = case.Case.to_json(case.Case()) req.return_value.content = return_value @@ -6925,6 +6956,7 @@ def test_search_case_classifications_rest_bad_request( 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.search_case_classifications(request) @@ -6960,6 +6992,7 @@ def test_search_case_classifications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_case_classifications(request) # Establish that the response is the type that we expect. @@ -7000,6 +7033,7 @@ def test_search_case_classifications_rest_interceptors(null_interceptor): 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 = case_service.SearchCaseClassificationsResponse.to_json( case_service.SearchCaseClassificationsResponse() ) diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py index 5af6c4e82fa1..79f9072b3ce4 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py @@ -2029,6 +2029,7 @@ def test_list_comments_rest_required_fields( response_value._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_comments(request) @@ -2082,6 +2083,7 @@ def test_list_comments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_comments(**mock_args) @@ -2276,6 +2278,7 @@ def test_create_comment_rest_required_fields( response_value._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_comment(request) @@ -2330,6 +2333,7 @@ def test_create_comment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_comment(**mock_args) @@ -2605,6 +2609,7 @@ def test_list_comments_rest_bad_request( 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_comments(request) @@ -2640,6 +2645,7 @@ def test_list_comments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_comments(request) # Establish that the response is the type that we expect. @@ -2680,6 +2686,7 @@ def test_list_comments_rest_interceptors(null_interceptor): 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 = comment_service.ListCommentsResponse.to_json( comment_service.ListCommentsResponse() ) @@ -2726,6 +2733,7 @@ def test_create_comment_rest_bad_request( 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_comment(request) @@ -2841,6 +2849,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_comment(request) # Establish that the response is the type that we expect. @@ -2883,6 +2892,7 @@ def test_create_comment_rest_interceptors(null_interceptor): 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 = gcs_comment.Comment.to_json(gcs_comment.Comment()) req.return_value.content = return_value diff --git a/packages/google-cloud-talent/google/cloud/talent/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-talent/google/cloud/talent/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/async_client.py index 3207524cddd1..283a53922366 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompanyServiceTransport from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport +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 CompanyServiceAsyncClient: """A service that handles company management, including CRUD and @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4.CompanyServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "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.talent.v4.CompanyService", + "credentialsType": None, + }, + ) + async def create_company( self, request: Optional[Union[company_service.CreateCompanyRequest, dict]] = None, @@ -272,7 +304,7 @@ async def create_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Creates a new company entity. @@ -330,8 +362,10 @@ async def sample_create_company(): 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, 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: google.cloud.talent_v4.types.Company: @@ -398,7 +432,7 @@ async def get_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Retrieves specified company. @@ -447,8 +481,10 @@ async def sample_get_company(): 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, 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: google.cloud.talent_v4.types.Company: @@ -514,7 +550,7 @@ async def update_company( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Updates specified company. @@ -579,8 +615,10 @@ async def sample_update_company(): 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, 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: google.cloud.talent_v4.types.Company: @@ -649,7 +687,7 @@ async def delete_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified company. Prerequisite: The company has no jobs associated with @@ -695,8 +733,10 @@ async def sample_delete_company(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -748,7 +788,7 @@ async def list_companies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCompaniesAsyncPager: r"""Lists all companies associated with the project. @@ -797,8 +837,10 @@ async def sample_list_companies(): 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, 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: google.cloud.talent_v4.services.company_service.pagers.ListCompaniesAsyncPager: @@ -872,7 +914,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -883,8 +925,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/client.py index d16a02a449cb..69cd7fd60bbc 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -603,6 +613,10 @@ def __init__( # 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( @@ -668,6 +682,29 @@ def __init__( 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.talent_v4.CompanyServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "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.talent.v4.CompanyService", + "credentialsType": None, + }, + ) + def create_company( self, request: Optional[Union[company_service.CreateCompanyRequest, dict]] = None, @@ -676,7 +713,7 @@ def create_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Creates a new company entity. @@ -734,8 +771,10 @@ def sample_create_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Company: @@ -799,7 +838,7 @@ def get_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Retrieves specified company. @@ -848,8 +887,10 @@ def sample_get_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Company: @@ -912,7 +953,7 @@ def update_company( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Updates specified company. @@ -977,8 +1018,10 @@ def sample_update_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Company: @@ -1044,7 +1087,7 @@ def delete_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified company. Prerequisite: The company has no jobs associated with @@ -1090,8 +1133,10 @@ def sample_delete_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1140,7 +1185,7 @@ def list_companies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCompaniesPager: r"""Lists all companies associated with the project. @@ -1189,8 +1234,10 @@ def sample_list_companies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.services.company_service.pagers.ListCompaniesPager: @@ -1274,7 +1321,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1285,8 +1332,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/pagers.py index 79b9da32dfb3..e18d937a1d08 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = company_service.ListCompaniesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = company_service.ListCompaniesRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc.py index 48472a88d71c..8c6f38c36b09 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import company from google.cloud.talent_v4.types import company as gct_company @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, CompanyServiceTransport +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.talent.v4.CompanyService", + "rpcName": 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.talent.v4.CompanyService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompanyServiceGrpcTransport(CompanyServiceTransport): """gRPC backend transport for CompanyService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_company" not in self._stubs: - self._stubs["create_company"] = self.grpc_channel.unary_unary( + self._stubs["create_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/CreateCompany", request_serializer=company_service.CreateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -284,7 +370,7 @@ def get_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_company" not in self._stubs: - self._stubs["get_company"] = self.grpc_channel.unary_unary( + self._stubs["get_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/GetCompany", request_serializer=company_service.GetCompanyRequest.serialize, response_deserializer=company.Company.deserialize, @@ -310,7 +396,7 @@ def update_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_company" not in self._stubs: - self._stubs["update_company"] = self.grpc_channel.unary_unary( + self._stubs["update_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/UpdateCompany", request_serializer=company_service.UpdateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -338,7 +424,7 @@ def delete_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_company" not in self._stubs: - self._stubs["delete_company"] = self.grpc_channel.unary_unary( + self._stubs["delete_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/DeleteCompany", request_serializer=company_service.DeleteCompanyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -366,7 +452,7 @@ def list_companies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_companies" not in self._stubs: - self._stubs["list_companies"] = self.grpc_channel.unary_unary( + self._stubs["list_companies"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/ListCompanies", request_serializer=company_service.ListCompaniesRequest.serialize, response_deserializer=company_service.ListCompaniesResponse.deserialize, @@ -374,7 +460,7 @@ def list_companies( return self._stubs["list_companies"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -386,7 +472,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py index ede136d93fe7..b7fbf25282f5 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import company from google.cloud.talent_v4.types import company as gct_company @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, CompanyServiceTransport from .grpc import CompanyServiceGrpcTransport +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.talent.v4.CompanyService", + "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.talent.v4.CompanyService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): """gRPC AsyncIO backend transport for CompanyService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_company" not in self._stubs: - self._stubs["create_company"] = self.grpc_channel.unary_unary( + self._stubs["create_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/CreateCompany", request_serializer=company_service.CreateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -294,7 +379,7 @@ def get_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_company" not in self._stubs: - self._stubs["get_company"] = self.grpc_channel.unary_unary( + self._stubs["get_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/GetCompany", request_serializer=company_service.GetCompanyRequest.serialize, response_deserializer=company.Company.deserialize, @@ -322,7 +407,7 @@ def update_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_company" not in self._stubs: - self._stubs["update_company"] = self.grpc_channel.unary_unary( + self._stubs["update_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/UpdateCompany", request_serializer=company_service.UpdateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -350,7 +435,7 @@ def delete_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_company" not in self._stubs: - self._stubs["delete_company"] = self.grpc_channel.unary_unary( + self._stubs["delete_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/DeleteCompany", request_serializer=company_service.DeleteCompanyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -379,7 +464,7 @@ def list_companies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_companies" not in self._stubs: - self._stubs["list_companies"] = self.grpc_channel.unary_unary( + self._stubs["list_companies"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.CompanyService/ListCompanies", request_serializer=company_service.ListCompaniesRequest.serialize, response_deserializer=company_service.ListCompaniesResponse.deserialize, @@ -457,7 +542,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -473,7 +558,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/rest.py index 6e26892669d2..b29794aa8172 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/company_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -109,8 +117,10 @@ def post_update_company(self, response): def pre_create_company( self, request: company_service.CreateCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.CreateCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.CreateCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_company Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_create_company(self, response: gct_company.Company) -> gct_company.Comp def pre_delete_company( self, request: company_service.DeleteCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.DeleteCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.DeleteCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_company Override in a subclass to manipulate the request or metadata @@ -142,8 +154,10 @@ def pre_delete_company( def pre_get_company( self, request: company_service.GetCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.GetCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.GetCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_company Override in a subclass to manipulate the request or metadata @@ -163,8 +177,10 @@ def post_get_company(self, response: company.Company) -> company.Company: def pre_list_companies( self, request: company_service.ListCompaniesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.ListCompaniesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.ListCompaniesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_companies Override in a subclass to manipulate the request or metadata @@ -186,8 +202,10 @@ def post_list_companies( def pre_update_company( self, request: company_service.UpdateCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.UpdateCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.UpdateCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_company Override in a subclass to manipulate the request or metadata @@ -207,8 +225,10 @@ def post_update_company(self, response: gct_company.Company) -> gct_company.Comp def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -350,7 +370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Call the create company method over HTTP. @@ -361,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_company.Company: @@ -378,6 +400,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseCreateCompany._get_http_options() ) + request, metadata = self._interceptor.pre_create_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseCreateCompany._get_transcoded_request( http_options, request @@ -392,6 +415,33 @@ def __call__( 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.talent_v4.CompanyServiceClient.CreateCompany", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "CreateCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._CreateCompany._get_response( self._host, @@ -413,7 +463,29 @@ def __call__( pb_resp = gct_company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_company.Company.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.talent_v4.CompanyServiceClient.create_company", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "CreateCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCompany( @@ -450,7 +522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete company method over HTTP. @@ -460,13 +532,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCompanyServiceRestTransport._BaseDeleteCompany._get_http_options() ) + request, metadata = self._interceptor.pre_delete_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseDeleteCompany._get_transcoded_request( http_options, request @@ -477,6 +552,33 @@ def __call__( 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.talent_v4.CompanyServiceClient.DeleteCompany", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "DeleteCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._DeleteCompany._get_response( self._host, @@ -526,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Call the get company method over HTTP. @@ -537,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.company.Company: @@ -554,6 +658,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetCompany._get_http_options() ) + request, metadata = self._interceptor.pre_get_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetCompany._get_transcoded_request( http_options, request @@ -566,6 +671,33 @@ def __call__( ) ) + 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.talent_v4.CompanyServiceClient.GetCompany", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "GetCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetCompany._get_response( self._host, @@ -586,7 +718,29 @@ def __call__( pb_resp = company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company.Company.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.talent_v4.CompanyServiceClient.get_company", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "GetCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCompanies( @@ -623,7 +777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company_service.ListCompaniesResponse: r"""Call the list companies method over HTTP. @@ -634,8 +788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.company_service.ListCompaniesResponse: @@ -645,6 +801,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseListCompanies._get_http_options() ) + request, metadata = self._interceptor.pre_list_companies(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseListCompanies._get_transcoded_request( http_options, request @@ -655,6 +812,33 @@ def __call__( 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.talent_v4.CompanyServiceClient.ListCompanies", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "ListCompanies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._ListCompanies._get_response( self._host, @@ -675,7 +859,31 @@ def __call__( pb_resp = company_service.ListCompaniesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_companies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company_service.ListCompaniesResponse.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.talent_v4.CompanyServiceClient.list_companies", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "ListCompanies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCompany( @@ -713,7 +921,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Call the update company method over HTTP. @@ -724,8 +932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_company.Company: @@ -741,6 +951,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseUpdateCompany._get_http_options() ) + request, metadata = self._interceptor.pre_update_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseUpdateCompany._get_transcoded_request( http_options, request @@ -755,6 +966,33 @@ def __call__( 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.talent_v4.CompanyServiceClient.UpdateCompany", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "UpdateCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._UpdateCompany._get_response( self._host, @@ -776,7 +1014,29 @@ def __call__( pb_resp = gct_company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_company.Company.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.talent_v4.CompanyServiceClient.update_company", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "UpdateCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -859,7 +1119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -869,8 +1129,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -879,6 +1141,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -889,6 +1152,33 @@ def __call__( 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.talent_v4.CompanyServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetOperation._get_response( self._host, @@ -908,6 +1198,27 @@ def __call__( 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.talent_v4.CompanyServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.CompanyService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/async_client.py index e889063b59e2..7f1b82c28424 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompletionTransport from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport +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 CompletionAsyncClient: """A service handles auto completion.""" @@ -251,13 +261,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4.CompletionAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "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.talent.v4.Completion", + "credentialsType": None, + }, + ) + async def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. Intended for use by a job search @@ -297,8 +329,10 @@ async def sample_complete_query(): 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, 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: google.cloud.talent_v4.types.CompleteQueryResponse: @@ -342,7 +376,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -353,8 +387,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/client.py index d63bd4a526bc..0ba561b4687e 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.talent_v4.types import common, completion_service @@ -594,6 +604,10 @@ def __init__( # 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( @@ -656,13 +670,36 @@ def __init__( 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.talent_v4.CompletionClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "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.talent.v4.Completion", + "credentialsType": None, + }, + ) + def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. Intended for use by a job search @@ -702,8 +739,10 @@ def sample_complete_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.CompleteQueryResponse: @@ -758,7 +797,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -769,8 +808,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc.py index 5d4ecaf18517..814c3a38ce50 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import completion_service from .base import DEFAULT_CLIENT_INFO, CompletionTransport +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.talent.v4.Completion", + "rpcName": 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.talent.v4.Completion", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionGrpcTransport(CompletionTransport): """gRPC backend transport for Completion. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.Completion/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -267,7 +353,7 @@ def complete_query( return self._stubs["complete_query"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -279,7 +365,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py index 5bd048655bc5..f0a04097a740 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import completion_service from .base import DEFAULT_CLIENT_INFO, CompletionTransport from .grpc import CompletionGrpcTransport +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.talent.v4.Completion", + "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.talent.v4.Completion", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionGrpcAsyncIOTransport(CompletionTransport): """gRPC AsyncIO backend transport for Completion. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.Completion/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -305,7 +390,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -321,7 +406,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/rest.py index 4249a12e8caf..aa27f8d55749 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/completion/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_complete_query(self, response): def pre_complete_query( self, request: completion_service.CompleteQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[completion_service.CompleteQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + completion_service.CompleteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_query Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_complete_query( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -242,7 +254,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Call the complete query method over HTTP. @@ -252,8 +264,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.completion_service.CompleteQueryResponse: @@ -263,6 +277,7 @@ def __call__( http_options = ( _BaseCompletionRestTransport._BaseCompleteQuery._get_http_options() ) + request, metadata = self._interceptor.pre_complete_query(request, metadata) transcoded_request = ( _BaseCompletionRestTransport._BaseCompleteQuery._get_transcoded_request( @@ -277,6 +292,33 @@ def __call__( ) ) + 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.talent_v4.CompletionClient.CompleteQuery", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "rpcName": "CompleteQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionRestTransport._CompleteQuery._get_response( self._host, @@ -297,7 +339,31 @@ def __call__( pb_resp = completion_service.CompleteQueryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = completion_service.CompleteQueryResponse.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.talent_v4.CompletionClient.complete_query", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "rpcName": "CompleteQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -349,7 +415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -359,8 +425,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -369,6 +437,7 @@ def __call__( http_options = ( _BaseCompletionRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseCompletionRestTransport._BaseGetOperation._get_transcoded_request( @@ -383,6 +452,33 @@ def __call__( ) ) + 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.talent_v4.CompletionClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionRestTransport._GetOperation._get_response( self._host, @@ -402,6 +498,27 @@ def __call__( 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.talent_v4.CompletionAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.Completion", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/async_client.py index 5d21e75997f7..c0bd78965499 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EventServiceTransport from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport +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 EventServiceAsyncClient: """A service handles client event report.""" @@ -252,6 +262,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4.EventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "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.talent.v4.EventService", + "credentialsType": None, + }, + ) + async def create_client_event( self, request: Optional[Union[event_service.CreateClientEventRequest, dict]] = None, @@ -260,7 +292,7 @@ async def create_client_event( client_event: Optional[event.ClientEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Report events issued when end user interacts with customer's application that uses Cloud Talent Solution. You may inspect the @@ -327,8 +359,10 @@ async def sample_create_client_event(): 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, 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: google.cloud.talent_v4.types.ClientEvent: @@ -398,7 +432,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -409,8 +443,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/client.py index d65e4c2a676e..52a1164f117f 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -573,6 +583,10 @@ def __init__( # 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( @@ -635,6 +649,29 @@ def __init__( 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.talent_v4.EventServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "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.talent.v4.EventService", + "credentialsType": None, + }, + ) + def create_client_event( self, request: Optional[Union[event_service.CreateClientEventRequest, dict]] = None, @@ -643,7 +680,7 @@ def create_client_event( client_event: Optional[event.ClientEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Report events issued when end user interacts with customer's application that uses Cloud Talent Solution. You may inspect the @@ -710,8 +747,10 @@ def sample_create_client_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.ClientEvent: @@ -791,7 +830,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -802,8 +841,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc.py index 8731192f3548..e8e5f11fa567 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import event, event_service from .base import DEFAULT_CLIENT_INFO, EventServiceTransport +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.talent.v4.EventService", + "rpcName": 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.talent.v4.EventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EventServiceGrpcTransport(EventServiceTransport): """gRPC backend transport for EventService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def create_client_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_event" not in self._stubs: - self._stubs["create_client_event"] = self.grpc_channel.unary_unary( + self._stubs["create_client_event"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.EventService/CreateClientEvent", request_serializer=event_service.CreateClientEventRequest.serialize, response_deserializer=event.ClientEvent.deserialize, @@ -268,7 +354,7 @@ def create_client_event( return self._stubs["create_client_event"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -280,7 +366,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py index f826469ba8b7..5abf00d2ebcc 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import event, event_service from .base import DEFAULT_CLIENT_INFO, EventServiceTransport from .grpc import EventServiceGrpcTransport +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.talent.v4.EventService", + "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.talent.v4.EventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EventServiceGrpcAsyncIOTransport(EventServiceTransport): """gRPC AsyncIO backend transport for EventService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def create_client_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_event" not in self._stubs: - self._stubs["create_client_event"] = self.grpc_channel.unary_unary( + self._stubs["create_client_event"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.EventService/CreateClientEvent", request_serializer=event_service.CreateClientEventRequest.serialize, response_deserializer=event.ClientEvent.deserialize, @@ -298,7 +383,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -314,7 +399,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/rest.py index 995f8f769a99..a8ad1e32e44a 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_create_client_event(self, response): def pre_create_client_event( self, request: event_service.CreateClientEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_service.CreateClientEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_service.CreateClientEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_client_event Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_create_client_event( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -243,7 +255,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Call the create client event method over HTTP. @@ -253,8 +265,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event.ClientEvent: @@ -274,6 +288,7 @@ def __call__( http_options = ( _BaseEventServiceRestTransport._BaseCreateClientEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_client_event( request, metadata ) @@ -290,6 +305,33 @@ def __call__( 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.talent_v4.EventServiceClient.CreateClientEvent", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "rpcName": "CreateClientEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EventServiceRestTransport._CreateClientEvent._get_response( self._host, @@ -311,7 +353,29 @@ def __call__( pb_resp = event.ClientEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_client_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event.ClientEvent.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.talent_v4.EventServiceClient.create_client_event", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "rpcName": "CreateClientEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -360,7 +424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -370,8 +434,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -380,6 +446,7 @@ def __call__( http_options = ( _BaseEventServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEventServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -392,6 +459,33 @@ def __call__( ) ) + 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.talent_v4.EventServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EventServiceRestTransport._GetOperation._get_response( self._host, @@ -411,6 +505,27 @@ def __call__( 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.talent_v4.EventServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.EventService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/async_client.py index 4b6be7ecf1cb..af0da5fb5846 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, JobServiceTransport from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport +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 JobServiceAsyncClient: """A service handles job management, including job CRUD, @@ -263,6 +273,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4.JobServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "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.talent.v4.JobService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[job_service.CreateJobRequest, dict]] = None, @@ -271,7 +303,7 @@ async def create_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Creates a new job. @@ -333,8 +365,10 @@ async def sample_create_job(): 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, 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: google.cloud.talent_v4.types.Job: @@ -400,7 +434,7 @@ async def batch_create_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Begins executing a batch create jobs operation. @@ -466,8 +500,10 @@ async def sample_batch_create_jobs(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -543,7 +579,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days. @@ -590,8 +626,10 @@ async def sample_get_job(): 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, 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: google.cloud.talent_v4.types.Job: @@ -653,7 +691,7 @@ async def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Updates specified job. @@ -720,8 +758,10 @@ async def sample_update_job(): 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, 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: google.cloud.talent_v4.types.Job: @@ -787,7 +827,7 @@ async def batch_update_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Begins executing a batch update jobs operation. @@ -853,8 +893,10 @@ async def sample_batch_update_jobs(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -930,7 +972,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified job. @@ -976,8 +1018,10 @@ async def sample_delete_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1030,7 +1074,7 @@ async def batch_delete_jobs( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Begins executing a batch delete jobs operation. @@ -1096,8 +1140,10 @@ async def sample_batch_delete_jobs(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1174,7 +1220,7 @@ async def list_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs by filter. @@ -1255,8 +1301,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.talent_v4.services.job_service.pagers.ListJobsAsyncPager: @@ -1332,7 +1380,7 @@ async def search_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. @@ -1374,8 +1422,10 @@ async def sample_search_jobs(): 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, 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: google.cloud.talent_v4.types.SearchJobsResponse: @@ -1419,7 +1469,7 @@ async def search_jobs_for_alert( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. @@ -1467,8 +1517,10 @@ async def sample_search_jobs_for_alert(): 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, 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: google.cloud.talent_v4.types.SearchJobsResponse: @@ -1512,7 +1564,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1523,8 +1575,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/client.py index 0fe5313648fc..e9eec7f70c9c 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -626,6 +636,10 @@ def __init__( # 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( @@ -688,6 +702,29 @@ def __init__( 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.talent_v4.JobServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "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.talent.v4.JobService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[job_service.CreateJobRequest, dict]] = None, @@ -696,7 +733,7 @@ def create_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Creates a new job. @@ -758,8 +795,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Job: @@ -822,7 +861,7 @@ def batch_create_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Begins executing a batch create jobs operation. @@ -888,8 +927,10 @@ def sample_batch_create_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -962,7 +1003,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days. @@ -1009,8 +1050,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Job: @@ -1071,7 +1114,7 @@ def update_job( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Updates specified job. @@ -1138,8 +1181,10 @@ def sample_update_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Job: @@ -1202,7 +1247,7 @@ def batch_update_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Begins executing a batch update jobs operation. @@ -1268,8 +1313,10 @@ def sample_batch_update_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1342,7 +1389,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified job. @@ -1388,8 +1435,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1439,7 +1488,7 @@ def batch_delete_jobs( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Begins executing a batch delete jobs operation. @@ -1505,8 +1554,10 @@ def sample_batch_delete_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1580,7 +1631,7 @@ def list_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists jobs by filter. @@ -1661,8 +1712,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.services.job_service.pagers.ListJobsPager: @@ -1735,7 +1788,7 @@ def search_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. @@ -1777,8 +1830,10 @@ def sample_search_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.SearchJobsResponse: @@ -1820,7 +1875,7 @@ def search_jobs_for_alert( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. @@ -1868,8 +1923,10 @@ def sample_search_jobs_for_alert(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.SearchJobsResponse: @@ -1924,7 +1981,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1935,8 +1992,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/pagers.py index 3bf4ac8d9f02..92cb87dce3d6 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = job_service.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = job_service.ListJobsRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc.py index 7a7efaa3705c..2f9f12c66da8 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import job from google.cloud.talent_v4.types import job as gct_job @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, JobServiceTransport +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.talent.v4.JobService", + "rpcName": 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.talent.v4.JobService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobServiceGrpcTransport(JobServiceTransport): """gRPC backend transport for JobService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def create_job(self) -> Callable[[job_service.CreateJobRequest], gct_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/CreateJob", request_serializer=job_service.CreateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -300,7 +388,7 @@ def batch_create_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_jobs" not in self._stubs: - self._stubs["batch_create_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchCreateJobs", request_serializer=job_service.BatchCreateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -325,7 +413,7 @@ def get_job(self) -> Callable[[job_service.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/GetJob", request_serializer=job_service.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -353,7 +441,7 @@ def update_job(self) -> Callable[[job_service.UpdateJobRequest], gct_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/UpdateJob", request_serializer=job_service.UpdateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -379,7 +467,7 @@ def batch_update_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_jobs" not in self._stubs: - self._stubs["batch_update_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchUpdateJobs", request_serializer=job_service.BatchUpdateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +494,7 @@ def delete_job(self) -> Callable[[job_service.DeleteJobRequest], empty_pb2.Empty # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/DeleteJob", request_serializer=job_service.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -432,7 +520,7 @@ def batch_delete_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_jobs" not in self._stubs: - self._stubs["batch_delete_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchDeleteJobs", request_serializer=job_service.BatchDeleteJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -458,7 +546,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/ListJobs", request_serializer=job_service.ListJobsRequest.serialize, response_deserializer=job_service.ListJobsResponse.deserialize, @@ -490,7 +578,7 @@ def search_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs" not in self._stubs: - self._stubs["search_jobs"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/SearchJobs", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -528,7 +616,7 @@ def search_jobs_for_alert( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs_for_alert" not in self._stubs: - self._stubs["search_jobs_for_alert"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs_for_alert"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/SearchJobsForAlert", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -536,7 +624,7 @@ def search_jobs_for_alert( return self._stubs["search_jobs_for_alert"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -548,7 +636,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py index ab2414dd36af..2a4826374eaa 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import job from google.cloud.talent_v4.types import job as gct_job @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, JobServiceTransport from .grpc import JobServiceGrpcTransport +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.talent.v4.JobService", + "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.talent.v4.JobService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobServiceGrpcAsyncIOTransport(JobServiceTransport): """gRPC AsyncIO backend transport for JobService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/CreateJob", request_serializer=job_service.CreateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -314,7 +399,7 @@ def batch_create_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_jobs" not in self._stubs: - self._stubs["batch_create_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchCreateJobs", request_serializer=job_service.BatchCreateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -339,7 +424,7 @@ def get_job(self) -> Callable[[job_service.GetJobRequest], Awaitable[job.Job]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/GetJob", request_serializer=job_service.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -369,7 +454,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/UpdateJob", request_serializer=job_service.UpdateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -397,7 +482,7 @@ def batch_update_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_jobs" not in self._stubs: - self._stubs["batch_update_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchUpdateJobs", request_serializer=job_service.BatchUpdateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -426,7 +511,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/DeleteJob", request_serializer=job_service.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -454,7 +539,7 @@ def batch_delete_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_jobs" not in self._stubs: - self._stubs["batch_delete_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/BatchDeleteJobs", request_serializer=job_service.BatchDeleteJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/ListJobs", request_serializer=job_service.ListJobsRequest.serialize, response_deserializer=job_service.ListJobsResponse.deserialize, @@ -516,7 +601,7 @@ def search_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs" not in self._stubs: - self._stubs["search_jobs"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/SearchJobs", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -556,7 +641,7 @@ def search_jobs_for_alert( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs_for_alert" not in self._stubs: - self._stubs["search_jobs_for_alert"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs_for_alert"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.JobService/SearchJobsForAlert", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -659,7 +744,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -675,7 +760,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/rest.py index 4c0b28e2eac5..9b90138178f1 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/job_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -149,8 +157,10 @@ def post_update_job(self, response): def pre_batch_create_jobs( self, request: job_service.BatchCreateJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchCreateJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchCreateJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_jobs Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_batch_create_jobs( def pre_batch_delete_jobs( self, request: job_service.BatchDeleteJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchDeleteJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchDeleteJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_jobs Override in a subclass to manipulate the request or metadata @@ -195,8 +207,10 @@ def post_batch_delete_jobs( def pre_batch_update_jobs( self, request: job_service.BatchUpdateJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchUpdateJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchUpdateJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_jobs Override in a subclass to manipulate the request or metadata @@ -216,8 +230,10 @@ def post_batch_update_jobs( return response def pre_create_job( - self, request: job_service.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -235,8 +251,10 @@ def post_create_job(self, response: gct_job.Job) -> gct_job.Job: return response def pre_delete_job( - self, request: job_service.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -245,8 +263,10 @@ def pre_delete_job( return request, metadata def pre_get_job( - self, request: job_service.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -264,8 +284,10 @@ def post_get_job(self, response: job.Job) -> job.Job: return response def pre_list_jobs( - self, request: job_service.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -287,8 +309,8 @@ def post_list_jobs( def pre_search_jobs( self, request: job_service.SearchJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_jobs Override in a subclass to manipulate the request or metadata @@ -310,8 +332,8 @@ def post_search_jobs( def pre_search_jobs_for_alert( self, request: job_service.SearchJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_jobs_for_alert Override in a subclass to manipulate the request or metadata @@ -331,8 +353,10 @@ def post_search_jobs_for_alert( return response def pre_update_job( - self, request: job_service.UpdateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.UpdateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.UpdateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -352,8 +376,10 @@ def post_update_job(self, response: gct_job.Job) -> gct_job.Job: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -530,7 +556,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create jobs method over HTTP. @@ -540,8 +566,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -554,6 +582,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseBatchCreateJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_jobs( request, metadata ) @@ -570,6 +599,33 @@ def __call__( 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.talent_v4.JobServiceClient.BatchCreateJobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchCreateJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchCreateJobs._get_response( self._host, @@ -589,7 +645,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_jobs(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.talent_v4.JobServiceClient.batch_create_jobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchCreateJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteJobs( @@ -627,7 +705,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete jobs method over HTTP. @@ -637,8 +715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -651,6 +731,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseBatchDeleteJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_jobs( request, metadata ) @@ -667,6 +748,33 @@ def __call__( 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.talent_v4.JobServiceClient.BatchDeleteJobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchDeleteJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchDeleteJobs._get_response( self._host, @@ -686,7 +794,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_jobs(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.talent_v4.JobServiceClient.batch_delete_jobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchDeleteJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateJobs( @@ -724,7 +854,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update jobs method over HTTP. @@ -734,8 +864,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -748,6 +880,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseBatchUpdateJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_jobs( request, metadata ) @@ -764,6 +897,33 @@ def __call__( 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.talent_v4.JobServiceClient.BatchUpdateJobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchUpdateJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchUpdateJobs._get_response( self._host, @@ -783,7 +943,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_jobs(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.talent_v4.JobServiceClient.batch_update_jobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "BatchUpdateJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateJob(_BaseJobServiceRestTransport._BaseCreateJob, JobServiceRestStub): @@ -819,7 +1001,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Call the create job method over HTTP. @@ -829,8 +1011,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_job.Job: @@ -844,6 +1028,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseCreateJob._get_transcoded_request( @@ -862,6 +1047,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._CreateJob._get_response( self._host, @@ -883,7 +1095,29 @@ def __call__( pb_resp = gct_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_job.Job.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.talent_v4.JobServiceClient.create_job", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob(_BaseJobServiceRestTransport._BaseDeleteJob, JobServiceRestStub): @@ -918,7 +1152,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job method over HTTP. @@ -928,13 +1162,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseJobServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseDeleteJob._get_transcoded_request( @@ -949,6 +1186,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._DeleteJob._get_response( self._host, @@ -996,7 +1260,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -1006,8 +1270,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -1019,6 +1285,7 @@ def __call__( """ http_options = _BaseJobServiceRestTransport._BaseGetJob._get_http_options() + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -1033,6 +1300,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._GetJob._get_response( self._host, @@ -1053,7 +1347,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.talent_v4.JobServiceClient.get_job", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs(_BaseJobServiceRestTransport._BaseListJobs, JobServiceRestStub): @@ -1088,7 +1404,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -1098,8 +1414,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.ListJobsResponse: @@ -1109,6 +1427,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseListJobs._get_transcoded_request( @@ -1123,6 +1442,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._ListJobs._get_response( self._host, @@ -1143,7 +1489,29 @@ def __call__( pb_resp = job_service.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.ListJobsResponse.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.talent_v4.JobServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchJobs(_BaseJobServiceRestTransport._BaseSearchJobs, JobServiceRestStub): @@ -1179,7 +1547,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Call the search jobs method over HTTP. @@ -1189,8 +1557,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.SearchJobsResponse: @@ -1200,6 +1570,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseSearchJobs._get_http_options() ) + request, metadata = self._interceptor.pre_search_jobs(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseSearchJobs._get_transcoded_request( @@ -1218,6 +1589,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.SearchJobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "SearchJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._SearchJobs._get_response( self._host, @@ -1239,7 +1637,29 @@ def __call__( pb_resp = job_service.SearchJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.SearchJobsResponse.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.talent_v4.JobServiceClient.search_jobs", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "SearchJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchJobsForAlert( @@ -1277,7 +1697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Call the search jobs for alert method over HTTP. @@ -1287,8 +1707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.SearchJobsResponse: @@ -1298,6 +1720,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseSearchJobsForAlert._get_http_options() ) + request, metadata = self._interceptor.pre_search_jobs_for_alert( request, metadata ) @@ -1314,6 +1737,33 @@ def __call__( 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.talent_v4.JobServiceClient.SearchJobsForAlert", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "SearchJobsForAlert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._SearchJobsForAlert._get_response( self._host, @@ -1335,7 +1785,29 @@ def __call__( pb_resp = job_service.SearchJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_jobs_for_alert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.SearchJobsResponse.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.talent_v4.JobServiceClient.search_jobs_for_alert", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "SearchJobsForAlert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob(_BaseJobServiceRestTransport._BaseUpdateJob, JobServiceRestStub): @@ -1371,7 +1843,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Call the update job method over HTTP. @@ -1381,8 +1853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_job.Job: @@ -1396,6 +1870,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseUpdateJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1414,6 +1889,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.UpdateJob", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._UpdateJob._get_response( self._host, @@ -1435,7 +1937,29 @@ def __call__( pb_resp = gct_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_job.Job.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.talent_v4.JobServiceClient.update_job", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1548,7 +2072,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1558,8 +2082,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1568,6 +2094,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -1582,6 +2109,33 @@ def __call__( ) ) + 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.talent_v4.JobServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._GetOperation._get_response( self._host, @@ -1601,6 +2155,27 @@ def __call__( 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.talent_v4.JobServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.JobService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/async_client.py index 2c7f9c0f21e8..f6a38659f8b4 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TenantServiceTransport from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport +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 TenantServiceAsyncClient: """A service that handles tenant management, including CRUD and @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4.TenantServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "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.talent.v4.TenantService", + "credentialsType": None, + }, + ) + async def create_tenant( self, request: Optional[Union[tenant_service.CreateTenantRequest, dict]] = None, @@ -269,7 +301,7 @@ async def create_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Creates a new tenant entity. @@ -325,8 +357,10 @@ async def sample_create_tenant(): 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, 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: google.cloud.talent_v4.types.Tenant: @@ -394,7 +428,7 @@ async def get_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Retrieves specified tenant. @@ -441,8 +475,10 @@ async def sample_get_tenant(): 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, 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: google.cloud.talent_v4.types.Tenant: @@ -509,7 +545,7 @@ async def update_tenant( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Updates specified tenant. @@ -573,8 +609,10 @@ async def sample_update_tenant(): 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, 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: google.cloud.talent_v4.types.Tenant: @@ -644,7 +682,7 @@ async def delete_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified tenant. @@ -687,8 +725,10 @@ async def sample_delete_tenant(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -740,7 +780,7 @@ async def list_tenants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTenantsAsyncPager: r"""Lists all tenants associated with the project. @@ -788,8 +828,10 @@ async def sample_list_tenants(): 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, 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: google.cloud.talent_v4.services.tenant_service.pagers.ListTenantsAsyncPager: @@ -863,7 +905,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -874,8 +916,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/client.py index 1ade16b06a01..80e20ba97875 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -578,6 +588,10 @@ def __init__( # 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( @@ -643,6 +657,29 @@ def __init__( 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.talent_v4.TenantServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "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.talent.v4.TenantService", + "credentialsType": None, + }, + ) + def create_tenant( self, request: Optional[Union[tenant_service.CreateTenantRequest, dict]] = None, @@ -651,7 +688,7 @@ def create_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Creates a new tenant entity. @@ -707,8 +744,10 @@ def sample_create_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Tenant: @@ -773,7 +812,7 @@ def get_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Retrieves specified tenant. @@ -820,8 +859,10 @@ def sample_get_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Tenant: @@ -885,7 +926,7 @@ def update_tenant( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Updates specified tenant. @@ -949,8 +990,10 @@ def sample_update_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.types.Tenant: @@ -1017,7 +1060,7 @@ def delete_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified tenant. @@ -1060,8 +1103,10 @@ def sample_delete_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1110,7 +1155,7 @@ def list_tenants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTenantsPager: r"""Lists all tenants associated with the project. @@ -1158,8 +1203,10 @@ def sample_list_tenants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4.services.tenant_service.pagers.ListTenantsPager: @@ -1243,7 +1290,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1254,8 +1301,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/pagers.py index 1bf3001ae265..267516526806 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tenant_service.ListTenantsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tenant_service.ListTenantsRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc.py index 4fa79f78ea99..c70aa6a5d7dc 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import tenant from google.cloud.talent_v4.types import tenant as gct_tenant @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, TenantServiceTransport +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.talent.v4.TenantService", + "rpcName": 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.talent.v4.TenantService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TenantServiceGrpcTransport(TenantServiceTransport): """gRPC backend transport for TenantService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tenant" not in self._stubs: - self._stubs["create_tenant"] = self.grpc_channel.unary_unary( + self._stubs["create_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/CreateTenant", request_serializer=tenant_service.CreateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -282,7 +368,7 @@ def get_tenant(self) -> Callable[[tenant_service.GetTenantRequest], tenant.Tenan # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tenant" not in self._stubs: - self._stubs["get_tenant"] = self.grpc_channel.unary_unary( + self._stubs["get_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/GetTenant", request_serializer=tenant_service.GetTenantRequest.serialize, response_deserializer=tenant.Tenant.deserialize, @@ -308,7 +394,7 @@ def update_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tenant" not in self._stubs: - self._stubs["update_tenant"] = self.grpc_channel.unary_unary( + self._stubs["update_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/UpdateTenant", request_serializer=tenant_service.UpdateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -334,7 +420,7 @@ def delete_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tenant" not in self._stubs: - self._stubs["delete_tenant"] = self.grpc_channel.unary_unary( + self._stubs["delete_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/DeleteTenant", request_serializer=tenant_service.DeleteTenantRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -362,7 +448,7 @@ def list_tenants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tenants" not in self._stubs: - self._stubs["list_tenants"] = self.grpc_channel.unary_unary( + self._stubs["list_tenants"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/ListTenants", request_serializer=tenant_service.ListTenantsRequest.serialize, response_deserializer=tenant_service.ListTenantsResponse.deserialize, @@ -370,7 +456,7 @@ def list_tenants( return self._stubs["list_tenants"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -382,7 +468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py index 00f2c02f83bc..e86538de7af1 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4.types import tenant from google.cloud.talent_v4.types import tenant as gct_tenant @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, TenantServiceTransport from .grpc import TenantServiceGrpcTransport +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.talent.v4.TenantService", + "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.talent.v4.TenantService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): """gRPC AsyncIO backend transport for TenantService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def create_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tenant" not in self._stubs: - self._stubs["create_tenant"] = self.grpc_channel.unary_unary( + self._stubs["create_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/CreateTenant", request_serializer=tenant_service.CreateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -292,7 +377,7 @@ def get_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tenant" not in self._stubs: - self._stubs["get_tenant"] = self.grpc_channel.unary_unary( + self._stubs["get_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/GetTenant", request_serializer=tenant_service.GetTenantRequest.serialize, response_deserializer=tenant.Tenant.deserialize, @@ -318,7 +403,7 @@ def update_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tenant" not in self._stubs: - self._stubs["update_tenant"] = self.grpc_channel.unary_unary( + self._stubs["update_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/UpdateTenant", request_serializer=tenant_service.UpdateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -344,7 +429,7 @@ def delete_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tenant" not in self._stubs: - self._stubs["delete_tenant"] = self.grpc_channel.unary_unary( + self._stubs["delete_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/DeleteTenant", request_serializer=tenant_service.DeleteTenantRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -373,7 +458,7 @@ def list_tenants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tenants" not in self._stubs: - self._stubs["list_tenants"] = self.grpc_channel.unary_unary( + self._stubs["list_tenants"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4.TenantService/ListTenants", request_serializer=tenant_service.ListTenantsRequest.serialize, response_deserializer=tenant_service.ListTenantsResponse.deserialize, @@ -451,7 +536,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -467,7 +552,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/rest.py index 34da9aa10501..9cf5767dc7b6 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/services/tenant_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -109,8 +117,10 @@ def post_update_tenant(self, response): def pre_create_tenant( self, request: tenant_service.CreateTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.CreateTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.CreateTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tenant Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_create_tenant(self, response: gct_tenant.Tenant) -> gct_tenant.Tenant: def pre_delete_tenant( self, request: tenant_service.DeleteTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.DeleteTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.DeleteTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tenant Override in a subclass to manipulate the request or metadata @@ -142,8 +154,10 @@ def pre_delete_tenant( def pre_get_tenant( self, request: tenant_service.GetTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.GetTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.GetTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_tenant Override in a subclass to manipulate the request or metadata @@ -163,8 +177,10 @@ def post_get_tenant(self, response: tenant.Tenant) -> tenant.Tenant: def pre_list_tenants( self, request: tenant_service.ListTenantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.ListTenantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.ListTenantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tenants Override in a subclass to manipulate the request or metadata @@ -186,8 +202,10 @@ def post_list_tenants( def pre_update_tenant( self, request: tenant_service.UpdateTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.UpdateTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.UpdateTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_tenant Override in a subclass to manipulate the request or metadata @@ -207,8 +225,10 @@ def post_update_tenant(self, response: gct_tenant.Tenant) -> gct_tenant.Tenant: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -350,7 +370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Call the create tenant method over HTTP. @@ -361,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_tenant.Tenant: @@ -379,6 +401,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseCreateTenant._get_http_options() ) + request, metadata = self._interceptor.pre_create_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseCreateTenant._get_transcoded_request( http_options, request @@ -393,6 +416,33 @@ def __call__( 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.talent_v4.TenantServiceClient.CreateTenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "CreateTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._CreateTenant._get_response( self._host, @@ -414,7 +464,29 @@ def __call__( pb_resp = gct_tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_tenant.Tenant.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.talent_v4.TenantServiceClient.create_tenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "CreateTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTenant( @@ -451,7 +523,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete tenant method over HTTP. @@ -461,13 +533,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTenantServiceRestTransport._BaseDeleteTenant._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseDeleteTenant._get_transcoded_request( http_options, request @@ -478,6 +553,33 @@ def __call__( 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.talent_v4.TenantServiceClient.DeleteTenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "DeleteTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._DeleteTenant._get_response( self._host, @@ -527,7 +629,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Call the get tenant method over HTTP. @@ -537,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tenant.Tenant: @@ -555,6 +659,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseGetTenant._get_http_options() ) + request, metadata = self._interceptor.pre_get_tenant(request, metadata) transcoded_request = ( _BaseTenantServiceRestTransport._BaseGetTenant._get_transcoded_request( @@ -569,6 +674,33 @@ def __call__( ) ) + 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.talent_v4.TenantServiceClient.GetTenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "GetTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._GetTenant._get_response( self._host, @@ -589,7 +721,29 @@ def __call__( pb_resp = tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tenant.Tenant.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.talent_v4.TenantServiceClient.get_tenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "GetTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTenants( @@ -626,7 +780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant_service.ListTenantsResponse: r"""Call the list tenants method over HTTP. @@ -637,8 +791,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tenant_service.ListTenantsResponse: @@ -648,6 +804,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseListTenants._get_http_options() ) + request, metadata = self._interceptor.pre_list_tenants(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseListTenants._get_transcoded_request( http_options, request @@ -660,6 +817,33 @@ def __call__( ) ) + 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.talent_v4.TenantServiceClient.ListTenants", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "ListTenants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._ListTenants._get_response( self._host, @@ -680,7 +864,31 @@ def __call__( pb_resp = tenant_service.ListTenantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tenants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tenant_service.ListTenantsResponse.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.talent_v4.TenantServiceClient.list_tenants", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "ListTenants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTenant( @@ -718,7 +926,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Call the update tenant method over HTTP. @@ -729,8 +937,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_tenant.Tenant: @@ -747,6 +957,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseUpdateTenant._get_http_options() ) + request, metadata = self._interceptor.pre_update_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseUpdateTenant._get_transcoded_request( http_options, request @@ -761,6 +972,33 @@ def __call__( 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.talent_v4.TenantServiceClient.UpdateTenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "UpdateTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._UpdateTenant._get_response( self._host, @@ -782,7 +1020,29 @@ def __call__( pb_resp = gct_tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_tenant.Tenant.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.talent_v4.TenantServiceClient.update_tenant", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "UpdateTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -863,7 +1123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -873,8 +1133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -883,6 +1145,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -893,6 +1156,33 @@ def __call__( 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.talent_v4.TenantServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._GetOperation._get_response( self._host, @@ -912,6 +1202,27 @@ def __call__( 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.talent_v4.TenantServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4.TenantService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/async_client.py index a53f4205f10e..8db9d254d2cb 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompanyServiceTransport from .transports.grpc_asyncio import CompanyServiceGrpcAsyncIOTransport +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 CompanyServiceAsyncClient: """A service that handles company management, including CRUD and @@ -261,6 +271,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4beta1.CompanyServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "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.talent.v4beta1.CompanyService", + "credentialsType": None, + }, + ) + async def create_company( self, request: Optional[Union[company_service.CreateCompanyRequest, dict]] = None, @@ -269,7 +301,7 @@ async def create_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Creates a new company entity. @@ -329,8 +361,10 @@ async def sample_create_company(): 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, 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: google.cloud.talent_v4beta1.types.Company: @@ -397,7 +431,7 @@ async def get_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Retrieves specified company. @@ -449,8 +483,10 @@ async def sample_get_company(): 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, 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: google.cloud.talent_v4beta1.types.Company: @@ -515,7 +551,7 @@ async def update_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Updates specified company. @@ -564,8 +600,10 @@ async def sample_update_company(): 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, 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: google.cloud.talent_v4beta1.types.Company: @@ -632,7 +670,7 @@ async def delete_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified company. Prerequisite: The company has no jobs associated with @@ -681,8 +719,10 @@ async def sample_delete_company(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -734,7 +774,7 @@ async def list_companies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCompaniesAsyncPager: r"""Lists all companies associated with the project. @@ -786,8 +826,10 @@ async def sample_list_companies(): 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, 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: google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesAsyncPager: @@ -861,7 +903,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -872,8 +914,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/client.py index 05e16a0ee0c1..7c749fd5dd73 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.talent_v4beta1.services.company_service import pagers @@ -585,6 +595,10 @@ def __init__( # 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( @@ -650,6 +664,29 @@ def __init__( 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.talent_v4beta1.CompanyServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "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.talent.v4beta1.CompanyService", + "credentialsType": None, + }, + ) + def create_company( self, request: Optional[Union[company_service.CreateCompanyRequest, dict]] = None, @@ -658,7 +695,7 @@ def create_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Creates a new company entity. @@ -718,8 +755,10 @@ def sample_create_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Company: @@ -783,7 +822,7 @@ def get_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Retrieves specified company. @@ -835,8 +874,10 @@ def sample_get_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Company: @@ -898,7 +939,7 @@ def update_company( company: Optional[gct_company.Company] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Updates specified company. @@ -947,8 +988,10 @@ def sample_update_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Company: @@ -1012,7 +1055,7 @@ def delete_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified company. Prerequisite: The company has no jobs associated with @@ -1061,8 +1104,10 @@ def sample_delete_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1111,7 +1156,7 @@ def list_companies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCompaniesPager: r"""Lists all companies associated with the project. @@ -1163,8 +1208,10 @@ def sample_list_companies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesPager: @@ -1248,7 +1295,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1259,8 +1306,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/pagers.py index 242f6fcc42f1..643edfd803c5 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = company_service.ListCompaniesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = company_service.ListCompaniesRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py index 77a8db95a677..175f76dfd0f1 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import company from google.cloud.talent_v4beta1.types import company as gct_company @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, CompanyServiceTransport +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.talent.v4beta1.CompanyService", + "rpcName": 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.talent.v4beta1.CompanyService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompanyServiceGrpcTransport(CompanyServiceTransport): """gRPC backend transport for CompanyService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_company" not in self._stubs: - self._stubs["create_company"] = self.grpc_channel.unary_unary( + self._stubs["create_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/CreateCompany", request_serializer=company_service.CreateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -284,7 +370,7 @@ def get_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_company" not in self._stubs: - self._stubs["get_company"] = self.grpc_channel.unary_unary( + self._stubs["get_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/GetCompany", request_serializer=company_service.GetCompanyRequest.serialize, response_deserializer=company.Company.deserialize, @@ -310,7 +396,7 @@ def update_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_company" not in self._stubs: - self._stubs["update_company"] = self.grpc_channel.unary_unary( + self._stubs["update_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/UpdateCompany", request_serializer=company_service.UpdateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -338,7 +424,7 @@ def delete_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_company" not in self._stubs: - self._stubs["delete_company"] = self.grpc_channel.unary_unary( + self._stubs["delete_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/DeleteCompany", request_serializer=company_service.DeleteCompanyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -366,7 +452,7 @@ def list_companies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_companies" not in self._stubs: - self._stubs["list_companies"] = self.grpc_channel.unary_unary( + self._stubs["list_companies"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/ListCompanies", request_serializer=company_service.ListCompaniesRequest.serialize, response_deserializer=company_service.ListCompaniesResponse.deserialize, @@ -374,7 +460,7 @@ def list_companies( return self._stubs["list_companies"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -386,7 +472,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py index a7f4db455c08..496735429b36 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import company from google.cloud.talent_v4beta1.types import company as gct_company @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, CompanyServiceTransport from .grpc import CompanyServiceGrpcTransport +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.talent.v4beta1.CompanyService", + "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.talent.v4beta1.CompanyService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompanyServiceGrpcAsyncIOTransport(CompanyServiceTransport): """gRPC AsyncIO backend transport for CompanyService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_company" not in self._stubs: - self._stubs["create_company"] = self.grpc_channel.unary_unary( + self._stubs["create_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/CreateCompany", request_serializer=company_service.CreateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -294,7 +379,7 @@ def get_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_company" not in self._stubs: - self._stubs["get_company"] = self.grpc_channel.unary_unary( + self._stubs["get_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/GetCompany", request_serializer=company_service.GetCompanyRequest.serialize, response_deserializer=company.Company.deserialize, @@ -322,7 +407,7 @@ def update_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_company" not in self._stubs: - self._stubs["update_company"] = self.grpc_channel.unary_unary( + self._stubs["update_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/UpdateCompany", request_serializer=company_service.UpdateCompanyRequest.serialize, response_deserializer=gct_company.Company.deserialize, @@ -350,7 +435,7 @@ def delete_company( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_company" not in self._stubs: - self._stubs["delete_company"] = self.grpc_channel.unary_unary( + self._stubs["delete_company"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/DeleteCompany", request_serializer=company_service.DeleteCompanyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -379,7 +464,7 @@ def list_companies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_companies" not in self._stubs: - self._stubs["list_companies"] = self.grpc_channel.unary_unary( + self._stubs["list_companies"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.CompanyService/ListCompanies", request_serializer=company_service.ListCompaniesRequest.serialize, response_deserializer=company_service.ListCompaniesResponse.deserialize, @@ -457,7 +542,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -473,7 +558,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/rest.py index 3c09bc9006a4..7c8ced42def4 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/company_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -109,8 +117,10 @@ def post_update_company(self, response): def pre_create_company( self, request: company_service.CreateCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.CreateCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.CreateCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_company Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_create_company(self, response: gct_company.Company) -> gct_company.Comp def pre_delete_company( self, request: company_service.DeleteCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.DeleteCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.DeleteCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_company Override in a subclass to manipulate the request or metadata @@ -142,8 +154,10 @@ def pre_delete_company( def pre_get_company( self, request: company_service.GetCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.GetCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.GetCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_company Override in a subclass to manipulate the request or metadata @@ -163,8 +177,10 @@ def post_get_company(self, response: company.Company) -> company.Company: def pre_list_companies( self, request: company_service.ListCompaniesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.ListCompaniesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.ListCompaniesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_companies Override in a subclass to manipulate the request or metadata @@ -186,8 +202,10 @@ def post_list_companies( def pre_update_company( self, request: company_service.UpdateCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.UpdateCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.UpdateCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_company Override in a subclass to manipulate the request or metadata @@ -207,8 +225,10 @@ def post_update_company(self, response: gct_company.Company) -> gct_company.Comp def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -350,7 +370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Call the create company method over HTTP. @@ -361,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_company.Company: @@ -378,6 +400,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseCreateCompany._get_http_options() ) + request, metadata = self._interceptor.pre_create_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseCreateCompany._get_transcoded_request( http_options, request @@ -392,6 +415,33 @@ def __call__( 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.talent_v4beta1.CompanyServiceClient.CreateCompany", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "CreateCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._CreateCompany._get_response( self._host, @@ -413,7 +463,29 @@ def __call__( pb_resp = gct_company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_company.Company.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.talent_v4beta1.CompanyServiceClient.create_company", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "CreateCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCompany( @@ -450,7 +522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete company method over HTTP. @@ -460,13 +532,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCompanyServiceRestTransport._BaseDeleteCompany._get_http_options() ) + request, metadata = self._interceptor.pre_delete_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseDeleteCompany._get_transcoded_request( http_options, request @@ -477,6 +552,33 @@ def __call__( 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.talent_v4beta1.CompanyServiceClient.DeleteCompany", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "DeleteCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._DeleteCompany._get_response( self._host, @@ -526,7 +628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company.Company: r"""Call the get company method over HTTP. @@ -537,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.company.Company: @@ -554,6 +658,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetCompany._get_http_options() ) + request, metadata = self._interceptor.pre_get_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetCompany._get_transcoded_request( http_options, request @@ -566,6 +671,33 @@ def __call__( ) ) + 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.talent_v4beta1.CompanyServiceClient.GetCompany", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "GetCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetCompany._get_response( self._host, @@ -586,7 +718,29 @@ def __call__( pb_resp = company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company.Company.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.talent_v4beta1.CompanyServiceClient.get_company", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "GetCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCompanies( @@ -623,7 +777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company_service.ListCompaniesResponse: r"""Call the list companies method over HTTP. @@ -634,8 +788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.company_service.ListCompaniesResponse: @@ -645,6 +801,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseListCompanies._get_http_options() ) + request, metadata = self._interceptor.pre_list_companies(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseListCompanies._get_transcoded_request( http_options, request @@ -655,6 +812,33 @@ def __call__( 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.talent_v4beta1.CompanyServiceClient.ListCompanies", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "ListCompanies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._ListCompanies._get_response( self._host, @@ -675,7 +859,31 @@ def __call__( pb_resp = company_service.ListCompaniesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_companies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company_service.ListCompaniesResponse.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.talent_v4beta1.CompanyServiceClient.list_companies", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "ListCompanies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCompany( @@ -713,7 +921,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_company.Company: r"""Call the update company method over HTTP. @@ -724,8 +932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_company.Company: @@ -741,6 +951,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseUpdateCompany._get_http_options() ) + request, metadata = self._interceptor.pre_update_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseUpdateCompany._get_transcoded_request( http_options, request @@ -755,6 +966,33 @@ def __call__( 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.talent_v4beta1.CompanyServiceClient.UpdateCompany", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "UpdateCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._UpdateCompany._get_response( self._host, @@ -776,7 +1014,29 @@ def __call__( pb_resp = gct_company.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_company.Company.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.talent_v4beta1.CompanyServiceClient.update_company", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "UpdateCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -859,7 +1119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -869,8 +1129,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -879,6 +1141,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -889,6 +1152,33 @@ def __call__( 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.talent_v4beta1.CompanyServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetOperation._get_response( self._host, @@ -908,6 +1198,27 @@ def __call__( 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.talent_v4beta1.CompanyServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.CompanyService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/async_client.py index eb658225669e..7482e6640e28 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CompletionTransport from .transports.grpc_asyncio import CompletionGrpcAsyncIOTransport +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 CompletionAsyncClient: """A service handles auto completion.""" @@ -249,13 +259,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4beta1.CompletionAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "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.talent.v4beta1.Completion", + "credentialsType": None, + }, + ) + async def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. Intended for use by a job search @@ -295,8 +327,10 @@ async def sample_complete_query(): 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, 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: google.cloud.talent_v4beta1.types.CompleteQueryResponse: @@ -340,7 +374,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -351,8 +385,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/client.py index c87f075f9e36..71cd10d3f048 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.talent_v4beta1.types import common, completion_service @@ -577,6 +587,10 @@ def __init__( # 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( @@ -639,13 +653,36 @@ def __init__( 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.talent_v4beta1.CompletionClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "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.talent.v4beta1.Completion", + "credentialsType": None, + }, + ) + def complete_query( self, request: Optional[Union[completion_service.CompleteQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Completes the specified prefix with keyword suggestions. Intended for use by a job search @@ -685,8 +722,10 @@ def sample_complete_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.CompleteQueryResponse: @@ -741,7 +780,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -752,8 +791,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc.py index dad1255a1b0f..914e3021e776 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import completion_service from .base import DEFAULT_CLIENT_INFO, CompletionTransport +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.talent.v4beta1.Completion", + "rpcName": 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.talent.v4beta1.Completion", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionGrpcTransport(CompletionTransport): """gRPC backend transport for Completion. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.Completion/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -267,7 +353,7 @@ def complete_query( return self._stubs["complete_query"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -279,7 +365,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py index cd61cb7b0aeb..21b4b7babeb1 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import completion_service from .base import DEFAULT_CLIENT_INFO, CompletionTransport from .grpc import CompletionGrpcTransport +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.talent.v4beta1.Completion", + "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.talent.v4beta1.Completion", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CompletionGrpcAsyncIOTransport(CompletionTransport): """gRPC AsyncIO backend transport for Completion. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def complete_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_query" not in self._stubs: - self._stubs["complete_query"] = self.grpc_channel.unary_unary( + self._stubs["complete_query"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.Completion/CompleteQuery", request_serializer=completion_service.CompleteQueryRequest.serialize, response_deserializer=completion_service.CompleteQueryResponse.deserialize, @@ -305,7 +390,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -321,7 +406,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/rest.py index d3b6c7e23cb3..c8f192e373e3 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/completion/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_complete_query(self, response): def pre_complete_query( self, request: completion_service.CompleteQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[completion_service.CompleteQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + completion_service.CompleteQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_query Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_complete_query( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -242,7 +254,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> completion_service.CompleteQueryResponse: r"""Call the complete query method over HTTP. @@ -252,8 +264,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.completion_service.CompleteQueryResponse: @@ -263,6 +277,7 @@ def __call__( http_options = ( _BaseCompletionRestTransport._BaseCompleteQuery._get_http_options() ) + request, metadata = self._interceptor.pre_complete_query(request, metadata) transcoded_request = ( _BaseCompletionRestTransport._BaseCompleteQuery._get_transcoded_request( @@ -277,6 +292,33 @@ def __call__( ) ) + 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.talent_v4beta1.CompletionClient.CompleteQuery", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "rpcName": "CompleteQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionRestTransport._CompleteQuery._get_response( self._host, @@ -297,7 +339,31 @@ def __call__( pb_resp = completion_service.CompleteQueryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = completion_service.CompleteQueryResponse.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.talent_v4beta1.CompletionClient.complete_query", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "rpcName": "CompleteQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -349,7 +415,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -359,8 +425,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -369,6 +437,7 @@ def __call__( http_options = ( _BaseCompletionRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseCompletionRestTransport._BaseGetOperation._get_transcoded_request( @@ -383,6 +452,33 @@ def __call__( ) ) + 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.talent_v4beta1.CompletionClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompletionRestTransport._GetOperation._get_response( self._host, @@ -402,6 +498,27 @@ def __call__( 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.talent_v4beta1.CompletionAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.Completion", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/async_client.py index 36e8693d62b7..417269ddb3a9 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EventServiceTransport from .transports.grpc_asyncio import EventServiceGrpcAsyncIOTransport +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 EventServiceAsyncClient: """A service handles client event report.""" @@ -252,6 +262,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4beta1.EventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "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.talent.v4beta1.EventService", + "credentialsType": None, + }, + ) + async def create_client_event( self, request: Optional[Union[event_service.CreateClientEventRequest, dict]] = None, @@ -260,7 +292,7 @@ async def create_client_event( client_event: Optional[event.ClientEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Report events issued when end user interacts with customer's application that uses Cloud Talent Solution. You may inspect the @@ -329,8 +361,10 @@ async def sample_create_client_event(): 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, 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: google.cloud.talent_v4beta1.types.ClientEvent: @@ -400,7 +434,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -411,8 +445,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/client.py index 750ca5206416..84a0e41cee41 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -578,6 +588,10 @@ def __init__( # 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( @@ -640,6 +654,29 @@ def __init__( 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.talent_v4beta1.EventServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "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.talent.v4beta1.EventService", + "credentialsType": None, + }, + ) + def create_client_event( self, request: Optional[Union[event_service.CreateClientEventRequest, dict]] = None, @@ -648,7 +685,7 @@ def create_client_event( client_event: Optional[event.ClientEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Report events issued when end user interacts with customer's application that uses Cloud Talent Solution. You may inspect the @@ -717,8 +754,10 @@ def sample_create_client_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.ClientEvent: @@ -798,7 +837,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -809,8 +848,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py index a12bd4f0ccd1..292733a54802 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import event, event_service from .base import DEFAULT_CLIENT_INFO, EventServiceTransport +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.talent.v4beta1.EventService", + "rpcName": 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.talent.v4beta1.EventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EventServiceGrpcTransport(EventServiceTransport): """gRPC backend transport for EventService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def create_client_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_event" not in self._stubs: - self._stubs["create_client_event"] = self.grpc_channel.unary_unary( + self._stubs["create_client_event"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.EventService/CreateClientEvent", request_serializer=event_service.CreateClientEventRequest.serialize, response_deserializer=event.ClientEvent.deserialize, @@ -268,7 +354,7 @@ def create_client_event( return self._stubs["create_client_event"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -280,7 +366,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py index 421a0c4d1b76..e30dce97d1eb 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import event, event_service from .base import DEFAULT_CLIENT_INFO, EventServiceTransport from .grpc import EventServiceGrpcTransport +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.talent.v4beta1.EventService", + "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.talent.v4beta1.EventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EventServiceGrpcAsyncIOTransport(EventServiceTransport): """gRPC AsyncIO backend transport for EventService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,7 @@ def create_client_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_event" not in self._stubs: - self._stubs["create_client_event"] = self.grpc_channel.unary_unary( + self._stubs["create_client_event"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.EventService/CreateClientEvent", request_serializer=event_service.CreateClientEventRequest.serialize, response_deserializer=event.ClientEvent.deserialize, @@ -298,7 +383,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -314,7 +399,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/rest.py index ddc9557d0d27..e085991140a3 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,10 @@ def post_create_client_event(self, response): def pre_create_client_event( self, request: event_service.CreateClientEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[event_service.CreateClientEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + event_service.CreateClientEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_client_event Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_create_client_event( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -243,7 +255,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event.ClientEvent: r"""Call the create client event method over HTTP. @@ -253,8 +265,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.event.ClientEvent: @@ -274,6 +288,7 @@ def __call__( http_options = ( _BaseEventServiceRestTransport._BaseCreateClientEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_client_event( request, metadata ) @@ -290,6 +305,33 @@ def __call__( 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.talent_v4beta1.EventServiceClient.CreateClientEvent", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "rpcName": "CreateClientEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EventServiceRestTransport._CreateClientEvent._get_response( self._host, @@ -311,7 +353,29 @@ def __call__( pb_resp = event.ClientEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_client_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event.ClientEvent.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.talent_v4beta1.EventServiceClient.create_client_event", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "rpcName": "CreateClientEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -360,7 +424,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -370,8 +434,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -380,6 +446,7 @@ def __call__( http_options = ( _BaseEventServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEventServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -392,6 +459,33 @@ def __call__( ) ) + 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.talent_v4beta1.EventServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EventServiceRestTransport._GetOperation._get_response( self._host, @@ -411,6 +505,27 @@ def __call__( 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.talent_v4beta1.EventServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.EventService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/async_client.py index 58f1eeb4460f..ee668a8e8228 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, JobServiceTransport from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport +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 JobServiceAsyncClient: """A service handles job management, including job CRUD, @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4beta1.JobServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "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.talent.v4beta1.JobService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[job_service.CreateJobRequest, dict]] = None, @@ -268,7 +300,7 @@ async def create_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Creates a new job. @@ -332,8 +364,10 @@ async def sample_create_job(): 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, 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: google.cloud.talent_v4beta1.types.Job: @@ -399,7 +433,7 @@ async def batch_create_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Begins executing a batch create jobs operation. @@ -464,8 +498,10 @@ async def sample_batch_create_jobs(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -543,7 +579,7 @@ async def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days. @@ -593,8 +629,10 @@ async def sample_get_job(): 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, 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: google.cloud.talent_v4beta1.types.Job: @@ -655,7 +693,7 @@ async def update_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Updates specified job. @@ -706,8 +744,10 @@ async def sample_update_job(): 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, 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: google.cloud.talent_v4beta1.types.Job: @@ -771,7 +811,7 @@ async def batch_update_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Begins executing a batch update jobs operation. @@ -836,8 +876,10 @@ async def sample_batch_update_jobs(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -915,7 +957,7 @@ async def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified job. @@ -964,8 +1006,10 @@ async def sample_delete_job(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1018,7 +1062,7 @@ async def batch_delete_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by filter. @@ -1083,8 +1127,10 @@ async def sample_batch_delete_jobs(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1139,7 +1185,7 @@ async def list_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs by filter. @@ -1222,8 +1268,10 @@ async def sample_list_jobs(): 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, 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: google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager: @@ -1299,7 +1347,7 @@ async def search_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchJobsAsyncPager: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. @@ -1342,8 +1390,10 @@ async def sample_search_jobs(): 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, 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: google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsAsyncPager: @@ -1403,7 +1453,7 @@ async def search_jobs_for_alert( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchJobsForAlertAsyncPager: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. @@ -1452,8 +1502,10 @@ async def sample_search_jobs_for_alert(): 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, 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: google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertAsyncPager: @@ -1513,7 +1565,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1524,8 +1576,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/client.py index 01a9141183b4..a30181bfe478 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -608,6 +618,10 @@ def __init__( # 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( @@ -670,6 +684,29 @@ def __init__( 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.talent_v4beta1.JobServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "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.talent.v4beta1.JobService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[job_service.CreateJobRequest, dict]] = None, @@ -678,7 +715,7 @@ def create_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Creates a new job. @@ -742,8 +779,10 @@ def sample_create_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Job: @@ -806,7 +845,7 @@ def batch_create_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Begins executing a batch create jobs operation. @@ -871,8 +910,10 @@ def sample_batch_create_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -947,7 +988,7 @@ def get_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days. @@ -997,8 +1038,10 @@ def sample_get_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Job: @@ -1058,7 +1101,7 @@ def update_job( job: Optional[gct_job.Job] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Updates specified job. @@ -1109,8 +1152,10 @@ def sample_update_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Job: @@ -1171,7 +1216,7 @@ def batch_update_jobs( jobs: Optional[MutableSequence[job.Job]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Begins executing a batch update jobs operation. @@ -1236,8 +1281,10 @@ def sample_batch_update_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1312,7 +1359,7 @@ def delete_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified job. @@ -1361,8 +1408,10 @@ def sample_delete_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1412,7 +1461,7 @@ def batch_delete_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by filter. @@ -1477,8 +1526,10 @@ def sample_batch_delete_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1530,7 +1581,7 @@ def list_jobs( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListJobsPager: r"""Lists jobs by filter. @@ -1613,8 +1664,10 @@ def sample_list_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager: @@ -1687,7 +1740,7 @@ def search_jobs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchJobsPager: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. @@ -1730,8 +1783,10 @@ def sample_search_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsPager: @@ -1789,7 +1844,7 @@ def search_jobs_for_alert( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchJobsForAlertPager: r"""Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest]. @@ -1838,8 +1893,10 @@ def sample_search_jobs_for_alert(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertPager: @@ -1910,7 +1967,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1921,8 +1978,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/pagers.py index 89b8005d6a2f..10afed907ac7 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = job_service.ListJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = job_service.ListJobsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = job_service.SearchJobsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = job_service.SearchJobsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = job_service.SearchJobsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = job_service.SearchJobsRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py index 1120835a7e44..bd6ac85ce160 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import job from google.cloud.talent_v4beta1.types import job as gct_job @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, JobServiceTransport +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.talent.v4beta1.JobService", + "rpcName": 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.talent.v4beta1.JobService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobServiceGrpcTransport(JobServiceTransport): """gRPC backend transport for JobService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def create_job(self) -> Callable[[job_service.CreateJobRequest], gct_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/CreateJob", request_serializer=job_service.CreateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -300,7 +388,7 @@ def batch_create_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_jobs" not in self._stubs: - self._stubs["batch_create_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchCreateJobs", request_serializer=job_service.BatchCreateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -325,7 +413,7 @@ def get_job(self) -> Callable[[job_service.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/GetJob", request_serializer=job_service.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -353,7 +441,7 @@ def update_job(self) -> Callable[[job_service.UpdateJobRequest], gct_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/UpdateJob", request_serializer=job_service.UpdateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -379,7 +467,7 @@ def batch_update_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_jobs" not in self._stubs: - self._stubs["batch_update_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs", request_serializer=job_service.BatchUpdateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +494,7 @@ def delete_job(self) -> Callable[[job_service.DeleteJobRequest], empty_pb2.Empty # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/DeleteJob", request_serializer=job_service.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -433,7 +521,7 @@ def batch_delete_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_jobs" not in self._stubs: - self._stubs["batch_delete_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs", request_serializer=job_service.BatchDeleteJobsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -459,7 +547,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/ListJobs", request_serializer=job_service.ListJobsRequest.serialize, response_deserializer=job_service.ListJobsResponse.deserialize, @@ -491,7 +579,7 @@ def search_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs" not in self._stubs: - self._stubs["search_jobs"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/SearchJobs", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -529,7 +617,7 @@ def search_jobs_for_alert( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs_for_alert" not in self._stubs: - self._stubs["search_jobs_for_alert"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs_for_alert"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -537,7 +625,7 @@ def search_jobs_for_alert( return self._stubs["search_jobs_for_alert"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -549,7 +637,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py index 3fc59a48f892..0ad50be5a776 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import job from google.cloud.talent_v4beta1.types import job as gct_job @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, JobServiceTransport from .grpc import JobServiceGrpcTransport +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.talent.v4beta1.JobService", + "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.talent.v4beta1.JobService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class JobServiceGrpcAsyncIOTransport(JobServiceTransport): """gRPC AsyncIO backend transport for JobService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def create_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/CreateJob", request_serializer=job_service.CreateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -314,7 +399,7 @@ def batch_create_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_jobs" not in self._stubs: - self._stubs["batch_create_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchCreateJobs", request_serializer=job_service.BatchCreateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -339,7 +424,7 @@ def get_job(self) -> Callable[[job_service.GetJobRequest], Awaitable[job.Job]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/GetJob", request_serializer=job_service.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -369,7 +454,7 @@ def update_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/UpdateJob", request_serializer=job_service.UpdateJobRequest.serialize, response_deserializer=gct_job.Job.deserialize, @@ -397,7 +482,7 @@ def batch_update_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_jobs" not in self._stubs: - self._stubs["batch_update_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchUpdateJobs", request_serializer=job_service.BatchUpdateJobsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -426,7 +511,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/DeleteJob", request_serializer=job_service.DeleteJobRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -453,7 +538,7 @@ def batch_delete_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_jobs" not in self._stubs: - self._stubs["batch_delete_jobs"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/BatchDeleteJobs", request_serializer=job_service.BatchDeleteJobsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -481,7 +566,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/ListJobs", request_serializer=job_service.ListJobsRequest.serialize, response_deserializer=job_service.ListJobsResponse.deserialize, @@ -515,7 +600,7 @@ def search_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs" not in self._stubs: - self._stubs["search_jobs"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/SearchJobs", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -555,7 +640,7 @@ def search_jobs_for_alert( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_jobs_for_alert" not in self._stubs: - self._stubs["search_jobs_for_alert"] = self.grpc_channel.unary_unary( + self._stubs["search_jobs_for_alert"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.JobService/SearchJobsForAlert", request_serializer=job_service.SearchJobsRequest.serialize, response_deserializer=job_service.SearchJobsResponse.deserialize, @@ -658,7 +743,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -674,7 +759,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/rest.py index be67c784a3e7..7ea696345cc0 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/job_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -145,8 +153,10 @@ def post_update_job(self, response): def pre_batch_create_jobs( self, request: job_service.BatchCreateJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchCreateJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchCreateJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_jobs Override in a subclass to manipulate the request or metadata @@ -168,8 +178,10 @@ def post_batch_create_jobs( def pre_batch_delete_jobs( self, request: job_service.BatchDeleteJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchDeleteJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchDeleteJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_jobs Override in a subclass to manipulate the request or metadata @@ -180,8 +192,10 @@ def pre_batch_delete_jobs( def pre_batch_update_jobs( self, request: job_service.BatchUpdateJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.BatchUpdateJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + job_service.BatchUpdateJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_jobs Override in a subclass to manipulate the request or metadata @@ -201,8 +215,10 @@ def post_batch_update_jobs( return response def pre_create_job( - self, request: job_service.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -220,8 +236,10 @@ def post_create_job(self, response: gct_job.Job) -> gct_job.Job: return response def pre_delete_job( - self, request: job_service.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -230,8 +248,10 @@ def pre_delete_job( return request, metadata def pre_get_job( - self, request: job_service.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -249,8 +269,10 @@ def post_get_job(self, response: job.Job) -> job.Job: return response def pre_list_jobs( - self, request: job_service.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -272,8 +294,8 @@ def post_list_jobs( def pre_search_jobs( self, request: job_service.SearchJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_jobs Override in a subclass to manipulate the request or metadata @@ -295,8 +317,8 @@ def post_search_jobs( def pre_search_jobs_for_alert( self, request: job_service.SearchJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.SearchJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_jobs_for_alert Override in a subclass to manipulate the request or metadata @@ -316,8 +338,10 @@ def post_search_jobs_for_alert( return response def pre_update_job( - self, request: job_service.UpdateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[job_service.UpdateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: job_service.UpdateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[job_service.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -337,8 +361,10 @@ def post_update_job(self, response: gct_job.Job) -> gct_job.Job: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -515,7 +541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create jobs method over HTTP. @@ -525,8 +551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -539,6 +567,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseBatchCreateJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_jobs( request, metadata ) @@ -555,6 +584,33 @@ def __call__( 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.talent_v4beta1.JobServiceClient.BatchCreateJobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "BatchCreateJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchCreateJobs._get_response( self._host, @@ -574,7 +630,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_jobs(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.talent_v4beta1.JobServiceClient.batch_create_jobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "BatchCreateJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteJobs( @@ -612,7 +690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the batch delete jobs method over HTTP. @@ -622,13 +700,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseJobServiceRestTransport._BaseBatchDeleteJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_jobs( request, metadata ) @@ -645,6 +726,33 @@ def __call__( 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.talent_v4beta1.JobServiceClient.BatchDeleteJobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "BatchDeleteJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchDeleteJobs._get_response( self._host, @@ -696,7 +804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update jobs method over HTTP. @@ -706,8 +814,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -720,6 +830,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseBatchUpdateJobs._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_jobs( request, metadata ) @@ -736,6 +847,33 @@ def __call__( 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.talent_v4beta1.JobServiceClient.BatchUpdateJobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "BatchUpdateJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._BatchUpdateJobs._get_response( self._host, @@ -755,7 +893,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_jobs(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.talent_v4beta1.JobServiceClient.batch_update_jobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "BatchUpdateJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateJob(_BaseJobServiceRestTransport._BaseCreateJob, JobServiceRestStub): @@ -791,7 +951,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Call the create job method over HTTP. @@ -801,8 +961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_job.Job: @@ -817,6 +979,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseCreateJob._get_transcoded_request( @@ -835,6 +998,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._CreateJob._get_response( self._host, @@ -856,7 +1046,29 @@ def __call__( pb_resp = gct_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_job.Job.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.talent_v4beta1.JobServiceClient.create_job", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob(_BaseJobServiceRestTransport._BaseDeleteJob, JobServiceRestStub): @@ -891,7 +1103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete job method over HTTP. @@ -901,13 +1113,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseJobServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseDeleteJob._get_transcoded_request( @@ -922,6 +1137,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._DeleteJob._get_response( self._host, @@ -969,7 +1211,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -979,8 +1221,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job.Job: @@ -993,6 +1237,7 @@ def __call__( """ http_options = _BaseJobServiceRestTransport._BaseGetJob._get_http_options() + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -1007,6 +1252,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._GetJob._get_response( self._host, @@ -1027,7 +1299,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.talent_v4beta1.JobServiceClient.get_job", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs(_BaseJobServiceRestTransport._BaseListJobs, JobServiceRestStub): @@ -1062,7 +1356,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -1072,8 +1366,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.ListJobsResponse: @@ -1083,6 +1379,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseListJobs._get_transcoded_request( @@ -1097,6 +1394,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._ListJobs._get_response( self._host, @@ -1117,7 +1441,29 @@ def __call__( pb_resp = job_service.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.ListJobsResponse.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.talent_v4beta1.JobServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchJobs(_BaseJobServiceRestTransport._BaseSearchJobs, JobServiceRestStub): @@ -1153,7 +1499,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Call the search jobs method over HTTP. @@ -1163,8 +1509,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.SearchJobsResponse: @@ -1174,6 +1522,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseSearchJobs._get_http_options() ) + request, metadata = self._interceptor.pre_search_jobs(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseSearchJobs._get_transcoded_request( @@ -1192,6 +1541,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.SearchJobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "SearchJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._SearchJobs._get_response( self._host, @@ -1213,7 +1589,29 @@ def __call__( pb_resp = job_service.SearchJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.SearchJobsResponse.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.talent_v4beta1.JobServiceClient.search_jobs", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "SearchJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchJobsForAlert( @@ -1251,7 +1649,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> job_service.SearchJobsResponse: r"""Call the search jobs for alert method over HTTP. @@ -1261,8 +1659,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.job_service.SearchJobsResponse: @@ -1272,6 +1672,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseSearchJobsForAlert._get_http_options() ) + request, metadata = self._interceptor.pre_search_jobs_for_alert( request, metadata ) @@ -1288,6 +1689,33 @@ def __call__( 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.talent_v4beta1.JobServiceClient.SearchJobsForAlert", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "SearchJobsForAlert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._SearchJobsForAlert._get_response( self._host, @@ -1309,7 +1737,29 @@ def __call__( pb_resp = job_service.SearchJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_jobs_for_alert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job_service.SearchJobsResponse.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.talent_v4beta1.JobServiceClient.search_jobs_for_alert", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "SearchJobsForAlert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob(_BaseJobServiceRestTransport._BaseUpdateJob, JobServiceRestStub): @@ -1345,7 +1795,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_job.Job: r"""Call the update job method over HTTP. @@ -1355,8 +1805,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_job.Job: @@ -1371,6 +1823,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseUpdateJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1389,6 +1842,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.UpdateJob", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._UpdateJob._get_response( self._host, @@ -1410,7 +1890,29 @@ def __call__( pb_resp = gct_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_job.Job.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.talent_v4beta1.JobServiceClient.update_job", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1523,7 +2025,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1533,8 +2035,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1543,6 +2047,7 @@ def __call__( http_options = ( _BaseJobServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseJobServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -1557,6 +2062,33 @@ def __call__( ) ) + 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.talent_v4beta1.JobServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = JobServiceRestTransport._GetOperation._get_response( self._host, @@ -1576,6 +2108,27 @@ def __call__( 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.talent_v4beta1.JobServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.JobService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/async_client.py index a37e805e2568..a277eb9a8b2b 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TenantServiceTransport from .transports.grpc_asyncio import TenantServiceGrpcAsyncIOTransport +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 TenantServiceAsyncClient: """A service that handles tenant management, including CRUD and @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.talent_v4beta1.TenantServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "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.talent.v4beta1.TenantService", + "credentialsType": None, + }, + ) + async def create_tenant( self, request: Optional[Union[tenant_service.CreateTenantRequest, dict]] = None, @@ -268,7 +300,7 @@ async def create_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Creates a new tenant entity. @@ -324,8 +356,10 @@ async def sample_create_tenant(): 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, 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: google.cloud.talent_v4beta1.types.Tenant: @@ -393,7 +427,7 @@ async def get_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Retrieves specified tenant. @@ -440,8 +474,10 @@ async def sample_get_tenant(): 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, 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: google.cloud.talent_v4beta1.types.Tenant: @@ -507,7 +543,7 @@ async def update_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Updates specified tenant. @@ -555,8 +591,10 @@ async def sample_update_tenant(): 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, 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: google.cloud.talent_v4beta1.types.Tenant: @@ -624,7 +662,7 @@ async def delete_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified tenant. @@ -667,8 +705,10 @@ async def sample_delete_tenant(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -720,7 +760,7 @@ async def list_tenants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTenantsAsyncPager: r"""Lists all tenants associated with the project. @@ -768,8 +808,10 @@ async def sample_list_tenants(): 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, 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: google.cloud.talent_v4beta1.services.tenant_service.pagers.ListTenantsAsyncPager: @@ -843,7 +885,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -854,8 +896,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/client.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/client.py index 1726dc56d212..009c5df95afc 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/client.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.talent_v4beta1.services.tenant_service import pagers @@ -577,6 +587,10 @@ def __init__( # 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( @@ -642,6 +656,29 @@ def __init__( 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.talent_v4beta1.TenantServiceClient`.", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "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.talent.v4beta1.TenantService", + "credentialsType": None, + }, + ) + def create_tenant( self, request: Optional[Union[tenant_service.CreateTenantRequest, dict]] = None, @@ -650,7 +687,7 @@ def create_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Creates a new tenant entity. @@ -706,8 +743,10 @@ def sample_create_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Tenant: @@ -772,7 +811,7 @@ def get_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Retrieves specified tenant. @@ -819,8 +858,10 @@ def sample_get_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Tenant: @@ -883,7 +924,7 @@ def update_tenant( tenant: Optional[gct_tenant.Tenant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Updates specified tenant. @@ -931,8 +972,10 @@ def sample_update_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.types.Tenant: @@ -997,7 +1040,7 @@ def delete_tenant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes specified tenant. @@ -1040,8 +1083,10 @@ def sample_delete_tenant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1090,7 +1135,7 @@ def list_tenants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTenantsPager: r"""Lists all tenants associated with the project. @@ -1138,8 +1183,10 @@ def sample_list_tenants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.talent_v4beta1.services.tenant_service.pagers.ListTenantsPager: @@ -1223,7 +1270,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1234,8 +1281,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/pagers.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/pagers.py index 966e6a66aeff..d5a1a1bc696e 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/pagers.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tenant_service.ListTenantsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tenant_service.ListTenantsRequest(request) diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py index e4b8188289fc..ccb0c9482f0a 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import tenant from google.cloud.talent_v4beta1.types import tenant as gct_tenant @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, TenantServiceTransport +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.talent.v4beta1.TenantService", + "rpcName": 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.talent.v4beta1.TenantService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TenantServiceGrpcTransport(TenantServiceTransport): """gRPC backend transport for TenantService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +344,7 @@ def create_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tenant" not in self._stubs: - self._stubs["create_tenant"] = self.grpc_channel.unary_unary( + self._stubs["create_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/CreateTenant", request_serializer=tenant_service.CreateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -282,7 +368,7 @@ def get_tenant(self) -> Callable[[tenant_service.GetTenantRequest], tenant.Tenan # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tenant" not in self._stubs: - self._stubs["get_tenant"] = self.grpc_channel.unary_unary( + self._stubs["get_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/GetTenant", request_serializer=tenant_service.GetTenantRequest.serialize, response_deserializer=tenant.Tenant.deserialize, @@ -308,7 +394,7 @@ def update_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tenant" not in self._stubs: - self._stubs["update_tenant"] = self.grpc_channel.unary_unary( + self._stubs["update_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/UpdateTenant", request_serializer=tenant_service.UpdateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -334,7 +420,7 @@ def delete_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tenant" not in self._stubs: - self._stubs["delete_tenant"] = self.grpc_channel.unary_unary( + self._stubs["delete_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/DeleteTenant", request_serializer=tenant_service.DeleteTenantRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -362,7 +448,7 @@ def list_tenants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tenants" not in self._stubs: - self._stubs["list_tenants"] = self.grpc_channel.unary_unary( + self._stubs["list_tenants"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/ListTenants", request_serializer=tenant_service.ListTenantsRequest.serialize, response_deserializer=tenant_service.ListTenantsResponse.deserialize, @@ -370,7 +456,7 @@ def list_tenants( return self._stubs["list_tenants"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -382,7 +468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py index 034dc05922b6..b19f5bd742d6 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.talent_v4beta1.types import tenant from google.cloud.talent_v4beta1.types import tenant as gct_tenant @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, TenantServiceTransport from .grpc import TenantServiceGrpcTransport +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.talent.v4beta1.TenantService", + "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.talent.v4beta1.TenantService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TenantServiceGrpcAsyncIOTransport(TenantServiceTransport): """gRPC AsyncIO backend transport for TenantService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def create_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tenant" not in self._stubs: - self._stubs["create_tenant"] = self.grpc_channel.unary_unary( + self._stubs["create_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/CreateTenant", request_serializer=tenant_service.CreateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -292,7 +377,7 @@ def get_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tenant" not in self._stubs: - self._stubs["get_tenant"] = self.grpc_channel.unary_unary( + self._stubs["get_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/GetTenant", request_serializer=tenant_service.GetTenantRequest.serialize, response_deserializer=tenant.Tenant.deserialize, @@ -318,7 +403,7 @@ def update_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tenant" not in self._stubs: - self._stubs["update_tenant"] = self.grpc_channel.unary_unary( + self._stubs["update_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/UpdateTenant", request_serializer=tenant_service.UpdateTenantRequest.serialize, response_deserializer=gct_tenant.Tenant.deserialize, @@ -344,7 +429,7 @@ def delete_tenant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tenant" not in self._stubs: - self._stubs["delete_tenant"] = self.grpc_channel.unary_unary( + self._stubs["delete_tenant"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/DeleteTenant", request_serializer=tenant_service.DeleteTenantRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -373,7 +458,7 @@ def list_tenants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tenants" not in self._stubs: - self._stubs["list_tenants"] = self.grpc_channel.unary_unary( + self._stubs["list_tenants"] = self._logged_channel.unary_unary( "/google.cloud.talent.v4beta1.TenantService/ListTenants", request_serializer=tenant_service.ListTenantsRequest.serialize, response_deserializer=tenant_service.ListTenantsResponse.deserialize, @@ -451,7 +536,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -467,7 +552,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/rest.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/rest.py index b89e8ee558a2..6693140e5ba5 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/rest.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/services/tenant_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -109,8 +117,10 @@ def post_update_tenant(self, response): def pre_create_tenant( self, request: tenant_service.CreateTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.CreateTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.CreateTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tenant Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_create_tenant(self, response: gct_tenant.Tenant) -> gct_tenant.Tenant: def pre_delete_tenant( self, request: tenant_service.DeleteTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.DeleteTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.DeleteTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tenant Override in a subclass to manipulate the request or metadata @@ -142,8 +154,10 @@ def pre_delete_tenant( def pre_get_tenant( self, request: tenant_service.GetTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.GetTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.GetTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_tenant Override in a subclass to manipulate the request or metadata @@ -163,8 +177,10 @@ def post_get_tenant(self, response: tenant.Tenant) -> tenant.Tenant: def pre_list_tenants( self, request: tenant_service.ListTenantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.ListTenantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.ListTenantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tenants Override in a subclass to manipulate the request or metadata @@ -186,8 +202,10 @@ def post_list_tenants( def pre_update_tenant( self, request: tenant_service.UpdateTenantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tenant_service.UpdateTenantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tenant_service.UpdateTenantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_tenant Override in a subclass to manipulate the request or metadata @@ -207,8 +225,10 @@ def post_update_tenant(self, response: gct_tenant.Tenant) -> gct_tenant.Tenant: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -350,7 +370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Call the create tenant method over HTTP. @@ -361,8 +381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_tenant.Tenant: @@ -379,6 +401,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseCreateTenant._get_http_options() ) + request, metadata = self._interceptor.pre_create_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseCreateTenant._get_transcoded_request( http_options, request @@ -393,6 +416,33 @@ def __call__( 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.talent_v4beta1.TenantServiceClient.CreateTenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "CreateTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._CreateTenant._get_response( self._host, @@ -414,7 +464,29 @@ def __call__( pb_resp = gct_tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_tenant.Tenant.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.talent_v4beta1.TenantServiceClient.create_tenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "CreateTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTenant( @@ -451,7 +523,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete tenant method over HTTP. @@ -461,13 +533,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTenantServiceRestTransport._BaseDeleteTenant._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseDeleteTenant._get_transcoded_request( http_options, request @@ -478,6 +553,33 @@ def __call__( 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.talent_v4beta1.TenantServiceClient.DeleteTenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "DeleteTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._DeleteTenant._get_response( self._host, @@ -527,7 +629,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant.Tenant: r"""Call the get tenant method over HTTP. @@ -537,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tenant.Tenant: @@ -555,6 +659,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseGetTenant._get_http_options() ) + request, metadata = self._interceptor.pre_get_tenant(request, metadata) transcoded_request = ( _BaseTenantServiceRestTransport._BaseGetTenant._get_transcoded_request( @@ -569,6 +674,33 @@ def __call__( ) ) + 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.talent_v4beta1.TenantServiceClient.GetTenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "GetTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._GetTenant._get_response( self._host, @@ -589,7 +721,29 @@ def __call__( pb_resp = tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tenant.Tenant.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.talent_v4beta1.TenantServiceClient.get_tenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "GetTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTenants( @@ -626,7 +780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tenant_service.ListTenantsResponse: r"""Call the list tenants method over HTTP. @@ -637,8 +791,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tenant_service.ListTenantsResponse: @@ -648,6 +804,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseListTenants._get_http_options() ) + request, metadata = self._interceptor.pre_list_tenants(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseListTenants._get_transcoded_request( http_options, request @@ -660,6 +817,33 @@ def __call__( ) ) + 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.talent_v4beta1.TenantServiceClient.ListTenants", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "ListTenants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._ListTenants._get_response( self._host, @@ -680,7 +864,31 @@ def __call__( pb_resp = tenant_service.ListTenantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tenants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tenant_service.ListTenantsResponse.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.talent_v4beta1.TenantServiceClient.list_tenants", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "ListTenants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTenant( @@ -718,7 +926,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_tenant.Tenant: r"""Call the update tenant method over HTTP. @@ -729,8 +937,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gct_tenant.Tenant: @@ -747,6 +957,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseUpdateTenant._get_http_options() ) + request, metadata = self._interceptor.pre_update_tenant(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseUpdateTenant._get_transcoded_request( http_options, request @@ -761,6 +972,33 @@ def __call__( 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.talent_v4beta1.TenantServiceClient.UpdateTenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "UpdateTenant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._UpdateTenant._get_response( self._host, @@ -782,7 +1020,29 @@ def __call__( pb_resp = gct_tenant.Tenant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tenant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_tenant.Tenant.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.talent_v4beta1.TenantServiceClient.update_tenant", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "UpdateTenant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -863,7 +1123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -873,8 +1133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -883,6 +1145,7 @@ def __call__( http_options = ( _BaseTenantServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTenantServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -893,6 +1156,33 @@ def __call__( 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.talent_v4beta1.TenantServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TenantServiceRestTransport._GetOperation._get_response( self._host, @@ -912,6 +1202,27 @@ def __call__( 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.talent_v4beta1.TenantServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.talent.v4beta1.TenantService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json index f2a77449c811..8caa824f22f3 100644 --- a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json +++ b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-talent", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_company" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_company" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.company_service.pagers.ListCompaniesAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.company_service.pagers.ListCompaniesPager", @@ -697,7 +697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Company", @@ -858,7 +858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.CompleteQueryResponse", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.CompleteQueryResponse", @@ -1019,7 +1019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.ClientEvent", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.ClientEvent", @@ -1188,7 +1188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1272,7 +1272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1357,7 +1357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1441,7 +1441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1526,7 +1526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1610,7 +1610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1695,7 +1695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -1779,7 +1779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -1860,7 +1860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -1937,7 +1937,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -2015,7 +2015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -2095,7 +2095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsAsyncPager", @@ -2264,7 +2264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.job_service.pagers.ListJobsPager", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", @@ -2417,7 +2417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", @@ -2494,7 +2494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", @@ -2570,7 +2570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.SearchJobsResponse", @@ -2655,7 +2655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -2739,7 +2739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Job", @@ -2824,7 +2824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", @@ -2908,7 +2908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", @@ -2989,7 +2989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tenant" @@ -3066,7 +3066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tenant" @@ -3144,7 +3144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", @@ -3224,7 +3224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", @@ -3305,7 +3305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.tenant_service.pagers.ListTenantsAsyncPager", @@ -3385,7 +3385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.services.tenant_service.pagers.ListTenantsPager", @@ -3470,7 +3470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", @@ -3554,7 +3554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4.types.Tenant", diff --git a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json index 210978c48b94..580e0ed3b33e 100644 --- a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json +++ b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-talent", - "version": "2.14.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_company" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_company" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.company_service.pagers.ListCompaniesPager", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Company", @@ -850,7 +850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", @@ -926,7 +926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.CompleteQueryResponse", @@ -1011,7 +1011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.ClientEvent", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1349,7 +1349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_jobs" @@ -1430,7 +1430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_jobs" @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1596,7 +1596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1681,7 +1681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -1765,7 +1765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -1846,7 +1846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -1923,7 +1923,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_job" @@ -2001,7 +2001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -2081,7 +2081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -2166,7 +2166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsAsyncPager", @@ -2250,7 +2250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.ListJobsPager", @@ -2327,7 +2327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertAsyncPager", @@ -2403,7 +2403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsForAlertPager", @@ -2480,7 +2480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsAsyncPager", @@ -2556,7 +2556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.job_service.pagers.SearchJobsPager", @@ -2637,7 +2637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -2717,7 +2717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Job", @@ -2802,7 +2802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", @@ -2886,7 +2886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", @@ -2967,7 +2967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tenant" @@ -3044,7 +3044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tenant" @@ -3122,7 +3122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", @@ -3202,7 +3202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", @@ -3283,7 +3283,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.tenant_service.pagers.ListTenantsAsyncPager", @@ -3363,7 +3363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.services.tenant_service.pagers.ListTenantsPager", @@ -3444,7 +3444,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", @@ -3524,7 +3524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.talent_v4beta1.types.Tenant", diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py index e8a308fd18ce..d086959a3b3b 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py @@ -3132,6 +3132,7 @@ def test_create_company_rest_required_fields( response_value._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_company(request) @@ -3186,6 +3187,7 @@ def test_create_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3317,6 +3319,7 @@ def test_get_company_rest_required_fields( response_value._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_company(request) @@ -3362,6 +3365,7 @@ def test_get_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3490,6 +3494,7 @@ def test_update_company_rest_required_fields( response_value._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_company(request) @@ -3538,6 +3543,7 @@ def test_update_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3667,6 +3673,7 @@ def test_delete_company_rest_required_fields( response_value._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_company(request) @@ -3710,6 +3717,7 @@ def test_delete_company_rest_flattened(): 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"} client.delete_company(**mock_args) @@ -3848,6 +3856,7 @@ def test_list_companies_rest_required_fields( response_value._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_companies(request) @@ -3902,6 +3911,7 @@ def test_list_companies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_companies(**mock_args) @@ -4416,6 +4426,7 @@ def test_create_company_rest_bad_request( 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_company(request) @@ -4568,6 +4579,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -4621,6 +4633,7 @@ def test_create_company_rest_interceptors(null_interceptor): 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 = gct_company.Company.to_json(gct_company.Company()) req.return_value.content = return_value @@ -4663,6 +4676,7 @@ def test_get_company_rest_bad_request(request_type=company_service.GetCompanyReq 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_company(request) @@ -4711,6 +4725,7 @@ def test_get_company_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -4764,6 +4779,7 @@ def test_get_company_rest_interceptors(null_interceptor): 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 = company.Company.to_json(company.Company()) req.return_value.content = return_value @@ -4810,6 +4826,7 @@ def test_update_company_rest_bad_request( 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_company(request) @@ -4964,6 +4981,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -5017,6 +5035,7 @@ def test_update_company_rest_interceptors(null_interceptor): 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 = gct_company.Company.to_json(gct_company.Company()) req.return_value.content = return_value @@ -5061,6 +5080,7 @@ def test_delete_company_rest_bad_request( 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_company(request) @@ -5091,6 +5111,7 @@ def test_delete_company_rest_call_success(request_type): 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_company(request) # Establish that the response is the type that we expect. @@ -5127,6 +5148,7 @@ def test_delete_company_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = company_service.DeleteCompanyRequest() metadata = [ @@ -5167,6 +5189,7 @@ def test_list_companies_rest_bad_request( 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_companies(request) @@ -5202,6 +5225,7 @@ def test_list_companies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_companies(request) # Establish that the response is the type that we expect. @@ -5242,6 +5266,7 @@ def test_list_companies_rest_interceptors(null_interceptor): 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 = company_service.ListCompaniesResponse.to_json( company_service.ListCompaniesResponse() ) @@ -5290,6 +5315,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5320,6 +5346,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py index 1fe80359a405..76de2040a8f8 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py @@ -1389,6 +1389,7 @@ def test_complete_query_rest_required_fields( response_value._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.complete_query(request) @@ -1628,6 +1629,7 @@ def test_complete_query_rest_bad_request( 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.complete_query(request) @@ -1661,6 +1663,7 @@ def test_complete_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.complete_query(request) # Establish that the response is the type that we expect. @@ -1700,6 +1703,7 @@ def test_complete_query_rest_interceptors(null_interceptor): 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 = completion_service.CompleteQueryResponse.to_json( completion_service.CompleteQueryResponse() ) @@ -1748,6 +1752,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1778,6 +1783,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py index 5c013b40d37a..6e870c342bf1 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py @@ -1503,6 +1503,7 @@ def test_create_client_event_rest_required_fields( response_value._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_client_event(request) @@ -1557,6 +1558,7 @@ def test_create_client_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_client_event(**mock_args) @@ -1788,6 +1790,7 @@ def test_create_client_event_rest_bad_request( 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_client_event(request) @@ -1899,6 +1902,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_client_event(request) # Establish that the response is the type that we expect. @@ -1941,6 +1945,7 @@ def test_create_client_event_rest_interceptors(null_interceptor): 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 = event.ClientEvent.to_json(event.ClientEvent()) req.return_value.content = return_value @@ -1987,6 +1992,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2017,6 +2023,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py index 40cb24f30588..103ea374fa1b 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py @@ -4747,6 +4747,7 @@ def test_create_job_rest_required_fields(request_type=job_service.CreateJobReque response_value._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_job(request) @@ -4801,6 +4802,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -4935,6 +4937,7 @@ def test_batch_create_jobs_rest_required_fields( response_value._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.batch_create_jobs(request) @@ -4987,6 +4990,7 @@ def test_batch_create_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_create_jobs(**mock_args) @@ -5117,6 +5121,7 @@ def test_get_job_rest_required_fields(request_type=job_service.GetJobRequest): response_value._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_job(request) @@ -5162,6 +5167,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -5287,6 +5293,7 @@ def test_update_job_rest_required_fields(request_type=job_service.UpdateJobReque response_value._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_job(request) @@ -5335,6 +5342,7 @@ def test_update_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -5470,6 +5478,7 @@ def test_batch_update_jobs_rest_required_fields( response_value._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.batch_update_jobs(request) @@ -5522,6 +5531,7 @@ def test_batch_update_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_update_jobs(**mock_args) @@ -5649,6 +5659,7 @@ def test_delete_job_rest_required_fields(request_type=job_service.DeleteJobReque response_value._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_job(request) @@ -5692,6 +5703,7 @@ def test_delete_job_rest_flattened(): 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"} client.delete_job(**mock_args) @@ -5825,6 +5837,7 @@ def test_batch_delete_jobs_rest_required_fields( response_value._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.batch_delete_jobs(request) @@ -5869,6 +5882,7 @@ def test_batch_delete_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_delete_jobs(**mock_args) @@ -6015,6 +6029,7 @@ def test_list_jobs_rest_required_fields(request_type=job_service.ListJobsRequest response_value._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_jobs(request) @@ -6082,6 +6097,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -6272,6 +6288,7 @@ def test_search_jobs_rest_required_fields(request_type=job_service.SearchJobsReq response_value._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.search_jobs(request) @@ -6405,6 +6422,7 @@ def test_search_jobs_for_alert_rest_required_fields( response_value._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.search_jobs_for_alert(request) @@ -7120,6 +7138,7 @@ def test_create_job_rest_bad_request(request_type=job_service.CreateJobRequest): 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_job(request) @@ -7321,6 +7340,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7377,6 +7397,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 = gct_job.Job.to_json(gct_job.Job()) req.return_value.content = return_value @@ -7421,6 +7442,7 @@ def test_batch_create_jobs_rest_bad_request( 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.batch_create_jobs(request) @@ -7451,6 +7473,7 @@ def test_batch_create_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_create_jobs(request) # Establish that the response is the type that we expect. @@ -7492,6 +7515,7 @@ def test_batch_create_jobs_rest_interceptors(null_interceptor): 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 @@ -7534,6 +7558,7 @@ def test_get_job_rest_bad_request(request_type=job_service.GetJobRequest): 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_job(request) @@ -7587,6 +7612,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7643,6 +7669,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -7685,6 +7712,7 @@ def test_update_job_rest_bad_request(request_type=job_service.UpdateJobRequest): 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_job(request) @@ -7886,6 +7914,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7942,6 +7971,7 @@ def test_update_job_rest_interceptors(null_interceptor): 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 = gct_job.Job.to_json(gct_job.Job()) req.return_value.content = return_value @@ -7986,6 +8016,7 @@ def test_batch_update_jobs_rest_bad_request( 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.batch_update_jobs(request) @@ -8016,6 +8047,7 @@ def test_batch_update_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_update_jobs(request) # Establish that the response is the type that we expect. @@ -8057,6 +8089,7 @@ def test_batch_update_jobs_rest_interceptors(null_interceptor): 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 @@ -8099,6 +8132,7 @@ def test_delete_job_rest_bad_request(request_type=job_service.DeleteJobRequest): 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_job(request) @@ -8129,6 +8163,7 @@ def test_delete_job_rest_call_success(request_type): 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_job(request) # Establish that the response is the type that we expect. @@ -8163,6 +8198,7 @@ def test_delete_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = job_service.DeleteJobRequest() metadata = [ @@ -8203,6 +8239,7 @@ def test_batch_delete_jobs_rest_bad_request( 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.batch_delete_jobs(request) @@ -8233,6 +8270,7 @@ def test_batch_delete_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_delete_jobs(request) # Establish that the response is the type that we expect. @@ -8274,6 +8312,7 @@ def test_batch_delete_jobs_rest_interceptors(null_interceptor): 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 @@ -8316,6 +8355,7 @@ def test_list_jobs_rest_bad_request(request_type=job_service.ListJobsRequest): 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_jobs(request) @@ -8351,6 +8391,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -8389,6 +8430,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = job_service.ListJobsResponse.to_json( job_service.ListJobsResponse() ) @@ -8433,6 +8475,7 @@ def test_search_jobs_rest_bad_request(request_type=job_service.SearchJobsRequest 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.search_jobs(request) @@ -8470,6 +8513,7 @@ def test_search_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_jobs(request) assert response.raw_page is response @@ -8512,6 +8556,7 @@ def test_search_jobs_rest_interceptors(null_interceptor): 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 = job_service.SearchJobsResponse.to_json( job_service.SearchJobsResponse() ) @@ -8558,6 +8603,7 @@ def test_search_jobs_for_alert_rest_bad_request( 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.search_jobs_for_alert(request) @@ -8595,6 +8641,7 @@ def test_search_jobs_for_alert_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_jobs_for_alert(request) assert response.raw_page is response @@ -8637,6 +8684,7 @@ def test_search_jobs_for_alert_rest_interceptors(null_interceptor): 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 = job_service.SearchJobsResponse.to_json( job_service.SearchJobsResponse() ) @@ -8685,6 +8733,7 @@ def test_get_operation_rest_bad_request( 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) @@ -8715,6 +8764,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py index 0e1d01212a39..06b682422875 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py @@ -2979,6 +2979,7 @@ def test_create_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3033,6 +3034,7 @@ def test_create_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3161,6 +3163,7 @@ def test_get_tenant_rest_required_fields(request_type=tenant_service.GetTenantRe response_value._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_tenant(request) @@ -3206,6 +3209,7 @@ def test_get_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3333,6 +3337,7 @@ def test_update_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3379,6 +3384,7 @@ def test_update_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3506,6 +3512,7 @@ def test_delete_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3549,6 +3556,7 @@ def test_delete_tenant_rest_flattened(): 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"} client.delete_tenant(**mock_args) @@ -3685,6 +3693,7 @@ def test_list_tenants_rest_required_fields( response_value._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_tenants(request) @@ -3738,6 +3747,7 @@ def test_list_tenants_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenants(**mock_args) @@ -4215,6 +4225,7 @@ def test_create_tenant_rest_bad_request( 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_tenant(request) @@ -4319,6 +4330,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4360,6 +4372,7 @@ def test_create_tenant_rest_interceptors(null_interceptor): 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 = gct_tenant.Tenant.to_json(gct_tenant.Tenant()) req.return_value.content = return_value @@ -4402,6 +4415,7 @@ def test_get_tenant_rest_bad_request(request_type=tenant_service.GetTenantReques 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_tenant(request) @@ -4438,6 +4452,7 @@ def test_get_tenant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4479,6 +4494,7 @@ def test_get_tenant_rest_interceptors(null_interceptor): 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 = tenant.Tenant.to_json(tenant.Tenant()) req.return_value.content = return_value @@ -4523,6 +4539,7 @@ def test_update_tenant_rest_bad_request( 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_tenant(request) @@ -4630,6 +4647,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4671,6 +4689,7 @@ def test_update_tenant_rest_interceptors(null_interceptor): 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 = gct_tenant.Tenant.to_json(gct_tenant.Tenant()) req.return_value.content = return_value @@ -4715,6 +4734,7 @@ def test_delete_tenant_rest_bad_request( 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_tenant(request) @@ -4745,6 +4765,7 @@ def test_delete_tenant_rest_call_success(request_type): 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_tenant(request) # Establish that the response is the type that we expect. @@ -4781,6 +4802,7 @@ def test_delete_tenant_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = tenant_service.DeleteTenantRequest() metadata = [ @@ -4819,6 +4841,7 @@ def test_list_tenants_rest_bad_request(request_type=tenant_service.ListTenantsRe 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_tenants(request) @@ -4854,6 +4877,7 @@ def test_list_tenants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenants(request) # Establish that the response is the type that we expect. @@ -4894,6 +4918,7 @@ def test_list_tenants_rest_interceptors(null_interceptor): 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 = tenant_service.ListTenantsResponse.to_json( tenant_service.ListTenantsResponse() ) @@ -4942,6 +4967,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4972,6 +4998,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py index cdb18654b6d4..5f0fe16efcbf 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py @@ -3122,6 +3122,7 @@ def test_create_company_rest_required_fields( response_value._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_company(request) @@ -3176,6 +3177,7 @@ def test_create_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3308,6 +3310,7 @@ def test_get_company_rest_required_fields( response_value._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_company(request) @@ -3353,6 +3356,7 @@ def test_get_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3480,6 +3484,7 @@ def test_update_company_rest_required_fields( response_value._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_company(request) @@ -3527,6 +3532,7 @@ def test_update_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_company(**mock_args) @@ -3655,6 +3661,7 @@ def test_delete_company_rest_required_fields( response_value._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_company(request) @@ -3698,6 +3705,7 @@ def test_delete_company_rest_flattened(): 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"} client.delete_company(**mock_args) @@ -3837,6 +3845,7 @@ def test_list_companies_rest_required_fields( response_value._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_companies(request) @@ -3891,6 +3900,7 @@ def test_list_companies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_companies(**mock_args) @@ -4406,6 +4416,7 @@ def test_create_company_rest_bad_request( 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_company(request) @@ -4454,6 +4465,7 @@ def test_create_company_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -4507,6 +4519,7 @@ def test_create_company_rest_interceptors(null_interceptor): 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 = gct_company.Company.to_json(gct_company.Company()) req.return_value.content = return_value @@ -4549,6 +4562,7 @@ def test_get_company_rest_bad_request(request_type=company_service.GetCompanyReq 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_company(request) @@ -4597,6 +4611,7 @@ def test_get_company_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -4650,6 +4665,7 @@ def test_get_company_rest_interceptors(null_interceptor): 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 = company.Company.to_json(company.Company()) req.return_value.content = return_value @@ -4696,6 +4712,7 @@ def test_update_company_rest_bad_request( 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_company(request) @@ -4746,6 +4763,7 @@ def test_update_company_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_company(request) # Establish that the response is the type that we expect. @@ -4799,6 +4817,7 @@ def test_update_company_rest_interceptors(null_interceptor): 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 = gct_company.Company.to_json(gct_company.Company()) req.return_value.content = return_value @@ -4843,6 +4862,7 @@ def test_delete_company_rest_bad_request( 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_company(request) @@ -4873,6 +4893,7 @@ def test_delete_company_rest_call_success(request_type): 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_company(request) # Establish that the response is the type that we expect. @@ -4909,6 +4930,7 @@ def test_delete_company_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = company_service.DeleteCompanyRequest() metadata = [ @@ -4949,6 +4971,7 @@ def test_list_companies_rest_bad_request( 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_companies(request) @@ -4984,6 +5007,7 @@ def test_list_companies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_companies(request) # Establish that the response is the type that we expect. @@ -5024,6 +5048,7 @@ def test_list_companies_rest_interceptors(null_interceptor): 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 = company_service.ListCompaniesResponse.to_json( company_service.ListCompaniesResponse() ) @@ -5072,6 +5097,7 @@ def test_get_operation_rest_bad_request( 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) @@ -5102,6 +5128,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py index 0dad6df92d63..b70551a16a57 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py @@ -1389,6 +1389,7 @@ def test_complete_query_rest_required_fields( response_value._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.complete_query(request) @@ -1628,6 +1629,7 @@ def test_complete_query_rest_bad_request( 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.complete_query(request) @@ -1661,6 +1663,7 @@ def test_complete_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.complete_query(request) # Establish that the response is the type that we expect. @@ -1700,6 +1703,7 @@ def test_complete_query_rest_interceptors(null_interceptor): 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 = completion_service.CompleteQueryResponse.to_json( completion_service.CompleteQueryResponse() ) @@ -1748,6 +1752,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1778,6 +1783,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py index 59ede8a45861..bb54fa977fac 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py @@ -1503,6 +1503,7 @@ def test_create_client_event_rest_required_fields( response_value._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_client_event(request) @@ -1557,6 +1558,7 @@ def test_create_client_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_client_event(**mock_args) @@ -1789,6 +1791,7 @@ def test_create_client_event_rest_bad_request( 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_client_event(request) @@ -1826,6 +1829,7 @@ def test_create_client_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_client_event(request) # Establish that the response is the type that we expect. @@ -1868,6 +1872,7 @@ def test_create_client_event_rest_interceptors(null_interceptor): 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 = event.ClientEvent.to_json(event.ClientEvent()) req.return_value.content = return_value @@ -1914,6 +1919,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1944,6 +1950,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py index 79676210fde8..451b4d1e6bec 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py @@ -5133,6 +5133,7 @@ def test_create_job_rest_required_fields(request_type=job_service.CreateJobReque response_value._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_job(request) @@ -5187,6 +5188,7 @@ def test_create_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -5322,6 +5324,7 @@ def test_batch_create_jobs_rest_required_fields( response_value._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.batch_create_jobs(request) @@ -5374,6 +5377,7 @@ def test_batch_create_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_create_jobs(**mock_args) @@ -5504,6 +5508,7 @@ def test_get_job_rest_required_fields(request_type=job_service.GetJobRequest): response_value._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_job(request) @@ -5549,6 +5554,7 @@ def test_get_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -5673,6 +5679,7 @@ def test_update_job_rest_required_fields(request_type=job_service.UpdateJobReque response_value._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_job(request) @@ -5720,6 +5727,7 @@ def test_update_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_job(**mock_args) @@ -5855,6 +5863,7 @@ def test_batch_update_jobs_rest_required_fields( response_value._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.batch_update_jobs(request) @@ -5907,6 +5916,7 @@ def test_batch_update_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.batch_update_jobs(**mock_args) @@ -6034,6 +6044,7 @@ def test_delete_job_rest_required_fields(request_type=job_service.DeleteJobReque response_value._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_job(request) @@ -6077,6 +6088,7 @@ def test_delete_job_rest_flattened(): 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"} client.delete_job(**mock_args) @@ -6211,6 +6223,7 @@ def test_batch_delete_jobs_rest_required_fields( response_value._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.batch_delete_jobs(request) @@ -6263,6 +6276,7 @@ def test_batch_delete_jobs_rest_flattened(): 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"} client.batch_delete_jobs(**mock_args) @@ -6409,6 +6423,7 @@ def test_list_jobs_rest_required_fields(request_type=job_service.ListJobsRequest response_value._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_jobs(request) @@ -6476,6 +6491,7 @@ def test_list_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_jobs(**mock_args) @@ -6667,6 +6683,7 @@ def test_search_jobs_rest_required_fields(request_type=job_service.SearchJobsReq response_value._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.search_jobs(request) @@ -6863,6 +6880,7 @@ def test_search_jobs_for_alert_rest_required_fields( response_value._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.search_jobs_for_alert(request) @@ -7641,6 +7659,7 @@ def test_create_job_rest_bad_request(request_type=job_service.CreateJobRequest): 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_job(request) @@ -7694,6 +7713,7 @@ def test_create_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -7750,6 +7770,7 @@ def test_create_job_rest_interceptors(null_interceptor): 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 = gct_job.Job.to_json(gct_job.Job()) req.return_value.content = return_value @@ -7794,6 +7815,7 @@ def test_batch_create_jobs_rest_bad_request( 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.batch_create_jobs(request) @@ -7824,6 +7846,7 @@ def test_batch_create_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_create_jobs(request) # Establish that the response is the type that we expect. @@ -7865,6 +7888,7 @@ def test_batch_create_jobs_rest_interceptors(null_interceptor): 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 @@ -7907,6 +7931,7 @@ def test_get_job_rest_bad_request(request_type=job_service.GetJobRequest): 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_job(request) @@ -7960,6 +7985,7 @@ def test_get_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -8016,6 +8042,7 @@ def test_get_job_rest_interceptors(null_interceptor): 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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -8058,6 +8085,7 @@ def test_update_job_rest_bad_request(request_type=job_service.UpdateJobRequest): 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_job(request) @@ -8111,6 +8139,7 @@ def test_update_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_job(request) # Establish that the response is the type that we expect. @@ -8167,6 +8196,7 @@ def test_update_job_rest_interceptors(null_interceptor): 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 = gct_job.Job.to_json(gct_job.Job()) req.return_value.content = return_value @@ -8211,6 +8241,7 @@ def test_batch_update_jobs_rest_bad_request( 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.batch_update_jobs(request) @@ -8241,6 +8272,7 @@ def test_batch_update_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_update_jobs(request) # Establish that the response is the type that we expect. @@ -8282,6 +8314,7 @@ def test_batch_update_jobs_rest_interceptors(null_interceptor): 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 @@ -8324,6 +8357,7 @@ def test_delete_job_rest_bad_request(request_type=job_service.DeleteJobRequest): 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_job(request) @@ -8354,6 +8388,7 @@ def test_delete_job_rest_call_success(request_type): 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_job(request) # Establish that the response is the type that we expect. @@ -8388,6 +8423,7 @@ def test_delete_job_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = job_service.DeleteJobRequest() metadata = [ @@ -8428,6 +8464,7 @@ def test_batch_delete_jobs_rest_bad_request( 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.batch_delete_jobs(request) @@ -8458,6 +8495,7 @@ def test_batch_delete_jobs_rest_call_success(request_type): 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.batch_delete_jobs(request) # Establish that the response is the type that we expect. @@ -8494,6 +8532,7 @@ def test_batch_delete_jobs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = job_service.BatchDeleteJobsRequest() metadata = [ @@ -8532,6 +8571,7 @@ def test_list_jobs_rest_bad_request(request_type=job_service.ListJobsRequest): 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_jobs(request) @@ -8567,6 +8607,7 @@ def test_list_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_jobs(request) # Establish that the response is the type that we expect. @@ -8605,6 +8646,7 @@ def test_list_jobs_rest_interceptors(null_interceptor): 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 = job_service.ListJobsResponse.to_json( job_service.ListJobsResponse() ) @@ -8649,6 +8691,7 @@ def test_search_jobs_rest_bad_request(request_type=job_service.SearchJobsRequest 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.search_jobs(request) @@ -8687,6 +8730,7 @@ def test_search_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_jobs(request) # Establish that the response is the type that we expect. @@ -8728,6 +8772,7 @@ def test_search_jobs_rest_interceptors(null_interceptor): 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 = job_service.SearchJobsResponse.to_json( job_service.SearchJobsResponse() ) @@ -8774,6 +8819,7 @@ def test_search_jobs_for_alert_rest_bad_request( 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.search_jobs_for_alert(request) @@ -8812,6 +8858,7 @@ def test_search_jobs_for_alert_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_jobs_for_alert(request) # Establish that the response is the type that we expect. @@ -8853,6 +8900,7 @@ def test_search_jobs_for_alert_rest_interceptors(null_interceptor): 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 = job_service.SearchJobsResponse.to_json( job_service.SearchJobsResponse() ) @@ -8901,6 +8949,7 @@ def test_get_operation_rest_bad_request( 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) @@ -8931,6 +8980,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py index 61b1b6fd0bb4..476af07ae03d 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py @@ -3017,6 +3017,7 @@ def test_create_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3071,6 +3072,7 @@ def test_create_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3199,6 +3201,7 @@ def test_get_tenant_rest_required_fields(request_type=tenant_service.GetTenantRe response_value._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_tenant(request) @@ -3244,6 +3247,7 @@ def test_get_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3369,6 +3373,7 @@ def test_update_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3414,6 +3419,7 @@ def test_update_tenant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenant(**mock_args) @@ -3541,6 +3547,7 @@ def test_delete_tenant_rest_required_fields( response_value._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_tenant(request) @@ -3584,6 +3591,7 @@ def test_delete_tenant_rest_flattened(): 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"} client.delete_tenant(**mock_args) @@ -3720,6 +3728,7 @@ def test_list_tenants_rest_required_fields( response_value._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_tenants(request) @@ -3773,6 +3782,7 @@ def test_list_tenants_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tenants(**mock_args) @@ -4262,6 +4272,7 @@ def test_create_tenant_rest_bad_request( 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_tenant(request) @@ -4302,6 +4313,7 @@ def test_create_tenant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4347,6 +4359,7 @@ def test_create_tenant_rest_interceptors(null_interceptor): 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 = gct_tenant.Tenant.to_json(gct_tenant.Tenant()) req.return_value.content = return_value @@ -4389,6 +4402,7 @@ def test_get_tenant_rest_bad_request(request_type=tenant_service.GetTenantReques 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_tenant(request) @@ -4429,6 +4443,7 @@ def test_get_tenant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4474,6 +4489,7 @@ def test_get_tenant_rest_interceptors(null_interceptor): 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 = tenant.Tenant.to_json(tenant.Tenant()) req.return_value.content = return_value @@ -4518,6 +4534,7 @@ def test_update_tenant_rest_bad_request( 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_tenant(request) @@ -4558,6 +4575,7 @@ def test_update_tenant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenant(request) # Establish that the response is the type that we expect. @@ -4603,6 +4621,7 @@ def test_update_tenant_rest_interceptors(null_interceptor): 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 = gct_tenant.Tenant.to_json(gct_tenant.Tenant()) req.return_value.content = return_value @@ -4647,6 +4666,7 @@ def test_delete_tenant_rest_bad_request( 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_tenant(request) @@ -4677,6 +4697,7 @@ def test_delete_tenant_rest_call_success(request_type): 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_tenant(request) # Establish that the response is the type that we expect. @@ -4713,6 +4734,7 @@ def test_delete_tenant_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = tenant_service.DeleteTenantRequest() metadata = [ @@ -4751,6 +4773,7 @@ def test_list_tenants_rest_bad_request(request_type=tenant_service.ListTenantsRe 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_tenants(request) @@ -4786,6 +4809,7 @@ def test_list_tenants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tenants(request) # Establish that the response is the type that we expect. @@ -4826,6 +4850,7 @@ def test_list_tenants_rest_interceptors(null_interceptor): 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 = tenant_service.ListTenantsResponse.to_json( tenant_service.ListTenantsResponse() ) @@ -4874,6 +4899,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4904,6 +4930,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation/gapic_version.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation/gapic_version.py index aa1763b52a3a..558c8aab67c5 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation/gapic_version.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.7" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/gapic_version.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/gapic_version.py index aa1763b52a3a..558c8aab67c5 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/gapic_version.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.7" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/async_client.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/async_client.py index eae2a7457dec..4dd357b5f12e 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/async_client.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport from .transports.grpc_asyncio import TelcoAutomationGrpcAsyncIOTransport +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 TelcoAutomationAsyncClient: """TelcoAutomation Service manages the control plane cluster @@ -289,6 +299,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.telcoautomation_v1.TelcoAutomationAsyncClient`.", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "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.telcoautomation.v1.TelcoAutomation", + "credentialsType": None, + }, + ) + async def list_orchestration_clusters( self, request: Optional[ @@ -298,7 +330,7 @@ async def list_orchestration_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrchestrationClustersAsyncPager: r"""Lists OrchestrationClusters in a given project and location. @@ -344,8 +376,10 @@ async def sample_list_orchestration_clusters(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListOrchestrationClustersAsyncPager: @@ -422,7 +456,7 @@ async def get_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Gets details of a single OrchestrationCluster. @@ -464,8 +498,10 @@ async def sample_get_orchestration_cluster(): 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, 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: google.cloud.telcoautomation_v1.types.OrchestrationCluster: @@ -531,7 +567,7 @@ async def create_orchestration_cluster( orchestration_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new OrchestrationCluster in a given project and location. @@ -593,8 +629,10 @@ async def sample_create_orchestration_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -673,7 +711,7 @@ async def delete_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single OrchestrationCluster. @@ -719,8 +757,10 @@ async def sample_delete_orchestration_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -799,7 +839,7 @@ async def list_edge_slms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEdgeSlmsAsyncPager: r"""Lists EdgeSlms in a given project and location. @@ -844,8 +884,10 @@ async def sample_list_edge_slms(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListEdgeSlmsAsyncPager: @@ -920,7 +962,7 @@ async def get_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Gets details of a single EdgeSlm. @@ -961,8 +1003,10 @@ async def sample_get_edge_slm(): 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, 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: google.cloud.telcoautomation_v1.types.EdgeSlm: @@ -1028,7 +1072,7 @@ async def create_edge_slm( edge_slm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new EdgeSlm in a given project and location. @@ -1088,8 +1132,10 @@ async def sample_create_edge_slm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1165,7 +1211,7 @@ async def delete_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single EdgeSlm. @@ -1210,8 +1256,10 @@ async def sample_delete_edge_slm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1292,7 +1340,7 @@ async def create_blueprint( blueprint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Creates a blueprint. @@ -1350,8 +1398,10 @@ async def sample_create_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -1427,7 +1477,7 @@ async def update_blueprint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Updates a blueprint. @@ -1479,8 +1529,10 @@ async def sample_update_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -1555,7 +1607,7 @@ async def get_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Returns the requested blueprint. @@ -1602,8 +1654,10 @@ async def sample_get_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -1674,7 +1728,7 @@ async def delete_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a blueprint and all its revisions. @@ -1716,8 +1770,10 @@ async def sample_delete_blueprint(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1769,7 +1825,7 @@ async def list_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintsAsyncPager: r"""List all blueprints. @@ -1814,8 +1870,10 @@ async def sample_list_blueprints(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintsAsyncPager: @@ -1889,7 +1947,7 @@ async def approve_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Approves a blueprint and commits a new revision. @@ -1934,8 +1992,10 @@ async def sample_approve_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2006,7 +2066,7 @@ async def propose_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Proposes a blueprint for approval of changes. @@ -2049,8 +2109,10 @@ async def sample_propose_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2121,7 +2183,7 @@ async def reject_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Rejects a blueprint revision proposal and flips it back to Draft state. @@ -2165,8 +2227,10 @@ async def sample_reject_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2239,7 +2303,7 @@ async def list_blueprint_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintRevisionsAsyncPager: r"""List blueprint revisions of a given blueprint. @@ -2283,8 +2347,10 @@ async def sample_list_blueprint_revisions(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintRevisionsAsyncPager: @@ -2361,7 +2427,7 @@ async def search_blueprint_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchBlueprintRevisionsAsyncPager: r"""Searches across blueprint revisions. @@ -2425,8 +2491,10 @@ async def sample_search_blueprint_revisions(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchBlueprintRevisionsAsyncPager: @@ -2505,7 +2573,7 @@ async def search_deployment_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchDeploymentRevisionsAsyncPager: r"""Searches across deployment revisions. @@ -2569,8 +2637,10 @@ async def sample_search_deployment_revisions(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchDeploymentRevisionsAsyncPager: @@ -2648,7 +2718,7 @@ async def discard_blueprint_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Discards the changes in a blueprint and reverts the blueprint to the last approved blueprint revision. No @@ -2694,8 +2764,10 @@ async def sample_discard_blueprint_changes(): 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, 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: google.cloud.telcoautomation_v1.types.DiscardBlueprintChangesResponse: @@ -2756,7 +2828,7 @@ async def list_public_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicBlueprintsAsyncPager: r"""Lists the blueprints in TNA's public catalog. Default page size = 20, Max Page Size = 100. @@ -2802,8 +2874,10 @@ async def sample_list_public_blueprints(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListPublicBlueprintsAsyncPager: @@ -2879,7 +2953,7 @@ async def get_public_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Returns the requested public blueprint. @@ -2922,8 +2996,10 @@ async def sample_get_public_blueprint(): 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, 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: google.cloud.telcoautomation_v1.types.PublicBlueprint: @@ -2993,7 +3069,7 @@ async def create_deployment( deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Creates a deployment. @@ -3051,8 +3127,10 @@ async def sample_create_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3121,7 +3199,7 @@ async def update_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Updates a deployment. @@ -3173,8 +3251,10 @@ async def sample_update_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3242,7 +3322,7 @@ async def get_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Returns the requested deployment. @@ -3289,8 +3369,10 @@ async def sample_get_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3354,7 +3436,7 @@ async def remove_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes the deployment by marking it as DELETING. Post which deployment and it's revisions gets deleted. @@ -3395,8 +3477,10 @@ async def sample_remove_deployment(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3448,7 +3532,7 @@ async def list_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentsAsyncPager: r"""List all deployments. @@ -3493,8 +3577,10 @@ async def sample_list_deployments(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentsAsyncPager: @@ -3570,7 +3656,7 @@ async def list_deployment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentRevisionsAsyncPager: r"""List deployment revisions of a given deployment. @@ -3615,8 +3701,10 @@ async def sample_list_deployment_revisions(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentRevisionsAsyncPager: @@ -3693,7 +3781,7 @@ async def discard_deployment_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Discards the changes in a deployment and reverts the deployment to the last approved deployment revision. No @@ -3739,8 +3827,10 @@ async def sample_discard_deployment_changes(): 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, 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: google.cloud.telcoautomation_v1.types.DiscardDeploymentChangesResponse: @@ -3799,7 +3889,7 @@ async def apply_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Applies the deployment's YAML files to the parent orchestration cluster. @@ -3845,8 +3935,10 @@ async def sample_apply_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3912,7 +4004,7 @@ async def compute_deployment_status( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Returns the requested deployment status. @@ -3955,8 +4047,10 @@ async def sample_compute_deployment_status(): 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, 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: google.cloud.telcoautomation_v1.types.ComputeDeploymentStatusResponse: @@ -4018,7 +4112,7 @@ async def rollback_deployment( revision_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Rollback the active deployment to the given past approved deployment revision. @@ -4068,8 +4162,10 @@ async def sample_rollback_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -4137,7 +4233,7 @@ async def get_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Returns the requested hydrated deployment. @@ -4180,8 +4276,10 @@ async def sample_get_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -4246,7 +4344,7 @@ async def list_hydrated_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHydratedDeploymentsAsyncPager: r"""List all hydrated deployments present under a deployment. @@ -4291,8 +4389,10 @@ async def sample_list_hydrated_deployments(): 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, 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListHydratedDeploymentsAsyncPager: @@ -4369,7 +4469,7 @@ async def update_hydrated_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Updates a hydrated deployment. @@ -4419,8 +4519,10 @@ async def sample_update_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -4489,7 +4591,7 @@ async def apply_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Applies a hydrated deployment to a workload cluster. @@ -4533,8 +4635,10 @@ async def sample_apply_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -4596,7 +4700,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4607,8 +4711,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4649,7 +4755,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4660,8 +4766,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4702,7 +4810,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4718,8 +4826,10 @@ async def delete_operation( 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, 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: None """ @@ -4756,7 +4866,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4771,8 +4881,10 @@ async def cancel_operation( 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, 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: None """ @@ -4809,7 +4921,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4820,8 +4932,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -4862,7 +4976,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4873,8 +4987,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/client.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/client.py index ece6507d7076..0d42ffdf61ba 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/client.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -711,6 +721,10 @@ def __init__( # 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( @@ -776,6 +790,29 @@ def __init__( 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.telcoautomation_v1.TelcoAutomationClient`.", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "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.telcoautomation.v1.TelcoAutomation", + "credentialsType": None, + }, + ) + def list_orchestration_clusters( self, request: Optional[ @@ -785,7 +822,7 @@ def list_orchestration_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrchestrationClustersPager: r"""Lists OrchestrationClusters in a given project and location. @@ -831,8 +868,10 @@ def sample_list_orchestration_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListOrchestrationClustersPager: @@ -908,7 +947,7 @@ def get_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Gets details of a single OrchestrationCluster. @@ -950,8 +989,10 @@ def sample_get_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.OrchestrationCluster: @@ -1016,7 +1057,7 @@ def create_orchestration_cluster( orchestration_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new OrchestrationCluster in a given project and location. @@ -1078,8 +1119,10 @@ def sample_create_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1157,7 +1200,7 @@ def delete_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single OrchestrationCluster. @@ -1203,8 +1246,10 @@ def sample_delete_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1282,7 +1327,7 @@ def list_edge_slms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEdgeSlmsPager: r"""Lists EdgeSlms in a given project and location. @@ -1327,8 +1372,10 @@ def sample_list_edge_slms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListEdgeSlmsPager: @@ -1400,7 +1447,7 @@ def get_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Gets details of a single EdgeSlm. @@ -1441,8 +1488,10 @@ def sample_get_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.EdgeSlm: @@ -1505,7 +1554,7 @@ def create_edge_slm( edge_slm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new EdgeSlm in a given project and location. @@ -1565,8 +1614,10 @@ def sample_create_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1639,7 +1690,7 @@ def delete_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single EdgeSlm. @@ -1684,8 +1735,10 @@ def sample_delete_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1763,7 +1816,7 @@ def create_blueprint( blueprint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Creates a blueprint. @@ -1821,8 +1874,10 @@ def sample_create_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -1895,7 +1950,7 @@ def update_blueprint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Updates a blueprint. @@ -1947,8 +2002,10 @@ def sample_update_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2020,7 +2077,7 @@ def get_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Returns the requested blueprint. @@ -2067,8 +2124,10 @@ def sample_get_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2136,7 +2195,7 @@ def delete_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a blueprint and all its revisions. @@ -2178,8 +2237,10 @@ def sample_delete_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2228,7 +2289,7 @@ def list_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintsPager: r"""List all blueprints. @@ -2273,8 +2334,10 @@ def sample_list_blueprints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintsPager: @@ -2345,7 +2408,7 @@ def approve_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Approves a blueprint and commits a new revision. @@ -2390,8 +2453,10 @@ def sample_approve_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2459,7 +2524,7 @@ def propose_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Proposes a blueprint for approval of changes. @@ -2502,8 +2567,10 @@ def sample_propose_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2571,7 +2638,7 @@ def reject_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Rejects a blueprint revision proposal and flips it back to Draft state. @@ -2615,8 +2682,10 @@ def sample_reject_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Blueprint: @@ -2686,7 +2755,7 @@ def list_blueprint_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintRevisionsPager: r"""List blueprint revisions of a given blueprint. @@ -2730,8 +2799,10 @@ def sample_list_blueprint_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintRevisionsPager: @@ -2805,7 +2876,7 @@ def search_blueprint_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchBlueprintRevisionsPager: r"""Searches across blueprint revisions. @@ -2869,8 +2940,10 @@ def sample_search_blueprint_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchBlueprintRevisionsPager: @@ -2948,7 +3021,7 @@ def search_deployment_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchDeploymentRevisionsPager: r"""Searches across deployment revisions. @@ -3012,8 +3085,10 @@ def sample_search_deployment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchDeploymentRevisionsPager: @@ -3090,7 +3165,7 @@ def discard_blueprint_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Discards the changes in a blueprint and reverts the blueprint to the last approved blueprint revision. No @@ -3136,8 +3211,10 @@ def sample_discard_blueprint_changes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.DiscardBlueprintChangesResponse: @@ -3197,7 +3274,7 @@ def list_public_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicBlueprintsPager: r"""Lists the blueprints in TNA's public catalog. Default page size = 20, Max Page Size = 100. @@ -3243,8 +3320,10 @@ def sample_list_public_blueprints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListPublicBlueprintsPager: @@ -3317,7 +3396,7 @@ def get_public_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Returns the requested public blueprint. @@ -3360,8 +3439,10 @@ def sample_get_public_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.PublicBlueprint: @@ -3428,7 +3509,7 @@ def create_deployment( deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Creates a deployment. @@ -3486,8 +3567,10 @@ def sample_create_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3553,7 +3636,7 @@ def update_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Updates a deployment. @@ -3605,8 +3688,10 @@ def sample_update_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3671,7 +3756,7 @@ def get_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Returns the requested deployment. @@ -3718,8 +3803,10 @@ def sample_get_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -3780,7 +3867,7 @@ def remove_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes the deployment by marking it as DELETING. Post which deployment and it's revisions gets deleted. @@ -3821,8 +3908,10 @@ def sample_remove_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3871,7 +3960,7 @@ def list_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentsPager: r"""List all deployments. @@ -3916,8 +4005,10 @@ def sample_list_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentsPager: @@ -3990,7 +4081,7 @@ def list_deployment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentRevisionsPager: r"""List deployment revisions of a given deployment. @@ -4035,8 +4126,10 @@ def sample_list_deployment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentRevisionsPager: @@ -4112,7 +4205,7 @@ def discard_deployment_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Discards the changes in a deployment and reverts the deployment to the last approved deployment revision. No @@ -4158,8 +4251,10 @@ def sample_discard_deployment_changes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.DiscardDeploymentChangesResponse: @@ -4217,7 +4312,7 @@ def apply_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Applies the deployment's YAML files to the parent orchestration cluster. @@ -4263,8 +4358,10 @@ def sample_apply_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -4327,7 +4424,7 @@ def compute_deployment_status( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Returns the requested deployment status. @@ -4370,8 +4467,10 @@ def sample_compute_deployment_status(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.ComputeDeploymentStatusResponse: @@ -4432,7 +4531,7 @@ def rollback_deployment( revision_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Rollback the active deployment to the given past approved deployment revision. @@ -4482,8 +4581,10 @@ def sample_rollback_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.Deployment: @@ -4548,7 +4649,7 @@ def get_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Returns the requested hydrated deployment. @@ -4591,8 +4692,10 @@ def sample_get_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -4654,7 +4757,7 @@ def list_hydrated_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHydratedDeploymentsPager: r"""List all hydrated deployments present under a deployment. @@ -4699,8 +4802,10 @@ def sample_list_hydrated_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListHydratedDeploymentsPager: @@ -4776,7 +4881,7 @@ def update_hydrated_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Updates a hydrated deployment. @@ -4826,8 +4931,10 @@ def sample_update_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -4895,7 +5002,7 @@ def apply_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Applies a hydrated deployment to a workload cluster. @@ -4939,8 +5046,10 @@ def sample_apply_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1.types.HydratedDeployment: @@ -5014,7 +5123,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5025,8 +5134,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -5067,7 +5178,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -5078,8 +5189,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5120,7 +5233,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -5136,8 +5249,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5174,7 +5289,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -5189,8 +5304,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5227,7 +5344,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -5238,8 +5355,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -5280,7 +5399,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -5291,8 +5410,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/pagers.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/pagers.py index 7262f71adb17..11c7e6e25269 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/pagers.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListOrchestrationClustersRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListOrchestrationClustersRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListEdgeSlmsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListEdgeSlmsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListBlueprintsRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListBlueprintsRequest(request) @@ -527,7 +539,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -541,8 +553,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListBlueprintRevisionsRequest(request) @@ -603,7 +617,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -617,8 +631,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListBlueprintRevisionsRequest(request) @@ -683,7 +699,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -697,8 +713,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.SearchBlueprintRevisionsRequest(request) @@ -759,7 +777,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -773,8 +791,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.SearchBlueprintRevisionsRequest(request) @@ -839,7 +859,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -853,8 +873,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.SearchDeploymentRevisionsRequest(request) @@ -915,7 +937,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -929,8 +951,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.SearchDeploymentRevisionsRequest(request) @@ -995,7 +1019,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1009,8 +1033,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListPublicBlueprintsRequest(request) @@ -1069,7 +1095,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1083,8 +1109,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListPublicBlueprintsRequest(request) @@ -1149,7 +1177,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1163,8 +1191,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListDeploymentsRequest(request) @@ -1223,7 +1253,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1237,8 +1267,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListDeploymentsRequest(request) @@ -1301,7 +1333,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1315,8 +1347,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListDeploymentRevisionsRequest(request) @@ -1377,7 +1411,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1391,8 +1425,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListDeploymentRevisionsRequest(request) @@ -1457,7 +1493,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1471,8 +1507,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListHydratedDeploymentsRequest(request) @@ -1533,7 +1571,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1547,8 +1585,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListHydratedDeploymentsRequest(request) diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc.py index bc3943375d03..3a0ebcd6e085 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.telcoautomation_v1.types import telcoautomation from .base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport +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.telcoautomation.v1.TelcoAutomation", + "rpcName": 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.telcoautomation.v1.TelcoAutomation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TelcoAutomationGrpcTransport(TelcoAutomationTransport): """gRPC backend transport for TelcoAutomation. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,9 @@ def list_orchestration_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_orchestration_clusters" not in self._stubs: - self._stubs["list_orchestration_clusters"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_orchestration_clusters" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListOrchestrationClusters", request_serializer=telcoautomation.ListOrchestrationClustersRequest.serialize, response_deserializer=telcoautomation.ListOrchestrationClustersResponse.deserialize, @@ -308,7 +398,7 @@ def get_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_orchestration_cluster" not in self._stubs: - self._stubs["get_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_orchestration_cluster"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetOrchestrationCluster", request_serializer=telcoautomation.GetOrchestrationClusterRequest.serialize, response_deserializer=telcoautomation.OrchestrationCluster.deserialize, @@ -337,7 +427,9 @@ def create_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_orchestration_cluster" not in self._stubs: - self._stubs["create_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateOrchestrationCluster", request_serializer=telcoautomation.CreateOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +457,9 @@ def delete_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_orchestration_cluster" not in self._stubs: - self._stubs["delete_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteOrchestrationCluster", request_serializer=telcoautomation.DeleteOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +487,7 @@ def list_edge_slms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_edge_slms" not in self._stubs: - self._stubs["list_edge_slms"] = self.grpc_channel.unary_unary( + self._stubs["list_edge_slms"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListEdgeSlms", request_serializer=telcoautomation.ListEdgeSlmsRequest.serialize, response_deserializer=telcoautomation.ListEdgeSlmsResponse.deserialize, @@ -419,7 +513,7 @@ def get_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_edge_slm" not in self._stubs: - self._stubs["get_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["get_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetEdgeSlm", request_serializer=telcoautomation.GetEdgeSlmRequest.serialize, response_deserializer=telcoautomation.EdgeSlm.deserialize, @@ -446,7 +540,7 @@ def create_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_edge_slm" not in self._stubs: - self._stubs["create_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["create_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateEdgeSlm", request_serializer=telcoautomation.CreateEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +566,7 @@ def delete_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_edge_slm" not in self._stubs: - self._stubs["delete_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["delete_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteEdgeSlm", request_serializer=telcoautomation.DeleteEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -498,7 +592,7 @@ def create_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_blueprint" not in self._stubs: - self._stubs["create_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["create_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateBlueprint", request_serializer=telcoautomation.CreateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -524,7 +618,7 @@ def update_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_blueprint" not in self._stubs: - self._stubs["update_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["update_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateBlueprint", request_serializer=telcoautomation.UpdateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -550,7 +644,7 @@ def get_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_blueprint" not in self._stubs: - self._stubs["get_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetBlueprint", request_serializer=telcoautomation.GetBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -576,7 +670,7 @@ def delete_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_blueprint" not in self._stubs: - self._stubs["delete_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["delete_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteBlueprint", request_serializer=telcoautomation.DeleteBlueprintRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -604,7 +698,7 @@ def list_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprints" not in self._stubs: - self._stubs["list_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListBlueprints", request_serializer=telcoautomation.ListBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintsResponse.deserialize, @@ -630,7 +724,7 @@ def approve_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_blueprint" not in self._stubs: - self._stubs["approve_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["approve_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApproveBlueprint", request_serializer=telcoautomation.ApproveBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -656,7 +750,7 @@ def propose_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "propose_blueprint" not in self._stubs: - self._stubs["propose_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["propose_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ProposeBlueprint", request_serializer=telcoautomation.ProposeBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -683,7 +777,7 @@ def reject_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_blueprint" not in self._stubs: - self._stubs["reject_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["reject_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RejectBlueprint", request_serializer=telcoautomation.RejectBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -712,7 +806,7 @@ def list_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprint_revisions" not in self._stubs: - self._stubs["list_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprint_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListBlueprintRevisions", request_serializer=telcoautomation.ListBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintRevisionsResponse.deserialize, @@ -741,7 +835,9 @@ def search_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_blueprint_revisions" not in self._stubs: - self._stubs["search_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_blueprint_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/SearchBlueprintRevisions", request_serializer=telcoautomation.SearchBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchBlueprintRevisionsResponse.deserialize, @@ -770,7 +866,9 @@ def search_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_deployment_revisions" not in self._stubs: - self._stubs["search_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_deployment_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/SearchDeploymentRevisions", request_serializer=telcoautomation.SearchDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchDeploymentRevisionsResponse.deserialize, @@ -802,7 +900,7 @@ def discard_blueprint_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_blueprint_changes" not in self._stubs: - self._stubs["discard_blueprint_changes"] = self.grpc_channel.unary_unary( + self._stubs["discard_blueprint_changes"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DiscardBlueprintChanges", request_serializer=telcoautomation.DiscardBlueprintChangesRequest.serialize, response_deserializer=telcoautomation.DiscardBlueprintChangesResponse.deserialize, @@ -832,7 +930,7 @@ def list_public_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_blueprints" not in self._stubs: - self._stubs["list_public_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_public_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListPublicBlueprints", request_serializer=telcoautomation.ListPublicBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListPublicBlueprintsResponse.deserialize, @@ -860,7 +958,7 @@ def get_public_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_public_blueprint" not in self._stubs: - self._stubs["get_public_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_public_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetPublicBlueprint", request_serializer=telcoautomation.GetPublicBlueprintRequest.serialize, response_deserializer=telcoautomation.PublicBlueprint.deserialize, @@ -888,7 +986,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateDeployment", request_serializer=telcoautomation.CreateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -916,7 +1014,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateDeployment", request_serializer=telcoautomation.UpdateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -942,7 +1040,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetDeployment", request_serializer=telcoautomation.GetDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -969,7 +1067,7 @@ def remove_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_deployment" not in self._stubs: - self._stubs["remove_deployment"] = self.grpc_channel.unary_unary( + self._stubs["remove_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RemoveDeployment", request_serializer=telcoautomation.RemoveDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -998,7 +1096,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListDeployments", request_serializer=telcoautomation.ListDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentsResponse.deserialize, @@ -1027,7 +1125,7 @@ def list_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployment_revisions" not in self._stubs: - self._stubs["list_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_deployment_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListDeploymentRevisions", request_serializer=telcoautomation.ListDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentRevisionsResponse.deserialize, @@ -1059,7 +1157,9 @@ def discard_deployment_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_deployment_changes" not in self._stubs: - self._stubs["discard_deployment_changes"] = self.grpc_channel.unary_unary( + self._stubs[ + "discard_deployment_changes" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DiscardDeploymentChanges", request_serializer=telcoautomation.DiscardDeploymentChangesRequest.serialize, response_deserializer=telcoautomation.DiscardDeploymentChangesResponse.deserialize, @@ -1086,7 +1186,7 @@ def apply_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_deployment" not in self._stubs: - self._stubs["apply_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApplyDeployment", request_serializer=telcoautomation.ApplyDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1115,7 +1215,7 @@ def compute_deployment_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_deployment_status" not in self._stubs: - self._stubs["compute_deployment_status"] = self.grpc_channel.unary_unary( + self._stubs["compute_deployment_status"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ComputeDeploymentStatus", request_serializer=telcoautomation.ComputeDeploymentStatusRequest.serialize, response_deserializer=telcoautomation.ComputeDeploymentStatusResponse.deserialize, @@ -1144,7 +1244,7 @@ def rollback_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_deployment" not in self._stubs: - self._stubs["rollback_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RollbackDeployment", request_serializer=telcoautomation.RollbackDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1173,7 +1273,7 @@ def get_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hydrated_deployment" not in self._stubs: - self._stubs["get_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetHydratedDeployment", request_serializer=telcoautomation.GetHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1203,7 +1303,7 @@ def list_hydrated_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hydrated_deployments" not in self._stubs: - self._stubs["list_hydrated_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_hydrated_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListHydratedDeployments", request_serializer=telcoautomation.ListHydratedDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListHydratedDeploymentsResponse.deserialize, @@ -1232,7 +1332,9 @@ def update_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hydrated_deployment" not in self._stubs: - self._stubs["update_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_hydrated_deployment" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateHydratedDeployment", request_serializer=telcoautomation.UpdateHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1261,7 +1363,7 @@ def apply_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_hydrated_deployment" not in self._stubs: - self._stubs["apply_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApplyHydratedDeployment", request_serializer=telcoautomation.ApplyHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1269,7 +1371,7 @@ def apply_hydrated_deployment( return self._stubs["apply_hydrated_deployment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1281,7 +1383,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1298,7 +1400,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1315,7 +1417,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1334,7 +1436,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1353,7 +1455,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1370,7 +1472,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc_asyncio.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc_asyncio.py index f7ba8d3dcf84..44925c7dea0f 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc_asyncio.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.telcoautomation_v1.types import telcoautomation from .base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport from .grpc import TelcoAutomationGrpcTransport +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.telcoautomation.v1.TelcoAutomation", + "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.telcoautomation.v1.TelcoAutomation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TelcoAutomationGrpcAsyncIOTransport(TelcoAutomationTransport): """gRPC AsyncIO backend transport for TelcoAutomation. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,9 @@ def list_orchestration_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_orchestration_clusters" not in self._stubs: - self._stubs["list_orchestration_clusters"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_orchestration_clusters" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListOrchestrationClusters", request_serializer=telcoautomation.ListOrchestrationClustersRequest.serialize, response_deserializer=telcoautomation.ListOrchestrationClustersResponse.deserialize, @@ -318,7 +405,7 @@ def get_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_orchestration_cluster" not in self._stubs: - self._stubs["get_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_orchestration_cluster"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetOrchestrationCluster", request_serializer=telcoautomation.GetOrchestrationClusterRequest.serialize, response_deserializer=telcoautomation.OrchestrationCluster.deserialize, @@ -348,7 +435,9 @@ def create_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_orchestration_cluster" not in self._stubs: - self._stubs["create_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateOrchestrationCluster", request_serializer=telcoautomation.CreateOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +466,9 @@ def delete_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_orchestration_cluster" not in self._stubs: - self._stubs["delete_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteOrchestrationCluster", request_serializer=telcoautomation.DeleteOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +497,7 @@ def list_edge_slms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_edge_slms" not in self._stubs: - self._stubs["list_edge_slms"] = self.grpc_channel.unary_unary( + self._stubs["list_edge_slms"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListEdgeSlms", request_serializer=telcoautomation.ListEdgeSlmsRequest.serialize, response_deserializer=telcoautomation.ListEdgeSlmsResponse.deserialize, @@ -434,7 +525,7 @@ def get_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_edge_slm" not in self._stubs: - self._stubs["get_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["get_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetEdgeSlm", request_serializer=telcoautomation.GetEdgeSlmRequest.serialize, response_deserializer=telcoautomation.EdgeSlm.deserialize, @@ -463,7 +554,7 @@ def create_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_edge_slm" not in self._stubs: - self._stubs["create_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["create_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateEdgeSlm", request_serializer=telcoautomation.CreateEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -491,7 +582,7 @@ def delete_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_edge_slm" not in self._stubs: - self._stubs["delete_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["delete_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteEdgeSlm", request_serializer=telcoautomation.DeleteEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +610,7 @@ def create_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_blueprint" not in self._stubs: - self._stubs["create_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["create_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateBlueprint", request_serializer=telcoautomation.CreateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -547,7 +638,7 @@ def update_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_blueprint" not in self._stubs: - self._stubs["update_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["update_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateBlueprint", request_serializer=telcoautomation.UpdateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -575,7 +666,7 @@ def get_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_blueprint" not in self._stubs: - self._stubs["get_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetBlueprint", request_serializer=telcoautomation.GetBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -601,7 +692,7 @@ def delete_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_blueprint" not in self._stubs: - self._stubs["delete_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["delete_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DeleteBlueprint", request_serializer=telcoautomation.DeleteBlueprintRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -630,7 +721,7 @@ def list_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprints" not in self._stubs: - self._stubs["list_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListBlueprints", request_serializer=telcoautomation.ListBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintsResponse.deserialize, @@ -658,7 +749,7 @@ def approve_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_blueprint" not in self._stubs: - self._stubs["approve_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["approve_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApproveBlueprint", request_serializer=telcoautomation.ApproveBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -686,7 +777,7 @@ def propose_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "propose_blueprint" not in self._stubs: - self._stubs["propose_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["propose_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ProposeBlueprint", request_serializer=telcoautomation.ProposeBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -715,7 +806,7 @@ def reject_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_blueprint" not in self._stubs: - self._stubs["reject_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["reject_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RejectBlueprint", request_serializer=telcoautomation.RejectBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -744,7 +835,7 @@ def list_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprint_revisions" not in self._stubs: - self._stubs["list_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprint_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListBlueprintRevisions", request_serializer=telcoautomation.ListBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintRevisionsResponse.deserialize, @@ -773,7 +864,9 @@ def search_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_blueprint_revisions" not in self._stubs: - self._stubs["search_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_blueprint_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/SearchBlueprintRevisions", request_serializer=telcoautomation.SearchBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchBlueprintRevisionsResponse.deserialize, @@ -802,7 +895,9 @@ def search_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_deployment_revisions" not in self._stubs: - self._stubs["search_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_deployment_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/SearchDeploymentRevisions", request_serializer=telcoautomation.SearchDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchDeploymentRevisionsResponse.deserialize, @@ -834,7 +929,7 @@ def discard_blueprint_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_blueprint_changes" not in self._stubs: - self._stubs["discard_blueprint_changes"] = self.grpc_channel.unary_unary( + self._stubs["discard_blueprint_changes"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DiscardBlueprintChanges", request_serializer=telcoautomation.DiscardBlueprintChangesRequest.serialize, response_deserializer=telcoautomation.DiscardBlueprintChangesResponse.deserialize, @@ -864,7 +959,7 @@ def list_public_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_blueprints" not in self._stubs: - self._stubs["list_public_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_public_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListPublicBlueprints", request_serializer=telcoautomation.ListPublicBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListPublicBlueprintsResponse.deserialize, @@ -893,7 +988,7 @@ def get_public_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_public_blueprint" not in self._stubs: - self._stubs["get_public_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_public_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetPublicBlueprint", request_serializer=telcoautomation.GetPublicBlueprintRequest.serialize, response_deserializer=telcoautomation.PublicBlueprint.deserialize, @@ -921,7 +1016,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/CreateDeployment", request_serializer=telcoautomation.CreateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -949,7 +1044,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateDeployment", request_serializer=telcoautomation.UpdateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -977,7 +1072,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetDeployment", request_serializer=telcoautomation.GetDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1006,7 +1101,7 @@ def remove_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_deployment" not in self._stubs: - self._stubs["remove_deployment"] = self.grpc_channel.unary_unary( + self._stubs["remove_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RemoveDeployment", request_serializer=telcoautomation.RemoveDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1035,7 +1130,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListDeployments", request_serializer=telcoautomation.ListDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentsResponse.deserialize, @@ -1064,7 +1159,7 @@ def list_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployment_revisions" not in self._stubs: - self._stubs["list_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_deployment_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListDeploymentRevisions", request_serializer=telcoautomation.ListDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentRevisionsResponse.deserialize, @@ -1096,7 +1191,9 @@ def discard_deployment_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_deployment_changes" not in self._stubs: - self._stubs["discard_deployment_changes"] = self.grpc_channel.unary_unary( + self._stubs[ + "discard_deployment_changes" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/DiscardDeploymentChanges", request_serializer=telcoautomation.DiscardDeploymentChangesRequest.serialize, response_deserializer=telcoautomation.DiscardDeploymentChangesResponse.deserialize, @@ -1125,7 +1222,7 @@ def apply_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_deployment" not in self._stubs: - self._stubs["apply_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApplyDeployment", request_serializer=telcoautomation.ApplyDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1154,7 +1251,7 @@ def compute_deployment_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_deployment_status" not in self._stubs: - self._stubs["compute_deployment_status"] = self.grpc_channel.unary_unary( + self._stubs["compute_deployment_status"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ComputeDeploymentStatus", request_serializer=telcoautomation.ComputeDeploymentStatusRequest.serialize, response_deserializer=telcoautomation.ComputeDeploymentStatusResponse.deserialize, @@ -1184,7 +1281,7 @@ def rollback_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_deployment" not in self._stubs: - self._stubs["rollback_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/RollbackDeployment", request_serializer=telcoautomation.RollbackDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1213,7 +1310,7 @@ def get_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hydrated_deployment" not in self._stubs: - self._stubs["get_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/GetHydratedDeployment", request_serializer=telcoautomation.GetHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1243,7 +1340,7 @@ def list_hydrated_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hydrated_deployments" not in self._stubs: - self._stubs["list_hydrated_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_hydrated_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ListHydratedDeployments", request_serializer=telcoautomation.ListHydratedDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListHydratedDeploymentsResponse.deserialize, @@ -1272,7 +1369,9 @@ def update_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hydrated_deployment" not in self._stubs: - self._stubs["update_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_hydrated_deployment" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/UpdateHydratedDeployment", request_serializer=telcoautomation.UpdateHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1301,7 +1400,7 @@ def apply_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_hydrated_deployment" not in self._stubs: - self._stubs["apply_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1.TelcoAutomation/ApplyHydratedDeployment", request_serializer=telcoautomation.ApplyHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1529,7 +1628,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1545,7 +1644,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1562,7 +1661,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1579,7 +1678,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1598,7 +1697,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1617,7 +1716,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1634,7 +1733,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/rest.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/rest.py index eb4ade59f98a..d6899346ef07 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/rest.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1/services/telco_automation/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -352,8 +360,10 @@ def post_update_hydrated_deployment(self, response): def pre_apply_deployment( self, request: telcoautomation.ApplyDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ApplyDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ApplyDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for apply_deployment Override in a subclass to manipulate the request or metadata @@ -375,9 +385,10 @@ def post_apply_deployment( def pre_apply_hydrated_deployment( self, request: telcoautomation.ApplyHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ApplyHydratedDeploymentRequest, Sequence[Tuple[str, str]] + telcoautomation.ApplyHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for apply_hydrated_deployment @@ -400,8 +411,10 @@ def post_apply_hydrated_deployment( def pre_approve_blueprint( self, request: telcoautomation.ApproveBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ApproveBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ApproveBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for approve_blueprint Override in a subclass to manipulate the request or metadata @@ -423,9 +436,10 @@ def post_approve_blueprint( def pre_compute_deployment_status( self, request: telcoautomation.ComputeDeploymentStatusRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ComputeDeploymentStatusRequest, Sequence[Tuple[str, str]] + telcoautomation.ComputeDeploymentStatusRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for compute_deployment_status @@ -448,8 +462,10 @@ def post_compute_deployment_status( def pre_create_blueprint( self, request: telcoautomation.CreateBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_blueprint Override in a subclass to manipulate the request or metadata @@ -471,8 +487,10 @@ def post_create_blueprint( def pre_create_deployment( self, request: telcoautomation.CreateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_deployment Override in a subclass to manipulate the request or metadata @@ -494,8 +512,10 @@ def post_create_deployment( def pre_create_edge_slm( self, request: telcoautomation.CreateEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_edge_slm Override in a subclass to manipulate the request or metadata @@ -517,9 +537,10 @@ def post_create_edge_slm( def pre_create_orchestration_cluster( self, request: telcoautomation.CreateOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.CreateOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.CreateOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_orchestration_cluster @@ -542,8 +563,10 @@ def post_create_orchestration_cluster( def pre_delete_blueprint( self, request: telcoautomation.DeleteBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.DeleteBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.DeleteBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_blueprint Override in a subclass to manipulate the request or metadata @@ -554,8 +577,10 @@ def pre_delete_blueprint( def pre_delete_edge_slm( self, request: telcoautomation.DeleteEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.DeleteEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.DeleteEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_edge_slm Override in a subclass to manipulate the request or metadata @@ -577,9 +602,10 @@ def post_delete_edge_slm( def pre_delete_orchestration_cluster( self, request: telcoautomation.DeleteOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DeleteOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.DeleteOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_orchestration_cluster @@ -602,9 +628,10 @@ def post_delete_orchestration_cluster( def pre_discard_blueprint_changes( self, request: telcoautomation.DiscardBlueprintChangesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DiscardBlueprintChangesRequest, Sequence[Tuple[str, str]] + telcoautomation.DiscardBlueprintChangesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for discard_blueprint_changes @@ -627,9 +654,10 @@ def post_discard_blueprint_changes( def pre_discard_deployment_changes( self, request: telcoautomation.DiscardDeploymentChangesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DiscardDeploymentChangesRequest, Sequence[Tuple[str, str]] + telcoautomation.DiscardDeploymentChangesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for discard_deployment_changes @@ -652,8 +680,10 @@ def post_discard_deployment_changes( def pre_get_blueprint( self, request: telcoautomation.GetBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_blueprint Override in a subclass to manipulate the request or metadata @@ -675,8 +705,10 @@ def post_get_blueprint( def pre_get_deployment( self, request: telcoautomation.GetDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_deployment Override in a subclass to manipulate the request or metadata @@ -698,8 +730,10 @@ def post_get_deployment( def pre_get_edge_slm( self, request: telcoautomation.GetEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_edge_slm Override in a subclass to manipulate the request or metadata @@ -721,8 +755,11 @@ def post_get_edge_slm( def pre_get_hydrated_deployment( self, request: telcoautomation.GetHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetHydratedDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_hydrated_deployment Override in a subclass to manipulate the request or metadata @@ -744,9 +781,10 @@ def post_get_hydrated_deployment( def pre_get_orchestration_cluster( self, request: telcoautomation.GetOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.GetOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.GetOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_orchestration_cluster @@ -769,8 +807,11 @@ def post_get_orchestration_cluster( def pre_get_public_blueprint( self, request: telcoautomation.GetPublicBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetPublicBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetPublicBlueprintRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_public_blueprint Override in a subclass to manipulate the request or metadata @@ -792,9 +833,10 @@ def post_get_public_blueprint( def pre_list_blueprint_revisions( self, request: telcoautomation.ListBlueprintRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListBlueprintRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListBlueprintRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_blueprint_revisions @@ -817,8 +859,10 @@ def post_list_blueprint_revisions( def pre_list_blueprints( self, request: telcoautomation.ListBlueprintsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListBlueprintsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListBlueprintsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_blueprints Override in a subclass to manipulate the request or metadata @@ -840,9 +884,10 @@ def post_list_blueprints( def pre_list_deployment_revisions( self, request: telcoautomation.ListDeploymentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListDeploymentRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListDeploymentRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_deployment_revisions @@ -865,8 +910,10 @@ def post_list_deployment_revisions( def pre_list_deployments( self, request: telcoautomation.ListDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListDeploymentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_deployments Override in a subclass to manipulate the request or metadata @@ -888,8 +935,10 @@ def post_list_deployments( def pre_list_edge_slms( self, request: telcoautomation.ListEdgeSlmsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListEdgeSlmsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListEdgeSlmsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_edge_slms Override in a subclass to manipulate the request or metadata @@ -911,9 +960,10 @@ def post_list_edge_slms( def pre_list_hydrated_deployments( self, request: telcoautomation.ListHydratedDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListHydratedDeploymentsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListHydratedDeploymentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_hydrated_deployments @@ -936,9 +986,10 @@ def post_list_hydrated_deployments( def pre_list_orchestration_clusters( self, request: telcoautomation.ListOrchestrationClustersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListOrchestrationClustersRequest, Sequence[Tuple[str, str]] + telcoautomation.ListOrchestrationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_orchestration_clusters @@ -961,8 +1012,11 @@ def post_list_orchestration_clusters( def pre_list_public_blueprints( self, request: telcoautomation.ListPublicBlueprintsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListPublicBlueprintsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListPublicBlueprintsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_public_blueprints Override in a subclass to manipulate the request or metadata @@ -984,8 +1038,10 @@ def post_list_public_blueprints( def pre_propose_blueprint( self, request: telcoautomation.ProposeBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ProposeBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ProposeBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for propose_blueprint Override in a subclass to manipulate the request or metadata @@ -1007,8 +1063,10 @@ def post_propose_blueprint( def pre_reject_blueprint( self, request: telcoautomation.RejectBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RejectBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RejectBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for reject_blueprint Override in a subclass to manipulate the request or metadata @@ -1030,8 +1088,10 @@ def post_reject_blueprint( def pre_remove_deployment( self, request: telcoautomation.RemoveDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RemoveDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RemoveDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_deployment Override in a subclass to manipulate the request or metadata @@ -1042,8 +1102,11 @@ def pre_remove_deployment( def pre_rollback_deployment( self, request: telcoautomation.RollbackDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RollbackDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RollbackDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for rollback_deployment Override in a subclass to manipulate the request or metadata @@ -1065,9 +1128,10 @@ def post_rollback_deployment( def pre_search_blueprint_revisions( self, request: telcoautomation.SearchBlueprintRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.SearchBlueprintRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.SearchBlueprintRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_blueprint_revisions @@ -1090,9 +1154,10 @@ def post_search_blueprint_revisions( def pre_search_deployment_revisions( self, request: telcoautomation.SearchDeploymentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.SearchDeploymentRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.SearchDeploymentRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_deployment_revisions @@ -1115,8 +1180,10 @@ def post_search_deployment_revisions( def pre_update_blueprint( self, request: telcoautomation.UpdateBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.UpdateBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.UpdateBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_blueprint Override in a subclass to manipulate the request or metadata @@ -1138,8 +1205,10 @@ def post_update_blueprint( def pre_update_deployment( self, request: telcoautomation.UpdateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.UpdateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.UpdateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_deployment Override in a subclass to manipulate the request or metadata @@ -1161,9 +1230,10 @@ def post_update_deployment( def pre_update_hydrated_deployment( self, request: telcoautomation.UpdateHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.UpdateHydratedDeploymentRequest, Sequence[Tuple[str, str]] + telcoautomation.UpdateHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_hydrated_deployment @@ -1186,8 +1256,10 @@ def post_update_hydrated_deployment( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -1209,8 +1281,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -1232,8 +1306,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1253,8 +1329,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1274,8 +1352,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1297,8 +1377,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1497,7 +1579,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the apply deployment method over HTTP. @@ -1509,8 +1591,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -1525,6 +1609,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApplyDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_apply_deployment( request, metadata ) @@ -1541,6 +1626,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ApplyDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApplyDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ApplyDeployment._get_response( self._host, @@ -1562,7 +1674,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1.TelcoAutomationClient.apply_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApplyDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApplyHydratedDeployment( @@ -1601,7 +1735,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the apply hydrated deployment method over HTTP. @@ -1612,8 +1746,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -1627,6 +1763,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApplyHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_apply_hydrated_deployment( request, metadata ) @@ -1643,6 +1780,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ApplyHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApplyHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ApplyHydratedDeployment._get_response( @@ -1666,7 +1830,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1.TelcoAutomationClient.apply_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApplyHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApproveBlueprint( @@ -1704,7 +1892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the approve blueprint method over HTTP. @@ -1714,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -1737,6 +1927,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApproveBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_approve_blueprint( request, metadata ) @@ -1753,6 +1944,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ApproveBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApproveBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ApproveBlueprint._get_response( self._host, @@ -1774,7 +1992,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.approve_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ApproveBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ComputeDeploymentStatus( @@ -1812,7 +2052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Call the compute deployment status method over HTTP. @@ -1822,8 +2062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ComputeDeploymentStatusResponse: @@ -1833,6 +2075,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseComputeDeploymentStatus._get_http_options() ) + request, metadata = self._interceptor.pre_compute_deployment_status( request, metadata ) @@ -1845,6 +2088,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ComputeDeploymentStatus", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ComputeDeploymentStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ComputeDeploymentStatus._get_response( @@ -1867,7 +2137,33 @@ def __call__( pb_resp = telcoautomation.ComputeDeploymentStatusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_deployment_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ComputeDeploymentStatusResponse.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.telcoautomation_v1.TelcoAutomationClient.compute_deployment_status", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ComputeDeploymentStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBlueprint( @@ -1905,7 +2201,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the create blueprint method over HTTP. @@ -1915,8 +2211,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -1938,6 +2236,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_create_blueprint( request, metadata ) @@ -1954,6 +2253,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.CreateBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateBlueprint._get_response( self._host, @@ -1975,7 +2301,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.create_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDeployment( @@ -2013,7 +2361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the create deployment method over HTTP. @@ -2023,8 +2371,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -2039,6 +2389,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_deployment( request, metadata ) @@ -2055,6 +2406,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.CreateDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateDeployment._get_response( self._host, @@ -2076,7 +2454,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1.TelcoAutomationClient.create_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEdgeSlm( @@ -2114,7 +2514,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create edge slm method over HTTP. @@ -2124,8 +2524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2138,6 +2540,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_create_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseCreateEdgeSlm._get_transcoded_request( http_options, request @@ -2152,6 +2555,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.CreateEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateEdgeSlm._get_response( self._host, @@ -2171,7 +2601,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_edge_slm(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.telcoautomation_v1.TelcoAutomationClient.create_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateOrchestrationCluster( @@ -2210,7 +2662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create orchestration cluster method over HTTP. @@ -2222,8 +2674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2236,6 +2690,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_orchestration_cluster( request, metadata ) @@ -2252,6 +2707,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.CreateOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._CreateOrchestrationCluster._get_response( @@ -2273,7 +2755,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_orchestration_cluster(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.telcoautomation_v1.TelcoAutomationClient.create_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CreateOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBlueprint( @@ -2310,7 +2814,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete blueprint method over HTTP. @@ -2320,13 +2824,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_blueprint( request, metadata ) @@ -2339,6 +2846,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DeleteBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteBlueprint._get_response( self._host, @@ -2388,7 +2922,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete edge slm method over HTTP. @@ -2398,8 +2932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2412,6 +2948,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_delete_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseDeleteEdgeSlm._get_transcoded_request( http_options, request @@ -2422,6 +2959,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DeleteEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteEdgeSlm._get_response( self._host, @@ -2440,7 +3004,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_edge_slm(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.telcoautomation_v1.TelcoAutomationClient.delete_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOrchestrationCluster( @@ -2478,7 +3064,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete orchestration cluster method over HTTP. @@ -2490,8 +3076,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2504,6 +3092,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_orchestration_cluster( request, metadata ) @@ -2516,6 +3105,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DeleteOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DeleteOrchestrationCluster._get_response( @@ -2536,7 +3152,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_orchestration_cluster(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.telcoautomation_v1.TelcoAutomationClient.delete_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DiscardBlueprintChanges( @@ -2575,7 +3213,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Call the discard blueprint changes method over HTTP. @@ -2585,8 +3223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.DiscardBlueprintChangesResponse: @@ -2596,6 +3236,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDiscardBlueprintChanges._get_http_options() ) + request, metadata = self._interceptor.pre_discard_blueprint_changes( request, metadata ) @@ -2612,6 +3253,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DiscardBlueprintChanges", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DiscardBlueprintChanges", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DiscardBlueprintChanges._get_response( @@ -2635,7 +3303,33 @@ def __call__( pb_resp = telcoautomation.DiscardBlueprintChangesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_discard_blueprint_changes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.DiscardBlueprintChangesResponse.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.telcoautomation_v1.TelcoAutomationClient.discard_blueprint_changes", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DiscardBlueprintChanges", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DiscardDeploymentChanges( @@ -2674,7 +3368,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Call the discard deployment changes method over HTTP. @@ -2685,8 +3379,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.DiscardDeploymentChangesResponse: @@ -2696,6 +3392,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDiscardDeploymentChanges._get_http_options() ) + request, metadata = self._interceptor.pre_discard_deployment_changes( request, metadata ) @@ -2712,6 +3409,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DiscardDeploymentChanges", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DiscardDeploymentChanges", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DiscardDeploymentChanges._get_response( @@ -2735,7 +3459,33 @@ def __call__( pb_resp = telcoautomation.DiscardDeploymentChangesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_discard_deployment_changes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.DiscardDeploymentChangesResponse.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.telcoautomation_v1.TelcoAutomationClient.discard_deployment_changes", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DiscardDeploymentChanges", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBlueprint( @@ -2772,7 +3522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the get blueprint method over HTTP. @@ -2782,8 +3532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -2805,6 +3557,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_get_blueprint(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetBlueprint._get_transcoded_request( http_options, request @@ -2815,6 +3568,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetBlueprint._get_response( self._host, @@ -2835,7 +3615,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.get_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeployment( @@ -2872,7 +3674,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the get deployment method over HTTP. @@ -2882,8 +3684,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -2898,6 +3702,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_deployment(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetDeployment._get_transcoded_request( http_options, request @@ -2908,6 +3713,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetDeployment._get_response( self._host, @@ -2928,7 +3760,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1.TelcoAutomationClient.get_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEdgeSlm( @@ -2965,7 +3819,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Call the get edge slm method over HTTP. @@ -2975,8 +3829,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.EdgeSlm: @@ -2991,6 +3847,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_get_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetEdgeSlm._get_transcoded_request( http_options, request @@ -3001,6 +3858,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetEdgeSlm._get_response( self._host, @@ -3021,7 +3905,29 @@ def __call__( pb_resp = telcoautomation.EdgeSlm.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_edge_slm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.EdgeSlm.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.telcoautomation_v1.TelcoAutomationClient.get_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHydratedDeployment( @@ -3059,7 +3965,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the get hydrated deployment method over HTTP. @@ -3069,8 +3975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -3084,6 +3992,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_hydrated_deployment( request, metadata ) @@ -3096,6 +4005,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._GetHydratedDeployment._get_response( @@ -3118,7 +4054,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1.TelcoAutomationClient.get_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrchestrationCluster( @@ -3156,7 +4116,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Call the get orchestration cluster method over HTTP. @@ -3167,8 +4127,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.OrchestrationCluster: @@ -3181,6 +4143,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_orchestration_cluster( request, metadata ) @@ -3193,6 +4156,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._GetOrchestrationCluster._get_response( @@ -3215,7 +4205,31 @@ def __call__( pb_resp = telcoautomation.OrchestrationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_orchestration_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.OrchestrationCluster.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.telcoautomation_v1.TelcoAutomationClient.get_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPublicBlueprint( @@ -3253,7 +4267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Call the get public blueprint method over HTTP. @@ -3263,8 +4277,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.PublicBlueprint: @@ -3283,6 +4299,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetPublicBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_get_public_blueprint( request, metadata ) @@ -3295,6 +4312,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetPublicBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetPublicBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetPublicBlueprint._get_response( self._host, @@ -3315,7 +4359,29 @@ def __call__( pb_resp = telcoautomation.PublicBlueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_public_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.PublicBlueprint.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.telcoautomation_v1.TelcoAutomationClient.get_public_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetPublicBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBlueprintRevisions( @@ -3353,7 +4419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListBlueprintRevisionsResponse: r"""Call the list blueprint revisions method over HTTP. @@ -3363,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListBlueprintRevisionsResponse: @@ -3374,6 +4442,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListBlueprintRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_blueprint_revisions( request, metadata ) @@ -3386,6 +4455,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListBlueprintRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListBlueprintRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListBlueprintRevisions._get_response( @@ -3408,7 +4504,31 @@ def __call__( pb_resp = telcoautomation.ListBlueprintRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_blueprint_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListBlueprintRevisionsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_blueprint_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListBlueprintRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBlueprints( @@ -3445,7 +4565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListBlueprintsResponse: r"""Call the list blueprints method over HTTP. @@ -3455,8 +4575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListBlueprintsResponse: @@ -3466,6 +4588,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListBlueprints._get_http_options() ) + request, metadata = self._interceptor.pre_list_blueprints(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListBlueprints._get_transcoded_request( http_options, request @@ -3476,6 +4599,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListBlueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListBlueprints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListBlueprints._get_response( self._host, @@ -3496,7 +4646,31 @@ def __call__( pb_resp = telcoautomation.ListBlueprintsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_blueprints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListBlueprintsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_blueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListBlueprints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeploymentRevisions( @@ -3534,7 +4708,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListDeploymentRevisionsResponse: r"""Call the list deployment revisions method over HTTP. @@ -3545,8 +4719,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListDeploymentRevisionsResponse: @@ -3558,6 +4734,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListDeploymentRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployment_revisions( request, metadata ) @@ -3570,6 +4747,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListDeploymentRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListDeploymentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListDeploymentRevisions._get_response( @@ -3592,7 +4796,33 @@ def __call__( pb_resp = telcoautomation.ListDeploymentRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListDeploymentRevisionsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_deployment_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListDeploymentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeployments( @@ -3629,7 +4859,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListDeploymentsResponse: r"""Call the list deployments method over HTTP. @@ -3639,8 +4869,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListDeploymentsResponse: @@ -3650,6 +4882,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployments( request, metadata ) @@ -3662,6 +4895,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListDeployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListDeployments._get_response( self._host, @@ -3682,7 +4942,31 @@ def __call__( pb_resp = telcoautomation.ListDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListDeploymentsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_deployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEdgeSlms( @@ -3719,7 +5003,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListEdgeSlmsResponse: r"""Call the list edge slms method over HTTP. @@ -3730,8 +5014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListEdgeSlmsResponse: @@ -3743,6 +5029,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListEdgeSlms._get_http_options() ) + request, metadata = self._interceptor.pre_list_edge_slms(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListEdgeSlms._get_transcoded_request( http_options, request @@ -3753,6 +5040,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListEdgeSlms", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListEdgeSlms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListEdgeSlms._get_response( self._host, @@ -3773,7 +5087,31 @@ def __call__( pb_resp = telcoautomation.ListEdgeSlmsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_edge_slms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListEdgeSlmsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_edge_slms", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListEdgeSlms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListHydratedDeployments( @@ -3811,7 +5149,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListHydratedDeploymentsResponse: r"""Call the list hydrated deployments method over HTTP. @@ -3821,8 +5159,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListHydratedDeploymentsResponse: @@ -3832,6 +5172,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListHydratedDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_hydrated_deployments( request, metadata ) @@ -3844,6 +5185,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListHydratedDeployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListHydratedDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListHydratedDeployments._get_response( @@ -3866,7 +5234,33 @@ def __call__( pb_resp = telcoautomation.ListHydratedDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_hydrated_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListHydratedDeploymentsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_hydrated_deployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListHydratedDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOrchestrationClusters( @@ -3904,7 +5298,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListOrchestrationClustersResponse: r"""Call the list orchestration clusters method over HTTP. @@ -3916,8 +5310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListOrchestrationClustersResponse: @@ -3929,6 +5325,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListOrchestrationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_orchestration_clusters( request, metadata ) @@ -3941,6 +5338,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListOrchestrationClusters", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListOrchestrationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListOrchestrationClusters._get_response( @@ -3963,7 +5387,33 @@ def __call__( pb_resp = telcoautomation.ListOrchestrationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_orchestration_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListOrchestrationClustersResponse.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.telcoautomation_v1.TelcoAutomationClient.list_orchestration_clusters", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListOrchestrationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPublicBlueprints( @@ -4001,7 +5451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListPublicBlueprintsResponse: r"""Call the list public blueprints method over HTTP. @@ -4011,8 +5461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListPublicBlueprintsResponse: @@ -4022,6 +5474,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListPublicBlueprints._get_http_options() ) + request, metadata = self._interceptor.pre_list_public_blueprints( request, metadata ) @@ -4034,6 +5487,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListPublicBlueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListPublicBlueprints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListPublicBlueprints._get_response( self._host, @@ -4054,7 +5534,31 @@ def __call__( pb_resp = telcoautomation.ListPublicBlueprintsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_public_blueprints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListPublicBlueprintsResponse.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.telcoautomation_v1.TelcoAutomationClient.list_public_blueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListPublicBlueprints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ProposeBlueprint( @@ -4092,7 +5596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the propose blueprint method over HTTP. @@ -4102,8 +5606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4125,6 +5631,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseProposeBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_propose_blueprint( request, metadata ) @@ -4141,6 +5648,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ProposeBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ProposeBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ProposeBlueprint._get_response( self._host, @@ -4162,7 +5696,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_propose_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.propose_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ProposeBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RejectBlueprint( @@ -4200,7 +5756,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the reject blueprint method over HTTP. @@ -4210,8 +5766,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4233,6 +5791,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseRejectBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_reject_blueprint( request, metadata ) @@ -4249,6 +5808,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.RejectBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "RejectBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RejectBlueprint._get_response( self._host, @@ -4270,7 +5856,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reject_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.reject_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "RejectBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveDeployment( @@ -4308,7 +5916,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the remove deployment method over HTTP. @@ -4318,13 +5926,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseRemoveDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_remove_deployment( request, metadata ) @@ -4341,6 +5952,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.RemoveDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "RemoveDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RemoveDeployment._get_response( self._host, @@ -4393,7 +6031,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the rollback deployment method over HTTP. @@ -4403,8 +6041,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -4419,6 +6059,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseRollbackDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_rollback_deployment( request, metadata ) @@ -4435,6 +6076,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.RollbackDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "RollbackDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RollbackDeployment._get_response( self._host, @@ -4456,7 +6124,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rollback_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1.TelcoAutomationClient.rollback_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "RollbackDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchBlueprintRevisions( @@ -4494,7 +6184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.SearchBlueprintRevisionsResponse: r"""Call the search blueprint revisions method over HTTP. @@ -4505,8 +6195,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.SearchBlueprintRevisionsResponse: @@ -4516,6 +6208,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseSearchBlueprintRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_search_blueprint_revisions( request, metadata ) @@ -4528,6 +6221,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.SearchBlueprintRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "SearchBlueprintRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._SearchBlueprintRevisions._get_response( @@ -4550,7 +6270,33 @@ def __call__( pb_resp = telcoautomation.SearchBlueprintRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_blueprint_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.SearchBlueprintRevisionsResponse.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.telcoautomation_v1.TelcoAutomationClient.search_blueprint_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "SearchBlueprintRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchDeploymentRevisions( @@ -4588,7 +6334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.SearchDeploymentRevisionsResponse: r"""Call the search deployment revisions method over HTTP. @@ -4599,8 +6345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.SearchDeploymentRevisionsResponse: @@ -4610,6 +6358,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseSearchDeploymentRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_search_deployment_revisions( request, metadata ) @@ -4622,6 +6371,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.SearchDeploymentRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "SearchDeploymentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._SearchDeploymentRevisions._get_response( @@ -4644,7 +6420,33 @@ def __call__( pb_resp = telcoautomation.SearchDeploymentRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_deployment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.SearchDeploymentRevisionsResponse.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.telcoautomation_v1.TelcoAutomationClient.search_deployment_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "SearchDeploymentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBlueprint( @@ -4682,7 +6484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the update blueprint method over HTTP. @@ -4692,8 +6494,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4715,6 +6519,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_update_blueprint( request, metadata ) @@ -4731,6 +6536,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.UpdateBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._UpdateBlueprint._get_response( self._host, @@ -4752,7 +6584,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1.TelcoAutomationClient.update_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeployment( @@ -4790,7 +6644,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the update deployment method over HTTP. @@ -4800,8 +6654,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -4816,6 +6672,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_deployment( request, metadata ) @@ -4832,6 +6689,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.UpdateDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._UpdateDeployment._get_response( self._host, @@ -4853,7 +6737,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1.TelcoAutomationClient.update_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateHydratedDeployment( @@ -4892,7 +6798,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the update hydrated deployment method over HTTP. @@ -4903,8 +6809,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -4918,6 +6826,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_hydrated_deployment( request, metadata ) @@ -4934,6 +6843,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.UpdateHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._UpdateHydratedDeployment._get_response( @@ -4957,7 +6893,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1.TelcoAutomationClient.update_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "UpdateHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5347,7 +7307,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -5357,8 +7317,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -5367,6 +7329,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -5377,6 +7340,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetLocation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetLocation._get_response( self._host, @@ -5396,6 +7386,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.telcoautomation_v1.TelcoAutomationAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5436,7 +7447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -5446,8 +7457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -5456,6 +7469,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5466,6 +7480,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListLocations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListLocations._get_response( self._host, @@ -5485,6 +7526,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.telcoautomation_v1.TelcoAutomationAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5526,7 +7588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -5536,13 +7598,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5559,6 +7624,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.CancelOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CancelOperation._get_response( self._host, @@ -5615,7 +7707,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -5625,13 +7717,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5644,6 +7739,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteOperation._get_response( self._host, @@ -5699,7 +7821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -5709,8 +7831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -5719,6 +7843,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5729,6 +7854,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.GetOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetOperation._get_response( self._host, @@ -5748,6 +7900,27 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5788,7 +7961,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -5798,8 +7971,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -5808,6 +7983,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5818,6 +7994,33 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationClient.ListOperations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListOperations._get_response( self._host, @@ -5837,6 +8040,27 @@ def __call__( 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.telcoautomation_v1.TelcoAutomationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1.TelcoAutomation", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/gapic_version.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/gapic_version.py index aa1763b52a3a..558c8aab67c5 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/gapic_version.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.7" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/async_client.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/async_client.py index 155a3629f708..18087fad27e4 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/async_client.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport from .transports.grpc_asyncio import TelcoAutomationGrpcAsyncIOTransport +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 TelcoAutomationAsyncClient: """TelcoAutomation Service manages the control plane cluster @@ -289,6 +299,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.telcoautomation_v1alpha1.TelcoAutomationAsyncClient`.", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "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.telcoautomation.v1alpha1.TelcoAutomation", + "credentialsType": None, + }, + ) + async def list_orchestration_clusters( self, request: Optional[ @@ -298,7 +330,7 @@ async def list_orchestration_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrchestrationClustersAsyncPager: r"""Lists OrchestrationClusters in a given project and location. @@ -344,8 +376,10 @@ async def sample_list_orchestration_clusters(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListOrchestrationClustersAsyncPager: @@ -422,7 +456,7 @@ async def get_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Gets details of a single OrchestrationCluster. @@ -464,8 +498,10 @@ async def sample_get_orchestration_cluster(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.OrchestrationCluster: @@ -531,7 +567,7 @@ async def create_orchestration_cluster( orchestration_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new OrchestrationCluster in a given project and location. @@ -593,8 +629,10 @@ async def sample_create_orchestration_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -673,7 +711,7 @@ async def delete_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single OrchestrationCluster. @@ -719,8 +757,10 @@ async def sample_delete_orchestration_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -799,7 +839,7 @@ async def list_edge_slms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEdgeSlmsAsyncPager: r"""Lists EdgeSlms in a given project and location. @@ -844,8 +884,10 @@ async def sample_list_edge_slms(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListEdgeSlmsAsyncPager: @@ -920,7 +962,7 @@ async def get_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Gets details of a single EdgeSlm. @@ -961,8 +1003,10 @@ async def sample_get_edge_slm(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.EdgeSlm: @@ -1028,7 +1072,7 @@ async def create_edge_slm( edge_slm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new EdgeSlm in a given project and location. @@ -1088,8 +1132,10 @@ async def sample_create_edge_slm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1165,7 +1211,7 @@ async def delete_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single EdgeSlm. @@ -1210,8 +1256,10 @@ async def sample_delete_edge_slm(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1292,7 +1340,7 @@ async def create_blueprint( blueprint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Creates a blueprint. @@ -1350,8 +1398,10 @@ async def sample_create_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -1427,7 +1477,7 @@ async def update_blueprint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Updates a blueprint. @@ -1479,8 +1529,10 @@ async def sample_update_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -1555,7 +1607,7 @@ async def get_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Returns the requested blueprint. @@ -1602,8 +1654,10 @@ async def sample_get_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -1674,7 +1728,7 @@ async def delete_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a blueprint and all its revisions. @@ -1716,8 +1770,10 @@ async def sample_delete_blueprint(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1769,7 +1825,7 @@ async def list_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintsAsyncPager: r"""List all blueprints. @@ -1814,8 +1870,10 @@ async def sample_list_blueprints(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintsAsyncPager: @@ -1889,7 +1947,7 @@ async def approve_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Approves a blueprint and commits a new revision. @@ -1934,8 +1992,10 @@ async def sample_approve_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2006,7 +2066,7 @@ async def propose_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Proposes a blueprint for approval of changes. @@ -2049,8 +2109,10 @@ async def sample_propose_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2121,7 +2183,7 @@ async def reject_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Rejects a blueprint revision proposal and flips it back to Draft state. @@ -2165,8 +2227,10 @@ async def sample_reject_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2239,7 +2303,7 @@ async def list_blueprint_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintRevisionsAsyncPager: r"""List blueprint revisions of a given blueprint. @@ -2283,8 +2347,10 @@ async def sample_list_blueprint_revisions(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintRevisionsAsyncPager: @@ -2361,7 +2427,7 @@ async def search_blueprint_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchBlueprintRevisionsAsyncPager: r"""Searches across blueprint revisions. @@ -2425,8 +2491,10 @@ async def sample_search_blueprint_revisions(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchBlueprintRevisionsAsyncPager: @@ -2505,7 +2573,7 @@ async def search_deployment_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchDeploymentRevisionsAsyncPager: r"""Searches across deployment revisions. @@ -2569,8 +2637,10 @@ async def sample_search_deployment_revisions(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchDeploymentRevisionsAsyncPager: @@ -2648,7 +2718,7 @@ async def discard_blueprint_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Discards the changes in a blueprint and reverts the blueprint to the last approved blueprint revision. No @@ -2694,8 +2764,10 @@ async def sample_discard_blueprint_changes(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.DiscardBlueprintChangesResponse: @@ -2756,7 +2828,7 @@ async def list_public_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicBlueprintsAsyncPager: r"""Lists the blueprints in TNA's public catalog. Default page size = 20, Max Page Size = 100. @@ -2802,8 +2874,10 @@ async def sample_list_public_blueprints(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListPublicBlueprintsAsyncPager: @@ -2879,7 +2953,7 @@ async def get_public_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Returns the requested public blueprint. @@ -2922,8 +2996,10 @@ async def sample_get_public_blueprint(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.PublicBlueprint: @@ -2993,7 +3069,7 @@ async def create_deployment( deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Creates a deployment. @@ -3051,8 +3127,10 @@ async def sample_create_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3121,7 +3199,7 @@ async def update_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Updates a deployment. @@ -3173,8 +3251,10 @@ async def sample_update_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3242,7 +3322,7 @@ async def get_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Returns the requested deployment. @@ -3289,8 +3369,10 @@ async def sample_get_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3354,7 +3436,7 @@ async def remove_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes the deployment by marking it as DELETING. Post which deployment and it's revisions gets deleted. @@ -3395,8 +3477,10 @@ async def sample_remove_deployment(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3448,7 +3532,7 @@ async def list_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentsAsyncPager: r"""List all deployments. @@ -3493,8 +3577,10 @@ async def sample_list_deployments(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentsAsyncPager: @@ -3570,7 +3656,7 @@ async def list_deployment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentRevisionsAsyncPager: r"""List deployment revisions of a given deployment. @@ -3615,8 +3701,10 @@ async def sample_list_deployment_revisions(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentRevisionsAsyncPager: @@ -3693,7 +3781,7 @@ async def discard_deployment_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Discards the changes in a deployment and reverts the deployment to the last approved deployment revision. No @@ -3739,8 +3827,10 @@ async def sample_discard_deployment_changes(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.DiscardDeploymentChangesResponse: @@ -3799,7 +3889,7 @@ async def apply_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Applies the deployment's YAML files to the parent orchestration cluster. @@ -3845,8 +3935,10 @@ async def sample_apply_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3912,7 +4004,7 @@ async def compute_deployment_status( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Returns the requested deployment status. @@ -3955,8 +4047,10 @@ async def sample_compute_deployment_status(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.ComputeDeploymentStatusResponse: @@ -4018,7 +4112,7 @@ async def rollback_deployment( revision_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Rollback the active deployment to the given past approved deployment revision. @@ -4068,8 +4162,10 @@ async def sample_rollback_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -4137,7 +4233,7 @@ async def get_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Returns the requested hydrated deployment. @@ -4180,8 +4276,10 @@ async def sample_get_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -4246,7 +4344,7 @@ async def list_hydrated_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHydratedDeploymentsAsyncPager: r"""List all hydrated deployments present under a deployment. @@ -4291,8 +4389,10 @@ async def sample_list_hydrated_deployments(): 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, 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListHydratedDeploymentsAsyncPager: @@ -4369,7 +4469,7 @@ async def update_hydrated_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Updates a hydrated deployment. @@ -4419,8 +4519,10 @@ async def sample_update_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -4489,7 +4591,7 @@ async def apply_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Applies a hydrated deployment to a workload cluster. @@ -4533,8 +4635,10 @@ async def sample_apply_hydrated_deployment(): 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, 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -4596,7 +4700,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4607,8 +4711,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4649,7 +4755,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4660,8 +4766,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4702,7 +4810,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4718,8 +4826,10 @@ async def delete_operation( 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, 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: None """ @@ -4756,7 +4866,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4771,8 +4881,10 @@ async def cancel_operation( 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, 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: None """ @@ -4809,7 +4921,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4820,8 +4932,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -4862,7 +4976,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4873,8 +4987,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/client.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/client.py index 3fe5379a0dca..078c51795c0e 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/client.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -711,6 +721,10 @@ def __init__( # 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( @@ -776,6 +790,29 @@ def __init__( 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.telcoautomation_v1alpha1.TelcoAutomationClient`.", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "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.telcoautomation.v1alpha1.TelcoAutomation", + "credentialsType": None, + }, + ) + def list_orchestration_clusters( self, request: Optional[ @@ -785,7 +822,7 @@ def list_orchestration_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrchestrationClustersPager: r"""Lists OrchestrationClusters in a given project and location. @@ -831,8 +868,10 @@ def sample_list_orchestration_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListOrchestrationClustersPager: @@ -908,7 +947,7 @@ def get_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Gets details of a single OrchestrationCluster. @@ -950,8 +989,10 @@ def sample_get_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.OrchestrationCluster: @@ -1016,7 +1057,7 @@ def create_orchestration_cluster( orchestration_cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new OrchestrationCluster in a given project and location. @@ -1078,8 +1119,10 @@ def sample_create_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1157,7 +1200,7 @@ def delete_orchestration_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single OrchestrationCluster. @@ -1203,8 +1246,10 @@ def sample_delete_orchestration_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1282,7 +1327,7 @@ def list_edge_slms( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEdgeSlmsPager: r"""Lists EdgeSlms in a given project and location. @@ -1327,8 +1372,10 @@ def sample_list_edge_slms(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListEdgeSlmsPager: @@ -1400,7 +1447,7 @@ def get_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Gets details of a single EdgeSlm. @@ -1441,8 +1488,10 @@ def sample_get_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.EdgeSlm: @@ -1505,7 +1554,7 @@ def create_edge_slm( edge_slm_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new EdgeSlm in a given project and location. @@ -1565,8 +1614,10 @@ def sample_create_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1639,7 +1690,7 @@ def delete_edge_slm( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single EdgeSlm. @@ -1684,8 +1735,10 @@ def sample_delete_edge_slm(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1763,7 +1816,7 @@ def create_blueprint( blueprint_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Creates a blueprint. @@ -1821,8 +1874,10 @@ def sample_create_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -1895,7 +1950,7 @@ def update_blueprint( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Updates a blueprint. @@ -1947,8 +2002,10 @@ def sample_update_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2020,7 +2077,7 @@ def get_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Returns the requested blueprint. @@ -2067,8 +2124,10 @@ def sample_get_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2136,7 +2195,7 @@ def delete_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a blueprint and all its revisions. @@ -2178,8 +2237,10 @@ def sample_delete_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2228,7 +2289,7 @@ def list_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintsPager: r"""List all blueprints. @@ -2273,8 +2334,10 @@ def sample_list_blueprints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintsPager: @@ -2345,7 +2408,7 @@ def approve_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Approves a blueprint and commits a new revision. @@ -2390,8 +2453,10 @@ def sample_approve_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2459,7 +2524,7 @@ def propose_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Proposes a blueprint for approval of changes. @@ -2502,8 +2567,10 @@ def sample_propose_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2571,7 +2638,7 @@ def reject_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Rejects a blueprint revision proposal and flips it back to Draft state. @@ -2615,8 +2682,10 @@ def sample_reject_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Blueprint: @@ -2686,7 +2755,7 @@ def list_blueprint_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBlueprintRevisionsPager: r"""List blueprint revisions of a given blueprint. @@ -2730,8 +2799,10 @@ def sample_list_blueprint_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintRevisionsPager: @@ -2805,7 +2876,7 @@ def search_blueprint_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchBlueprintRevisionsPager: r"""Searches across blueprint revisions. @@ -2869,8 +2940,10 @@ def sample_search_blueprint_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchBlueprintRevisionsPager: @@ -2948,7 +3021,7 @@ def search_deployment_revisions( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchDeploymentRevisionsPager: r"""Searches across deployment revisions. @@ -3012,8 +3085,10 @@ def sample_search_deployment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchDeploymentRevisionsPager: @@ -3090,7 +3165,7 @@ def discard_blueprint_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Discards the changes in a blueprint and reverts the blueprint to the last approved blueprint revision. No @@ -3136,8 +3211,10 @@ def sample_discard_blueprint_changes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.DiscardBlueprintChangesResponse: @@ -3197,7 +3274,7 @@ def list_public_blueprints( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPublicBlueprintsPager: r"""Lists the blueprints in TNA's public catalog. Default page size = 20, Max Page Size = 100. @@ -3243,8 +3320,10 @@ def sample_list_public_blueprints(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListPublicBlueprintsPager: @@ -3317,7 +3396,7 @@ def get_public_blueprint( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Returns the requested public blueprint. @@ -3360,8 +3439,10 @@ def sample_get_public_blueprint(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.PublicBlueprint: @@ -3428,7 +3509,7 @@ def create_deployment( deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Creates a deployment. @@ -3486,8 +3567,10 @@ def sample_create_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3553,7 +3636,7 @@ def update_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Updates a deployment. @@ -3605,8 +3688,10 @@ def sample_update_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3671,7 +3756,7 @@ def get_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Returns the requested deployment. @@ -3718,8 +3803,10 @@ def sample_get_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -3780,7 +3867,7 @@ def remove_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes the deployment by marking it as DELETING. Post which deployment and it's revisions gets deleted. @@ -3821,8 +3908,10 @@ def sample_remove_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3871,7 +3960,7 @@ def list_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentsPager: r"""List all deployments. @@ -3916,8 +4005,10 @@ def sample_list_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentsPager: @@ -3990,7 +4081,7 @@ def list_deployment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentRevisionsPager: r"""List deployment revisions of a given deployment. @@ -4035,8 +4126,10 @@ def sample_list_deployment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentRevisionsPager: @@ -4112,7 +4205,7 @@ def discard_deployment_changes( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Discards the changes in a deployment and reverts the deployment to the last approved deployment revision. No @@ -4158,8 +4251,10 @@ def sample_discard_deployment_changes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.DiscardDeploymentChangesResponse: @@ -4217,7 +4312,7 @@ def apply_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Applies the deployment's YAML files to the parent orchestration cluster. @@ -4263,8 +4358,10 @@ def sample_apply_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -4327,7 +4424,7 @@ def compute_deployment_status( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Returns the requested deployment status. @@ -4370,8 +4467,10 @@ def sample_compute_deployment_status(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.ComputeDeploymentStatusResponse: @@ -4432,7 +4531,7 @@ def rollback_deployment( revision_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Rollback the active deployment to the given past approved deployment revision. @@ -4482,8 +4581,10 @@ def sample_rollback_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.Deployment: @@ -4548,7 +4649,7 @@ def get_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Returns the requested hydrated deployment. @@ -4591,8 +4692,10 @@ def sample_get_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -4654,7 +4757,7 @@ def list_hydrated_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHydratedDeploymentsPager: r"""List all hydrated deployments present under a deployment. @@ -4699,8 +4802,10 @@ def sample_list_hydrated_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListHydratedDeploymentsPager: @@ -4776,7 +4881,7 @@ def update_hydrated_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Updates a hydrated deployment. @@ -4826,8 +4931,10 @@ def sample_update_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -4895,7 +5002,7 @@ def apply_hydrated_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Applies a hydrated deployment to a workload cluster. @@ -4939,8 +5046,10 @@ def sample_apply_hydrated_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment: @@ -5014,7 +5123,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -5025,8 +5134,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -5067,7 +5178,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -5078,8 +5189,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -5120,7 +5233,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -5136,8 +5249,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5174,7 +5289,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -5189,8 +5304,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -5227,7 +5344,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -5238,8 +5355,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -5280,7 +5399,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -5291,8 +5410,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/pagers.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/pagers.py index 883e76f2fdf1..b8cf706e7dd4 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/pagers.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListOrchestrationClustersRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListOrchestrationClustersRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListEdgeSlmsRequest(request) @@ -297,7 +303,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -311,8 +317,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListEdgeSlmsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListBlueprintsRequest(request) @@ -449,7 +459,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -463,8 +473,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListBlueprintsRequest(request) @@ -527,7 +539,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -541,8 +553,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListBlueprintRevisionsRequest(request) @@ -603,7 +617,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -617,8 +631,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListBlueprintRevisionsRequest(request) @@ -683,7 +699,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -697,8 +713,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.SearchBlueprintRevisionsRequest(request) @@ -759,7 +777,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -773,8 +791,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.SearchBlueprintRevisionsRequest(request) @@ -839,7 +859,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -853,8 +873,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.SearchDeploymentRevisionsRequest(request) @@ -915,7 +937,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -929,8 +951,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.SearchDeploymentRevisionsRequest(request) @@ -995,7 +1019,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1009,8 +1033,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListPublicBlueprintsRequest(request) @@ -1069,7 +1095,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1083,8 +1109,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListPublicBlueprintsRequest(request) @@ -1149,7 +1177,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1163,8 +1191,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListDeploymentsRequest(request) @@ -1223,7 +1253,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1237,8 +1267,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListDeploymentsRequest(request) @@ -1301,7 +1333,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1315,8 +1347,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListDeploymentRevisionsRequest(request) @@ -1377,7 +1411,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1391,8 +1425,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListDeploymentRevisionsRequest(request) @@ -1457,7 +1493,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1471,8 +1507,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = telcoautomation.ListHydratedDeploymentsRequest(request) @@ -1533,7 +1571,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1547,8 +1585,10 @@ def __init__( 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, 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`. """ self._method = method self._request = telcoautomation.ListHydratedDeploymentsRequest(request) diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc.py index 094228c7eeb7..9dde0cad81db 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.telcoautomation_v1alpha1.types import telcoautomation from .base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport +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.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": 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.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TelcoAutomationGrpcTransport(TelcoAutomationTransport): """gRPC backend transport for TelcoAutomation. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,9 @@ def list_orchestration_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_orchestration_clusters" not in self._stubs: - self._stubs["list_orchestration_clusters"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_orchestration_clusters" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListOrchestrationClusters", request_serializer=telcoautomation.ListOrchestrationClustersRequest.serialize, response_deserializer=telcoautomation.ListOrchestrationClustersResponse.deserialize, @@ -308,7 +398,7 @@ def get_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_orchestration_cluster" not in self._stubs: - self._stubs["get_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_orchestration_cluster"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetOrchestrationCluster", request_serializer=telcoautomation.GetOrchestrationClusterRequest.serialize, response_deserializer=telcoautomation.OrchestrationCluster.deserialize, @@ -337,7 +427,9 @@ def create_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_orchestration_cluster" not in self._stubs: - self._stubs["create_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateOrchestrationCluster", request_serializer=telcoautomation.CreateOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +457,9 @@ def delete_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_orchestration_cluster" not in self._stubs: - self._stubs["delete_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteOrchestrationCluster", request_serializer=telcoautomation.DeleteOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +487,7 @@ def list_edge_slms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_edge_slms" not in self._stubs: - self._stubs["list_edge_slms"] = self.grpc_channel.unary_unary( + self._stubs["list_edge_slms"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListEdgeSlms", request_serializer=telcoautomation.ListEdgeSlmsRequest.serialize, response_deserializer=telcoautomation.ListEdgeSlmsResponse.deserialize, @@ -419,7 +513,7 @@ def get_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_edge_slm" not in self._stubs: - self._stubs["get_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["get_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetEdgeSlm", request_serializer=telcoautomation.GetEdgeSlmRequest.serialize, response_deserializer=telcoautomation.EdgeSlm.deserialize, @@ -446,7 +540,7 @@ def create_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_edge_slm" not in self._stubs: - self._stubs["create_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["create_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateEdgeSlm", request_serializer=telcoautomation.CreateEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +566,7 @@ def delete_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_edge_slm" not in self._stubs: - self._stubs["delete_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["delete_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteEdgeSlm", request_serializer=telcoautomation.DeleteEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -498,7 +592,7 @@ def create_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_blueprint" not in self._stubs: - self._stubs["create_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["create_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateBlueprint", request_serializer=telcoautomation.CreateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -524,7 +618,7 @@ def update_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_blueprint" not in self._stubs: - self._stubs["update_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["update_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateBlueprint", request_serializer=telcoautomation.UpdateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -550,7 +644,7 @@ def get_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_blueprint" not in self._stubs: - self._stubs["get_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetBlueprint", request_serializer=telcoautomation.GetBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -576,7 +670,7 @@ def delete_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_blueprint" not in self._stubs: - self._stubs["delete_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["delete_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteBlueprint", request_serializer=telcoautomation.DeleteBlueprintRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -604,7 +698,7 @@ def list_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprints" not in self._stubs: - self._stubs["list_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListBlueprints", request_serializer=telcoautomation.ListBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintsResponse.deserialize, @@ -630,7 +724,7 @@ def approve_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_blueprint" not in self._stubs: - self._stubs["approve_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["approve_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApproveBlueprint", request_serializer=telcoautomation.ApproveBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -656,7 +750,7 @@ def propose_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "propose_blueprint" not in self._stubs: - self._stubs["propose_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["propose_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ProposeBlueprint", request_serializer=telcoautomation.ProposeBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -683,7 +777,7 @@ def reject_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_blueprint" not in self._stubs: - self._stubs["reject_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["reject_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RejectBlueprint", request_serializer=telcoautomation.RejectBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -712,7 +806,7 @@ def list_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprint_revisions" not in self._stubs: - self._stubs["list_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprint_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListBlueprintRevisions", request_serializer=telcoautomation.ListBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintRevisionsResponse.deserialize, @@ -741,7 +835,9 @@ def search_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_blueprint_revisions" not in self._stubs: - self._stubs["search_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_blueprint_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/SearchBlueprintRevisions", request_serializer=telcoautomation.SearchBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchBlueprintRevisionsResponse.deserialize, @@ -770,7 +866,9 @@ def search_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_deployment_revisions" not in self._stubs: - self._stubs["search_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_deployment_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/SearchDeploymentRevisions", request_serializer=telcoautomation.SearchDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchDeploymentRevisionsResponse.deserialize, @@ -802,7 +900,7 @@ def discard_blueprint_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_blueprint_changes" not in self._stubs: - self._stubs["discard_blueprint_changes"] = self.grpc_channel.unary_unary( + self._stubs["discard_blueprint_changes"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DiscardBlueprintChanges", request_serializer=telcoautomation.DiscardBlueprintChangesRequest.serialize, response_deserializer=telcoautomation.DiscardBlueprintChangesResponse.deserialize, @@ -832,7 +930,7 @@ def list_public_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_blueprints" not in self._stubs: - self._stubs["list_public_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_public_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListPublicBlueprints", request_serializer=telcoautomation.ListPublicBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListPublicBlueprintsResponse.deserialize, @@ -860,7 +958,7 @@ def get_public_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_public_blueprint" not in self._stubs: - self._stubs["get_public_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_public_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetPublicBlueprint", request_serializer=telcoautomation.GetPublicBlueprintRequest.serialize, response_deserializer=telcoautomation.PublicBlueprint.deserialize, @@ -888,7 +986,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateDeployment", request_serializer=telcoautomation.CreateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -916,7 +1014,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateDeployment", request_serializer=telcoautomation.UpdateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -942,7 +1040,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetDeployment", request_serializer=telcoautomation.GetDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -969,7 +1067,7 @@ def remove_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_deployment" not in self._stubs: - self._stubs["remove_deployment"] = self.grpc_channel.unary_unary( + self._stubs["remove_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RemoveDeployment", request_serializer=telcoautomation.RemoveDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -998,7 +1096,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListDeployments", request_serializer=telcoautomation.ListDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentsResponse.deserialize, @@ -1027,7 +1125,7 @@ def list_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployment_revisions" not in self._stubs: - self._stubs["list_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_deployment_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListDeploymentRevisions", request_serializer=telcoautomation.ListDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentRevisionsResponse.deserialize, @@ -1059,7 +1157,9 @@ def discard_deployment_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_deployment_changes" not in self._stubs: - self._stubs["discard_deployment_changes"] = self.grpc_channel.unary_unary( + self._stubs[ + "discard_deployment_changes" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DiscardDeploymentChanges", request_serializer=telcoautomation.DiscardDeploymentChangesRequest.serialize, response_deserializer=telcoautomation.DiscardDeploymentChangesResponse.deserialize, @@ -1086,7 +1186,7 @@ def apply_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_deployment" not in self._stubs: - self._stubs["apply_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApplyDeployment", request_serializer=telcoautomation.ApplyDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1115,7 +1215,7 @@ def compute_deployment_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_deployment_status" not in self._stubs: - self._stubs["compute_deployment_status"] = self.grpc_channel.unary_unary( + self._stubs["compute_deployment_status"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ComputeDeploymentStatus", request_serializer=telcoautomation.ComputeDeploymentStatusRequest.serialize, response_deserializer=telcoautomation.ComputeDeploymentStatusResponse.deserialize, @@ -1144,7 +1244,7 @@ def rollback_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_deployment" not in self._stubs: - self._stubs["rollback_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RollbackDeployment", request_serializer=telcoautomation.RollbackDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1173,7 +1273,7 @@ def get_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hydrated_deployment" not in self._stubs: - self._stubs["get_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetHydratedDeployment", request_serializer=telcoautomation.GetHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1203,7 +1303,7 @@ def list_hydrated_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hydrated_deployments" not in self._stubs: - self._stubs["list_hydrated_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_hydrated_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListHydratedDeployments", request_serializer=telcoautomation.ListHydratedDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListHydratedDeploymentsResponse.deserialize, @@ -1232,7 +1332,9 @@ def update_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hydrated_deployment" not in self._stubs: - self._stubs["update_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_hydrated_deployment" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateHydratedDeployment", request_serializer=telcoautomation.UpdateHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1261,7 +1363,7 @@ def apply_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_hydrated_deployment" not in self._stubs: - self._stubs["apply_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApplyHydratedDeployment", request_serializer=telcoautomation.ApplyHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1269,7 +1371,7 @@ def apply_hydrated_deployment( return self._stubs["apply_hydrated_deployment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1281,7 +1383,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1298,7 +1400,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1315,7 +1417,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1334,7 +1436,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1353,7 +1455,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1370,7 +1472,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc_asyncio.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc_asyncio.py index 86d2ff16e372..a6c6a4b22e85 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc_asyncio.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.telcoautomation_v1alpha1.types import telcoautomation from .base import DEFAULT_CLIENT_INFO, TelcoAutomationTransport from .grpc import TelcoAutomationGrpcTransport +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.telcoautomation.v1alpha1.TelcoAutomation", + "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.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TelcoAutomationGrpcAsyncIOTransport(TelcoAutomationTransport): """gRPC AsyncIO backend transport for TelcoAutomation. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,9 @@ def list_orchestration_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_orchestration_clusters" not in self._stubs: - self._stubs["list_orchestration_clusters"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_orchestration_clusters" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListOrchestrationClusters", request_serializer=telcoautomation.ListOrchestrationClustersRequest.serialize, response_deserializer=telcoautomation.ListOrchestrationClustersResponse.deserialize, @@ -318,7 +405,7 @@ def get_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_orchestration_cluster" not in self._stubs: - self._stubs["get_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_orchestration_cluster"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetOrchestrationCluster", request_serializer=telcoautomation.GetOrchestrationClusterRequest.serialize, response_deserializer=telcoautomation.OrchestrationCluster.deserialize, @@ -348,7 +435,9 @@ def create_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_orchestration_cluster" not in self._stubs: - self._stubs["create_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateOrchestrationCluster", request_serializer=telcoautomation.CreateOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +466,9 @@ def delete_orchestration_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_orchestration_cluster" not in self._stubs: - self._stubs["delete_orchestration_cluster"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_orchestration_cluster" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteOrchestrationCluster", request_serializer=telcoautomation.DeleteOrchestrationClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +497,7 @@ def list_edge_slms( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_edge_slms" not in self._stubs: - self._stubs["list_edge_slms"] = self.grpc_channel.unary_unary( + self._stubs["list_edge_slms"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListEdgeSlms", request_serializer=telcoautomation.ListEdgeSlmsRequest.serialize, response_deserializer=telcoautomation.ListEdgeSlmsResponse.deserialize, @@ -434,7 +525,7 @@ def get_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_edge_slm" not in self._stubs: - self._stubs["get_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["get_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetEdgeSlm", request_serializer=telcoautomation.GetEdgeSlmRequest.serialize, response_deserializer=telcoautomation.EdgeSlm.deserialize, @@ -463,7 +554,7 @@ def create_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_edge_slm" not in self._stubs: - self._stubs["create_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["create_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateEdgeSlm", request_serializer=telcoautomation.CreateEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -491,7 +582,7 @@ def delete_edge_slm( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_edge_slm" not in self._stubs: - self._stubs["delete_edge_slm"] = self.grpc_channel.unary_unary( + self._stubs["delete_edge_slm"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteEdgeSlm", request_serializer=telcoautomation.DeleteEdgeSlmRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +610,7 @@ def create_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_blueprint" not in self._stubs: - self._stubs["create_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["create_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateBlueprint", request_serializer=telcoautomation.CreateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -547,7 +638,7 @@ def update_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_blueprint" not in self._stubs: - self._stubs["update_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["update_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateBlueprint", request_serializer=telcoautomation.UpdateBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -575,7 +666,7 @@ def get_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_blueprint" not in self._stubs: - self._stubs["get_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetBlueprint", request_serializer=telcoautomation.GetBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -601,7 +692,7 @@ def delete_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_blueprint" not in self._stubs: - self._stubs["delete_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["delete_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DeleteBlueprint", request_serializer=telcoautomation.DeleteBlueprintRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -630,7 +721,7 @@ def list_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprints" not in self._stubs: - self._stubs["list_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListBlueprints", request_serializer=telcoautomation.ListBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintsResponse.deserialize, @@ -658,7 +749,7 @@ def approve_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_blueprint" not in self._stubs: - self._stubs["approve_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["approve_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApproveBlueprint", request_serializer=telcoautomation.ApproveBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -686,7 +777,7 @@ def propose_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "propose_blueprint" not in self._stubs: - self._stubs["propose_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["propose_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ProposeBlueprint", request_serializer=telcoautomation.ProposeBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -715,7 +806,7 @@ def reject_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_blueprint" not in self._stubs: - self._stubs["reject_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["reject_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RejectBlueprint", request_serializer=telcoautomation.RejectBlueprintRequest.serialize, response_deserializer=telcoautomation.Blueprint.deserialize, @@ -744,7 +835,7 @@ def list_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_blueprint_revisions" not in self._stubs: - self._stubs["list_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_blueprint_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListBlueprintRevisions", request_serializer=telcoautomation.ListBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.ListBlueprintRevisionsResponse.deserialize, @@ -773,7 +864,9 @@ def search_blueprint_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_blueprint_revisions" not in self._stubs: - self._stubs["search_blueprint_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_blueprint_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/SearchBlueprintRevisions", request_serializer=telcoautomation.SearchBlueprintRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchBlueprintRevisionsResponse.deserialize, @@ -802,7 +895,9 @@ def search_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_deployment_revisions" not in self._stubs: - self._stubs["search_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_deployment_revisions" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/SearchDeploymentRevisions", request_serializer=telcoautomation.SearchDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.SearchDeploymentRevisionsResponse.deserialize, @@ -834,7 +929,7 @@ def discard_blueprint_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_blueprint_changes" not in self._stubs: - self._stubs["discard_blueprint_changes"] = self.grpc_channel.unary_unary( + self._stubs["discard_blueprint_changes"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DiscardBlueprintChanges", request_serializer=telcoautomation.DiscardBlueprintChangesRequest.serialize, response_deserializer=telcoautomation.DiscardBlueprintChangesResponse.deserialize, @@ -864,7 +959,7 @@ def list_public_blueprints( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_public_blueprints" not in self._stubs: - self._stubs["list_public_blueprints"] = self.grpc_channel.unary_unary( + self._stubs["list_public_blueprints"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListPublicBlueprints", request_serializer=telcoautomation.ListPublicBlueprintsRequest.serialize, response_deserializer=telcoautomation.ListPublicBlueprintsResponse.deserialize, @@ -893,7 +988,7 @@ def get_public_blueprint( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_public_blueprint" not in self._stubs: - self._stubs["get_public_blueprint"] = self.grpc_channel.unary_unary( + self._stubs["get_public_blueprint"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetPublicBlueprint", request_serializer=telcoautomation.GetPublicBlueprintRequest.serialize, response_deserializer=telcoautomation.PublicBlueprint.deserialize, @@ -921,7 +1016,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/CreateDeployment", request_serializer=telcoautomation.CreateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -949,7 +1044,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateDeployment", request_serializer=telcoautomation.UpdateDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -977,7 +1072,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetDeployment", request_serializer=telcoautomation.GetDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1006,7 +1101,7 @@ def remove_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_deployment" not in self._stubs: - self._stubs["remove_deployment"] = self.grpc_channel.unary_unary( + self._stubs["remove_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RemoveDeployment", request_serializer=telcoautomation.RemoveDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1035,7 +1130,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListDeployments", request_serializer=telcoautomation.ListDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentsResponse.deserialize, @@ -1064,7 +1159,7 @@ def list_deployment_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployment_revisions" not in self._stubs: - self._stubs["list_deployment_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_deployment_revisions"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListDeploymentRevisions", request_serializer=telcoautomation.ListDeploymentRevisionsRequest.serialize, response_deserializer=telcoautomation.ListDeploymentRevisionsResponse.deserialize, @@ -1096,7 +1191,9 @@ def discard_deployment_changes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "discard_deployment_changes" not in self._stubs: - self._stubs["discard_deployment_changes"] = self.grpc_channel.unary_unary( + self._stubs[ + "discard_deployment_changes" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/DiscardDeploymentChanges", request_serializer=telcoautomation.DiscardDeploymentChangesRequest.serialize, response_deserializer=telcoautomation.DiscardDeploymentChangesResponse.deserialize, @@ -1125,7 +1222,7 @@ def apply_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_deployment" not in self._stubs: - self._stubs["apply_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApplyDeployment", request_serializer=telcoautomation.ApplyDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1154,7 +1251,7 @@ def compute_deployment_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compute_deployment_status" not in self._stubs: - self._stubs["compute_deployment_status"] = self.grpc_channel.unary_unary( + self._stubs["compute_deployment_status"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ComputeDeploymentStatus", request_serializer=telcoautomation.ComputeDeploymentStatusRequest.serialize, response_deserializer=telcoautomation.ComputeDeploymentStatusResponse.deserialize, @@ -1184,7 +1281,7 @@ def rollback_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_deployment" not in self._stubs: - self._stubs["rollback_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/RollbackDeployment", request_serializer=telcoautomation.RollbackDeploymentRequest.serialize, response_deserializer=telcoautomation.Deployment.deserialize, @@ -1213,7 +1310,7 @@ def get_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hydrated_deployment" not in self._stubs: - self._stubs["get_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/GetHydratedDeployment", request_serializer=telcoautomation.GetHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1243,7 +1340,7 @@ def list_hydrated_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hydrated_deployments" not in self._stubs: - self._stubs["list_hydrated_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_hydrated_deployments"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ListHydratedDeployments", request_serializer=telcoautomation.ListHydratedDeploymentsRequest.serialize, response_deserializer=telcoautomation.ListHydratedDeploymentsResponse.deserialize, @@ -1272,7 +1369,9 @@ def update_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hydrated_deployment" not in self._stubs: - self._stubs["update_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_hydrated_deployment" + ] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/UpdateHydratedDeployment", request_serializer=telcoautomation.UpdateHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1301,7 +1400,7 @@ def apply_hydrated_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "apply_hydrated_deployment" not in self._stubs: - self._stubs["apply_hydrated_deployment"] = self.grpc_channel.unary_unary( + self._stubs["apply_hydrated_deployment"] = self._logged_channel.unary_unary( "/google.cloud.telcoautomation.v1alpha1.TelcoAutomation/ApplyHydratedDeployment", request_serializer=telcoautomation.ApplyHydratedDeploymentRequest.serialize, response_deserializer=telcoautomation.HydratedDeployment.deserialize, @@ -1556,7 +1655,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1572,7 +1671,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1589,7 +1688,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1606,7 +1705,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1625,7 +1724,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1644,7 +1743,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1661,7 +1760,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/rest.py b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/rest.py index 40581e683914..f2d984ffd703 100644 --- a/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/rest.py +++ b/packages/google-cloud-telcoautomation/google/cloud/telcoautomation_v1alpha1/services/telco_automation/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -352,8 +360,10 @@ def post_update_hydrated_deployment(self, response): def pre_apply_deployment( self, request: telcoautomation.ApplyDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ApplyDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ApplyDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for apply_deployment Override in a subclass to manipulate the request or metadata @@ -375,9 +385,10 @@ def post_apply_deployment( def pre_apply_hydrated_deployment( self, request: telcoautomation.ApplyHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ApplyHydratedDeploymentRequest, Sequence[Tuple[str, str]] + telcoautomation.ApplyHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for apply_hydrated_deployment @@ -400,8 +411,10 @@ def post_apply_hydrated_deployment( def pre_approve_blueprint( self, request: telcoautomation.ApproveBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ApproveBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ApproveBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for approve_blueprint Override in a subclass to manipulate the request or metadata @@ -423,9 +436,10 @@ def post_approve_blueprint( def pre_compute_deployment_status( self, request: telcoautomation.ComputeDeploymentStatusRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ComputeDeploymentStatusRequest, Sequence[Tuple[str, str]] + telcoautomation.ComputeDeploymentStatusRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for compute_deployment_status @@ -448,8 +462,10 @@ def post_compute_deployment_status( def pre_create_blueprint( self, request: telcoautomation.CreateBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_blueprint Override in a subclass to manipulate the request or metadata @@ -471,8 +487,10 @@ def post_create_blueprint( def pre_create_deployment( self, request: telcoautomation.CreateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_deployment Override in a subclass to manipulate the request or metadata @@ -494,8 +512,10 @@ def post_create_deployment( def pre_create_edge_slm( self, request: telcoautomation.CreateEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.CreateEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.CreateEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_edge_slm Override in a subclass to manipulate the request or metadata @@ -517,9 +537,10 @@ def post_create_edge_slm( def pre_create_orchestration_cluster( self, request: telcoautomation.CreateOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.CreateOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.CreateOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_orchestration_cluster @@ -542,8 +563,10 @@ def post_create_orchestration_cluster( def pre_delete_blueprint( self, request: telcoautomation.DeleteBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.DeleteBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.DeleteBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_blueprint Override in a subclass to manipulate the request or metadata @@ -554,8 +577,10 @@ def pre_delete_blueprint( def pre_delete_edge_slm( self, request: telcoautomation.DeleteEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.DeleteEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.DeleteEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_edge_slm Override in a subclass to manipulate the request or metadata @@ -577,9 +602,10 @@ def post_delete_edge_slm( def pre_delete_orchestration_cluster( self, request: telcoautomation.DeleteOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DeleteOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.DeleteOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_orchestration_cluster @@ -602,9 +628,10 @@ def post_delete_orchestration_cluster( def pre_discard_blueprint_changes( self, request: telcoautomation.DiscardBlueprintChangesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DiscardBlueprintChangesRequest, Sequence[Tuple[str, str]] + telcoautomation.DiscardBlueprintChangesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for discard_blueprint_changes @@ -627,9 +654,10 @@ def post_discard_blueprint_changes( def pre_discard_deployment_changes( self, request: telcoautomation.DiscardDeploymentChangesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.DiscardDeploymentChangesRequest, Sequence[Tuple[str, str]] + telcoautomation.DiscardDeploymentChangesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for discard_deployment_changes @@ -652,8 +680,10 @@ def post_discard_deployment_changes( def pre_get_blueprint( self, request: telcoautomation.GetBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_blueprint Override in a subclass to manipulate the request or metadata @@ -675,8 +705,10 @@ def post_get_blueprint( def pre_get_deployment( self, request: telcoautomation.GetDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_deployment Override in a subclass to manipulate the request or metadata @@ -698,8 +730,10 @@ def post_get_deployment( def pre_get_edge_slm( self, request: telcoautomation.GetEdgeSlmRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetEdgeSlmRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetEdgeSlmRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_edge_slm Override in a subclass to manipulate the request or metadata @@ -721,8 +755,11 @@ def post_get_edge_slm( def pre_get_hydrated_deployment( self, request: telcoautomation.GetHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetHydratedDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_hydrated_deployment Override in a subclass to manipulate the request or metadata @@ -744,9 +781,10 @@ def post_get_hydrated_deployment( def pre_get_orchestration_cluster( self, request: telcoautomation.GetOrchestrationClusterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.GetOrchestrationClusterRequest, Sequence[Tuple[str, str]] + telcoautomation.GetOrchestrationClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_orchestration_cluster @@ -769,8 +807,11 @@ def post_get_orchestration_cluster( def pre_get_public_blueprint( self, request: telcoautomation.GetPublicBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.GetPublicBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.GetPublicBlueprintRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_public_blueprint Override in a subclass to manipulate the request or metadata @@ -792,9 +833,10 @@ def post_get_public_blueprint( def pre_list_blueprint_revisions( self, request: telcoautomation.ListBlueprintRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListBlueprintRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListBlueprintRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_blueprint_revisions @@ -817,8 +859,10 @@ def post_list_blueprint_revisions( def pre_list_blueprints( self, request: telcoautomation.ListBlueprintsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListBlueprintsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListBlueprintsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_blueprints Override in a subclass to manipulate the request or metadata @@ -840,9 +884,10 @@ def post_list_blueprints( def pre_list_deployment_revisions( self, request: telcoautomation.ListDeploymentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListDeploymentRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListDeploymentRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_deployment_revisions @@ -865,8 +910,10 @@ def post_list_deployment_revisions( def pre_list_deployments( self, request: telcoautomation.ListDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListDeploymentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_deployments Override in a subclass to manipulate the request or metadata @@ -888,8 +935,10 @@ def post_list_deployments( def pre_list_edge_slms( self, request: telcoautomation.ListEdgeSlmsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListEdgeSlmsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListEdgeSlmsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_edge_slms Override in a subclass to manipulate the request or metadata @@ -911,9 +960,10 @@ def post_list_edge_slms( def pre_list_hydrated_deployments( self, request: telcoautomation.ListHydratedDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListHydratedDeploymentsRequest, Sequence[Tuple[str, str]] + telcoautomation.ListHydratedDeploymentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_hydrated_deployments @@ -936,9 +986,10 @@ def post_list_hydrated_deployments( def pre_list_orchestration_clusters( self, request: telcoautomation.ListOrchestrationClustersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.ListOrchestrationClustersRequest, Sequence[Tuple[str, str]] + telcoautomation.ListOrchestrationClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_orchestration_clusters @@ -961,8 +1012,11 @@ def post_list_orchestration_clusters( def pre_list_public_blueprints( self, request: telcoautomation.ListPublicBlueprintsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ListPublicBlueprintsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ListPublicBlueprintsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_public_blueprints Override in a subclass to manipulate the request or metadata @@ -984,8 +1038,10 @@ def post_list_public_blueprints( def pre_propose_blueprint( self, request: telcoautomation.ProposeBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.ProposeBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.ProposeBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for propose_blueprint Override in a subclass to manipulate the request or metadata @@ -1007,8 +1063,10 @@ def post_propose_blueprint( def pre_reject_blueprint( self, request: telcoautomation.RejectBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RejectBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RejectBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for reject_blueprint Override in a subclass to manipulate the request or metadata @@ -1030,8 +1088,10 @@ def post_reject_blueprint( def pre_remove_deployment( self, request: telcoautomation.RemoveDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RemoveDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RemoveDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_deployment Override in a subclass to manipulate the request or metadata @@ -1042,8 +1102,11 @@ def pre_remove_deployment( def pre_rollback_deployment( self, request: telcoautomation.RollbackDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.RollbackDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.RollbackDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for rollback_deployment Override in a subclass to manipulate the request or metadata @@ -1065,9 +1128,10 @@ def post_rollback_deployment( def pre_search_blueprint_revisions( self, request: telcoautomation.SearchBlueprintRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.SearchBlueprintRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.SearchBlueprintRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_blueprint_revisions @@ -1090,9 +1154,10 @@ def post_search_blueprint_revisions( def pre_search_deployment_revisions( self, request: telcoautomation.SearchDeploymentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.SearchDeploymentRevisionsRequest, Sequence[Tuple[str, str]] + telcoautomation.SearchDeploymentRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_deployment_revisions @@ -1115,8 +1180,10 @@ def post_search_deployment_revisions( def pre_update_blueprint( self, request: telcoautomation.UpdateBlueprintRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.UpdateBlueprintRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.UpdateBlueprintRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_blueprint Override in a subclass to manipulate the request or metadata @@ -1138,8 +1205,10 @@ def post_update_blueprint( def pre_update_deployment( self, request: telcoautomation.UpdateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[telcoautomation.UpdateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + telcoautomation.UpdateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_deployment Override in a subclass to manipulate the request or metadata @@ -1161,9 +1230,10 @@ def post_update_deployment( def pre_update_hydrated_deployment( self, request: telcoautomation.UpdateHydratedDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - telcoautomation.UpdateHydratedDeploymentRequest, Sequence[Tuple[str, str]] + telcoautomation.UpdateHydratedDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_hydrated_deployment @@ -1186,8 +1256,10 @@ def post_update_hydrated_deployment( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -1209,8 +1281,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -1232,8 +1306,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1253,8 +1329,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1274,8 +1352,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1297,8 +1377,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1497,7 +1579,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the apply deployment method over HTTP. @@ -1509,8 +1591,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -1525,6 +1609,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApplyDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_apply_deployment( request, metadata ) @@ -1541,6 +1626,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ApplyDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApplyDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ApplyDeployment._get_response( self._host, @@ -1562,7 +1674,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.apply_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApplyDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApplyHydratedDeployment( @@ -1601,7 +1735,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the apply hydrated deployment method over HTTP. @@ -1612,8 +1746,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -1627,6 +1763,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApplyHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_apply_hydrated_deployment( request, metadata ) @@ -1643,6 +1780,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ApplyHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApplyHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ApplyHydratedDeployment._get_response( @@ -1666,7 +1830,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.apply_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApplyHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApproveBlueprint( @@ -1704,7 +1892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the approve blueprint method over HTTP. @@ -1714,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -1737,6 +1927,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseApproveBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_approve_blueprint( request, metadata ) @@ -1753,6 +1944,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ApproveBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApproveBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ApproveBlueprint._get_response( self._host, @@ -1774,7 +1992,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.approve_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ApproveBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ComputeDeploymentStatus( @@ -1812,7 +2052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ComputeDeploymentStatusResponse: r"""Call the compute deployment status method over HTTP. @@ -1822,8 +2062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ComputeDeploymentStatusResponse: @@ -1833,6 +2075,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseComputeDeploymentStatus._get_http_options() ) + request, metadata = self._interceptor.pre_compute_deployment_status( request, metadata ) @@ -1845,6 +2088,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ComputeDeploymentStatus", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ComputeDeploymentStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ComputeDeploymentStatus._get_response( @@ -1867,7 +2137,33 @@ def __call__( pb_resp = telcoautomation.ComputeDeploymentStatusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compute_deployment_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ComputeDeploymentStatusResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.compute_deployment_status", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ComputeDeploymentStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBlueprint( @@ -1905,7 +2201,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the create blueprint method over HTTP. @@ -1915,8 +2211,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -1938,6 +2236,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_create_blueprint( request, metadata ) @@ -1954,6 +2253,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.CreateBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateBlueprint._get_response( self._host, @@ -1975,7 +2301,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.create_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDeployment( @@ -2013,7 +2361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the create deployment method over HTTP. @@ -2023,8 +2371,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -2039,6 +2389,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_deployment( request, metadata ) @@ -2055,6 +2406,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.CreateDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateDeployment._get_response( self._host, @@ -2076,7 +2454,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.create_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEdgeSlm( @@ -2114,7 +2514,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create edge slm method over HTTP. @@ -2124,8 +2524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2138,6 +2540,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_create_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseCreateEdgeSlm._get_transcoded_request( http_options, request @@ -2152,6 +2555,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.CreateEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CreateEdgeSlm._get_response( self._host, @@ -2171,7 +2601,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_edge_slm(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.telcoautomation_v1alpha1.TelcoAutomationClient.create_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateOrchestrationCluster( @@ -2210,7 +2662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create orchestration cluster method over HTTP. @@ -2222,8 +2674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2236,6 +2690,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseCreateOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_orchestration_cluster( request, metadata ) @@ -2252,6 +2707,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.CreateOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._CreateOrchestrationCluster._get_response( @@ -2273,7 +2755,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_orchestration_cluster(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.telcoautomation_v1alpha1.TelcoAutomationClient.create_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CreateOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBlueprint( @@ -2310,7 +2814,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete blueprint method over HTTP. @@ -2320,13 +2824,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_delete_blueprint( request, metadata ) @@ -2339,6 +2846,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DeleteBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteBlueprint._get_response( self._host, @@ -2388,7 +2922,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete edge slm method over HTTP. @@ -2398,8 +2932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2412,6 +2948,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_delete_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseDeleteEdgeSlm._get_transcoded_request( http_options, request @@ -2422,6 +2959,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DeleteEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteEdgeSlm._get_response( self._host, @@ -2440,7 +3004,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_edge_slm(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.telcoautomation_v1alpha1.TelcoAutomationClient.delete_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOrchestrationCluster( @@ -2478,7 +3064,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete orchestration cluster method over HTTP. @@ -2490,8 +3076,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2504,6 +3092,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_orchestration_cluster( request, metadata ) @@ -2516,6 +3105,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DeleteOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DeleteOrchestrationCluster._get_response( @@ -2536,7 +3152,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_orchestration_cluster(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.telcoautomation_v1alpha1.TelcoAutomationClient.delete_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DiscardBlueprintChanges( @@ -2575,7 +3213,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardBlueprintChangesResponse: r"""Call the discard blueprint changes method over HTTP. @@ -2585,8 +3223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.DiscardBlueprintChangesResponse: @@ -2596,6 +3236,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDiscardBlueprintChanges._get_http_options() ) + request, metadata = self._interceptor.pre_discard_blueprint_changes( request, metadata ) @@ -2612,6 +3253,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DiscardBlueprintChanges", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DiscardBlueprintChanges", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DiscardBlueprintChanges._get_response( @@ -2635,7 +3303,33 @@ def __call__( pb_resp = telcoautomation.DiscardBlueprintChangesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_discard_blueprint_changes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.DiscardBlueprintChangesResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.discard_blueprint_changes", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DiscardBlueprintChanges", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DiscardDeploymentChanges( @@ -2674,7 +3368,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.DiscardDeploymentChangesResponse: r"""Call the discard deployment changes method over HTTP. @@ -2685,8 +3379,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.DiscardDeploymentChangesResponse: @@ -2696,6 +3392,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseDiscardDeploymentChanges._get_http_options() ) + request, metadata = self._interceptor.pre_discard_deployment_changes( request, metadata ) @@ -2712,6 +3409,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DiscardDeploymentChanges", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DiscardDeploymentChanges", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._DiscardDeploymentChanges._get_response( @@ -2735,7 +3459,33 @@ def __call__( pb_resp = telcoautomation.DiscardDeploymentChangesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_discard_deployment_changes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.DiscardDeploymentChangesResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.discard_deployment_changes", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DiscardDeploymentChanges", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBlueprint( @@ -2772,7 +3522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the get blueprint method over HTTP. @@ -2782,8 +3532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -2805,6 +3557,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_get_blueprint(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetBlueprint._get_transcoded_request( http_options, request @@ -2815,6 +3568,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetBlueprint._get_response( self._host, @@ -2835,7 +3615,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeployment( @@ -2872,7 +3674,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the get deployment method over HTTP. @@ -2882,8 +3684,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -2898,6 +3702,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_deployment(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetDeployment._get_transcoded_request( http_options, request @@ -2908,6 +3713,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetDeployment._get_response( self._host, @@ -2928,7 +3760,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEdgeSlm( @@ -2965,7 +3819,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.EdgeSlm: r"""Call the get edge slm method over HTTP. @@ -2975,8 +3829,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.EdgeSlm: @@ -2991,6 +3847,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetEdgeSlm._get_http_options() ) + request, metadata = self._interceptor.pre_get_edge_slm(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetEdgeSlm._get_transcoded_request( http_options, request @@ -3001,6 +3858,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetEdgeSlm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetEdgeSlm", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetEdgeSlm._get_response( self._host, @@ -3021,7 +3905,29 @@ def __call__( pb_resp = telcoautomation.EdgeSlm.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_edge_slm(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.EdgeSlm.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_edge_slm", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetEdgeSlm", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHydratedDeployment( @@ -3059,7 +3965,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the get hydrated deployment method over HTTP. @@ -3069,8 +3975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -3084,6 +3992,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_hydrated_deployment( request, metadata ) @@ -3096,6 +4005,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._GetHydratedDeployment._get_response( @@ -3118,7 +4054,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrchestrationCluster( @@ -3156,7 +4116,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.OrchestrationCluster: r"""Call the get orchestration cluster method over HTTP. @@ -3167,8 +4127,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.OrchestrationCluster: @@ -3181,6 +4143,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetOrchestrationCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_orchestration_cluster( request, metadata ) @@ -3193,6 +4156,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetOrchestrationCluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetOrchestrationCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._GetOrchestrationCluster._get_response( @@ -3215,7 +4205,31 @@ def __call__( pb_resp = telcoautomation.OrchestrationCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_orchestration_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.OrchestrationCluster.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_orchestration_cluster", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetOrchestrationCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPublicBlueprint( @@ -3253,7 +4267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.PublicBlueprint: r"""Call the get public blueprint method over HTTP. @@ -3263,8 +4277,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.PublicBlueprint: @@ -3283,6 +4299,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetPublicBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_get_public_blueprint( request, metadata ) @@ -3295,6 +4312,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetPublicBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetPublicBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetPublicBlueprint._get_response( self._host, @@ -3315,7 +4359,29 @@ def __call__( pb_resp = telcoautomation.PublicBlueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_public_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.PublicBlueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.get_public_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetPublicBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBlueprintRevisions( @@ -3353,7 +4419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListBlueprintRevisionsResponse: r"""Call the list blueprint revisions method over HTTP. @@ -3363,8 +4429,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListBlueprintRevisionsResponse: @@ -3374,6 +4442,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListBlueprintRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_blueprint_revisions( request, metadata ) @@ -3386,6 +4455,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListBlueprintRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListBlueprintRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListBlueprintRevisions._get_response( @@ -3408,7 +4504,31 @@ def __call__( pb_resp = telcoautomation.ListBlueprintRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_blueprint_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListBlueprintRevisionsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_blueprint_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListBlueprintRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBlueprints( @@ -3445,7 +4565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListBlueprintsResponse: r"""Call the list blueprints method over HTTP. @@ -3455,8 +4575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListBlueprintsResponse: @@ -3466,6 +4588,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListBlueprints._get_http_options() ) + request, metadata = self._interceptor.pre_list_blueprints(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListBlueprints._get_transcoded_request( http_options, request @@ -3476,6 +4599,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListBlueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListBlueprints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListBlueprints._get_response( self._host, @@ -3496,7 +4646,31 @@ def __call__( pb_resp = telcoautomation.ListBlueprintsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_blueprints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListBlueprintsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_blueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListBlueprints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeploymentRevisions( @@ -3534,7 +4708,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListDeploymentRevisionsResponse: r"""Call the list deployment revisions method over HTTP. @@ -3545,8 +4719,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListDeploymentRevisionsResponse: @@ -3558,6 +4734,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListDeploymentRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployment_revisions( request, metadata ) @@ -3570,6 +4747,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListDeploymentRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListDeploymentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListDeploymentRevisions._get_response( @@ -3592,7 +4796,33 @@ def __call__( pb_resp = telcoautomation.ListDeploymentRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListDeploymentRevisionsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_deployment_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListDeploymentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeployments( @@ -3629,7 +4859,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListDeploymentsResponse: r"""Call the list deployments method over HTTP. @@ -3639,8 +4869,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListDeploymentsResponse: @@ -3650,6 +4882,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployments( request, metadata ) @@ -3662,6 +4895,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListDeployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListDeployments._get_response( self._host, @@ -3682,7 +4942,31 @@ def __call__( pb_resp = telcoautomation.ListDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListDeploymentsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_deployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEdgeSlms( @@ -3719,7 +5003,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListEdgeSlmsResponse: r"""Call the list edge slms method over HTTP. @@ -3730,8 +5014,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListEdgeSlmsResponse: @@ -3743,6 +5029,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListEdgeSlms._get_http_options() ) + request, metadata = self._interceptor.pre_list_edge_slms(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListEdgeSlms._get_transcoded_request( http_options, request @@ -3753,6 +5040,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListEdgeSlms", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListEdgeSlms", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListEdgeSlms._get_response( self._host, @@ -3773,7 +5087,31 @@ def __call__( pb_resp = telcoautomation.ListEdgeSlmsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_edge_slms(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.ListEdgeSlmsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_edge_slms", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListEdgeSlms", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListHydratedDeployments( @@ -3811,7 +5149,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListHydratedDeploymentsResponse: r"""Call the list hydrated deployments method over HTTP. @@ -3821,8 +5159,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListHydratedDeploymentsResponse: @@ -3832,6 +5172,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListHydratedDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_hydrated_deployments( request, metadata ) @@ -3844,6 +5185,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListHydratedDeployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListHydratedDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListHydratedDeployments._get_response( @@ -3866,7 +5234,33 @@ def __call__( pb_resp = telcoautomation.ListHydratedDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_hydrated_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListHydratedDeploymentsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_hydrated_deployments", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListHydratedDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOrchestrationClusters( @@ -3904,7 +5298,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListOrchestrationClustersResponse: r"""Call the list orchestration clusters method over HTTP. @@ -3916,8 +5310,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListOrchestrationClustersResponse: @@ -3929,6 +5325,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListOrchestrationClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_orchestration_clusters( request, metadata ) @@ -3941,6 +5338,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListOrchestrationClusters", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListOrchestrationClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._ListOrchestrationClusters._get_response( @@ -3963,7 +5387,33 @@ def __call__( pb_resp = telcoautomation.ListOrchestrationClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_orchestration_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListOrchestrationClustersResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_orchestration_clusters", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListOrchestrationClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPublicBlueprints( @@ -4001,7 +5451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.ListPublicBlueprintsResponse: r"""Call the list public blueprints method over HTTP. @@ -4011,8 +5461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.ListPublicBlueprintsResponse: @@ -4022,6 +5474,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListPublicBlueprints._get_http_options() ) + request, metadata = self._interceptor.pre_list_public_blueprints( request, metadata ) @@ -4034,6 +5487,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListPublicBlueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListPublicBlueprints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListPublicBlueprints._get_response( self._host, @@ -4054,7 +5534,31 @@ def __call__( pb_resp = telcoautomation.ListPublicBlueprintsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_public_blueprints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.ListPublicBlueprintsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.list_public_blueprints", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListPublicBlueprints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ProposeBlueprint( @@ -4092,7 +5596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the propose blueprint method over HTTP. @@ -4102,8 +5606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4125,6 +5631,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseProposeBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_propose_blueprint( request, metadata ) @@ -4141,6 +5648,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ProposeBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ProposeBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ProposeBlueprint._get_response( self._host, @@ -4162,7 +5696,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_propose_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.propose_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ProposeBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RejectBlueprint( @@ -4200,7 +5756,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the reject blueprint method over HTTP. @@ -4210,8 +5766,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4233,6 +5791,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseRejectBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_reject_blueprint( request, metadata ) @@ -4249,6 +5808,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.RejectBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "RejectBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RejectBlueprint._get_response( self._host, @@ -4270,7 +5856,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reject_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.reject_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "RejectBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveDeployment( @@ -4308,7 +5916,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the remove deployment method over HTTP. @@ -4318,13 +5926,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseRemoveDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_remove_deployment( request, metadata ) @@ -4341,6 +5952,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.RemoveDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "RemoveDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RemoveDeployment._get_response( self._host, @@ -4393,7 +6031,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the rollback deployment method over HTTP. @@ -4403,8 +6041,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -4419,6 +6059,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseRollbackDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_rollback_deployment( request, metadata ) @@ -4435,6 +6076,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.RollbackDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "RollbackDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._RollbackDeployment._get_response( self._host, @@ -4456,7 +6124,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rollback_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.rollback_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "RollbackDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchBlueprintRevisions( @@ -4494,7 +6184,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.SearchBlueprintRevisionsResponse: r"""Call the search blueprint revisions method over HTTP. @@ -4505,8 +6195,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.SearchBlueprintRevisionsResponse: @@ -4516,6 +6208,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseSearchBlueprintRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_search_blueprint_revisions( request, metadata ) @@ -4528,6 +6221,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.SearchBlueprintRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "SearchBlueprintRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._SearchBlueprintRevisions._get_response( @@ -4550,7 +6270,33 @@ def __call__( pb_resp = telcoautomation.SearchBlueprintRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_blueprint_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.SearchBlueprintRevisionsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.search_blueprint_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "SearchBlueprintRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchDeploymentRevisions( @@ -4588,7 +6334,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.SearchDeploymentRevisionsResponse: r"""Call the search deployment revisions method over HTTP. @@ -4599,8 +6345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.SearchDeploymentRevisionsResponse: @@ -4610,6 +6358,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseSearchDeploymentRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_search_deployment_revisions( request, metadata ) @@ -4622,6 +6371,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.SearchDeploymentRevisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "SearchDeploymentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._SearchDeploymentRevisions._get_response( @@ -4644,7 +6420,33 @@ def __call__( pb_resp = telcoautomation.SearchDeploymentRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_deployment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + telcoautomation.SearchDeploymentRevisionsResponse.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.telcoautomation_v1alpha1.TelcoAutomationClient.search_deployment_revisions", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "SearchDeploymentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBlueprint( @@ -4682,7 +6484,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Blueprint: r"""Call the update blueprint method over HTTP. @@ -4692,8 +6494,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Blueprint: @@ -4715,6 +6519,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateBlueprint._get_http_options() ) + request, metadata = self._interceptor.pre_update_blueprint( request, metadata ) @@ -4731,6 +6536,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.UpdateBlueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateBlueprint", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._UpdateBlueprint._get_response( self._host, @@ -4752,7 +6584,29 @@ def __call__( pb_resp = telcoautomation.Blueprint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_blueprint(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Blueprint.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.telcoautomation_v1alpha1.TelcoAutomationClient.update_blueprint", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateBlueprint", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeployment( @@ -4790,7 +6644,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.Deployment: r"""Call the update deployment method over HTTP. @@ -4800,8 +6654,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.Deployment: @@ -4816,6 +6672,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_deployment( request, metadata ) @@ -4832,6 +6689,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.UpdateDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._UpdateDeployment._get_response( self._host, @@ -4853,7 +6737,29 @@ def __call__( pb_resp = telcoautomation.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.Deployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.update_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateHydratedDeployment( @@ -4892,7 +6798,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> telcoautomation.HydratedDeployment: r"""Call the update hydrated deployment method over HTTP. @@ -4903,8 +6809,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.telcoautomation.HydratedDeployment: @@ -4918,6 +6826,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseUpdateHydratedDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_hydrated_deployment( request, metadata ) @@ -4934,6 +6843,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.UpdateHydratedDeployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateHydratedDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TelcoAutomationRestTransport._UpdateHydratedDeployment._get_response( @@ -4957,7 +6893,31 @@ def __call__( pb_resp = telcoautomation.HydratedDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_hydrated_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = telcoautomation.HydratedDeployment.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.telcoautomation_v1alpha1.TelcoAutomationClient.update_hydrated_deployment", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "UpdateHydratedDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5347,7 +7307,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -5357,8 +7317,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -5367,6 +7329,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -5377,6 +7340,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetLocation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetLocation._get_response( self._host, @@ -5396,6 +7386,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.telcoautomation_v1alpha1.TelcoAutomationAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5436,7 +7447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -5446,8 +7457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -5456,6 +7469,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5466,6 +7480,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListLocations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListLocations._get_response( self._host, @@ -5485,6 +7526,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.telcoautomation_v1alpha1.TelcoAutomationAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5526,7 +7588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -5536,13 +7598,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5559,6 +7624,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.CancelOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._CancelOperation._get_response( self._host, @@ -5615,7 +7707,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -5625,13 +7717,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseTelcoAutomationRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5644,6 +7739,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._DeleteOperation._get_response( self._host, @@ -5699,7 +7821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -5709,8 +7831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -5719,6 +7843,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5729,6 +7854,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.GetOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._GetOperation._get_response( self._host, @@ -5748,6 +7900,27 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5788,7 +7961,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -5798,8 +7971,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -5808,6 +7983,7 @@ def __call__( http_options = ( _BaseTelcoAutomationRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTelcoAutomationRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5818,6 +7994,33 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationClient.ListOperations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TelcoAutomationRestTransport._ListOperations._get_response( self._host, @@ -5837,6 +8040,27 @@ def __call__( 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.telcoautomation_v1alpha1.TelcoAutomationAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.telcoautomation.v1alpha1.TelcoAutomation", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1.json b/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1.json index d296a06f551b..93aa6c2fef47 100644 --- a/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1.json +++ b/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-telcoautomation", - "version": "0.2.7" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.ComputeDeploymentStatusResponse", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.ComputeDeploymentStatusResponse", @@ -699,7 +699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1230,7 +1230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1318,7 +1318,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1399,7 +1399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_blueprint" @@ -1476,7 +1476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_blueprint" @@ -1554,7 +1554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1634,7 +1634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1715,7 +1715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1795,7 +1795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1876,7 +1876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.DiscardBlueprintChangesResponse", @@ -1956,7 +1956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.DiscardBlueprintChangesResponse", @@ -2037,7 +2037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.DiscardDeploymentChangesResponse", @@ -2117,7 +2117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.DiscardDeploymentChangesResponse", @@ -2198,7 +2198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -2278,7 +2278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -2359,7 +2359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -2439,7 +2439,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -2520,7 +2520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.EdgeSlm", @@ -2600,7 +2600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.EdgeSlm", @@ -2681,7 +2681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", @@ -2761,7 +2761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", @@ -2842,7 +2842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.OrchestrationCluster", @@ -2922,7 +2922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.OrchestrationCluster", @@ -3003,7 +3003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.PublicBlueprint", @@ -3083,7 +3083,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.PublicBlueprint", @@ -3164,7 +3164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintRevisionsAsyncPager", @@ -3244,7 +3244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintRevisionsPager", @@ -3325,7 +3325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintsAsyncPager", @@ -3405,7 +3405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListBlueprintsPager", @@ -3486,7 +3486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentRevisionsAsyncPager", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentRevisionsPager", @@ -3647,7 +3647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentsAsyncPager", @@ -3727,7 +3727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListDeploymentsPager", @@ -3808,7 +3808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListEdgeSlmsAsyncPager", @@ -3888,7 +3888,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListEdgeSlmsPager", @@ -3969,7 +3969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListHydratedDeploymentsAsyncPager", @@ -4049,7 +4049,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListHydratedDeploymentsPager", @@ -4130,7 +4130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListOrchestrationClustersAsyncPager", @@ -4210,7 +4210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListOrchestrationClustersPager", @@ -4291,7 +4291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListPublicBlueprintsAsyncPager", @@ -4371,7 +4371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.ListPublicBlueprintsPager", @@ -4452,7 +4452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -4532,7 +4532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -4613,7 +4613,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -4693,7 +4693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -4774,7 +4774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_deployment" @@ -4851,7 +4851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_deployment" @@ -4933,7 +4933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -5017,7 +5017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -5102,7 +5102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchBlueprintRevisionsAsyncPager", @@ -5186,7 +5186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchBlueprintRevisionsPager", @@ -5271,7 +5271,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchDeploymentRevisionsAsyncPager", @@ -5355,7 +5355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.services.telco_automation.pagers.SearchDeploymentRevisionsPager", @@ -5440,7 +5440,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -5524,7 +5524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Blueprint", @@ -5609,7 +5609,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -5693,7 +5693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.Deployment", @@ -5778,7 +5778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", @@ -5862,7 +5862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1.types.HydratedDeployment", diff --git a/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1alpha1.json b/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1alpha1.json index b481a639609b..49a97e5ab862 100644 --- a/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1alpha1.json +++ b/packages/google-cloud-telcoautomation/samples/generated_samples/snippet_metadata_google.cloud.telcoautomation.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-telcoautomation", - "version": "0.2.7" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.ComputeDeploymentStatusResponse", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.ComputeDeploymentStatusResponse", @@ -699,7 +699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1230,7 +1230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1318,7 +1318,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1399,7 +1399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_blueprint" @@ -1476,7 +1476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_blueprint" @@ -1554,7 +1554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1634,7 +1634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1715,7 +1715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1795,7 +1795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1876,7 +1876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.DiscardBlueprintChangesResponse", @@ -1956,7 +1956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.DiscardBlueprintChangesResponse", @@ -2037,7 +2037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.DiscardDeploymentChangesResponse", @@ -2117,7 +2117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.DiscardDeploymentChangesResponse", @@ -2198,7 +2198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -2278,7 +2278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -2359,7 +2359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -2439,7 +2439,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -2520,7 +2520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.EdgeSlm", @@ -2600,7 +2600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.EdgeSlm", @@ -2681,7 +2681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", @@ -2761,7 +2761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", @@ -2842,7 +2842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.OrchestrationCluster", @@ -2922,7 +2922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.OrchestrationCluster", @@ -3003,7 +3003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.PublicBlueprint", @@ -3083,7 +3083,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.PublicBlueprint", @@ -3164,7 +3164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintRevisionsAsyncPager", @@ -3244,7 +3244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintRevisionsPager", @@ -3325,7 +3325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintsAsyncPager", @@ -3405,7 +3405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListBlueprintsPager", @@ -3486,7 +3486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentRevisionsAsyncPager", @@ -3566,7 +3566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentRevisionsPager", @@ -3647,7 +3647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentsAsyncPager", @@ -3727,7 +3727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListDeploymentsPager", @@ -3808,7 +3808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListEdgeSlmsAsyncPager", @@ -3888,7 +3888,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListEdgeSlmsPager", @@ -3969,7 +3969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListHydratedDeploymentsAsyncPager", @@ -4049,7 +4049,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListHydratedDeploymentsPager", @@ -4130,7 +4130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListOrchestrationClustersAsyncPager", @@ -4210,7 +4210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListOrchestrationClustersPager", @@ -4291,7 +4291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListPublicBlueprintsAsyncPager", @@ -4371,7 +4371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.ListPublicBlueprintsPager", @@ -4452,7 +4452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -4532,7 +4532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -4613,7 +4613,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -4693,7 +4693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -4774,7 +4774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_deployment" @@ -4851,7 +4851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "remove_deployment" @@ -4933,7 +4933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -5017,7 +5017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -5102,7 +5102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchBlueprintRevisionsAsyncPager", @@ -5186,7 +5186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchBlueprintRevisionsPager", @@ -5271,7 +5271,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchDeploymentRevisionsAsyncPager", @@ -5355,7 +5355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.services.telco_automation.pagers.SearchDeploymentRevisionsPager", @@ -5440,7 +5440,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -5524,7 +5524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Blueprint", @@ -5609,7 +5609,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -5693,7 +5693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.Deployment", @@ -5778,7 +5778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", @@ -5862,7 +5862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.telcoautomation_v1alpha1.types.HydratedDeployment", diff --git a/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1/test_telco_automation.py b/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1/test_telco_automation.py index eb7560a2c571..c108e83fe541 100644 --- a/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1/test_telco_automation.py +++ b/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1/test_telco_automation.py @@ -15937,6 +15937,7 @@ def test_list_orchestration_clusters_rest_required_fields( response_value._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_orchestration_clusters(request) @@ -15994,6 +15995,7 @@ def test_list_orchestration_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_clusters(**mock_args) @@ -16194,6 +16196,7 @@ def test_get_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16241,6 +16244,7 @@ def test_get_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16398,6 +16402,7 @@ def test_create_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16465,6 +16470,7 @@ def test_create_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16608,6 +16614,7 @@ def test_delete_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16653,6 +16660,7 @@ def test_delete_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16793,6 +16801,7 @@ def test_list_edge_slms_rest_required_fields( response_value._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_edge_slms(request) @@ -16848,6 +16857,7 @@ def test_list_edge_slms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slms(**mock_args) @@ -17041,6 +17051,7 @@ def test_get_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17086,6 +17097,7 @@ def test_get_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17232,6 +17244,7 @@ def test_create_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17297,6 +17310,7 @@ def test_create_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17432,6 +17446,7 @@ def test_delete_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17475,6 +17490,7 @@ def test_delete_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17610,6 +17626,7 @@ def test_create_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -17667,6 +17684,7 @@ def test_create_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -17800,6 +17818,7 @@ def test_update_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -17858,6 +17877,7 @@ def test_update_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -17992,6 +18012,7 @@ def test_get_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -18039,6 +18060,7 @@ def test_get_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -18169,6 +18191,7 @@ def test_delete_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -18214,6 +18237,7 @@ def test_delete_blueprint_rest_flattened(): 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"} client.delete_blueprint(**mock_args) @@ -18353,6 +18377,7 @@ def test_list_blueprints_rest_required_fields( response_value._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_blueprints(request) @@ -18409,6 +18434,7 @@ def test_list_blueprints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprints(**mock_args) @@ -18608,6 +18634,7 @@ def test_approve_blueprint_rest_required_fields( response_value._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.approve_blueprint(request) @@ -18655,6 +18682,7 @@ def test_approve_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.approve_blueprint(**mock_args) @@ -18789,6 +18817,7 @@ def test_propose_blueprint_rest_required_fields( response_value._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.propose_blueprint(request) @@ -18836,6 +18865,7 @@ def test_propose_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.propose_blueprint(**mock_args) @@ -18970,6 +19000,7 @@ def test_reject_blueprint_rest_required_fields( response_value._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.reject_blueprint(request) @@ -19017,6 +19048,7 @@ def test_reject_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reject_blueprint(**mock_args) @@ -19162,6 +19194,7 @@ def test_list_blueprint_revisions_rest_required_fields( response_value._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_blueprint_revisions(request) @@ -19217,6 +19250,7 @@ def test_list_blueprint_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint_revisions(**mock_args) @@ -19435,6 +19469,7 @@ def test_search_blueprint_revisions_rest_required_fields( response_value._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.search_blueprint_revisions(request) @@ -19503,6 +19538,7 @@ def test_search_blueprint_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_blueprint_revisions(**mock_args) @@ -19723,6 +19759,7 @@ def test_search_deployment_revisions_rest_required_fields( response_value._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.search_deployment_revisions(request) @@ -19793,6 +19830,7 @@ def test_search_deployment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_deployment_revisions(**mock_args) @@ -19999,6 +20037,7 @@ def test_discard_blueprint_changes_rest_required_fields( response_value._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.discard_blueprint_changes(request) @@ -20046,6 +20085,7 @@ def test_discard_blueprint_changes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.discard_blueprint_changes(**mock_args) @@ -20189,6 +20229,7 @@ def test_list_public_blueprints_rest_required_fields( response_value._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_public_blueprints(request) @@ -20242,6 +20283,7 @@ def test_list_public_blueprints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_public_blueprints(**mock_args) @@ -20440,6 +20482,7 @@ def test_get_public_blueprint_rest_required_fields( response_value._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_public_blueprint(request) @@ -20487,6 +20530,7 @@ def test_get_public_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_public_blueprint(**mock_args) @@ -20623,6 +20667,7 @@ def test_create_deployment_rest_required_fields( response_value._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_deployment(request) @@ -20680,6 +20725,7 @@ def test_create_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -20813,6 +20859,7 @@ def test_update_deployment_rest_required_fields( response_value._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_deployment(request) @@ -20871,6 +20918,7 @@ def test_update_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -21005,6 +21053,7 @@ def test_get_deployment_rest_required_fields( response_value._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_deployment(request) @@ -21052,6 +21101,7 @@ def test_get_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -21183,6 +21233,7 @@ def test_remove_deployment_rest_required_fields( response_value._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.remove_deployment(request) @@ -21228,6 +21279,7 @@ def test_remove_deployment_rest_flattened(): 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"} client.remove_deployment(**mock_args) @@ -21369,6 +21421,7 @@ def test_list_deployments_rest_required_fields( response_value._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_deployments(request) @@ -21425,6 +21478,7 @@ def test_list_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployments(**mock_args) @@ -21635,6 +21689,7 @@ def test_list_deployment_revisions_rest_required_fields( response_value._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_deployment_revisions(request) @@ -21690,6 +21745,7 @@ def test_list_deployment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment_revisions(**mock_args) @@ -21894,6 +21950,7 @@ def test_discard_deployment_changes_rest_required_fields( response_value._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.discard_deployment_changes(request) @@ -21941,6 +21998,7 @@ def test_discard_deployment_changes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.discard_deployment_changes(**mock_args) @@ -22075,6 +22133,7 @@ def test_apply_deployment_rest_required_fields( response_value._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.apply_deployment(request) @@ -22122,6 +22181,7 @@ def test_apply_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.apply_deployment(**mock_args) @@ -22260,6 +22320,7 @@ def test_compute_deployment_status_rest_required_fields( response_value._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.compute_deployment_status(request) @@ -22307,6 +22368,7 @@ def test_compute_deployment_status_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.compute_deployment_status(**mock_args) @@ -22447,6 +22509,7 @@ def test_rollback_deployment_rest_required_fields( response_value._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.rollback_deployment(request) @@ -22503,6 +22566,7 @@ def test_rollback_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.rollback_deployment(**mock_args) @@ -22640,6 +22704,7 @@ def test_get_hydrated_deployment_rest_required_fields( response_value._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_hydrated_deployment(request) @@ -22687,6 +22752,7 @@ def test_get_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployment(**mock_args) @@ -22832,6 +22898,7 @@ def test_list_hydrated_deployments_rest_required_fields( response_value._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_hydrated_deployments(request) @@ -22887,6 +22954,7 @@ def test_list_hydrated_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployments(**mock_args) @@ -23086,6 +23154,7 @@ def test_update_hydrated_deployment_rest_required_fields( response_value._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_hydrated_deployment(request) @@ -23144,6 +23213,7 @@ def test_update_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployment(**mock_args) @@ -23282,6 +23352,7 @@ def test_apply_hydrated_deployment_rest_required_fields( response_value._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.apply_hydrated_deployment(request) @@ -23329,6 +23400,7 @@ def test_apply_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.apply_hydrated_deployment(**mock_args) @@ -25419,6 +25491,7 @@ def test_list_orchestration_clusters_rest_bad_request( 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_orchestration_clusters(request) @@ -25457,6 +25530,7 @@ def test_list_orchestration_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_clusters(request) # Establish that the response is the type that we expect. @@ -25498,6 +25572,7 @@ def test_list_orchestration_clusters_rest_interceptors(null_interceptor): 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 = telcoautomation.ListOrchestrationClustersResponse.to_json( telcoautomation.ListOrchestrationClustersResponse() ) @@ -25546,6 +25621,7 @@ def test_get_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25585,6 +25661,7 @@ def test_get_orchestration_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25627,6 +25704,7 @@ def test_get_orchestration_cluster_rest_interceptors(null_interceptor): 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 = telcoautomation.OrchestrationCluster.to_json( telcoautomation.OrchestrationCluster() ) @@ -25673,6 +25751,7 @@ def test_create_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25811,6 +25890,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25852,6 +25932,7 @@ def test_create_orchestration_cluster_rest_interceptors(null_interceptor): 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 @@ -25898,6 +25979,7 @@ def test_delete_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25930,6 +26012,7 @@ def test_delete_orchestration_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25971,6 +26054,7 @@ def test_delete_orchestration_cluster_rest_interceptors(null_interceptor): 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 @@ -26015,6 +26099,7 @@ def test_list_edge_slms_rest_bad_request( 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_edge_slms(request) @@ -26051,6 +26136,7 @@ def test_list_edge_slms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slms(request) # Establish that the response is the type that we expect. @@ -26092,6 +26178,7 @@ def test_list_edge_slms_rest_interceptors(null_interceptor): 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 = telcoautomation.ListEdgeSlmsResponse.to_json( telcoautomation.ListEdgeSlmsResponse() ) @@ -26136,6 +26223,7 @@ def test_get_edge_slm_rest_bad_request(request_type=telcoautomation.GetEdgeSlmRe 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_edge_slm(request) @@ -26175,6 +26263,7 @@ def test_get_edge_slm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26222,6 +26311,7 @@ def test_get_edge_slm_rest_interceptors(null_interceptor): 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 = telcoautomation.EdgeSlm.to_json(telcoautomation.EdgeSlm()) req.return_value.content = return_value @@ -26266,6 +26356,7 @@ def test_create_edge_slm_rest_bad_request( 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_edge_slm(request) @@ -26373,6 +26464,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26414,6 +26506,7 @@ def test_create_edge_slm_rest_interceptors(null_interceptor): 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 @@ -26458,6 +26551,7 @@ def test_delete_edge_slm_rest_bad_request( 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_edge_slm(request) @@ -26488,6 +26582,7 @@ def test_delete_edge_slm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26529,6 +26624,7 @@ def test_delete_edge_slm_rest_interceptors(null_interceptor): 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 @@ -26575,6 +26671,7 @@ def test_create_blueprint_rest_bad_request( 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_blueprint(request) @@ -26710,6 +26807,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -26758,6 +26856,7 @@ def test_create_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -26806,6 +26905,7 @@ def test_update_blueprint_rest_bad_request( 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_blueprint(request) @@ -26943,6 +27043,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -26991,6 +27092,7 @@ def test_update_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27037,6 +27139,7 @@ def test_get_blueprint_rest_bad_request( 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_blueprint(request) @@ -27082,6 +27185,7 @@ def test_get_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -27130,6 +27234,7 @@ def test_get_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27176,6 +27281,7 @@ def test_delete_blueprint_rest_bad_request( 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_blueprint(request) @@ -27208,6 +27314,7 @@ def test_delete_blueprint_rest_call_success(request_type): 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_blueprint(request) # Establish that the response is the type that we expect. @@ -27244,6 +27351,7 @@ def test_delete_blueprint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = telcoautomation.DeleteBlueprintRequest() metadata = [ @@ -27286,6 +27394,7 @@ def test_list_blueprints_rest_bad_request( 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_blueprints(request) @@ -27323,6 +27432,7 @@ def test_list_blueprints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprints(request) # Establish that the response is the type that we expect. @@ -27363,6 +27473,7 @@ def test_list_blueprints_rest_interceptors(null_interceptor): 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 = telcoautomation.ListBlueprintsResponse.to_json( telcoautomation.ListBlueprintsResponse() ) @@ -27411,6 +27522,7 @@ def test_approve_blueprint_rest_bad_request( 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.approve_blueprint(request) @@ -27456,6 +27568,7 @@ def test_approve_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.approve_blueprint(request) # Establish that the response is the type that we expect. @@ -27504,6 +27617,7 @@ def test_approve_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27550,6 +27664,7 @@ def test_propose_blueprint_rest_bad_request( 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.propose_blueprint(request) @@ -27595,6 +27710,7 @@ def test_propose_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.propose_blueprint(request) # Establish that the response is the type that we expect. @@ -27643,6 +27759,7 @@ def test_propose_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27689,6 +27806,7 @@ def test_reject_blueprint_rest_bad_request( 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.reject_blueprint(request) @@ -27734,6 +27852,7 @@ def test_reject_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reject_blueprint(request) # Establish that the response is the type that we expect. @@ -27782,6 +27901,7 @@ def test_reject_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27828,6 +27948,7 @@ def test_list_blueprint_revisions_rest_bad_request( 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_blueprint_revisions(request) @@ -27865,6 +27986,7 @@ def test_list_blueprint_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint_revisions(request) # Establish that the response is the type that we expect. @@ -27905,6 +28027,7 @@ def test_list_blueprint_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.ListBlueprintRevisionsResponse.to_json( telcoautomation.ListBlueprintRevisionsResponse() ) @@ -27953,6 +28076,7 @@ def test_search_blueprint_revisions_rest_bad_request( 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.search_blueprint_revisions(request) @@ -27990,6 +28114,7 @@ def test_search_blueprint_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_blueprint_revisions(request) # Establish that the response is the type that we expect. @@ -28030,6 +28155,7 @@ def test_search_blueprint_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.SearchBlueprintRevisionsResponse.to_json( telcoautomation.SearchBlueprintRevisionsResponse() ) @@ -28078,6 +28204,7 @@ def test_search_deployment_revisions_rest_bad_request( 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.search_deployment_revisions(request) @@ -28117,6 +28244,7 @@ def test_search_deployment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_deployment_revisions(request) # Establish that the response is the type that we expect. @@ -28157,6 +28285,7 @@ def test_search_deployment_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.SearchDeploymentRevisionsResponse.to_json( telcoautomation.SearchDeploymentRevisionsResponse() ) @@ -28205,6 +28334,7 @@ def test_discard_blueprint_changes_rest_bad_request( 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.discard_blueprint_changes(request) @@ -28240,6 +28370,7 @@ def test_discard_blueprint_changes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.discard_blueprint_changes(request) # Establish that the response is the type that we expect. @@ -28279,6 +28410,7 @@ def test_discard_blueprint_changes_rest_interceptors(null_interceptor): 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 = telcoautomation.DiscardBlueprintChangesResponse.to_json( telcoautomation.DiscardBlueprintChangesResponse() ) @@ -28325,6 +28457,7 @@ def test_list_public_blueprints_rest_bad_request( 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_public_blueprints(request) @@ -28360,6 +28493,7 @@ def test_list_public_blueprints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_public_blueprints(request) # Establish that the response is the type that we expect. @@ -28400,6 +28534,7 @@ def test_list_public_blueprints_rest_interceptors(null_interceptor): 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 = telcoautomation.ListPublicBlueprintsResponse.to_json( telcoautomation.ListPublicBlueprintsResponse() ) @@ -28448,6 +28583,7 @@ def test_get_public_blueprint_rest_bad_request( 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_public_blueprint(request) @@ -28490,6 +28626,7 @@ def test_get_public_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_public_blueprint(request) # Establish that the response is the type that we expect. @@ -28535,6 +28672,7 @@ def test_get_public_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.PublicBlueprint.to_json( telcoautomation.PublicBlueprint() ) @@ -28583,6 +28721,7 @@ def test_create_deployment_rest_bad_request( 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_deployment(request) @@ -28720,6 +28859,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -28769,6 +28909,7 @@ def test_create_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -28817,6 +28958,7 @@ def test_update_deployment_rest_bad_request( 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_deployment(request) @@ -28956,6 +29098,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -29005,6 +29148,7 @@ def test_update_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29051,6 +29195,7 @@ def test_get_deployment_rest_bad_request( 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_deployment(request) @@ -29097,6 +29242,7 @@ def test_get_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -29146,6 +29292,7 @@ def test_get_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29192,6 +29339,7 @@ def test_remove_deployment_rest_bad_request( 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.remove_deployment(request) @@ -29224,6 +29372,7 @@ def test_remove_deployment_rest_call_success(request_type): 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.remove_deployment(request) # Establish that the response is the type that we expect. @@ -29260,6 +29409,7 @@ def test_remove_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = telcoautomation.RemoveDeploymentRequest() metadata = [ @@ -29302,6 +29452,7 @@ def test_list_deployments_rest_bad_request( 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_deployments(request) @@ -29339,6 +29490,7 @@ def test_list_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployments(request) # Establish that the response is the type that we expect. @@ -29379,6 +29531,7 @@ def test_list_deployments_rest_interceptors(null_interceptor): 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 = telcoautomation.ListDeploymentsResponse.to_json( telcoautomation.ListDeploymentsResponse() ) @@ -29427,6 +29580,7 @@ def test_list_deployment_revisions_rest_bad_request( 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_deployment_revisions(request) @@ -29464,6 +29618,7 @@ def test_list_deployment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment_revisions(request) # Establish that the response is the type that we expect. @@ -29504,6 +29659,7 @@ def test_list_deployment_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.ListDeploymentRevisionsResponse.to_json( telcoautomation.ListDeploymentRevisionsResponse() ) @@ -29552,6 +29708,7 @@ def test_discard_deployment_changes_rest_bad_request( 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.discard_deployment_changes(request) @@ -29587,6 +29744,7 @@ def test_discard_deployment_changes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.discard_deployment_changes(request) # Establish that the response is the type that we expect. @@ -29626,6 +29784,7 @@ def test_discard_deployment_changes_rest_interceptors(null_interceptor): 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 = telcoautomation.DiscardDeploymentChangesResponse.to_json( telcoautomation.DiscardDeploymentChangesResponse() ) @@ -29674,6 +29833,7 @@ def test_apply_deployment_rest_bad_request( 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.apply_deployment(request) @@ -29720,6 +29880,7 @@ def test_apply_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.apply_deployment(request) # Establish that the response is the type that we expect. @@ -29769,6 +29930,7 @@ def test_apply_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29815,6 +29977,7 @@ def test_compute_deployment_status_rest_bad_request( 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.compute_deployment_status(request) @@ -29853,6 +30016,7 @@ def test_compute_deployment_status_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.compute_deployment_status(request) # Establish that the response is the type that we expect. @@ -29894,6 +30058,7 @@ def test_compute_deployment_status_rest_interceptors(null_interceptor): 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 = telcoautomation.ComputeDeploymentStatusResponse.to_json( telcoautomation.ComputeDeploymentStatusResponse() ) @@ -29942,6 +30107,7 @@ def test_rollback_deployment_rest_bad_request( 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.rollback_deployment(request) @@ -29988,6 +30154,7 @@ def test_rollback_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.rollback_deployment(request) # Establish that the response is the type that we expect. @@ -30037,6 +30204,7 @@ def test_rollback_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -30083,6 +30251,7 @@ def test_get_hydrated_deployment_rest_bad_request( 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_hydrated_deployment(request) @@ -30122,6 +30291,7 @@ def test_get_hydrated_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30164,6 +30334,7 @@ def test_get_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30212,6 +30383,7 @@ def test_list_hydrated_deployments_rest_bad_request( 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_hydrated_deployments(request) @@ -30249,6 +30421,7 @@ def test_list_hydrated_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployments(request) # Establish that the response is the type that we expect. @@ -30289,6 +30462,7 @@ def test_list_hydrated_deployments_rest_interceptors(null_interceptor): 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 = telcoautomation.ListHydratedDeploymentsResponse.to_json( telcoautomation.ListHydratedDeploymentsResponse() ) @@ -30339,6 +30513,7 @@ def test_update_hydrated_deployment_rest_bad_request( 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_hydrated_deployment(request) @@ -30462,6 +30637,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30504,6 +30680,7 @@ def test_update_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30552,6 +30729,7 @@ def test_apply_hydrated_deployment_rest_bad_request( 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.apply_hydrated_deployment(request) @@ -30591,6 +30769,7 @@ def test_apply_hydrated_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.apply_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30633,6 +30812,7 @@ def test_apply_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30679,6 +30859,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -30709,6 +30890,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -30737,6 +30919,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -30767,6 +30950,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -30797,6 +30981,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -30827,6 +31012,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -30857,6 +31043,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -30887,6 +31074,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -30917,6 +31105,7 @@ def test_get_operation_rest_bad_request( 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) @@ -30947,6 +31136,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -30977,6 +31167,7 @@ def test_list_operations_rest_bad_request( 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) @@ -31007,6 +31198,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1alpha1/test_telco_automation.py b/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1alpha1/test_telco_automation.py index cf4bfcc1632b..2ed665cb933b 100644 --- a/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1alpha1/test_telco_automation.py +++ b/packages/google-cloud-telcoautomation/tests/unit/gapic/telcoautomation_v1alpha1/test_telco_automation.py @@ -15937,6 +15937,7 @@ def test_list_orchestration_clusters_rest_required_fields( response_value._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_orchestration_clusters(request) @@ -15994,6 +15995,7 @@ def test_list_orchestration_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_clusters(**mock_args) @@ -16194,6 +16196,7 @@ def test_get_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16241,6 +16244,7 @@ def test_get_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16398,6 +16402,7 @@ def test_create_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16465,6 +16470,7 @@ def test_create_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16608,6 +16614,7 @@ def test_delete_orchestration_cluster_rest_required_fields( response_value._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_orchestration_cluster(request) @@ -16653,6 +16660,7 @@ def test_delete_orchestration_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_orchestration_cluster(**mock_args) @@ -16793,6 +16801,7 @@ def test_list_edge_slms_rest_required_fields( response_value._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_edge_slms(request) @@ -16848,6 +16857,7 @@ def test_list_edge_slms_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slms(**mock_args) @@ -17042,6 +17052,7 @@ def test_get_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17087,6 +17098,7 @@ def test_get_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17234,6 +17246,7 @@ def test_create_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17299,6 +17312,7 @@ def test_create_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17435,6 +17449,7 @@ def test_delete_edge_slm_rest_required_fields( response_value._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_edge_slm(request) @@ -17478,6 +17493,7 @@ def test_delete_edge_slm_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_edge_slm(**mock_args) @@ -17614,6 +17630,7 @@ def test_create_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -17671,6 +17688,7 @@ def test_create_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -17804,6 +17822,7 @@ def test_update_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -17862,6 +17881,7 @@ def test_update_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -17996,6 +18016,7 @@ def test_get_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -18043,6 +18064,7 @@ def test_get_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint(**mock_args) @@ -18173,6 +18195,7 @@ def test_delete_blueprint_rest_required_fields( response_value._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_blueprint(request) @@ -18218,6 +18241,7 @@ def test_delete_blueprint_rest_flattened(): 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"} client.delete_blueprint(**mock_args) @@ -18357,6 +18381,7 @@ def test_list_blueprints_rest_required_fields( response_value._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_blueprints(request) @@ -18413,6 +18438,7 @@ def test_list_blueprints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprints(**mock_args) @@ -18612,6 +18638,7 @@ def test_approve_blueprint_rest_required_fields( response_value._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.approve_blueprint(request) @@ -18659,6 +18686,7 @@ def test_approve_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.approve_blueprint(**mock_args) @@ -18793,6 +18821,7 @@ def test_propose_blueprint_rest_required_fields( response_value._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.propose_blueprint(request) @@ -18840,6 +18869,7 @@ def test_propose_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.propose_blueprint(**mock_args) @@ -18974,6 +19004,7 @@ def test_reject_blueprint_rest_required_fields( response_value._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.reject_blueprint(request) @@ -19021,6 +19052,7 @@ def test_reject_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reject_blueprint(**mock_args) @@ -19166,6 +19198,7 @@ def test_list_blueprint_revisions_rest_required_fields( response_value._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_blueprint_revisions(request) @@ -19221,6 +19254,7 @@ def test_list_blueprint_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_blueprint_revisions(**mock_args) @@ -19439,6 +19473,7 @@ def test_search_blueprint_revisions_rest_required_fields( response_value._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.search_blueprint_revisions(request) @@ -19507,6 +19542,7 @@ def test_search_blueprint_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_blueprint_revisions(**mock_args) @@ -19727,6 +19763,7 @@ def test_search_deployment_revisions_rest_required_fields( response_value._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.search_deployment_revisions(request) @@ -19797,6 +19834,7 @@ def test_search_deployment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_deployment_revisions(**mock_args) @@ -20003,6 +20041,7 @@ def test_discard_blueprint_changes_rest_required_fields( response_value._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.discard_blueprint_changes(request) @@ -20050,6 +20089,7 @@ def test_discard_blueprint_changes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.discard_blueprint_changes(**mock_args) @@ -20193,6 +20233,7 @@ def test_list_public_blueprints_rest_required_fields( response_value._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_public_blueprints(request) @@ -20246,6 +20287,7 @@ def test_list_public_blueprints_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_public_blueprints(**mock_args) @@ -20444,6 +20486,7 @@ def test_get_public_blueprint_rest_required_fields( response_value._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_public_blueprint(request) @@ -20491,6 +20534,7 @@ def test_get_public_blueprint_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_public_blueprint(**mock_args) @@ -20627,6 +20671,7 @@ def test_create_deployment_rest_required_fields( response_value._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_deployment(request) @@ -20684,6 +20729,7 @@ def test_create_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -20817,6 +20863,7 @@ def test_update_deployment_rest_required_fields( response_value._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_deployment(request) @@ -20875,6 +20922,7 @@ def test_update_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -21009,6 +21057,7 @@ def test_get_deployment_rest_required_fields( response_value._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_deployment(request) @@ -21056,6 +21105,7 @@ def test_get_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment(**mock_args) @@ -21187,6 +21237,7 @@ def test_remove_deployment_rest_required_fields( response_value._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.remove_deployment(request) @@ -21232,6 +21283,7 @@ def test_remove_deployment_rest_flattened(): 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"} client.remove_deployment(**mock_args) @@ -21373,6 +21425,7 @@ def test_list_deployments_rest_required_fields( response_value._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_deployments(request) @@ -21429,6 +21482,7 @@ def test_list_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployments(**mock_args) @@ -21639,6 +21693,7 @@ def test_list_deployment_revisions_rest_required_fields( response_value._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_deployment_revisions(request) @@ -21694,6 +21749,7 @@ def test_list_deployment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_deployment_revisions(**mock_args) @@ -21898,6 +21954,7 @@ def test_discard_deployment_changes_rest_required_fields( response_value._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.discard_deployment_changes(request) @@ -21945,6 +22002,7 @@ def test_discard_deployment_changes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.discard_deployment_changes(**mock_args) @@ -22079,6 +22137,7 @@ def test_apply_deployment_rest_required_fields( response_value._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.apply_deployment(request) @@ -22126,6 +22185,7 @@ def test_apply_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.apply_deployment(**mock_args) @@ -22264,6 +22324,7 @@ def test_compute_deployment_status_rest_required_fields( response_value._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.compute_deployment_status(request) @@ -22311,6 +22372,7 @@ def test_compute_deployment_status_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.compute_deployment_status(**mock_args) @@ -22451,6 +22513,7 @@ def test_rollback_deployment_rest_required_fields( response_value._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.rollback_deployment(request) @@ -22507,6 +22570,7 @@ def test_rollback_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.rollback_deployment(**mock_args) @@ -22644,6 +22708,7 @@ def test_get_hydrated_deployment_rest_required_fields( response_value._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_hydrated_deployment(request) @@ -22691,6 +22756,7 @@ def test_get_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployment(**mock_args) @@ -22836,6 +22902,7 @@ def test_list_hydrated_deployments_rest_required_fields( response_value._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_hydrated_deployments(request) @@ -22891,6 +22958,7 @@ def test_list_hydrated_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployments(**mock_args) @@ -23090,6 +23158,7 @@ def test_update_hydrated_deployment_rest_required_fields( response_value._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_hydrated_deployment(request) @@ -23148,6 +23217,7 @@ def test_update_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_hydrated_deployment(**mock_args) @@ -23286,6 +23356,7 @@ def test_apply_hydrated_deployment_rest_required_fields( response_value._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.apply_hydrated_deployment(request) @@ -23333,6 +23404,7 @@ def test_apply_hydrated_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.apply_hydrated_deployment(**mock_args) @@ -25423,6 +25495,7 @@ def test_list_orchestration_clusters_rest_bad_request( 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_orchestration_clusters(request) @@ -25461,6 +25534,7 @@ def test_list_orchestration_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_clusters(request) # Establish that the response is the type that we expect. @@ -25502,6 +25576,7 @@ def test_list_orchestration_clusters_rest_interceptors(null_interceptor): 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 = telcoautomation.ListOrchestrationClustersResponse.to_json( telcoautomation.ListOrchestrationClustersResponse() ) @@ -25550,6 +25625,7 @@ def test_get_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25589,6 +25665,7 @@ def test_get_orchestration_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25631,6 +25708,7 @@ def test_get_orchestration_cluster_rest_interceptors(null_interceptor): 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 = telcoautomation.OrchestrationCluster.to_json( telcoautomation.OrchestrationCluster() ) @@ -25677,6 +25755,7 @@ def test_create_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25815,6 +25894,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25856,6 +25936,7 @@ def test_create_orchestration_cluster_rest_interceptors(null_interceptor): 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 @@ -25902,6 +25983,7 @@ def test_delete_orchestration_cluster_rest_bad_request( 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_orchestration_cluster(request) @@ -25934,6 +26016,7 @@ def test_delete_orchestration_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_orchestration_cluster(request) # Establish that the response is the type that we expect. @@ -25975,6 +26058,7 @@ def test_delete_orchestration_cluster_rest_interceptors(null_interceptor): 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 @@ -26019,6 +26103,7 @@ def test_list_edge_slms_rest_bad_request( 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_edge_slms(request) @@ -26055,6 +26140,7 @@ def test_list_edge_slms_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slms(request) # Establish that the response is the type that we expect. @@ -26096,6 +26182,7 @@ def test_list_edge_slms_rest_interceptors(null_interceptor): 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 = telcoautomation.ListEdgeSlmsResponse.to_json( telcoautomation.ListEdgeSlmsResponse() ) @@ -26140,6 +26227,7 @@ def test_get_edge_slm_rest_bad_request(request_type=telcoautomation.GetEdgeSlmRe 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_edge_slm(request) @@ -26179,6 +26267,7 @@ def test_get_edge_slm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26226,6 +26315,7 @@ def test_get_edge_slm_rest_interceptors(null_interceptor): 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 = telcoautomation.EdgeSlm.to_json(telcoautomation.EdgeSlm()) req.return_value.content = return_value @@ -26270,6 +26360,7 @@ def test_create_edge_slm_rest_bad_request( 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_edge_slm(request) @@ -26377,6 +26468,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26418,6 +26510,7 @@ def test_create_edge_slm_rest_interceptors(null_interceptor): 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 @@ -26462,6 +26555,7 @@ def test_delete_edge_slm_rest_bad_request( 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_edge_slm(request) @@ -26492,6 +26586,7 @@ def test_delete_edge_slm_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_edge_slm(request) # Establish that the response is the type that we expect. @@ -26533,6 +26628,7 @@ def test_delete_edge_slm_rest_interceptors(null_interceptor): 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 @@ -26579,6 +26675,7 @@ def test_create_blueprint_rest_bad_request( 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_blueprint(request) @@ -26714,6 +26811,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -26762,6 +26860,7 @@ def test_create_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -26810,6 +26909,7 @@ def test_update_blueprint_rest_bad_request( 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_blueprint(request) @@ -26947,6 +27047,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -26995,6 +27096,7 @@ def test_update_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27041,6 +27143,7 @@ def test_get_blueprint_rest_bad_request( 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_blueprint(request) @@ -27086,6 +27189,7 @@ def test_get_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint(request) # Establish that the response is the type that we expect. @@ -27134,6 +27238,7 @@ def test_get_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27180,6 +27285,7 @@ def test_delete_blueprint_rest_bad_request( 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_blueprint(request) @@ -27212,6 +27318,7 @@ def test_delete_blueprint_rest_call_success(request_type): 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_blueprint(request) # Establish that the response is the type that we expect. @@ -27248,6 +27355,7 @@ def test_delete_blueprint_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = telcoautomation.DeleteBlueprintRequest() metadata = [ @@ -27290,6 +27398,7 @@ def test_list_blueprints_rest_bad_request( 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_blueprints(request) @@ -27327,6 +27436,7 @@ def test_list_blueprints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprints(request) # Establish that the response is the type that we expect. @@ -27367,6 +27477,7 @@ def test_list_blueprints_rest_interceptors(null_interceptor): 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 = telcoautomation.ListBlueprintsResponse.to_json( telcoautomation.ListBlueprintsResponse() ) @@ -27415,6 +27526,7 @@ def test_approve_blueprint_rest_bad_request( 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.approve_blueprint(request) @@ -27460,6 +27572,7 @@ def test_approve_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.approve_blueprint(request) # Establish that the response is the type that we expect. @@ -27508,6 +27621,7 @@ def test_approve_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27554,6 +27668,7 @@ def test_propose_blueprint_rest_bad_request( 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.propose_blueprint(request) @@ -27599,6 +27714,7 @@ def test_propose_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.propose_blueprint(request) # Establish that the response is the type that we expect. @@ -27647,6 +27763,7 @@ def test_propose_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27693,6 +27810,7 @@ def test_reject_blueprint_rest_bad_request( 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.reject_blueprint(request) @@ -27738,6 +27856,7 @@ def test_reject_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reject_blueprint(request) # Establish that the response is the type that we expect. @@ -27786,6 +27905,7 @@ def test_reject_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.Blueprint.to_json(telcoautomation.Blueprint()) req.return_value.content = return_value @@ -27832,6 +27952,7 @@ def test_list_blueprint_revisions_rest_bad_request( 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_blueprint_revisions(request) @@ -27869,6 +27990,7 @@ def test_list_blueprint_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_blueprint_revisions(request) # Establish that the response is the type that we expect. @@ -27909,6 +28031,7 @@ def test_list_blueprint_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.ListBlueprintRevisionsResponse.to_json( telcoautomation.ListBlueprintRevisionsResponse() ) @@ -27957,6 +28080,7 @@ def test_search_blueprint_revisions_rest_bad_request( 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.search_blueprint_revisions(request) @@ -27994,6 +28118,7 @@ def test_search_blueprint_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_blueprint_revisions(request) # Establish that the response is the type that we expect. @@ -28034,6 +28159,7 @@ def test_search_blueprint_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.SearchBlueprintRevisionsResponse.to_json( telcoautomation.SearchBlueprintRevisionsResponse() ) @@ -28082,6 +28208,7 @@ def test_search_deployment_revisions_rest_bad_request( 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.search_deployment_revisions(request) @@ -28121,6 +28248,7 @@ def test_search_deployment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_deployment_revisions(request) # Establish that the response is the type that we expect. @@ -28161,6 +28289,7 @@ def test_search_deployment_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.SearchDeploymentRevisionsResponse.to_json( telcoautomation.SearchDeploymentRevisionsResponse() ) @@ -28209,6 +28338,7 @@ def test_discard_blueprint_changes_rest_bad_request( 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.discard_blueprint_changes(request) @@ -28244,6 +28374,7 @@ def test_discard_blueprint_changes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.discard_blueprint_changes(request) # Establish that the response is the type that we expect. @@ -28283,6 +28414,7 @@ def test_discard_blueprint_changes_rest_interceptors(null_interceptor): 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 = telcoautomation.DiscardBlueprintChangesResponse.to_json( telcoautomation.DiscardBlueprintChangesResponse() ) @@ -28329,6 +28461,7 @@ def test_list_public_blueprints_rest_bad_request( 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_public_blueprints(request) @@ -28364,6 +28497,7 @@ def test_list_public_blueprints_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_public_blueprints(request) # Establish that the response is the type that we expect. @@ -28404,6 +28538,7 @@ def test_list_public_blueprints_rest_interceptors(null_interceptor): 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 = telcoautomation.ListPublicBlueprintsResponse.to_json( telcoautomation.ListPublicBlueprintsResponse() ) @@ -28452,6 +28587,7 @@ def test_get_public_blueprint_rest_bad_request( 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_public_blueprint(request) @@ -28494,6 +28630,7 @@ def test_get_public_blueprint_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_public_blueprint(request) # Establish that the response is the type that we expect. @@ -28539,6 +28676,7 @@ def test_get_public_blueprint_rest_interceptors(null_interceptor): 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 = telcoautomation.PublicBlueprint.to_json( telcoautomation.PublicBlueprint() ) @@ -28587,6 +28725,7 @@ def test_create_deployment_rest_bad_request( 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_deployment(request) @@ -28724,6 +28863,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -28773,6 +28913,7 @@ def test_create_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -28821,6 +28962,7 @@ def test_update_deployment_rest_bad_request( 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_deployment(request) @@ -28960,6 +29102,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -29009,6 +29152,7 @@ def test_update_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29055,6 +29199,7 @@ def test_get_deployment_rest_bad_request( 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_deployment(request) @@ -29101,6 +29246,7 @@ def test_get_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment(request) # Establish that the response is the type that we expect. @@ -29150,6 +29296,7 @@ def test_get_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29196,6 +29343,7 @@ def test_remove_deployment_rest_bad_request( 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.remove_deployment(request) @@ -29228,6 +29376,7 @@ def test_remove_deployment_rest_call_success(request_type): 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.remove_deployment(request) # Establish that the response is the type that we expect. @@ -29264,6 +29413,7 @@ def test_remove_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = telcoautomation.RemoveDeploymentRequest() metadata = [ @@ -29306,6 +29456,7 @@ def test_list_deployments_rest_bad_request( 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_deployments(request) @@ -29343,6 +29494,7 @@ def test_list_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployments(request) # Establish that the response is the type that we expect. @@ -29383,6 +29535,7 @@ def test_list_deployments_rest_interceptors(null_interceptor): 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 = telcoautomation.ListDeploymentsResponse.to_json( telcoautomation.ListDeploymentsResponse() ) @@ -29431,6 +29584,7 @@ def test_list_deployment_revisions_rest_bad_request( 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_deployment_revisions(request) @@ -29468,6 +29622,7 @@ def test_list_deployment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_deployment_revisions(request) # Establish that the response is the type that we expect. @@ -29508,6 +29663,7 @@ def test_list_deployment_revisions_rest_interceptors(null_interceptor): 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 = telcoautomation.ListDeploymentRevisionsResponse.to_json( telcoautomation.ListDeploymentRevisionsResponse() ) @@ -29556,6 +29712,7 @@ def test_discard_deployment_changes_rest_bad_request( 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.discard_deployment_changes(request) @@ -29591,6 +29748,7 @@ def test_discard_deployment_changes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.discard_deployment_changes(request) # Establish that the response is the type that we expect. @@ -29630,6 +29788,7 @@ def test_discard_deployment_changes_rest_interceptors(null_interceptor): 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 = telcoautomation.DiscardDeploymentChangesResponse.to_json( telcoautomation.DiscardDeploymentChangesResponse() ) @@ -29678,6 +29837,7 @@ def test_apply_deployment_rest_bad_request( 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.apply_deployment(request) @@ -29724,6 +29884,7 @@ def test_apply_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.apply_deployment(request) # Establish that the response is the type that we expect. @@ -29773,6 +29934,7 @@ def test_apply_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -29819,6 +29981,7 @@ def test_compute_deployment_status_rest_bad_request( 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.compute_deployment_status(request) @@ -29857,6 +30020,7 @@ def test_compute_deployment_status_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.compute_deployment_status(request) # Establish that the response is the type that we expect. @@ -29898,6 +30062,7 @@ def test_compute_deployment_status_rest_interceptors(null_interceptor): 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 = telcoautomation.ComputeDeploymentStatusResponse.to_json( telcoautomation.ComputeDeploymentStatusResponse() ) @@ -29946,6 +30111,7 @@ def test_rollback_deployment_rest_bad_request( 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.rollback_deployment(request) @@ -29992,6 +30158,7 @@ def test_rollback_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.rollback_deployment(request) # Establish that the response is the type that we expect. @@ -30041,6 +30208,7 @@ def test_rollback_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.Deployment.to_json(telcoautomation.Deployment()) req.return_value.content = return_value @@ -30087,6 +30255,7 @@ def test_get_hydrated_deployment_rest_bad_request( 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_hydrated_deployment(request) @@ -30126,6 +30295,7 @@ def test_get_hydrated_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30168,6 +30338,7 @@ def test_get_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30216,6 +30387,7 @@ def test_list_hydrated_deployments_rest_bad_request( 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_hydrated_deployments(request) @@ -30253,6 +30425,7 @@ def test_list_hydrated_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployments(request) # Establish that the response is the type that we expect. @@ -30293,6 +30466,7 @@ def test_list_hydrated_deployments_rest_interceptors(null_interceptor): 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 = telcoautomation.ListHydratedDeploymentsResponse.to_json( telcoautomation.ListHydratedDeploymentsResponse() ) @@ -30343,6 +30517,7 @@ def test_update_hydrated_deployment_rest_bad_request( 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_hydrated_deployment(request) @@ -30466,6 +30641,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30508,6 +30684,7 @@ def test_update_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30556,6 +30733,7 @@ def test_apply_hydrated_deployment_rest_bad_request( 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.apply_hydrated_deployment(request) @@ -30595,6 +30773,7 @@ def test_apply_hydrated_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.apply_hydrated_deployment(request) # Establish that the response is the type that we expect. @@ -30637,6 +30816,7 @@ def test_apply_hydrated_deployment_rest_interceptors(null_interceptor): 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 = telcoautomation.HydratedDeployment.to_json( telcoautomation.HydratedDeployment() ) @@ -30683,6 +30863,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -30713,6 +30894,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -30741,6 +30923,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -30771,6 +30954,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -30801,6 +30985,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -30831,6 +31016,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -30861,6 +31047,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -30891,6 +31078,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -30921,6 +31109,7 @@ def test_get_operation_rest_bad_request( 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) @@ -30951,6 +31140,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -30981,6 +31171,7 @@ def test_list_operations_rest_bad_request( 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) @@ -31011,6 +31202,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech/gapic_version.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech/gapic_version.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/gapic_version.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/gapic_version.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py index 270a2680e7c5..ed9024599859 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TextToSpeechTransport from .transports.grpc_asyncio import TextToSpeechGrpcAsyncIOTransport +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 TextToSpeechAsyncClient: """Service that implements Google Cloud Text-to-Speech API.""" @@ -257,6 +267,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.texttospeech_v1.TextToSpeechAsyncClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "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.texttospeech.v1.TextToSpeech", + "credentialsType": None, + }, + ) + async def list_voices( self, request: Optional[Union[cloud_tts.ListVoicesRequest, dict]] = None, @@ -264,7 +296,7 @@ async def list_voices( language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. @@ -314,8 +346,10 @@ async def sample_list_voices(): 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, 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: google.cloud.texttospeech_v1.types.ListVoicesResponse: @@ -372,7 +406,7 @@ async def synthesize_speech( audio_config: Optional[cloud_tts.AudioConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Synthesizes speech synchronously: receive results after all text input has been processed. @@ -442,8 +476,10 @@ async def sample_synthesize_speech(): 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, 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: google.cloud.texttospeech_v1.types.SynthesizeSpeechResponse: @@ -501,7 +537,7 @@ def streaming_synthesize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[cloud_tts.StreamingSynthesizeResponse]]: r"""Performs bidirectional streaming speech synthesis: receive audio while sending text. @@ -557,8 +593,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.texttospeech_v1.types.StreamingSynthesizeResponse]: @@ -595,7 +633,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -606,8 +644,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -648,7 +688,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -659,8 +699,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/client.py index 82708deca9c1..edcc85a61104 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.texttospeech_v1.types import cloud_tts @@ -582,6 +592,10 @@ def __init__( # 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( @@ -644,6 +658,29 @@ def __init__( 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.texttospeech_v1.TextToSpeechClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "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.texttospeech.v1.TextToSpeech", + "credentialsType": None, + }, + ) + def list_voices( self, request: Optional[Union[cloud_tts.ListVoicesRequest, dict]] = None, @@ -651,7 +688,7 @@ def list_voices( language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. @@ -701,8 +738,10 @@ def sample_list_voices(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.texttospeech_v1.types.ListVoicesResponse: @@ -756,7 +795,7 @@ def synthesize_speech( audio_config: Optional[cloud_tts.AudioConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Synthesizes speech synchronously: receive results after all text input has been processed. @@ -826,8 +865,10 @@ def sample_synthesize_speech(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.texttospeech_v1.types.SynthesizeSpeechResponse: @@ -882,7 +923,7 @@ def streaming_synthesize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[cloud_tts.StreamingSynthesizeResponse]: r"""Performs bidirectional streaming speech synthesis: receive audio while sending text. @@ -938,8 +979,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.texttospeech_v1.types.StreamingSynthesizeResponse]: @@ -987,7 +1030,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -998,8 +1041,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1040,7 +1085,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1051,8 +1096,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc.py index 13950d3132b2..af7a2eb5ecc5 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1.types import cloud_tts from .base import DEFAULT_CLIENT_INFO, TextToSpeechTransport +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.texttospeech.v1.TextToSpeech", + "rpcName": 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.texttospeech.v1.TextToSpeech", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechGrpcTransport(TextToSpeechTransport): """gRPC backend transport for TextToSpeech. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,7 @@ def list_voices( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_voices" not in self._stubs: - self._stubs["list_voices"] = self.grpc_channel.unary_unary( + self._stubs["list_voices"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeech/ListVoices", request_serializer=cloud_tts.ListVoicesRequest.serialize, response_deserializer=cloud_tts.ListVoicesResponse.deserialize, @@ -283,7 +369,7 @@ def synthesize_speech( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_speech" not in self._stubs: - self._stubs["synthesize_speech"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_speech"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech", request_serializer=cloud_tts.SynthesizeSpeechRequest.serialize, response_deserializer=cloud_tts.SynthesizeSpeechResponse.deserialize, @@ -312,7 +398,7 @@ def streaming_synthesize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_synthesize" not in self._stubs: - self._stubs["streaming_synthesize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_synthesize"] = self._logged_channel.stream_stream( "/google.cloud.texttospeech.v1.TextToSpeech/StreamingSynthesize", request_serializer=cloud_tts.StreamingSynthesizeRequest.serialize, response_deserializer=cloud_tts.StreamingSynthesizeResponse.deserialize, @@ -320,7 +406,7 @@ def streaming_synthesize( return self._stubs["streaming_synthesize"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -332,7 +418,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -351,7 +437,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc_asyncio.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc_asyncio.py index a110c785e43b..683e13d3c4ef 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1.types import cloud_tts from .base import DEFAULT_CLIENT_INFO, TextToSpeechTransport from .grpc import TextToSpeechGrpcTransport +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.texttospeech.v1.TextToSpeech", + "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.texttospeech.v1.TextToSpeech", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechGrpcAsyncIOTransport(TextToSpeechTransport): """gRPC AsyncIO backend transport for TextToSpeech. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -264,7 +349,7 @@ def list_voices( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_voices" not in self._stubs: - self._stubs["list_voices"] = self.grpc_channel.unary_unary( + self._stubs["list_voices"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeech/ListVoices", request_serializer=cloud_tts.ListVoicesRequest.serialize, response_deserializer=cloud_tts.ListVoicesResponse.deserialize, @@ -294,7 +379,7 @@ def synthesize_speech( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_speech" not in self._stubs: - self._stubs["synthesize_speech"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_speech"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech", request_serializer=cloud_tts.SynthesizeSpeechRequest.serialize, response_deserializer=cloud_tts.SynthesizeSpeechResponse.deserialize, @@ -324,7 +409,7 @@ def streaming_synthesize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_synthesize" not in self._stubs: - self._stubs["streaming_synthesize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_synthesize"] = self._logged_channel.stream_stream( "/google.cloud.texttospeech.v1.TextToSpeech/StreamingSynthesize", request_serializer=cloud_tts.StreamingSynthesizeRequest.serialize, response_deserializer=cloud_tts.StreamingSynthesizeResponse.deserialize, @@ -367,7 +452,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -383,7 +468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -402,7 +487,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/rest.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/rest.py index 29fe4ad53e5a..8f619b0473a2 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/rest.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -84,8 +92,10 @@ def post_synthesize_speech(self, response): """ def pre_list_voices( - self, request: cloud_tts.ListVoicesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tts.ListVoicesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tts.ListVoicesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tts.ListVoicesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_voices Override in a subclass to manipulate the request or metadata @@ -107,8 +117,10 @@ def post_list_voices( def pre_synthesize_speech( self, request: cloud_tts.SynthesizeSpeechRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tts.SynthesizeSpeechRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tts.SynthesizeSpeechRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for synthesize_speech Override in a subclass to manipulate the request or metadata @@ -130,8 +142,10 @@ def post_synthesize_speech( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -153,8 +167,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -298,7 +314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Call the list voices method over HTTP. @@ -309,8 +325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tts.ListVoicesResponse: @@ -322,6 +340,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseListVoices._get_http_options() ) + request, metadata = self._interceptor.pre_list_voices(request, metadata) transcoded_request = ( _BaseTextToSpeechRestTransport._BaseListVoices._get_transcoded_request( @@ -336,6 +355,33 @@ def __call__( ) ) + 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.texttospeech_v1.TextToSpeechClient.ListVoices", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "ListVoices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._ListVoices._get_response( self._host, @@ -356,7 +402,29 @@ def __call__( pb_resp = cloud_tts.ListVoicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_voices(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tts.ListVoicesResponse.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.texttospeech_v1.TextToSpeechClient.list_voices", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "ListVoices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingSynthesize( @@ -371,7 +439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingSynthesize is not available over REST transport" @@ -412,7 +480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Call the synthesize speech method over HTTP. @@ -423,8 +491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tts.SynthesizeSpeechResponse: @@ -436,6 +506,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseSynthesizeSpeech._get_http_options() ) + request, metadata = self._interceptor.pre_synthesize_speech( request, metadata ) @@ -452,6 +523,33 @@ def __call__( 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.texttospeech_v1.TextToSpeechClient.SynthesizeSpeech", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "SynthesizeSpeech", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._SynthesizeSpeech._get_response( self._host, @@ -473,7 +571,31 @@ def __call__( pb_resp = cloud_tts.SynthesizeSpeechResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_synthesize_speech(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tts.SynthesizeSpeechResponse.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.texttospeech_v1.TextToSpeechClient.synthesize_speech", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "SynthesizeSpeech", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -542,7 +664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -552,8 +674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -562,6 +686,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTextToSpeechRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -574,6 +699,33 @@ def __call__( ) ) + 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.texttospeech_v1.TextToSpeechClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._GetOperation._get_response( self._host, @@ -593,6 +745,27 @@ def __call__( 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.texttospeech_v1.TextToSpeechAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -633,7 +806,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -643,8 +816,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -653,6 +828,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTextToSpeechRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -663,6 +839,33 @@ def __call__( 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.texttospeech_v1.TextToSpeechClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._ListOperations._get_response( self._host, @@ -682,6 +885,27 @@ def __call__( 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.texttospeech_v1.TextToSpeechAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeech", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/async_client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/async_client.py index 5cacf3a69af8..ac6dd1098e35 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/async_client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ ) from .transports.grpc_asyncio import TextToSpeechLongAudioSynthesizeGrpcAsyncIOTransport +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 TextToSpeechLongAudioSynthesizeAsyncClient: """Service that implements Google Cloud Text-to-Speech API.""" @@ -277,13 +287,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.texttospeech_v1.TextToSpeechLongAudioSynthesizeAsyncClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "credentialsType": None, + }, + ) + async def synthesize_long_audio( self, request: Optional[Union[cloud_tts_lrs.SynthesizeLongAudioRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Synthesizes long form text asynchronously. @@ -336,8 +368,10 @@ async def sample_synthesize_long_audio(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -395,7 +429,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -406,8 +440,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -448,7 +484,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -459,8 +495,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/client.py index ec002a1e9eaa..863c49ad34b2 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -601,6 +611,10 @@ def __init__( # 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( @@ -671,13 +685,36 @@ def __init__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "credentialsType": None, + }, + ) + def synthesize_long_audio( self, request: Optional[Union[cloud_tts_lrs.SynthesizeLongAudioRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Synthesizes long form text asynchronously. @@ -730,8 +767,10 @@ def sample_synthesize_long_audio(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -800,7 +839,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -811,8 +850,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -853,7 +894,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -864,8 +905,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc.py index af79b5174ecc..05be31c9a76d 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1.types import cloud_tts_lrs from .base import DEFAULT_CLIENT_INFO, TextToSpeechLongAudioSynthesizeTransport +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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": 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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechLongAudioSynthesizeGrpcTransport( TextToSpeechLongAudioSynthesizeTransport @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def synthesize_long_audio( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_long_audio" not in self._stubs: - self._stubs["synthesize_long_audio"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_long_audio"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio", request_serializer=cloud_tts_lrs.SynthesizeLongAudioRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -279,7 +367,7 @@ def synthesize_long_audio( return self._stubs["synthesize_long_audio"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -291,7 +379,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -310,7 +398,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py index 9e8ed82e5fc6..481d8126087c 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1.types import cloud_tts_lrs from .base import DEFAULT_CLIENT_INFO, TextToSpeechLongAudioSynthesizeTransport from .grpc import TextToSpeechLongAudioSynthesizeGrpcTransport +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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechLongAudioSynthesizeGrpcAsyncIOTransport( TextToSpeechLongAudioSynthesizeTransport @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def synthesize_long_audio( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_long_audio" not in self._stubs: - self._stubs["synthesize_long_audio"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_long_audio"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio", request_serializer=cloud_tts_lrs.SynthesizeLongAudioRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +401,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -332,7 +417,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -351,7 +436,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/rest.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/rest.py index aef1fb1b427e..831b35a7a3bc 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/rest.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech_long_audio_synthesize/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,11 @@ def post_synthesize_long_audio(self, response): def pre_synthesize_long_audio( self, request: cloud_tts_lrs.SynthesizeLongAudioRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tts_lrs.SynthesizeLongAudioRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tts_lrs.SynthesizeLongAudioRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for synthesize_long_audio Override in a subclass to manipulate the request or metadata @@ -101,8 +112,10 @@ def post_synthesize_long_audio( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -124,8 +137,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -318,7 +333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the synthesize long audio method over HTTP. @@ -329,8 +344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -343,6 +360,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseSynthesizeLongAudio._get_http_options() ) + request, metadata = self._interceptor.pre_synthesize_long_audio( request, metadata ) @@ -359,6 +377,33 @@ def __call__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeClient.SynthesizeLongAudio", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "SynthesizeLongAudio", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._SynthesizeLongAudio._get_response( self._host, @@ -378,7 +423,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_synthesize_long_audio(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.texttospeech_v1.TextToSpeechLongAudioSynthesizeClient.synthesize_long_audio", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "SynthesizeLongAudio", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -428,7 +495,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -438,8 +505,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -448,6 +517,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -458,6 +528,33 @@ def __call__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._GetOperation._get_response( self._host, @@ -477,6 +574,27 @@ def __call__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -518,7 +636,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -528,8 +646,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -538,6 +658,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -548,6 +669,33 @@ def __call__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._ListOperations._get_response( self._host, @@ -567,6 +715,27 @@ def __call__( 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.texttospeech_v1.TextToSpeechLongAudioSynthesizeAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/gapic_version.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/gapic_version.py index 7d2cbaca5b24..558c8aab67c5 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/gapic_version.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.21.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py index e728cf5c9746..643b98dd686a 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( AsyncIterable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TextToSpeechTransport from .transports.grpc_asyncio import TextToSpeechGrpcAsyncIOTransport +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 TextToSpeechAsyncClient: """Service that implements Google Cloud Text-to-Speech API.""" @@ -257,6 +267,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.texttospeech_v1beta1.TextToSpeechAsyncClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "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.texttospeech.v1beta1.TextToSpeech", + "credentialsType": None, + }, + ) + async def list_voices( self, request: Optional[Union[cloud_tts.ListVoicesRequest, dict]] = None, @@ -264,7 +296,7 @@ async def list_voices( language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. @@ -314,8 +346,10 @@ async def sample_list_voices(): 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, 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: google.cloud.texttospeech_v1beta1.types.ListVoicesResponse: @@ -372,7 +406,7 @@ async def synthesize_speech( audio_config: Optional[cloud_tts.AudioConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Synthesizes speech synchronously: receive results after all text input has been processed. @@ -442,8 +476,10 @@ async def sample_synthesize_speech(): 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, 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: google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechResponse: @@ -501,7 +537,7 @@ def streaming_synthesize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Awaitable[AsyncIterable[cloud_tts.StreamingSynthesizeResponse]]: r"""Performs bidirectional streaming speech synthesis: receive audio while sending text. @@ -557,8 +593,10 @@ def request_generator(): 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, 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: AsyncIterable[google.cloud.texttospeech_v1beta1.types.StreamingSynthesizeResponse]: @@ -595,7 +633,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -606,8 +644,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -648,7 +688,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -659,8 +699,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py index 300a6cb23b50..cb0b1f98ec7a 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ 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.longrunning import operations_pb2 # type: ignore from google.cloud.texttospeech_v1beta1.types import cloud_tts @@ -582,6 +592,10 @@ def __init__( # 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( @@ -644,6 +658,29 @@ def __init__( 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.texttospeech_v1beta1.TextToSpeechClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "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.texttospeech.v1beta1.TextToSpeech", + "credentialsType": None, + }, + ) + def list_voices( self, request: Optional[Union[cloud_tts.ListVoicesRequest, dict]] = None, @@ -651,7 +688,7 @@ def list_voices( language_code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. @@ -701,8 +738,10 @@ def sample_list_voices(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.texttospeech_v1beta1.types.ListVoicesResponse: @@ -756,7 +795,7 @@ def synthesize_speech( audio_config: Optional[cloud_tts.AudioConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Synthesizes speech synchronously: receive results after all text input has been processed. @@ -826,8 +865,10 @@ def sample_synthesize_speech(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechResponse: @@ -882,7 +923,7 @@ def streaming_synthesize( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> Iterable[cloud_tts.StreamingSynthesizeResponse]: r"""Performs bidirectional streaming speech synthesis: receive audio while sending text. @@ -938,8 +979,10 @@ def request_generator(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: Iterable[google.cloud.texttospeech_v1beta1.types.StreamingSynthesizeResponse]: @@ -987,7 +1030,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -998,8 +1041,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1040,7 +1085,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1051,8 +1096,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc.py index 68c20e80e3ca..6efe78c9728b 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1beta1.types import cloud_tts from .base import DEFAULT_CLIENT_INFO, TextToSpeechTransport +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.texttospeech.v1beta1.TextToSpeech", + "rpcName": 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.texttospeech.v1beta1.TextToSpeech", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechGrpcTransport(TextToSpeechTransport): """gRPC backend transport for TextToSpeech. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,7 @@ def list_voices( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_voices" not in self._stubs: - self._stubs["list_voices"] = self.grpc_channel.unary_unary( + self._stubs["list_voices"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeech/ListVoices", request_serializer=cloud_tts.ListVoicesRequest.serialize, response_deserializer=cloud_tts.ListVoicesResponse.deserialize, @@ -283,7 +369,7 @@ def synthesize_speech( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_speech" not in self._stubs: - self._stubs["synthesize_speech"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_speech"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeech/SynthesizeSpeech", request_serializer=cloud_tts.SynthesizeSpeechRequest.serialize, response_deserializer=cloud_tts.SynthesizeSpeechResponse.deserialize, @@ -312,7 +398,7 @@ def streaming_synthesize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_synthesize" not in self._stubs: - self._stubs["streaming_synthesize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_synthesize"] = self._logged_channel.stream_stream( "/google.cloud.texttospeech.v1beta1.TextToSpeech/StreamingSynthesize", request_serializer=cloud_tts.StreamingSynthesizeRequest.serialize, response_deserializer=cloud_tts.StreamingSynthesizeResponse.deserialize, @@ -320,7 +406,7 @@ def streaming_synthesize( return self._stubs["streaming_synthesize"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -332,7 +418,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -351,7 +437,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc_asyncio.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc_asyncio.py index 772e158df22a..d627ea16ba09 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1beta1.types import cloud_tts from .base import DEFAULT_CLIENT_INFO, TextToSpeechTransport from .grpc import TextToSpeechGrpcTransport +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.texttospeech.v1beta1.TextToSpeech", + "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.texttospeech.v1beta1.TextToSpeech", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechGrpcAsyncIOTransport(TextToSpeechTransport): """gRPC AsyncIO backend transport for TextToSpeech. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -264,7 +349,7 @@ def list_voices( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_voices" not in self._stubs: - self._stubs["list_voices"] = self.grpc_channel.unary_unary( + self._stubs["list_voices"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeech/ListVoices", request_serializer=cloud_tts.ListVoicesRequest.serialize, response_deserializer=cloud_tts.ListVoicesResponse.deserialize, @@ -294,7 +379,7 @@ def synthesize_speech( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_speech" not in self._stubs: - self._stubs["synthesize_speech"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_speech"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeech/SynthesizeSpeech", request_serializer=cloud_tts.SynthesizeSpeechRequest.serialize, response_deserializer=cloud_tts.SynthesizeSpeechResponse.deserialize, @@ -324,7 +409,7 @@ def streaming_synthesize( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_synthesize" not in self._stubs: - self._stubs["streaming_synthesize"] = self.grpc_channel.stream_stream( + self._stubs["streaming_synthesize"] = self._logged_channel.stream_stream( "/google.cloud.texttospeech.v1beta1.TextToSpeech/StreamingSynthesize", request_serializer=cloud_tts.StreamingSynthesizeRequest.serialize, response_deserializer=cloud_tts.StreamingSynthesizeResponse.deserialize, @@ -367,7 +452,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -383,7 +468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -402,7 +487,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/rest.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/rest.py index acb68ea0dcbe..40de85a5479e 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/rest.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -84,8 +92,10 @@ def post_synthesize_speech(self, response): """ def pre_list_voices( - self, request: cloud_tts.ListVoicesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloud_tts.ListVoicesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloud_tts.ListVoicesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_tts.ListVoicesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_voices Override in a subclass to manipulate the request or metadata @@ -107,8 +117,10 @@ def post_list_voices( def pre_synthesize_speech( self, request: cloud_tts.SynthesizeSpeechRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tts.SynthesizeSpeechRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tts.SynthesizeSpeechRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for synthesize_speech Override in a subclass to manipulate the request or metadata @@ -130,8 +142,10 @@ def post_synthesize_speech( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -153,8 +167,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -298,7 +314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.ListVoicesResponse: r"""Call the list voices method over HTTP. @@ -309,8 +325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tts.ListVoicesResponse: @@ -322,6 +340,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseListVoices._get_http_options() ) + request, metadata = self._interceptor.pre_list_voices(request, metadata) transcoded_request = ( _BaseTextToSpeechRestTransport._BaseListVoices._get_transcoded_request( @@ -336,6 +355,33 @@ def __call__( ) ) + 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.texttospeech_v1beta1.TextToSpeechClient.ListVoices", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "ListVoices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._ListVoices._get_response( self._host, @@ -356,7 +402,29 @@ def __call__( pb_resp = cloud_tts.ListVoicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_voices(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tts.ListVoicesResponse.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.texttospeech_v1beta1.TextToSpeechClient.list_voices", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "ListVoices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingSynthesize( @@ -371,7 +439,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingSynthesize is not available over REST transport" @@ -412,7 +480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_tts.SynthesizeSpeechResponse: r"""Call the synthesize speech method over HTTP. @@ -423,8 +491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_tts.SynthesizeSpeechResponse: @@ -436,6 +506,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseSynthesizeSpeech._get_http_options() ) + request, metadata = self._interceptor.pre_synthesize_speech( request, metadata ) @@ -452,6 +523,33 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechClient.SynthesizeSpeech", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "SynthesizeSpeech", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._SynthesizeSpeech._get_response( self._host, @@ -473,7 +571,31 @@ def __call__( pb_resp = cloud_tts.SynthesizeSpeechResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_synthesize_speech(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_tts.SynthesizeSpeechResponse.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.texttospeech_v1beta1.TextToSpeechClient.synthesize_speech", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "SynthesizeSpeech", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -542,7 +664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -552,8 +674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -562,6 +686,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTextToSpeechRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -574,6 +699,33 @@ def __call__( ) ) + 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.texttospeech_v1beta1.TextToSpeechClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._GetOperation._get_response( self._host, @@ -593,6 +745,27 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -633,7 +806,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -643,8 +816,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -653,6 +828,7 @@ def __call__( http_options = ( _BaseTextToSpeechRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTextToSpeechRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -663,6 +839,33 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechRestTransport._ListOperations._get_response( self._host, @@ -682,6 +885,27 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeech", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/async_client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/async_client.py index 5e57fe35a67d..0ce6ef53e15d 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/async_client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -55,6 +56,15 @@ ) from .transports.grpc_asyncio import TextToSpeechLongAudioSynthesizeGrpcAsyncIOTransport +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 TextToSpeechLongAudioSynthesizeAsyncClient: """Service that implements Google Cloud Text-to-Speech API.""" @@ -277,13 +287,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeAsyncClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "credentialsType": None, + }, + ) + async def synthesize_long_audio( self, request: Optional[Union[cloud_tts_lrs.SynthesizeLongAudioRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Synthesizes long form text asynchronously. @@ -336,8 +368,10 @@ async def sample_synthesize_long_audio(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -395,7 +429,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -406,8 +440,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -448,7 +484,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -459,8 +495,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/client.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/client.py index 5c7a99154b32..7dbc928ce7c2 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/client.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -601,6 +611,10 @@ def __init__( # 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( @@ -671,13 +685,36 @@ def __init__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeClient`.", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "credentialsType": None, + }, + ) + def synthesize_long_audio( self, request: Optional[Union[cloud_tts_lrs.SynthesizeLongAudioRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Synthesizes long form text asynchronously. @@ -730,8 +767,10 @@ def sample_synthesize_long_audio(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -800,7 +839,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -811,8 +850,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -853,7 +894,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -864,8 +905,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc.py index c2fbe43580ed..67955dd925fa 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1beta1.types import cloud_tts_lrs from .base import DEFAULT_CLIENT_INFO, TextToSpeechLongAudioSynthesizeTransport +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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": 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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechLongAudioSynthesizeGrpcTransport( TextToSpeechLongAudioSynthesizeTransport @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def synthesize_long_audio( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_long_audio" not in self._stubs: - self._stubs["synthesize_long_audio"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_long_audio"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio", request_serializer=cloud_tts_lrs.SynthesizeLongAudioRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -279,7 +367,7 @@ def synthesize_long_audio( return self._stubs["synthesize_long_audio"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -291,7 +379,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -310,7 +398,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py index 36d8854568b9..292b5ccc26e1 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.texttospeech_v1beta1.types import cloud_tts_lrs from .base import DEFAULT_CLIENT_INFO, TextToSpeechLongAudioSynthesizeTransport from .grpc import TextToSpeechLongAudioSynthesizeGrpcTransport +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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "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.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextToSpeechLongAudioSynthesizeGrpcAsyncIOTransport( TextToSpeechLongAudioSynthesizeTransport @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def synthesize_long_audio( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "synthesize_long_audio" not in self._stubs: - self._stubs["synthesize_long_audio"] = self.grpc_channel.unary_unary( + self._stubs["synthesize_long_audio"] = self._logged_channel.unary_unary( "/google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio", request_serializer=cloud_tts_lrs.SynthesizeLongAudioRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +401,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -332,7 +417,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -351,7 +436,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/rest.py b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/rest.py index 8574e90d027f..ee531ecb80c6 100644 --- a/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/rest.py +++ b/packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech_long_audio_synthesize/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -78,8 +86,11 @@ def post_synthesize_long_audio(self, response): def pre_synthesize_long_audio( self, request: cloud_tts_lrs.SynthesizeLongAudioRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_tts_lrs.SynthesizeLongAudioRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_tts_lrs.SynthesizeLongAudioRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for synthesize_long_audio Override in a subclass to manipulate the request or metadata @@ -101,8 +112,10 @@ def post_synthesize_long_audio( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -124,8 +137,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -318,7 +333,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the synthesize long audio method over HTTP. @@ -329,8 +344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -343,6 +360,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseSynthesizeLongAudio._get_http_options() ) + request, metadata = self._interceptor.pre_synthesize_long_audio( request, metadata ) @@ -359,6 +377,33 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeClient.SynthesizeLongAudio", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "SynthesizeLongAudio", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._SynthesizeLongAudio._get_response( self._host, @@ -378,7 +423,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_synthesize_long_audio(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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeClient.synthesize_long_audio", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "SynthesizeLongAudio", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -428,7 +495,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -438,8 +505,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -448,6 +517,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -458,6 +528,33 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._GetOperation._get_response( self._host, @@ -477,6 +574,27 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -518,7 +636,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -528,8 +646,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -538,6 +658,7 @@ def __call__( http_options = ( _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTextToSpeechLongAudioSynthesizeRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -548,6 +669,33 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextToSpeechLongAudioSynthesizeRestTransport._ListOperations._get_response( self._host, @@ -567,6 +715,27 @@ def __call__( 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.texttospeech_v1beta1.TextToSpeechLongAudioSynthesizeAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.texttospeech.v1beta1.TextToSpeechLongAudioSynthesize", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1.json b/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1.json index 8ab0d2b69255..5b86979204f3 100644 --- a/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1.json +++ b/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-texttospeech", - "version": "2.21.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1.types.ListVoicesResponse", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1.types.ListVoicesResponse", @@ -357,7 +357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.texttospeech_v1.types.StreamingSynthesizeResponse]", @@ -433,7 +433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.texttospeech_v1.types.StreamingSynthesizeResponse]", @@ -522,7 +522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1.types.SynthesizeSpeechResponse", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1.types.SynthesizeSpeechResponse", diff --git a/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1beta1.json b/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1beta1.json index ea008e161362..1494a35ba1c6 100644 --- a/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1beta1.json +++ b/packages/google-cloud-texttospeech/samples/generated_samples/snippet_metadata_google.cloud.texttospeech.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-texttospeech", - "version": "2.21.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1beta1.types.ListVoicesResponse", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1beta1.types.ListVoicesResponse", @@ -357,7 +357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.texttospeech_v1beta1.types.StreamingSynthesizeResponse]", @@ -433,7 +433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.texttospeech_v1beta1.types.StreamingSynthesizeResponse]", @@ -522,7 +522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechResponse", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechResponse", diff --git a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech.py b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech.py index f2a3b94982dd..59f0c9da2b71 100644 --- a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech.py +++ b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech.py @@ -1816,6 +1816,7 @@ def test_list_voices_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_voices(**mock_args) @@ -1941,6 +1942,7 @@ def test_synthesize_speech_rest_required_fields( response_value._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.synthesize_speech(request) @@ -1999,6 +2001,7 @@ def test_synthesize_speech_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.synthesize_speech(**mock_args) @@ -2298,6 +2301,7 @@ def test_list_voices_rest_bad_request(request_type=cloud_tts.ListVoicesRequest): 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_voices(request) @@ -2331,6 +2335,7 @@ def test_list_voices_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_voices(request) # Establish that the response is the type that we expect. @@ -2368,6 +2373,7 @@ def test_list_voices_rest_interceptors(null_interceptor): 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 = cloud_tts.ListVoicesResponse.to_json( cloud_tts.ListVoicesResponse() ) @@ -2414,6 +2420,7 @@ def test_synthesize_speech_rest_bad_request( 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.synthesize_speech(request) @@ -2449,6 +2456,7 @@ def test_synthesize_speech_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.synthesize_speech(request) # Establish that the response is the type that we expect. @@ -2489,6 +2497,7 @@ def test_synthesize_speech_rest_interceptors(null_interceptor): 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 = cloud_tts.SynthesizeSpeechResponse.to_json( cloud_tts.SynthesizeSpeechResponse() ) @@ -2549,6 +2558,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2579,6 +2589,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2609,6 +2620,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2639,6 +2651,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech_long_audio_synthesize.py b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech_long_audio_synthesize.py index 18cd5f88ad1e..dd83bbcac9f8 100644 --- a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech_long_audio_synthesize.py +++ b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech_long_audio_synthesize.py @@ -1537,6 +1537,7 @@ def test_synthesize_long_audio_rest_required_fields( response_value._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.synthesize_long_audio(request) @@ -1762,6 +1763,7 @@ def test_synthesize_long_audio_rest_bad_request( 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.synthesize_long_audio(request) @@ -1792,6 +1794,7 @@ def test_synthesize_long_audio_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.synthesize_long_audio(request) # Establish that the response is the type that we expect. @@ -1835,6 +1838,7 @@ def test_synthesize_long_audio_rest_interceptors(null_interceptor): 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 @@ -1881,6 +1885,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1911,6 +1916,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1941,6 +1947,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1971,6 +1978,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech.py b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech.py index 26ef2a7728ff..9583633352a2 100644 --- a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech.py +++ b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech.py @@ -1816,6 +1816,7 @@ def test_list_voices_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_voices(**mock_args) @@ -1943,6 +1944,7 @@ def test_synthesize_speech_rest_required_fields( response_value._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.synthesize_speech(request) @@ -2001,6 +2003,7 @@ def test_synthesize_speech_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.synthesize_speech(**mock_args) @@ -2300,6 +2303,7 @@ def test_list_voices_rest_bad_request(request_type=cloud_tts.ListVoicesRequest): 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_voices(request) @@ -2333,6 +2337,7 @@ def test_list_voices_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_voices(request) # Establish that the response is the type that we expect. @@ -2370,6 +2375,7 @@ def test_list_voices_rest_interceptors(null_interceptor): 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 = cloud_tts.ListVoicesResponse.to_json( cloud_tts.ListVoicesResponse() ) @@ -2416,6 +2422,7 @@ def test_synthesize_speech_rest_bad_request( 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.synthesize_speech(request) @@ -2451,6 +2458,7 @@ def test_synthesize_speech_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.synthesize_speech(request) # Establish that the response is the type that we expect. @@ -2491,6 +2499,7 @@ def test_synthesize_speech_rest_interceptors(null_interceptor): 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 = cloud_tts.SynthesizeSpeechResponse.to_json( cloud_tts.SynthesizeSpeechResponse() ) @@ -2551,6 +2560,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2581,6 +2591,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -2611,6 +2622,7 @@ def test_list_operations_rest_bad_request( 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) @@ -2641,6 +2653,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech_long_audio_synthesize.py b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech_long_audio_synthesize.py index e5bc34ba9869..8ed392394293 100644 --- a/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech_long_audio_synthesize.py +++ b/packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech_long_audio_synthesize.py @@ -1537,6 +1537,7 @@ def test_synthesize_long_audio_rest_required_fields( response_value._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.synthesize_long_audio(request) @@ -1762,6 +1763,7 @@ def test_synthesize_long_audio_rest_bad_request( 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.synthesize_long_audio(request) @@ -1792,6 +1794,7 @@ def test_synthesize_long_audio_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.synthesize_long_audio(request) # Establish that the response is the type that we expect. @@ -1835,6 +1838,7 @@ def test_synthesize_long_audio_rest_interceptors(null_interceptor): 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 @@ -1881,6 +1885,7 @@ def test_get_operation_rest_bad_request( 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) @@ -1911,6 +1916,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -1941,6 +1947,7 @@ def test_list_operations_rest_bad_request( 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) @@ -1971,6 +1978,7 @@ def test_list_operations_rest(request_type): response_value.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) From 8e6b0cca8709ae8c7f0c722c5ebf0707358d3359 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:21:21 +0500 Subject: [PATCH 3/3] feat: [Many APIs] Add support for opt-in debug logging (#13346) BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: https://github.com/googleapis/googleapis/commit/f9b8b9150f7fcd600b0acaeef91236b1843f5e49 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca1e0a1e472d6e6f5de883a5cb54724f112ce348 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9wdGltaXphdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zLWNvbmZpZy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zLWxvZ2luLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBoaXNoaW5nLXByb3RlY3Rpb24vLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeS10cm91Ymxlc2hvb3Rlci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeXNpbXVsYXRvci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeXRyb3VibGVzaG9vdGVyLWlhbS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZhdGUtY2EvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZhdGUtY2F0YWxvZy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZpbGVnZWRhY2Nlc3NtYW5hZ2VyLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXB1YmxpYy1jYS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXF1b3Rhcy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJhcGlkbWlncmF0aW9uYXNzZXNzbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYS1lbnRlcnByaXNlLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY29tbWVuZGF0aW9ucy1haS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY29tbWVuZGVyLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlZGlzLWNsdXN0ZXIvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlZGlzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlLW1hbmFnZXIvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlLXNldHRpbmdzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../cloud/optimization/gapic_version.py | 2 +- .../cloud/optimization_v1/gapic_version.py | 2 +- .../services/fleet_routing/async_client.py | 56 +- .../services/fleet_routing/client.py | 61 +- .../services/fleet_routing/transports/grpc.py | 100 +- .../fleet_routing/transports/grpc_asyncio.py | 97 +- .../services/fleet_routing/transports/rest.py | 203 +- ...metadata_google.cloud.optimization.v1.json | 10 +- .../optimization_v1/test_fleet_routing.py | 10 + .../google/cloud/osconfig/gapic_version.py | 2 +- .../google/cloud/osconfig_v1/gapic_version.py | 2 +- .../os_config_service/async_client.py | 128 +- .../services/os_config_service/client.py | 133 +- .../services/os_config_service/pagers.py | 48 +- .../os_config_service/transports/grpc.py | 114 +- .../transports/grpc_asyncio.py | 113 +- .../os_config_service/transports/rest.py | 764 +++++- .../os_config_zonal_service/async_client.py | 128 +- .../os_config_zonal_service/client.py | 133 +- .../os_config_zonal_service/pagers.py | 80 +- .../transports/grpc.py | 128 +- .../transports/grpc_asyncio.py | 125 +- .../transports/rest.py | 785 +++++- .../cloud/osconfig_v1alpha/gapic_version.py | 2 +- .../os_config_zonal_service/async_client.py | 144 +- .../os_config_zonal_service/client.py | 149 +- .../os_config_zonal_service/pagers.py | 96 +- .../transports/grpc.py | 132 +- .../transports/grpc_asyncio.py | 129 +- .../transports/rest.py | 913 ++++++- ...pet_metadata_google.cloud.osconfig.v1.json | 98 +- ...etadata_google.cloud.osconfig.v1alpha.json | 58 +- .../osconfig_v1/test_os_config_service.py | 58 + .../test_os_config_zonal_service.py | 60 + .../test_os_config_zonal_service.py | 70 + .../google/cloud/oslogin/gapic_version.py | 2 +- .../google/cloud/oslogin_v1/gapic_version.py | 2 +- .../services/os_login_service/async_client.py | 88 +- .../services/os_login_service/client.py | 93 +- .../os_login_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 103 +- .../os_login_service/transports/rest.py | 412 ++- ...ppet_metadata_google.cloud.oslogin.v1.json | 30 +- .../gapic/oslogin_v1/test_os_login_service.py | 35 + .../cloud/phishingprotection/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../async_client.py | 40 +- .../client.py | 45 +- .../transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../transports/rest.py | 77 +- ...ogle.cloud.phishingprotection.v1beta1.json | 6 +- ...st_phishing_protection_service_v1_beta1.py | 5 + .../policytroubleshooter/gapic_version.py | 2 +- .../policytroubleshooter_v1/gapic_version.py | 2 +- .../services/iam_checker/async_client.py | 40 +- .../services/iam_checker/client.py | 45 +- .../services/iam_checker/transports/grpc.py | 92 +- .../iam_checker/transports/grpc_asyncio.py | 91 +- .../services/iam_checker/transports/rest.py | 76 +- ..._google.cloud.policytroubleshooter.v1.json | 6 +- .../test_iam_checker.py | 3 + .../cloud/policysimulator/gapic_version.py | 2 +- .../cloud/policysimulator_v1/gapic_version.py | 2 +- .../services/simulator/async_client.py | 72 +- .../services/simulator/client.py | 77 +- .../services/simulator/pagers.py | 16 +- .../services/simulator/transports/grpc.py | 104 +- .../simulator/transports/grpc_asyncio.py | 101 +- .../services/simulator/transports/rest.py | 328 ++- ...adata_google.cloud.policysimulator.v1.json | 14 +- .../policysimulator_v1/test_simulator.py | 19 + .../policytroubleshooter_iam/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../policy_troubleshooter/async_client.py | 40 +- .../services/policy_troubleshooter/client.py | 45 +- .../policy_troubleshooter/transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../policy_troubleshooter/transports/rest.py | 77 +- ...gle.cloud.policytroubleshooter.iam.v3.json | 6 +- .../test_policy_troubleshooter.py | 3 + .../cloud/security/privateca/gapic_version.py | 2 +- .../security/privateca_v1/gapic_version.py | 2 +- .../async_client.py | 336 ++- .../certificate_authority_service/client.py | 341 ++- .../certificate_authority_service/pagers.py | 80 +- .../transports/grpc.py | 188 +- .../transports/grpc_asyncio.py | 185 +- .../transports/rest.py | 2413 +++++++++++++++-- .../privateca_v1beta1/gapic_version.py | 2 +- .../async_client.py | 192 +- .../certificate_authority_service/client.py | 197 +- .../certificate_authority_service/pagers.py | 64 +- .../transports/grpc.py | 142 +- .../transports/grpc_asyncio.py | 139 +- .../transports/rest.py | 1306 ++++++++- ...ta_google.cloud.security.privateca.v1.json | 118 +- ...ogle.cloud.security.privateca.v1beta1.json | 82 +- .../test_certificate_authority_service.py | 163 ++ .../test_certificate_authority_service.py | 100 + .../cloud/privatecatalog/gapic_version.py | 2 +- .../privatecatalog_v1beta1/gapic_version.py | 2 +- .../services/private_catalog/async_client.py | 56 +- .../services/private_catalog/client.py | 61 +- .../services/private_catalog/pagers.py | 48 +- .../private_catalog/transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../private_catalog/transports/rest.py | 208 +- ...a_google.cloud.privatecatalog.v1beta1.json | 14 +- .../test_private_catalog.py | 12 + .../privilegedaccessmanager/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../privileged_access_manager/async_client.py | 184 +- .../privileged_access_manager/client.py | 189 +- .../privileged_access_manager/pagers.py | 64 +- .../transports/grpc.py | 132 +- .../transports/grpc_asyncio.py | 129 +- .../transports/rest.py | 1217 ++++++++- ...ogle.cloud.privilegedaccessmanager.v1.json | 58 +- .../test_privileged_access_manager.py | 74 + .../cloud/security/publicca/gapic_version.py | 2 +- .../security/publicca_v1/gapic_version.py | 2 +- .../async_client.py | 40 +- .../client.py | 45 +- .../transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- .../publicca_v1beta1/gapic_version.py | 2 +- .../async_client.py | 40 +- .../client.py | 45 +- .../transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 93 +- .../transports/rest.py | 74 +- ...ata_google.cloud.security.publicca.v1.json | 6 +- ...oogle.cloud.security.publicca.v1beta1.json | 6 +- ...st_public_certificate_authority_service.py | 5 + ...st_public_certificate_authority_service.py | 5 + .../google/cloud/cloudquotas/gapic_version.py | 2 +- .../cloud/cloudquotas_v1/gapic_version.py | 2 +- .../services/cloud_quotas/async_client.py | 80 +- .../services/cloud_quotas/client.py | 85 +- .../services/cloud_quotas/pagers.py | 32 +- .../services/cloud_quotas/transports/grpc.py | 102 +- .../cloud_quotas/transports/grpc_asyncio.py | 101 +- .../services/cloud_quotas/transports/rest.py | 400 ++- ...et_metadata_google.api.cloudquotas.v1.json | 26 +- .../gapic/cloudquotas_v1/test_cloud_quotas.py | 30 + .../rapidmigrationassessment/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../async_client.py | 160 +- .../rapid_migration_assessment/client.py | 165 +- .../rapid_migration_assessment/pagers.py | 16 +- .../transports/grpc.py | 126 +- .../transports/grpc_asyncio.py | 123 +- .../transports/rest.py | 982 ++++++- ...gle.cloud.rapidmigrationassessment.v1.json | 42 +- .../test_rapid_migration_assessment.py | 62 + .../async_client.py | 208 +- .../recaptcha_enterprise_service/client.py | 213 +- .../recaptcha_enterprise_service/pagers.py | 96 +- .../transports/grpc.py | 138 +- .../transports/grpc_asyncio.py | 137 +- ...a_google.cloud.recaptchaenterprise.v1.json | 88 +- .../recommendationengine/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../services/catalog_service/async_client.py | 80 +- .../services/catalog_service/client.py | 85 +- .../services/catalog_service/pagers.py | 16 +- .../catalog_service/transports/grpc.py | 106 +- .../transports/grpc_asyncio.py | 103 +- .../catalog_service/transports/rest.py | 377 ++- .../async_client.py | 56 +- .../prediction_api_key_registry/client.py | 61 +- .../prediction_api_key_registry/pagers.py | 16 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../transports/rest.py | 178 +- .../prediction_service/async_client.py | 40 +- .../services/prediction_service/client.py | 45 +- .../services/prediction_service/pagers.py | 16 +- .../prediction_service/transports/grpc.py | 92 +- .../transports/grpc_asyncio.py | 91 +- .../prediction_service/transports/rest.py | 76 +- .../user_event_service/async_client.py | 72 +- .../services/user_event_service/client.py | 77 +- .../services/user_event_service/pagers.py | 16 +- .../user_event_service/transports/grpc.py | 104 +- .../transports/grpc_asyncio.py | 101 +- .../user_event_service/transports/rest.py | 336 ++- ...le.cloud.recommendationengine.v1beta1.json | 62 +- .../test_catalog_service.py | 30 + .../test_prediction_api_key_registry.py | 15 + .../test_prediction_service.py | 5 + .../test_user_event_service.py | 25 + .../google/cloud/recommender/gapic_version.py | 2 +- .../cloud/recommender_v1/gapic_version.py | 2 +- .../services/recommender/async_client.py | 136 +- .../services/recommender/client.py | 141 +- .../services/recommender/pagers.py | 32 +- .../services/recommender/transports/grpc.py | 122 +- .../recommender/transports/grpc_asyncio.py | 121 +- .../services/recommender/transports/rest.py | 845 +++++- .../recommender_v1beta1/gapic_version.py | 2 +- .../services/recommender/async_client.py | 144 +- .../services/recommender/client.py | 149 +- .../services/recommender/pagers.py | 64 +- .../services/recommender/transports/grpc.py | 124 +- .../recommender/transports/grpc_asyncio.py | 123 +- .../services/recommender/transports/rest.py | 917 ++++++- ..._metadata_google.cloud.recommender.v1.json | 54 +- ...data_google.cloud.recommender.v1beta1.json | 58 +- .../gapic/recommender_v1/test_recommender.py | 64 + .../recommender_v1beta1/test_recommender.py | 66 + .../cloud/redis_cluster/gapic_version.py | 2 +- .../cloud/redis_cluster_v1/gapic_version.py | 2 +- .../cloud_redis_cluster/async_client.py | 128 +- .../services/cloud_redis_cluster/client.py | 133 +- .../services/cloud_redis_cluster/pagers.py | 16 +- .../cloud_redis_cluster/transports/grpc.py | 118 +- .../transports/grpc_asyncio.py | 115 +- .../cloud_redis_cluster/transports/rest.py | 735 ++++- .../redis_cluster_v1beta1/gapic_version.py | 2 +- .../cloud_redis_cluster/async_client.py | 128 +- .../services/cloud_redis_cluster/client.py | 133 +- .../services/cloud_redis_cluster/pagers.py | 16 +- .../cloud_redis_cluster/transports/grpc.py | 118 +- .../transports/grpc_asyncio.py | 115 +- .../cloud_redis_cluster/transports/rest.py | 735 ++++- ...etadata_google.cloud.redis.cluster.v1.json | 26 +- ...ta_google.cloud.redis.cluster.v1beta1.json | 26 +- .../test_cloud_redis_cluster.py | 42 + .../test_cloud_redis_cluster.py | 42 + .../google/cloud/redis/gapic_version.py | 2 +- .../google/cloud/redis_v1/gapic_version.py | 2 +- .../services/cloud_redis/async_client.py | 168 +- .../redis_v1/services/cloud_redis/client.py | 173 +- .../redis_v1/services/cloud_redis/pagers.py | 16 +- .../services/cloud_redis/transports/grpc.py | 128 +- .../cloud_redis/transports/grpc_asyncio.py | 125 +- .../services/cloud_redis/transports/rest.py | 1052 ++++++- .../cloud/redis_v1beta1/gapic_version.py | 2 +- .../services/cloud_redis/async_client.py | 120 +- .../services/cloud_redis/client.py | 125 +- .../services/cloud_redis/pagers.py | 16 +- .../services/cloud_redis/transports/grpc.py | 116 +- .../cloud_redis/transports/grpc_asyncio.py | 113 +- .../services/cloud_redis/transports/rest.py | 716 ++++- ...nippet_metadata_google.cloud.redis.v1.json | 46 +- ...t_metadata_google.cloud.redis.v1beta1.json | 46 +- .../unit/gapic/redis_v1/test_cloud_redis.py | 67 + .../gapic/redis_v1beta1/test_cloud_redis.py | 55 + .../cloud/resourcemanager/gapic_version.py | 2 +- .../cloud/resourcemanager_v3/gapic_version.py | 2 +- .../services/folders/async_client.py | 128 +- .../services/folders/client.py | 133 +- .../services/folders/pagers.py | 32 +- .../services/folders/transports/grpc.py | 118 +- .../folders/transports/grpc_asyncio.py | 115 +- .../services/folders/transports/rest.py | 776 +++++- .../services/organizations/async_client.py | 80 +- .../services/organizations/client.py | 85 +- .../services/organizations/pagers.py | 16 +- .../services/organizations/transports/grpc.py | 102 +- .../organizations/transports/grpc_asyncio.py | 101 +- .../services/organizations/transports/rest.py | 397 ++- .../services/projects/async_client.py | 128 +- .../services/projects/client.py | 133 +- .../services/projects/pagers.py | 32 +- .../services/projects/transports/grpc.py | 118 +- .../projects/transports/grpc_asyncio.py | 115 +- .../services/projects/transports/rest.py | 770 +++++- .../services/tag_bindings/async_client.py | 72 +- .../services/tag_bindings/client.py | 77 +- .../services/tag_bindings/pagers.py | 32 +- .../services/tag_bindings/transports/grpc.py | 104 +- .../tag_bindings/transports/grpc_asyncio.py | 101 +- .../services/tag_bindings/transports/rest.py | 333 ++- .../services/tag_holds/async_client.py | 64 +- .../services/tag_holds/client.py | 69 +- .../services/tag_holds/pagers.py | 16 +- .../services/tag_holds/transports/grpc.py | 102 +- .../tag_holds/transports/grpc_asyncio.py | 99 +- .../services/tag_holds/transports/rest.py | 259 +- .../services/tag_keys/async_client.py | 112 +- .../services/tag_keys/client.py | 117 +- .../services/tag_keys/pagers.py | 16 +- .../services/tag_keys/transports/grpc.py | 114 +- .../tag_keys/transports/grpc_asyncio.py | 111 +- .../services/tag_keys/transports/rest.py | 650 ++++- .../services/tag_values/async_client.py | 112 +- .../services/tag_values/client.py | 117 +- .../services/tag_values/pagers.py | 16 +- .../services/tag_values/transports/grpc.py | 114 +- .../tag_values/transports/grpc_asyncio.py | 111 +- .../services/tag_values/transports/rest.py | 650 ++++- ...adata_google.cloud.resourcemanager.v3.json | 210 +- .../gapic/resourcemanager_v3/test_folders.py | 56 + .../resourcemanager_v3/test_organizations.py | 26 + .../gapic/resourcemanager_v3/test_projects.py | 56 + .../resourcemanager_v3/test_tag_bindings.py | 22 + .../resourcemanager_v3/test_tag_holds.py | 17 + .../gapic/resourcemanager_v3/test_tag_keys.py | 47 + .../resourcemanager_v3/test_tag_values.py | 47 + .../cloud/resourcesettings/gapic_version.py | 2 +- .../resourcesettings_v1/gapic_version.py | 2 +- .../resource_settings_service/async_client.py | 56 +- .../resource_settings_service/client.py | 61 +- .../resource_settings_service/pagers.py | 16 +- .../transports/grpc.py | 96 +- .../transports/grpc_asyncio.py | 95 +- .../transports/rest.py | 204 +- ...data_google.cloud.resourcesettings.v1.json | 14 +- .../test_resource_settings_service.py | 14 + 313 files changed, 34461 insertions(+), 5542 deletions(-) diff --git a/packages/google-cloud-optimization/google/cloud/optimization/gapic_version.py b/packages/google-cloud-optimization/google/cloud/optimization/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization/gapic_version.py +++ b/packages/google-cloud-optimization/google/cloud/optimization/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/gapic_version.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/gapic_version.py index 402b34e179e9..558c8aab67c5 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/gapic_version.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.9.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/async_client.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/async_client.py index eaf22cc84c9e..fd680c4fb252 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/async_client.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, FleetRoutingTransport from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport +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 FleetRoutingAsyncClient: """A service for optimizing vehicle tours. @@ -274,13 +284,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.optimization_v1.FleetRoutingAsyncClient`.", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "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.optimization.v1.FleetRouting", + "credentialsType": None, + }, + ) + async def optimize_tours( self, request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> fleet_routing.OptimizeToursResponse: r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel`` and returns an ``OptimizeToursResponse`` containing @@ -334,8 +366,10 @@ async def sample_optimize_tours(): 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, 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: google.cloud.optimization_v1.types.OptimizeToursResponse: @@ -384,7 +418,7 @@ async def batch_optimize_tours( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest`` messages as a batch. @@ -445,8 +479,10 @@ async def sample_batch_optimize_tours(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -502,7 +538,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -513,8 +549,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/client.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/client.py index 1e8b66a47f27..04f632a49918 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/client.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -580,6 +590,10 @@ def __init__( # 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( @@ -642,13 +656,36 @@ def __init__( 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.optimization_v1.FleetRoutingClient`.", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "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.optimization.v1.FleetRouting", + "credentialsType": None, + }, + ) + def optimize_tours( self, request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> fleet_routing.OptimizeToursResponse: r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel`` and returns an ``OptimizeToursResponse`` containing @@ -702,8 +739,10 @@ def sample_optimize_tours(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.optimization_v1.types.OptimizeToursResponse: @@ -750,7 +789,7 @@ def batch_optimize_tours( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest`` messages as a batch. @@ -811,8 +850,10 @@ def sample_batch_optimize_tours(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -879,7 +920,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -890,8 +931,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py index 07ce13a7de88..863261bc52a6 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.optimization_v1.types import fleet_routing from .base import DEFAULT_CLIENT_INFO, FleetRoutingTransport +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.optimization.v1.FleetRouting", + "rpcName": 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.optimization.v1.FleetRouting", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FleetRoutingGrpcTransport(FleetRoutingTransport): """gRPC backend transport for FleetRouting. @@ -203,7 +284,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +353,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -308,7 +396,7 @@ def optimize_tours( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "optimize_tours" not in self._stubs: - self._stubs["optimize_tours"] = self.grpc_channel.unary_unary( + self._stubs["optimize_tours"] = self._logged_channel.unary_unary( "/google.cloud.optimization.v1.FleetRouting/OptimizeTours", request_serializer=fleet_routing.OptimizeToursRequest.serialize, response_deserializer=fleet_routing.OptimizeToursResponse.deserialize, @@ -344,7 +432,7 @@ def batch_optimize_tours( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_optimize_tours" not in self._stubs: - self._stubs["batch_optimize_tours"] = self.grpc_channel.unary_unary( + self._stubs["batch_optimize_tours"] = self._logged_channel.unary_unary( "/google.cloud.optimization.v1.FleetRouting/BatchOptimizeTours", request_serializer=fleet_routing.BatchOptimizeToursRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -352,7 +440,7 @@ def batch_optimize_tours( return self._stubs["batch_optimize_tours"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -364,7 +452,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py index 2177d24ec96c..661a700f6eef 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.optimization_v1.types import fleet_routing from .base import DEFAULT_CLIENT_INFO, FleetRoutingTransport from .grpc import FleetRoutingGrpcTransport +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.optimization.v1.FleetRouting", + "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.optimization.v1.FleetRouting", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FleetRoutingGrpcAsyncIOTransport(FleetRoutingTransport): """gRPC AsyncIO backend transport for FleetRouting. @@ -250,10 +332,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -276,7 +361,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -319,7 +404,7 @@ def optimize_tours( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "optimize_tours" not in self._stubs: - self._stubs["optimize_tours"] = self.grpc_channel.unary_unary( + self._stubs["optimize_tours"] = self._logged_channel.unary_unary( "/google.cloud.optimization.v1.FleetRouting/OptimizeTours", request_serializer=fleet_routing.OptimizeToursRequest.serialize, response_deserializer=fleet_routing.OptimizeToursResponse.deserialize, @@ -357,7 +442,7 @@ def batch_optimize_tours( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_optimize_tours" not in self._stubs: - self._stubs["batch_optimize_tours"] = self.grpc_channel.unary_unary( + self._stubs["batch_optimize_tours"] = self._logged_channel.unary_unary( "/google.cloud.optimization.v1.FleetRouting/BatchOptimizeTours", request_serializer=fleet_routing.BatchOptimizeToursRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +493,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -424,7 +509,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py index 1cf5825d1407..a90db1f29f4b 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -86,8 +94,10 @@ def post_optimize_tours(self, response): def pre_batch_optimize_tours( self, request: fleet_routing.BatchOptimizeToursRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[fleet_routing.BatchOptimizeToursRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + fleet_routing.BatchOptimizeToursRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_optimize_tours Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_batch_optimize_tours( def pre_optimize_tours( self, request: fleet_routing.OptimizeToursRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[fleet_routing.OptimizeToursRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + fleet_routing.OptimizeToursRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for optimize_tours Override in a subclass to manipulate the request or metadata @@ -132,8 +144,10 @@ def post_optimize_tours( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -335,7 +349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch optimize tours method over HTTP. @@ -351,8 +365,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -365,6 +381,7 @@ def __call__( http_options = ( _BaseFleetRoutingRestTransport._BaseBatchOptimizeTours._get_http_options() ) + request, metadata = self._interceptor.pre_batch_optimize_tours( request, metadata ) @@ -381,6 +398,33 @@ def __call__( 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.optimization_v1.FleetRoutingClient.BatchOptimizeTours", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "BatchOptimizeTours", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FleetRoutingRestTransport._BatchOptimizeTours._get_response( self._host, @@ -400,7 +444,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_optimize_tours(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.optimization_v1.FleetRoutingClient.batch_optimize_tours", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "BatchOptimizeTours", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _OptimizeTours( @@ -438,7 +504,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> fleet_routing.OptimizeToursResponse: r"""Call the optimize tours method over HTTP. @@ -451,8 +517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.fleet_routing.OptimizeToursResponse: @@ -467,6 +535,7 @@ def __call__( http_options = ( _BaseFleetRoutingRestTransport._BaseOptimizeTours._get_http_options() ) + request, metadata = self._interceptor.pre_optimize_tours(request, metadata) transcoded_request = _BaseFleetRoutingRestTransport._BaseOptimizeTours._get_transcoded_request( http_options, request @@ -481,6 +550,33 @@ def __call__( 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.optimization_v1.FleetRoutingClient.OptimizeTours", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "OptimizeTours", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FleetRoutingRestTransport._OptimizeTours._get_response( self._host, @@ -502,7 +598,31 @@ def __call__( pb_resp = fleet_routing.OptimizeToursResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_optimize_tours(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = fleet_routing.OptimizeToursResponse.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.optimization_v1.FleetRoutingClient.optimize_tours", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "OptimizeTours", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -561,7 +681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -571,8 +691,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -581,6 +703,7 @@ def __call__( http_options = ( _BaseFleetRoutingRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseFleetRoutingRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -593,6 +716,33 @@ def __call__( ) ) + 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.optimization_v1.FleetRoutingClient.GetOperation", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FleetRoutingRestTransport._GetOperation._get_response( self._host, @@ -612,6 +762,27 @@ def __call__( 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.optimization_v1.FleetRoutingAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.optimization.v1.FleetRouting", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-optimization/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json b/packages/google-cloud-optimization/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json index 9f867ccc68ed..0666a7af3b7c 100644 --- a/packages/google-cloud-optimization/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json +++ b/packages/google-cloud-optimization/samples/generated_samples/snippet_metadata_google.cloud.optimization.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-optimization", - "version": "1.9.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.optimization_v1.types.OptimizeToursResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.optimization_v1.types.OptimizeToursResponse", diff --git a/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py b/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py index f575b9fab9cb..1f050ecf9ea6 100644 --- a/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py +++ b/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py @@ -1659,6 +1659,7 @@ def test_optimize_tours_rest_required_fields( response_value._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.optimize_tours(request) @@ -1784,6 +1785,7 @@ def test_batch_optimize_tours_rest_required_fields( response_value._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.batch_optimize_tours(request) @@ -2056,6 +2058,7 @@ def test_optimize_tours_rest_bad_request( 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.optimize_tours(request) @@ -2092,6 +2095,7 @@ def test_optimize_tours_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.optimize_tours(request) # Establish that the response is the type that we expect. @@ -2133,6 +2137,7 @@ def test_optimize_tours_rest_interceptors(null_interceptor): 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 = fleet_routing.OptimizeToursResponse.to_json( fleet_routing.OptimizeToursResponse() ) @@ -2179,6 +2184,7 @@ def test_batch_optimize_tours_rest_bad_request( 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.batch_optimize_tours(request) @@ -2209,6 +2215,7 @@ def test_batch_optimize_tours_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.batch_optimize_tours(request) # Establish that the response is the type that we expect. @@ -2250,6 +2257,7 @@ def test_batch_optimize_tours_rest_interceptors(null_interceptor): 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 @@ -2296,6 +2304,7 @@ def test_get_operation_rest_bad_request( 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) @@ -2326,6 +2335,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig/gapic_version.py b/packages/google-cloud-os-config/google/cloud/osconfig/gapic_version.py index ef9777764da2..558c8aab67c5 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig/gapic_version.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.18.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_version.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_version.py index ef9777764da2..558c8aab67c5 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_version.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.18.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py index 04a0ae0e8e95..ed6c774fef65 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, OsConfigServiceTransport from .transports.grpc_asyncio import OsConfigServiceGrpcAsyncIOTransport +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 OsConfigServiceAsyncClient: """OS Config API @@ -271,13 +281,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.osconfig_v1.OsConfigServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "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.osconfig.v1.OsConfigService", + "credentialsType": None, + }, + ) + async def execute_patch_job( self, request: Optional[Union[patch_jobs.ExecutePatchJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Patch VM instances by creating and running a patch job. @@ -316,8 +348,10 @@ async def sample_execute_patch_job(): 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, 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: google.cloud.osconfig_v1.types.PatchJob: @@ -372,7 +406,7 @@ async def get_patch_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Get the patch job. This can be used to track the progress of an ongoing patch job or review the details @@ -418,8 +452,10 @@ async def sample_get_patch_job(): 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, 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: google.cloud.osconfig_v1.types.PatchJob: @@ -487,7 +523,7 @@ async def cancel_patch_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted. @@ -524,8 +560,10 @@ async def sample_cancel_patch_job(): 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, 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: google.cloud.osconfig_v1.types.PatchJob: @@ -580,7 +618,7 @@ async def list_patch_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchJobsAsyncPager: r"""Get a list of patch jobs. @@ -623,8 +661,10 @@ async def sample_list_patch_jobs(): 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, 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobsAsyncPager: @@ -701,7 +741,7 @@ async def list_patch_job_instance_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchJobInstanceDetailsAsyncPager: r"""Get a list of instance details for a given patch job. @@ -746,8 +786,10 @@ async def sample_list_patch_job_instance_details(): 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, 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobInstanceDetailsAsyncPager: @@ -826,7 +868,7 @@ async def create_patch_deployment( patch_deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Create an OS Config patch deployment. @@ -892,8 +934,10 @@ async def sample_create_patch_deployment(): 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, 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -964,7 +1008,7 @@ async def get_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Get an OS Config patch deployment. @@ -1008,8 +1052,10 @@ async def sample_get_patch_deployment(): 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, 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1076,7 +1122,7 @@ async def list_patch_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchDeploymentsAsyncPager: r"""Get a page of OS Config patch deployments. @@ -1121,8 +1167,10 @@ async def sample_list_patch_deployments(): 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, 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchDeploymentsAsyncPager: @@ -1199,7 +1247,7 @@ async def delete_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an OS Config patch deployment. @@ -1240,8 +1288,10 @@ async def sample_delete_patch_deployment(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1296,7 +1346,7 @@ async def update_patch_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Update an OS Config patch deployment. @@ -1347,8 +1397,10 @@ async def sample_update_patch_deployment(): 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, 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1419,7 +1471,7 @@ async def pause_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Change state of patch deployment to "PAUSED". Patch deployment in paused state doesn't generate patch @@ -1465,8 +1517,10 @@ async def sample_pause_patch_deployment(): 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, 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1533,7 +1587,7 @@ async def resume_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Change state of patch deployment back to "ACTIVE". Patch deployment in active state continues to generate @@ -1579,8 +1633,10 @@ async def sample_resume_patch_deployment(): 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, 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: google.cloud.osconfig_v1.types.PatchDeployment: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py index f2e9cadb390c..370827d901c1 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -626,6 +636,10 @@ def __init__( # 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( @@ -691,13 +705,36 @@ def __init__( 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.osconfig_v1.OsConfigServiceClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "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.osconfig.v1.OsConfigService", + "credentialsType": None, + }, + ) + def execute_patch_job( self, request: Optional[Union[patch_jobs.ExecutePatchJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Patch VM instances by creating and running a patch job. @@ -736,8 +773,10 @@ def sample_execute_patch_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchJob: @@ -790,7 +829,7 @@ def get_patch_job( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Get the patch job. This can be used to track the progress of an ongoing patch job or review the details @@ -836,8 +875,10 @@ def sample_get_patch_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchJob: @@ -902,7 +943,7 @@ def cancel_patch_job( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted. @@ -939,8 +980,10 @@ def sample_cancel_patch_job(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchJob: @@ -993,7 +1036,7 @@ def list_patch_jobs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchJobsPager: r"""Get a list of patch jobs. @@ -1036,8 +1079,10 @@ def sample_list_patch_jobs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobsPager: @@ -1111,7 +1156,7 @@ def list_patch_job_instance_details( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchJobInstanceDetailsPager: r"""Get a list of instance details for a given patch job. @@ -1156,8 +1201,10 @@ def sample_list_patch_job_instance_details(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobInstanceDetailsPager: @@ -1235,7 +1282,7 @@ def create_patch_deployment( patch_deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Create an OS Config patch deployment. @@ -1301,8 +1348,10 @@ def sample_create_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1370,7 +1419,7 @@ def get_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Get an OS Config patch deployment. @@ -1414,8 +1463,10 @@ def sample_get_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1479,7 +1530,7 @@ def list_patch_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPatchDeploymentsPager: r"""Get a page of OS Config patch deployments. @@ -1524,8 +1575,10 @@ def sample_list_patch_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchDeploymentsPager: @@ -1599,7 +1652,7 @@ def delete_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an OS Config patch deployment. @@ -1640,8 +1693,10 @@ def sample_delete_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1693,7 +1748,7 @@ def update_patch_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Update an OS Config patch deployment. @@ -1744,8 +1799,10 @@ def sample_update_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1813,7 +1870,7 @@ def pause_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Change state of patch deployment to "PAUSED". Patch deployment in paused state doesn't generate patch @@ -1859,8 +1916,10 @@ def sample_pause_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchDeployment: @@ -1924,7 +1983,7 @@ def resume_patch_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Change state of patch deployment back to "ACTIVE". Patch deployment in active state continues to generate @@ -1970,8 +2029,10 @@ def sample_resume_patch_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.PatchDeployment: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py index 1002030830df..6ff130784421 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = patch_jobs.ListPatchJobsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = patch_jobs.ListPatchJobsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = patch_jobs.ListPatchJobInstanceDetailsRequest(request) @@ -295,7 +301,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -309,8 +315,10 @@ def __init__( 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, 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`. """ self._method = method self._request = patch_jobs.ListPatchJobInstanceDetailsRequest(request) @@ -375,7 +383,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -389,8 +397,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = patch_deployments.ListPatchDeploymentsRequest(request) @@ -451,7 +461,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -465,8 +475,10 @@ def __init__( 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, 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`. """ self._method = method self._request = patch_deployments.ListPatchDeploymentsRequest(request) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py index f39ce31eb33b..c9cff26dbe68 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1.types import patch_deployments, patch_jobs from .base import DEFAULT_CLIENT_INFO, OsConfigServiceTransport +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.osconfig.v1.OsConfigService", + "rpcName": 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.osconfig.v1.OsConfigService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigServiceGrpcTransport(OsConfigServiceTransport): """gRPC backend transport for OsConfigService. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def execute_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_patch_job" not in self._stubs: - self._stubs["execute_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["execute_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ExecutePatchJob", request_serializer=patch_jobs.ExecutePatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -287,7 +373,7 @@ def get_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_patch_job" not in self._stubs: - self._stubs["get_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["get_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/GetPatchJob", request_serializer=patch_jobs.GetPatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -314,7 +400,7 @@ def cancel_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_patch_job" not in self._stubs: - self._stubs["cancel_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/CancelPatchJob", request_serializer=patch_jobs.CancelPatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -340,7 +426,7 @@ def list_patch_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_patch_jobs" not in self._stubs: - self._stubs["list_patch_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_patch_jobs"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchJobs", request_serializer=patch_jobs.ListPatchJobsRequest.serialize, response_deserializer=patch_jobs.ListPatchJobsResponse.deserialize, @@ -372,7 +458,7 @@ def list_patch_job_instance_details( if "list_patch_job_instance_details" not in self._stubs: self._stubs[ "list_patch_job_instance_details" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchJobInstanceDetails", request_serializer=patch_jobs.ListPatchJobInstanceDetailsRequest.serialize, response_deserializer=patch_jobs.ListPatchJobInstanceDetailsResponse.deserialize, @@ -401,7 +487,7 @@ def create_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_patch_deployment" not in self._stubs: - self._stubs["create_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/CreatePatchDeployment", request_serializer=patch_deployments.CreatePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -429,7 +515,7 @@ def get_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_patch_deployment" not in self._stubs: - self._stubs["get_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/GetPatchDeployment", request_serializer=patch_deployments.GetPatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -458,7 +544,7 @@ def list_patch_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_patch_deployments" not in self._stubs: - self._stubs["list_patch_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_patch_deployments"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchDeployments", request_serializer=patch_deployments.ListPatchDeploymentsRequest.serialize, response_deserializer=patch_deployments.ListPatchDeploymentsResponse.deserialize, @@ -484,7 +570,7 @@ def delete_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_patch_deployment" not in self._stubs: - self._stubs["delete_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment", request_serializer=patch_deployments.DeletePatchDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -513,7 +599,7 @@ def update_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_patch_deployment" not in self._stubs: - self._stubs["update_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/UpdatePatchDeployment", request_serializer=patch_deployments.UpdatePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -544,7 +630,7 @@ def pause_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_patch_deployment" not in self._stubs: - self._stubs["pause_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["pause_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/PausePatchDeployment", request_serializer=patch_deployments.PausePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -575,7 +661,7 @@ def resume_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_patch_deployment" not in self._stubs: - self._stubs["resume_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["resume_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ResumePatchDeployment", request_serializer=patch_deployments.ResumePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -583,7 +669,7 @@ def resume_patch_deployment( return self._stubs["resume_patch_deployment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py index e2a801da1e5d..afc8a3403d2d 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1.types import patch_deployments, patch_jobs from .base import DEFAULT_CLIENT_INFO, OsConfigServiceTransport from .grpc import OsConfigServiceGrpcTransport +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.osconfig.v1.OsConfigService", + "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.osconfig.v1.OsConfigService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigServiceGrpcAsyncIOTransport(OsConfigServiceTransport): """gRPC AsyncIO backend transport for OsConfigService. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def execute_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_patch_job" not in self._stubs: - self._stubs["execute_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["execute_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ExecutePatchJob", request_serializer=patch_jobs.ExecutePatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -295,7 +380,7 @@ def get_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_patch_job" not in self._stubs: - self._stubs["get_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["get_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/GetPatchJob", request_serializer=patch_jobs.GetPatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -322,7 +407,7 @@ def cancel_patch_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_patch_job" not in self._stubs: - self._stubs["cancel_patch_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_patch_job"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/CancelPatchJob", request_serializer=patch_jobs.CancelPatchJobRequest.serialize, response_deserializer=patch_jobs.PatchJob.deserialize, @@ -350,7 +435,7 @@ def list_patch_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_patch_jobs" not in self._stubs: - self._stubs["list_patch_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_patch_jobs"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchJobs", request_serializer=patch_jobs.ListPatchJobsRequest.serialize, response_deserializer=patch_jobs.ListPatchJobsResponse.deserialize, @@ -382,7 +467,7 @@ def list_patch_job_instance_details( if "list_patch_job_instance_details" not in self._stubs: self._stubs[ "list_patch_job_instance_details" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchJobInstanceDetails", request_serializer=patch_jobs.ListPatchJobInstanceDetailsRequest.serialize, response_deserializer=patch_jobs.ListPatchJobInstanceDetailsResponse.deserialize, @@ -411,7 +496,7 @@ def create_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_patch_deployment" not in self._stubs: - self._stubs["create_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/CreatePatchDeployment", request_serializer=patch_deployments.CreatePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -440,7 +525,7 @@ def get_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_patch_deployment" not in self._stubs: - self._stubs["get_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/GetPatchDeployment", request_serializer=patch_deployments.GetPatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -469,7 +554,7 @@ def list_patch_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_patch_deployments" not in self._stubs: - self._stubs["list_patch_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_patch_deployments"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ListPatchDeployments", request_serializer=patch_deployments.ListPatchDeploymentsRequest.serialize, response_deserializer=patch_deployments.ListPatchDeploymentsResponse.deserialize, @@ -497,7 +582,7 @@ def delete_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_patch_deployment" not in self._stubs: - self._stubs["delete_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment", request_serializer=patch_deployments.DeletePatchDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -526,7 +611,7 @@ def update_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_patch_deployment" not in self._stubs: - self._stubs["update_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/UpdatePatchDeployment", request_serializer=patch_deployments.UpdatePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -557,7 +642,7 @@ def pause_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_patch_deployment" not in self._stubs: - self._stubs["pause_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["pause_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/PausePatchDeployment", request_serializer=patch_deployments.PausePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -588,7 +673,7 @@ def resume_patch_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_patch_deployment" not in self._stubs: - self._stubs["resume_patch_deployment"] = self.grpc_channel.unary_unary( + self._stubs["resume_patch_deployment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/ResumePatchDeployment", request_serializer=patch_deployments.ResumePatchDeploymentRequest.serialize, response_deserializer=patch_deployments.PatchDeployment.deserialize, @@ -666,7 +751,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/rest.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/rest.py index 04244dd2a285..ef56b649cbaa 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/rest.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -162,8 +170,10 @@ def post_update_patch_deployment(self, response): def pre_cancel_patch_job( self, request: patch_jobs.CancelPatchJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[patch_jobs.CancelPatchJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + patch_jobs.CancelPatchJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_patch_job Override in a subclass to manipulate the request or metadata @@ -185,9 +195,10 @@ def post_cancel_patch_job( def pre_create_patch_deployment( self, request: patch_deployments.CreatePatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.CreatePatchDeploymentRequest, Sequence[Tuple[str, str]] + patch_deployments.CreatePatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_patch_deployment @@ -210,9 +221,10 @@ def post_create_patch_deployment( def pre_delete_patch_deployment( self, request: patch_deployments.DeletePatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.DeletePatchDeploymentRequest, Sequence[Tuple[str, str]] + patch_deployments.DeletePatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_patch_deployment @@ -224,8 +236,10 @@ def pre_delete_patch_deployment( def pre_execute_patch_job( self, request: patch_jobs.ExecutePatchJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[patch_jobs.ExecutePatchJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + patch_jobs.ExecutePatchJobRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for execute_patch_job Override in a subclass to manipulate the request or metadata @@ -247,8 +261,11 @@ def post_execute_patch_job( def pre_get_patch_deployment( self, request: patch_deployments.GetPatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[patch_deployments.GetPatchDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + patch_deployments.GetPatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_patch_deployment Override in a subclass to manipulate the request or metadata @@ -270,8 +287,8 @@ def post_get_patch_deployment( def pre_get_patch_job( self, request: patch_jobs.GetPatchJobRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[patch_jobs.GetPatchJobRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[patch_jobs.GetPatchJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_patch_job Override in a subclass to manipulate the request or metadata @@ -291,9 +308,10 @@ def post_get_patch_job(self, response: patch_jobs.PatchJob) -> patch_jobs.PatchJ def pre_list_patch_deployments( self, request: patch_deployments.ListPatchDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.ListPatchDeploymentsRequest, Sequence[Tuple[str, str]] + patch_deployments.ListPatchDeploymentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_patch_deployments @@ -316,9 +334,10 @@ def post_list_patch_deployments( def pre_list_patch_job_instance_details( self, request: patch_jobs.ListPatchJobInstanceDetailsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_jobs.ListPatchJobInstanceDetailsRequest, Sequence[Tuple[str, str]] + patch_jobs.ListPatchJobInstanceDetailsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_patch_job_instance_details @@ -341,8 +360,10 @@ def post_list_patch_job_instance_details( def pre_list_patch_jobs( self, request: patch_jobs.ListPatchJobsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[patch_jobs.ListPatchJobsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + patch_jobs.ListPatchJobsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_patch_jobs Override in a subclass to manipulate the request or metadata @@ -364,9 +385,10 @@ def post_list_patch_jobs( def pre_pause_patch_deployment( self, request: patch_deployments.PausePatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.PausePatchDeploymentRequest, Sequence[Tuple[str, str]] + patch_deployments.PausePatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for pause_patch_deployment @@ -389,9 +411,10 @@ def post_pause_patch_deployment( def pre_resume_patch_deployment( self, request: patch_deployments.ResumePatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.ResumePatchDeploymentRequest, Sequence[Tuple[str, str]] + patch_deployments.ResumePatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for resume_patch_deployment @@ -414,9 +437,10 @@ def post_resume_patch_deployment( def pre_update_patch_deployment( self, request: patch_deployments.UpdatePatchDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - patch_deployments.UpdatePatchDeploymentRequest, Sequence[Tuple[str, str]] + patch_deployments.UpdatePatchDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_patch_deployment @@ -562,7 +586,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Call the cancel patch job method over HTTP. @@ -572,8 +596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_jobs.PatchJob: @@ -593,6 +619,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseCancelPatchJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_patch_job( request, metadata ) @@ -609,6 +636,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.CancelPatchJob", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "CancelPatchJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._CancelPatchJob._get_response( self._host, @@ -630,7 +684,29 @@ def __call__( pb_resp = patch_jobs.PatchJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_patch_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_jobs.PatchJob.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.osconfig_v1.OsConfigServiceClient.cancel_patch_job", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "CancelPatchJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePatchDeployment( @@ -669,7 +745,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Call the create patch deployment method over HTTP. @@ -680,8 +756,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.PatchDeployment: @@ -697,6 +775,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseCreatePatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_patch_deployment( request, metadata ) @@ -713,6 +792,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.CreatePatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "CreatePatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigServiceRestTransport._CreatePatchDeployment._get_response( @@ -736,7 +842,31 @@ def __call__( pb_resp = patch_deployments.PatchDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_patch_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_deployments.PatchDeployment.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.osconfig_v1.OsConfigServiceClient.create_patch_deployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "CreatePatchDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePatchDeployment( @@ -774,7 +904,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete patch deployment method over HTTP. @@ -785,13 +915,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseOsConfigServiceRestTransport._BaseDeletePatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_patch_deployment( request, metadata ) @@ -804,6 +937,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.DeletePatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "DeletePatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigServiceRestTransport._DeletePatchDeployment._get_response( @@ -856,7 +1016,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Call the execute patch job method over HTTP. @@ -868,8 +1028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_jobs.PatchJob: @@ -889,6 +1051,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseExecutePatchJob._get_http_options() ) + request, metadata = self._interceptor.pre_execute_patch_job( request, metadata ) @@ -905,6 +1068,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.ExecutePatchJob", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ExecutePatchJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._ExecutePatchJob._get_response( self._host, @@ -926,7 +1116,29 @@ def __call__( pb_resp = patch_jobs.PatchJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_patch_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_jobs.PatchJob.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.osconfig_v1.OsConfigServiceClient.execute_patch_job", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ExecutePatchJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPatchDeployment( @@ -964,7 +1176,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Call the get patch deployment method over HTTP. @@ -975,8 +1187,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.PatchDeployment: @@ -992,6 +1206,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseGetPatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_patch_deployment( request, metadata ) @@ -1004,6 +1219,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.GetPatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "GetPatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._GetPatchDeployment._get_response( self._host, @@ -1024,7 +1266,31 @@ def __call__( pb_resp = patch_deployments.PatchDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_patch_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_deployments.PatchDeployment.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.osconfig_v1.OsConfigServiceClient.get_patch_deployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "GetPatchDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPatchJob( @@ -1061,7 +1327,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.PatchJob: r"""Call the get patch job method over HTTP. @@ -1072,8 +1338,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_jobs.PatchJob: @@ -1093,6 +1361,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseGetPatchJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_patch_job(request, metadata) transcoded_request = _BaseOsConfigServiceRestTransport._BaseGetPatchJob._get_transcoded_request( http_options, request @@ -1103,6 +1372,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.GetPatchJob", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "GetPatchJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._GetPatchJob._get_response( self._host, @@ -1123,7 +1419,29 @@ def __call__( pb_resp = patch_jobs.PatchJob.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_patch_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_jobs.PatchJob.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.osconfig_v1.OsConfigServiceClient.get_patch_job", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "GetPatchJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPatchDeployments( @@ -1161,7 +1479,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.ListPatchDeploymentsResponse: r"""Call the list patch deployments method over HTTP. @@ -1172,8 +1490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.ListPatchDeploymentsResponse: @@ -1185,6 +1505,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseListPatchDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_patch_deployments( request, metadata ) @@ -1197,6 +1518,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.ListPatchDeployments", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._ListPatchDeployments._get_response( self._host, @@ -1217,7 +1565,31 @@ def __call__( pb_resp = patch_deployments.ListPatchDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_patch_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + patch_deployments.ListPatchDeploymentsResponse.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.osconfig_v1.OsConfigServiceClient.list_patch_deployments", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPatchJobInstanceDetails( @@ -1255,7 +1627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.ListPatchJobInstanceDetailsResponse: r"""Call the list patch job instance details method over HTTP. @@ -1267,8 +1639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_jobs.ListPatchJobInstanceDetailsResponse: @@ -1280,6 +1654,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseListPatchJobInstanceDetails._get_http_options() ) + request, metadata = self._interceptor.pre_list_patch_job_instance_details( request, metadata ) @@ -1292,6 +1667,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.ListPatchJobInstanceDetails", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchJobInstanceDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigServiceRestTransport._ListPatchJobInstanceDetails._get_response( @@ -1314,7 +1716,31 @@ def __call__( pb_resp = patch_jobs.ListPatchJobInstanceDetailsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_patch_job_instance_details(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + patch_jobs.ListPatchJobInstanceDetailsResponse.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.osconfig_v1.OsConfigServiceClient.list_patch_job_instance_details", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchJobInstanceDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPatchJobs( @@ -1351,7 +1777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_jobs.ListPatchJobsResponse: r"""Call the list patch jobs method over HTTP. @@ -1362,8 +1788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_jobs.ListPatchJobsResponse: @@ -1375,6 +1803,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseListPatchJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_patch_jobs(request, metadata) transcoded_request = _BaseOsConfigServiceRestTransport._BaseListPatchJobs._get_transcoded_request( http_options, request @@ -1385,6 +1814,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.ListPatchJobs", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._ListPatchJobs._get_response( self._host, @@ -1405,7 +1861,31 @@ def __call__( pb_resp = patch_jobs.ListPatchJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_patch_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_jobs.ListPatchJobsResponse.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.osconfig_v1.OsConfigServiceClient.list_patch_jobs", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ListPatchJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PausePatchDeployment( @@ -1444,7 +1924,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Call the pause patch deployment method over HTTP. @@ -1455,8 +1935,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.PatchDeployment: @@ -1472,6 +1954,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BasePausePatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_pause_patch_deployment( request, metadata ) @@ -1488,6 +1971,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.PausePatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "PausePatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigServiceRestTransport._PausePatchDeployment._get_response( self._host, @@ -1509,7 +2019,31 @@ def __call__( pb_resp = patch_deployments.PatchDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_patch_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_deployments.PatchDeployment.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.osconfig_v1.OsConfigServiceClient.pause_patch_deployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "PausePatchDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumePatchDeployment( @@ -1548,7 +2082,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Call the resume patch deployment method over HTTP. @@ -1559,8 +2093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.PatchDeployment: @@ -1576,6 +2112,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseResumePatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_resume_patch_deployment( request, metadata ) @@ -1592,6 +2129,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.ResumePatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ResumePatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigServiceRestTransport._ResumePatchDeployment._get_response( @@ -1615,7 +2179,31 @@ def __call__( pb_resp = patch_deployments.PatchDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_patch_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_deployments.PatchDeployment.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.osconfig_v1.OsConfigServiceClient.resume_patch_deployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "ResumePatchDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePatchDeployment( @@ -1654,7 +2242,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> patch_deployments.PatchDeployment: r"""Call the update patch deployment method over HTTP. @@ -1665,8 +2253,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.patch_deployments.PatchDeployment: @@ -1682,6 +2272,7 @@ def __call__( http_options = ( _BaseOsConfigServiceRestTransport._BaseUpdatePatchDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_patch_deployment( request, metadata ) @@ -1698,6 +2289,33 @@ def __call__( 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.osconfig_v1.OsConfigServiceClient.UpdatePatchDeployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "UpdatePatchDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigServiceRestTransport._UpdatePatchDeployment._get_response( @@ -1721,7 +2339,31 @@ def __call__( pb_resp = patch_deployments.PatchDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_patch_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = patch_deployments.PatchDeployment.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.osconfig_v1.OsConfigServiceClient.update_patch_deployment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigService", + "rpcName": "UpdatePatchDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/async_client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/async_client.py index 28af081169b2..5b17e35f2000 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/async_client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport from .transports.grpc_asyncio import OsConfigZonalServiceGrpcAsyncIOTransport +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 OsConfigZonalServiceAsyncClient: """Zonal OS Config API @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.osconfig_v1.OsConfigZonalServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "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.osconfig.v1.OsConfigZonalService", + "credentialsType": None, + }, + ) + async def create_os_policy_assignment( self, request: Optional[ @@ -312,7 +344,7 @@ async def create_os_policy_assignment( os_policy_assignment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create an OS policy assignment. @@ -402,8 +434,10 @@ async def sample_create_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -495,7 +529,7 @@ async def update_os_policy_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update an existing OS policy assignment. @@ -568,8 +602,10 @@ async def sample_update_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -658,7 +694,7 @@ async def get_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Retrieve an existing OS policy assignment. @@ -708,8 +744,10 @@ async def sample_get_os_policy_assignment(): 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, 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: google.cloud.osconfig_v1.types.OSPolicyAssignment: @@ -782,7 +820,7 @@ async def list_os_policy_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentsAsyncPager: r"""List the OS policy assignments under the parent resource. @@ -828,8 +866,10 @@ async def sample_list_os_policy_assignments(): 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, 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsAsyncPager: @@ -908,7 +948,7 @@ async def list_os_policy_assignment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentRevisionsAsyncPager: r"""List the OS policy assignment revisions for a given OS policy assignment. @@ -954,8 +994,10 @@ async def sample_list_os_policy_assignment_revisions(): 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, 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsAsyncPager: @@ -1036,7 +1078,7 @@ async def delete_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete the OS policy assignment. @@ -1096,8 +1138,10 @@ async def sample_delete_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1180,7 +1224,7 @@ async def get_os_policy_assignment_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Get the OS policy asssignment report for the specified Compute Engine VM instance. @@ -1235,8 +1279,10 @@ async def sample_get_os_policy_assignment_report(): 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, 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: google.cloud.osconfig_v1.types.OSPolicyAssignmentReport: @@ -1305,7 +1351,7 @@ async def list_os_policy_assignment_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentReportsAsyncPager: r"""List OS policy asssignment reports for all Compute Engine VM instances in the specified zone. @@ -1375,8 +1421,10 @@ async def sample_list_os_policy_assignment_reports(): 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, 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsAsyncPager: @@ -1457,7 +1505,7 @@ async def get_inventory( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Get inventory data for the specified VM instance. If the VM has no associated inventory, the message ``NOT_FOUND`` is returned. @@ -1509,8 +1557,10 @@ async def sample_get_inventory(): 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, 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: google.cloud.osconfig_v1.types.Inventory: @@ -1579,7 +1629,7 @@ async def list_inventories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInventoriesAsyncPager: r"""List inventory data for all VM instances in the specified zone. @@ -1631,8 +1681,10 @@ async def sample_list_inventories(): 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, 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListInventoriesAsyncPager: @@ -1711,7 +1763,7 @@ async def get_vulnerability_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have @@ -1765,8 +1817,10 @@ async def sample_get_vulnerability_report(): 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, 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: google.cloud.osconfig_v1.types.VulnerabilityReport: @@ -1833,7 +1887,7 @@ async def list_vulnerability_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVulnerabilityReportsAsyncPager: r"""List vulnerability reports for all VM instances in the specified zone. @@ -1885,8 +1939,10 @@ async def sample_list_vulnerability_reports(): 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, 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListVulnerabilityReportsAsyncPager: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/client.py index ce15fa6caeab..19af033a39d0 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import empty_pb2 # type: ignore @@ -713,6 +723,10 @@ def __init__( # 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( @@ -779,6 +793,29 @@ def __init__( 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.osconfig_v1.OsConfigZonalServiceClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "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.osconfig.v1.OsConfigZonalService", + "credentialsType": None, + }, + ) + def create_os_policy_assignment( self, request: Optional[ @@ -790,7 +827,7 @@ def create_os_policy_assignment( os_policy_assignment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create an OS policy assignment. @@ -880,8 +917,10 @@ def sample_create_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -972,7 +1011,7 @@ def update_os_policy_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update an existing OS policy assignment. @@ -1045,8 +1084,10 @@ def sample_update_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1134,7 +1175,7 @@ def get_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Retrieve an existing OS policy assignment. @@ -1184,8 +1225,10 @@ def sample_get_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.OSPolicyAssignment: @@ -1255,7 +1298,7 @@ def list_os_policy_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentsPager: r"""List the OS policy assignments under the parent resource. @@ -1301,8 +1344,10 @@ def sample_list_os_policy_assignments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsPager: @@ -1380,7 +1425,7 @@ def list_os_policy_assignment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentRevisionsPager: r"""List the OS policy assignment revisions for a given OS policy assignment. @@ -1426,8 +1471,10 @@ def sample_list_os_policy_assignment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsPager: @@ -1507,7 +1554,7 @@ def delete_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete the OS policy assignment. @@ -1567,8 +1614,10 @@ def sample_delete_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1650,7 +1699,7 @@ def get_os_policy_assignment_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Get the OS policy asssignment report for the specified Compute Engine VM instance. @@ -1705,8 +1754,10 @@ def sample_get_os_policy_assignment_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.OSPolicyAssignmentReport: @@ -1774,7 +1825,7 @@ def list_os_policy_assignment_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentReportsPager: r"""List OS policy asssignment reports for all Compute Engine VM instances in the specified zone. @@ -1844,8 +1895,10 @@ def sample_list_os_policy_assignment_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsPager: @@ -1925,7 +1978,7 @@ def get_inventory( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Get inventory data for the specified VM instance. If the VM has no associated inventory, the message ``NOT_FOUND`` is returned. @@ -1977,8 +2030,10 @@ def sample_get_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.Inventory: @@ -2044,7 +2099,7 @@ def list_inventories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInventoriesPager: r"""List inventory data for all VM instances in the specified zone. @@ -2096,8 +2151,10 @@ def sample_list_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListInventoriesPager: @@ -2173,7 +2230,7 @@ def get_vulnerability_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have @@ -2227,8 +2284,10 @@ def sample_get_vulnerability_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.types.VulnerabilityReport: @@ -2292,7 +2351,7 @@ def list_vulnerability_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVulnerabilityReportsPager: r"""List vulnerability reports for all VM instances in the specified zone. @@ -2344,8 +2403,10 @@ def sample_list_vulnerability_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListVulnerabilityReportsPager: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/pagers.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/pagers.py index 7353ffa03b22..8eff9e2c2653 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/pagers.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentsRequest(request) @@ -148,7 +150,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -162,8 +164,10 @@ def __init__( 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, 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentsRequest(request) @@ -230,7 +234,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -244,8 +248,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest( @@ -311,7 +317,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -325,8 +331,10 @@ def __init__( 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, 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest( @@ -395,7 +403,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -409,8 +417,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -480,7 +490,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -494,8 +504,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -566,7 +578,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -580,8 +592,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = inventory.ListInventoriesRequest(request) @@ -640,7 +654,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -654,8 +668,10 @@ def __init__( 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, 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`. """ self._method = method self._request = inventory.ListInventoriesRequest(request) @@ -718,7 +734,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -732,8 +748,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vulnerability.ListVulnerabilityReportsRequest(request) @@ -794,7 +812,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -808,8 +826,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vulnerability.ListVulnerabilityReportsRequest(request) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py index b7e66e6c4240..63e1099a1b6b 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1.types import ( inventory, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport +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.osconfig.v1.OsConfigZonalService", + "rpcName": 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.osconfig.v1.OsConfigZonalService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigZonalServiceGrpcTransport(OsConfigZonalServiceTransport): """gRPC backend transport for OsConfigZonalService. @@ -190,7 +271,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -254,7 +340,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -291,7 +379,9 @@ def create_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_os_policy_assignment" not in self._stubs: - self._stubs["create_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/CreateOSPolicyAssignment", request_serializer=os_policy_assignments.CreateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -329,7 +419,9 @@ def update_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_os_policy_assignment" not in self._stubs: - self._stubs["update_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/UpdateOSPolicyAssignment", request_serializer=os_policy_assignments.UpdateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -362,7 +454,7 @@ def get_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_os_policy_assignment" not in self._stubs: - self._stubs["get_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs["get_os_policy_assignment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignment", request_serializer=os_policy_assignments.GetOSPolicyAssignmentRequest.serialize, response_deserializer=os_policy_assignments.OSPolicyAssignment.deserialize, @@ -394,7 +486,9 @@ def list_os_policy_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_policy_assignments" not in self._stubs: - self._stubs["list_os_policy_assignments"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_os_policy_assignments" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignments", request_serializer=os_policy_assignments.ListOSPolicyAssignmentsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentsResponse.deserialize, @@ -427,7 +521,7 @@ def list_os_policy_assignment_revisions( if "list_os_policy_assignment_revisions" not in self._stubs: self._stubs[ "list_os_policy_assignment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentRevisions", request_serializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.deserialize, @@ -468,7 +562,9 @@ def delete_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_os_policy_assignment" not in self._stubs: - self._stubs["delete_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/DeleteOSPolicyAssignment", request_serializer=os_policy_assignments.DeleteOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -501,7 +597,7 @@ def get_os_policy_assignment_report( if "get_os_policy_assignment_report" not in self._stubs: self._stubs[ "get_os_policy_assignment_report" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignmentReport", request_serializer=os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest.serialize, response_deserializer=os_policy_assignment_reports.OSPolicyAssignmentReport.deserialize, @@ -534,7 +630,7 @@ def list_os_policy_assignment_reports( if "list_os_policy_assignment_reports" not in self._stubs: self._stubs[ "list_os_policy_assignment_reports" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentReports", request_serializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest.serialize, response_deserializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.deserialize, @@ -561,7 +657,7 @@ def get_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_inventory" not in self._stubs: - self._stubs["get_inventory"] = self.grpc_channel.unary_unary( + self._stubs["get_inventory"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetInventory", request_serializer=inventory.GetInventoryRequest.serialize, response_deserializer=inventory.Inventory.deserialize, @@ -590,7 +686,7 @@ def list_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inventories" not in self._stubs: - self._stubs["list_inventories"] = self.grpc_channel.unary_unary( + self._stubs["list_inventories"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListInventories", request_serializer=inventory.ListInventoriesRequest.serialize, response_deserializer=inventory.ListInventoriesResponse.deserialize, @@ -620,7 +716,7 @@ def get_vulnerability_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vulnerability_report" not in self._stubs: - self._stubs["get_vulnerability_report"] = self.grpc_channel.unary_unary( + self._stubs["get_vulnerability_report"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetVulnerabilityReport", request_serializer=vulnerability.GetVulnerabilityReportRequest.serialize, response_deserializer=vulnerability.VulnerabilityReport.deserialize, @@ -650,7 +746,9 @@ def list_vulnerability_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vulnerability_reports" not in self._stubs: - self._stubs["list_vulnerability_reports"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vulnerability_reports" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListVulnerabilityReports", request_serializer=vulnerability.ListVulnerabilityReportsRequest.serialize, response_deserializer=vulnerability.ListVulnerabilityReportsResponse.deserialize, @@ -658,7 +756,7 @@ def list_vulnerability_reports( return self._stubs["list_vulnerability_reports"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py index 2d443f7081e0..14cc19b13295 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1.types import ( inventory, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport from .grpc import OsConfigZonalServiceGrpcTransport +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.osconfig.v1.OsConfigZonalService", + "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.osconfig.v1.OsConfigZonalService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigZonalServiceGrpcAsyncIOTransport(OsConfigZonalServiceTransport): """gRPC AsyncIO backend transport for OsConfigZonalService. @@ -237,10 +319,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -263,7 +348,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -301,7 +386,9 @@ def create_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_os_policy_assignment" not in self._stubs: - self._stubs["create_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/CreateOSPolicyAssignment", request_serializer=os_policy_assignments.CreateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -339,7 +426,9 @@ def update_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_os_policy_assignment" not in self._stubs: - self._stubs["update_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/UpdateOSPolicyAssignment", request_serializer=os_policy_assignments.UpdateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +461,7 @@ def get_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_os_policy_assignment" not in self._stubs: - self._stubs["get_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs["get_os_policy_assignment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignment", request_serializer=os_policy_assignments.GetOSPolicyAssignmentRequest.serialize, response_deserializer=os_policy_assignments.OSPolicyAssignment.deserialize, @@ -404,7 +493,9 @@ def list_os_policy_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_policy_assignments" not in self._stubs: - self._stubs["list_os_policy_assignments"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_os_policy_assignments" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignments", request_serializer=os_policy_assignments.ListOSPolicyAssignmentsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentsResponse.deserialize, @@ -437,7 +528,7 @@ def list_os_policy_assignment_revisions( if "list_os_policy_assignment_revisions" not in self._stubs: self._stubs[ "list_os_policy_assignment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentRevisions", request_serializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.deserialize, @@ -478,7 +569,9 @@ def delete_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_os_policy_assignment" not in self._stubs: - self._stubs["delete_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/DeleteOSPolicyAssignment", request_serializer=os_policy_assignments.DeleteOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -511,7 +604,7 @@ def get_os_policy_assignment_report( if "get_os_policy_assignment_report" not in self._stubs: self._stubs[ "get_os_policy_assignment_report" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignmentReport", request_serializer=os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest.serialize, response_deserializer=os_policy_assignment_reports.OSPolicyAssignmentReport.deserialize, @@ -544,7 +637,7 @@ def list_os_policy_assignment_reports( if "list_os_policy_assignment_reports" not in self._stubs: self._stubs[ "list_os_policy_assignment_reports" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentReports", request_serializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest.serialize, response_deserializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.deserialize, @@ -571,7 +664,7 @@ def get_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_inventory" not in self._stubs: - self._stubs["get_inventory"] = self.grpc_channel.unary_unary( + self._stubs["get_inventory"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetInventory", request_serializer=inventory.GetInventoryRequest.serialize, response_deserializer=inventory.Inventory.deserialize, @@ -600,7 +693,7 @@ def list_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inventories" not in self._stubs: - self._stubs["list_inventories"] = self.grpc_channel.unary_unary( + self._stubs["list_inventories"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListInventories", request_serializer=inventory.ListInventoriesRequest.serialize, response_deserializer=inventory.ListInventoriesResponse.deserialize, @@ -631,7 +724,7 @@ def get_vulnerability_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vulnerability_report" not in self._stubs: - self._stubs["get_vulnerability_report"] = self.grpc_channel.unary_unary( + self._stubs["get_vulnerability_report"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/GetVulnerabilityReport", request_serializer=vulnerability.GetVulnerabilityReportRequest.serialize, response_deserializer=vulnerability.VulnerabilityReport.deserialize, @@ -661,7 +754,9 @@ def list_vulnerability_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vulnerability_reports" not in self._stubs: - self._stubs["list_vulnerability_reports"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vulnerability_reports" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigZonalService/ListVulnerabilityReports", request_serializer=vulnerability.ListVulnerabilityReportsRequest.serialize, response_deserializer=vulnerability.ListVulnerabilityReportsResponse.deserialize, @@ -739,7 +834,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/rest.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/rest.py index 5d165139669e..a95840be7ab8 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/rest.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -171,9 +179,10 @@ def post_update_os_policy_assignment(self, response): def pre_create_os_policy_assignment( self, request: os_policy_assignments.CreateOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.CreateOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.CreateOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_os_policy_assignment @@ -196,9 +205,10 @@ def post_create_os_policy_assignment( def pre_delete_os_policy_assignment( self, request: os_policy_assignments.DeleteOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.DeleteOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.DeleteOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_os_policy_assignment @@ -221,8 +231,8 @@ def post_delete_os_policy_assignment( def pre_get_inventory( self, request: inventory.GetInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[inventory.GetInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[inventory.GetInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_inventory Override in a subclass to manipulate the request or metadata @@ -242,9 +252,10 @@ def post_get_inventory(self, response: inventory.Inventory) -> inventory.Invento def pre_get_os_policy_assignment( self, request: os_policy_assignments.GetOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.GetOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.GetOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_os_policy_assignment @@ -267,10 +278,10 @@ def post_get_os_policy_assignment( def pre_get_os_policy_assignment_report( self, request: os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_os_policy_assignment_report @@ -293,8 +304,11 @@ def post_get_os_policy_assignment_report( def pre_get_vulnerability_report( self, request: vulnerability.GetVulnerabilityReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vulnerability.GetVulnerabilityReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vulnerability.GetVulnerabilityReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_vulnerability_report Override in a subclass to manipulate the request or metadata @@ -316,8 +330,10 @@ def post_get_vulnerability_report( def pre_list_inventories( self, request: inventory.ListInventoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[inventory.ListInventoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + inventory.ListInventoriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_inventories Override in a subclass to manipulate the request or metadata @@ -339,10 +355,10 @@ def post_list_inventories( def pre_list_os_policy_assignment_reports( self, request: os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignment_reports @@ -366,10 +382,10 @@ def post_list_os_policy_assignment_reports( def pre_list_os_policy_assignment_revisions( self, request: os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignment_revisions @@ -392,9 +408,10 @@ def post_list_os_policy_assignment_revisions( def pre_list_os_policy_assignments( self, request: os_policy_assignments.ListOSPolicyAssignmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.ListOSPolicyAssignmentsRequest, Sequence[Tuple[str, str]] + os_policy_assignments.ListOSPolicyAssignmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignments @@ -417,9 +434,10 @@ def post_list_os_policy_assignments( def pre_list_vulnerability_reports( self, request: vulnerability.ListVulnerabilityReportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vulnerability.ListVulnerabilityReportsRequest, Sequence[Tuple[str, str]] + vulnerability.ListVulnerabilityReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_vulnerability_reports @@ -442,9 +460,10 @@ def post_list_vulnerability_reports( def pre_update_os_policy_assignment( self, request: os_policy_assignments.UpdateOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.UpdateOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.UpdateOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_os_policy_assignment @@ -633,7 +652,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create os policy assignment method over HTTP. @@ -645,8 +664,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -659,6 +680,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseCreateOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_create_os_policy_assignment( request, metadata ) @@ -675,6 +697,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.CreateOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "CreateOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._CreateOSPolicyAssignment._get_response( self._host, @@ -694,7 +743,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_os_policy_assignment(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.osconfig_v1.OsConfigZonalServiceClient.create_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "CreateOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOSPolicyAssignment( @@ -732,7 +803,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete os policy assignment method over HTTP. @@ -744,8 +815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -758,6 +831,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseDeleteOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_os_policy_assignment( request, metadata ) @@ -770,6 +844,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.DeleteOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "DeleteOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._DeleteOSPolicyAssignment._get_response( self._host, @@ -788,7 +889,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_os_policy_assignment(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.osconfig_v1.OsConfigZonalServiceClient.delete_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "DeleteOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInventory( @@ -826,7 +949,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Call the get inventory method over HTTP. @@ -837,8 +960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.inventory.Inventory: @@ -858,6 +983,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetInventory._get_http_options() ) + request, metadata = self._interceptor.pre_get_inventory(request, metadata) transcoded_request = _BaseOsConfigZonalServiceRestTransport._BaseGetInventory._get_transcoded_request( http_options, request @@ -868,6 +994,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.GetInventory", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._GetInventory._get_response( self._host, @@ -888,7 +1041,29 @@ def __call__( pb_resp = inventory.Inventory.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_inventory(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = inventory.Inventory.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.osconfig_v1.OsConfigZonalServiceClient.get_inventory", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOSPolicyAssignment( @@ -926,7 +1101,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Call the get os policy assignment method over HTTP. @@ -937,8 +1112,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.OSPolicyAssignment: @@ -960,6 +1137,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_get_os_policy_assignment( request, metadata ) @@ -972,6 +1150,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.GetOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigZonalServiceRestTransport._GetOSPolicyAssignment._get_response( @@ -994,7 +1199,31 @@ def __call__( pb_resp = os_policy_assignments.OSPolicyAssignment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_os_policy_assignment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignments.OSPolicyAssignment.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.osconfig_v1.OsConfigZonalServiceClient.get_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOSPolicyAssignmentReport( @@ -1032,7 +1261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Call the get os policy assignment report method over HTTP. @@ -1044,8 +1273,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignment_reports.OSPolicyAssignmentReport: @@ -1057,6 +1288,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetOSPolicyAssignmentReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_os_policy_assignment_report( request, metadata ) @@ -1069,6 +1301,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.GetOSPolicyAssignmentReport", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignmentReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._GetOSPolicyAssignmentReport._get_response( self._host, @@ -1089,7 +1348,33 @@ def __call__( pb_resp = os_policy_assignment_reports.OSPolicyAssignmentReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_os_policy_assignment_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + os_policy_assignment_reports.OSPolicyAssignmentReport.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.osconfig_v1.OsConfigZonalServiceClient.get_os_policy_assignment_report", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignmentReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVulnerabilityReport( @@ -1127,7 +1412,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Call the get vulnerability report method over HTTP. @@ -1139,8 +1424,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vulnerability.VulnerabilityReport: @@ -1156,6 +1443,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetVulnerabilityReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_vulnerability_report( request, metadata ) @@ -1168,6 +1456,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.GetVulnerabilityReport", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetVulnerabilityReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigZonalServiceRestTransport._GetVulnerabilityReport._get_response( @@ -1190,7 +1505,31 @@ def __call__( pb_resp = vulnerability.VulnerabilityReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_vulnerability_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vulnerability.VulnerabilityReport.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.osconfig_v1.OsConfigZonalServiceClient.get_vulnerability_report", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "GetVulnerabilityReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInventories( @@ -1228,7 +1567,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.ListInventoriesResponse: r"""Call the list inventories method over HTTP. @@ -1240,8 +1579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.inventory.ListInventoriesResponse: @@ -1254,6 +1595,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListInventories._get_http_options() ) + request, metadata = self._interceptor.pre_list_inventories( request, metadata ) @@ -1266,6 +1608,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.ListInventories", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListInventories._get_response( self._host, @@ -1286,7 +1655,31 @@ def __call__( pb_resp = inventory.ListInventoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_inventories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = inventory.ListInventoriesResponse.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.osconfig_v1.OsConfigZonalServiceClient.list_inventories", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignmentReports( @@ -1326,7 +1719,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse: r"""Call the list os policy assignment reports method over HTTP. @@ -1338,8 +1731,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse: @@ -1352,6 +1747,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignmentReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_os_policy_assignment_reports( request, metadata ) @@ -1364,6 +1760,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentReports", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignmentReports._get_response( self._host, @@ -1388,7 +1811,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignment_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.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.osconfig_v1.OsConfigZonalServiceClient.list_os_policy_assignment_reports", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignmentRevisions( @@ -1428,7 +1875,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse: r"""Call the list os policy assignment revisions method over HTTP. @@ -1440,8 +1887,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse: @@ -1453,6 +1902,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignmentRevisions._get_http_options() ) + ( request, metadata, @@ -1468,6 +1918,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisions", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignmentRevisions._get_response( self._host, @@ -1490,7 +1967,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.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.osconfig_v1.OsConfigZonalServiceClient.list_os_policy_assignment_revisions", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignments( @@ -1528,7 +2029,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.ListOSPolicyAssignmentsResponse: r"""Call the list os policy assignments method over HTTP. @@ -1540,8 +2041,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.ListOSPolicyAssignmentsResponse: @@ -1553,6 +2056,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignments._get_http_options() ) + request, metadata = self._interceptor.pre_list_os_policy_assignments( request, metadata ) @@ -1565,6 +2069,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.ListOSPolicyAssignments", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignments._get_response( self._host, @@ -1585,7 +2116,33 @@ def __call__( pb_resp = os_policy_assignments.ListOSPolicyAssignmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + os_policy_assignments.ListOSPolicyAssignmentsResponse.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.osconfig_v1.OsConfigZonalServiceClient.list_os_policy_assignments", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVulnerabilityReports( @@ -1623,7 +2180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.ListVulnerabilityReportsResponse: r"""Call the list vulnerability reports method over HTTP. @@ -1636,8 +2193,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vulnerability.ListVulnerabilityReportsResponse: @@ -1650,6 +2209,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListVulnerabilityReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_vulnerability_reports( request, metadata ) @@ -1662,6 +2222,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.ListVulnerabilityReports", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListVulnerabilityReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListVulnerabilityReports._get_response( self._host, @@ -1682,7 +2269,31 @@ def __call__( pb_resp = vulnerability.ListVulnerabilityReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_vulnerability_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vulnerability.ListVulnerabilityReportsResponse.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.osconfig_v1.OsConfigZonalServiceClient.list_vulnerability_reports", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "ListVulnerabilityReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOSPolicyAssignment( @@ -1721,7 +2332,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update os policy assignment method over HTTP. @@ -1733,8 +2344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1747,6 +2360,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseUpdateOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_update_os_policy_assignment( request, metadata ) @@ -1763,6 +2377,33 @@ def __call__( 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.osconfig_v1.OsConfigZonalServiceClient.UpdateOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "UpdateOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._UpdateOSPolicyAssignment._get_response( self._host, @@ -1782,7 +2423,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_os_policy_assignment(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.osconfig_v1.OsConfigZonalServiceClient.update_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1.OsConfigZonalService", + "rpcName": "UpdateOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/gapic_version.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/gapic_version.py index ef9777764da2..558c8aab67c5 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/gapic_version.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.18.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/async_client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/async_client.py index 83c038226273..3e893872761f 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/async_client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport from .transports.grpc_asyncio import OsConfigZonalServiceGrpcAsyncIOTransport +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 OsConfigZonalServiceAsyncClient: """Zonal OS Config API @@ -310,6 +320,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.osconfig_v1alpha.OsConfigZonalServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "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.osconfig.v1alpha.OsConfigZonalService", + "credentialsType": None, + }, + ) + async def create_os_policy_assignment( self, request: Optional[ @@ -321,7 +353,7 @@ async def create_os_policy_assignment( os_policy_assignment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create an OS policy assignment. @@ -411,8 +443,10 @@ async def sample_create_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -504,7 +538,7 @@ async def update_os_policy_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update an existing OS policy assignment. @@ -577,8 +611,10 @@ async def sample_update_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -667,7 +703,7 @@ async def get_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Retrieve an existing OS policy assignment. @@ -717,8 +753,10 @@ async def sample_get_os_policy_assignment(): 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, 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: google.cloud.osconfig_v1alpha.types.OSPolicyAssignment: @@ -791,7 +829,7 @@ async def list_os_policy_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentsAsyncPager: r"""List the OS policy assignments under the parent resource. @@ -837,8 +875,10 @@ async def sample_list_os_policy_assignments(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsAsyncPager: @@ -917,7 +957,7 @@ async def list_os_policy_assignment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentRevisionsAsyncPager: r"""List the OS policy assignment revisions for a given OS policy assignment. @@ -963,8 +1003,10 @@ async def sample_list_os_policy_assignment_revisions(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsAsyncPager: @@ -1045,7 +1087,7 @@ async def delete_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete the OS policy assignment. @@ -1105,8 +1147,10 @@ async def sample_delete_os_policy_assignment(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1192,7 +1236,7 @@ async def get_instance_os_policies_compliance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance_os_policies_compliance.InstanceOSPoliciesCompliance: r"""Get OS policies compliance data for the specified Compute Engine VM instance. @@ -1246,8 +1290,10 @@ async def sample_get_instance_os_policies_compliance(): 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, 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: google.cloud.osconfig_v1alpha.types.InstanceOSPoliciesCompliance: @@ -1338,7 +1384,7 @@ async def list_instance_os_policies_compliances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstanceOSPoliciesCompliancesAsyncPager: r"""List OS policies compliance data for all Compute Engine VM instances in the specified zone. @@ -1389,8 +1435,10 @@ async def sample_list_instance_os_policies_compliances(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInstanceOSPoliciesCompliancesAsyncPager: @@ -1479,7 +1527,7 @@ async def get_os_policy_assignment_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Get the OS policy asssignment report for the specified Compute Engine VM instance. @@ -1534,8 +1582,10 @@ async def sample_get_os_policy_assignment_report(): 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, 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: google.cloud.osconfig_v1alpha.types.OSPolicyAssignmentReport: @@ -1604,7 +1654,7 @@ async def list_os_policy_assignment_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentReportsAsyncPager: r"""List OS policy asssignment reports for all Compute Engine VM instances in the specified zone. @@ -1674,8 +1724,10 @@ async def sample_list_os_policy_assignment_reports(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsAsyncPager: @@ -1756,7 +1808,7 @@ async def get_inventory( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Get inventory data for the specified VM instance. If the VM has no associated inventory, the message ``NOT_FOUND`` is returned. @@ -1808,8 +1860,10 @@ async def sample_get_inventory(): 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, 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: google.cloud.osconfig_v1alpha.types.Inventory: @@ -1878,7 +1932,7 @@ async def list_inventories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInventoriesAsyncPager: r"""List inventory data for all VM instances in the specified zone. @@ -1930,8 +1984,10 @@ async def sample_list_inventories(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInventoriesAsyncPager: @@ -2010,7 +2066,7 @@ async def get_vulnerability_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have @@ -2064,8 +2120,10 @@ async def sample_get_vulnerability_report(): 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, 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: google.cloud.osconfig_v1alpha.types.VulnerabilityReport: @@ -2132,7 +2190,7 @@ async def list_vulnerability_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVulnerabilityReportsAsyncPager: r"""List vulnerability reports for all VM instances in the specified zone. @@ -2184,8 +2242,10 @@ async def sample_list_vulnerability_reports(): 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, 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListVulnerabilityReportsAsyncPager: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/client.py index dc9bacd2a138..003cbc70c0a8 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import empty_pb2 # type: ignore @@ -737,6 +747,10 @@ def __init__( # 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( @@ -803,6 +817,29 @@ def __init__( 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.osconfig_v1alpha.OsConfigZonalServiceClient`.", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "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.osconfig.v1alpha.OsConfigZonalService", + "credentialsType": None, + }, + ) + def create_os_policy_assignment( self, request: Optional[ @@ -814,7 +851,7 @@ def create_os_policy_assignment( os_policy_assignment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create an OS policy assignment. @@ -904,8 +941,10 @@ def sample_create_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -996,7 +1035,7 @@ def update_os_policy_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update an existing OS policy assignment. @@ -1069,8 +1108,10 @@ def sample_update_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1158,7 +1199,7 @@ def get_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Retrieve an existing OS policy assignment. @@ -1208,8 +1249,10 @@ def sample_get_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.types.OSPolicyAssignment: @@ -1279,7 +1322,7 @@ def list_os_policy_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentsPager: r"""List the OS policy assignments under the parent resource. @@ -1325,8 +1368,10 @@ def sample_list_os_policy_assignments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsPager: @@ -1404,7 +1449,7 @@ def list_os_policy_assignment_revisions( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentRevisionsPager: r"""List the OS policy assignment revisions for a given OS policy assignment. @@ -1450,8 +1495,10 @@ def sample_list_os_policy_assignment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsPager: @@ -1531,7 +1578,7 @@ def delete_os_policy_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete the OS policy assignment. @@ -1591,8 +1638,10 @@ def sample_delete_os_policy_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1677,7 +1726,7 @@ def get_instance_os_policies_compliance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance_os_policies_compliance.InstanceOSPoliciesCompliance: r"""Get OS policies compliance data for the specified Compute Engine VM instance. @@ -1731,8 +1780,10 @@ def sample_get_instance_os_policies_compliance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.types.InstanceOSPoliciesCompliance: @@ -1822,7 +1873,7 @@ def list_instance_os_policies_compliances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstanceOSPoliciesCompliancesPager: r"""List OS policies compliance data for all Compute Engine VM instances in the specified zone. @@ -1873,8 +1924,10 @@ def sample_list_instance_os_policies_compliances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInstanceOSPoliciesCompliancesPager: @@ -1962,7 +2015,7 @@ def get_os_policy_assignment_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Get the OS policy asssignment report for the specified Compute Engine VM instance. @@ -2017,8 +2070,10 @@ def sample_get_os_policy_assignment_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.types.OSPolicyAssignmentReport: @@ -2086,7 +2141,7 @@ def list_os_policy_assignment_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOSPolicyAssignmentReportsPager: r"""List OS policy asssignment reports for all Compute Engine VM instances in the specified zone. @@ -2156,8 +2211,10 @@ def sample_list_os_policy_assignment_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsPager: @@ -2237,7 +2294,7 @@ def get_inventory( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Get inventory data for the specified VM instance. If the VM has no associated inventory, the message ``NOT_FOUND`` is returned. @@ -2289,8 +2346,10 @@ def sample_get_inventory(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.types.Inventory: @@ -2356,7 +2415,7 @@ def list_inventories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInventoriesPager: r"""List inventory data for all VM instances in the specified zone. @@ -2408,8 +2467,10 @@ def sample_list_inventories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInventoriesPager: @@ -2485,7 +2546,7 @@ def get_vulnerability_report( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have @@ -2539,8 +2600,10 @@ def sample_get_vulnerability_report(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.types.VulnerabilityReport: @@ -2604,7 +2667,7 @@ def list_vulnerability_reports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVulnerabilityReportsPager: r"""List vulnerability reports for all VM instances in the specified zone. @@ -2656,8 +2719,10 @@ def sample_list_vulnerability_reports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListVulnerabilityReportsPager: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/pagers.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/pagers.py index 41a4b247a35f..3cce3cd38749 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/pagers.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/pagers.py @@ -73,7 +73,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -87,8 +87,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentsRequest(request) @@ -149,7 +151,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -163,8 +165,10 @@ def __init__( 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, 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentsRequest(request) @@ -231,7 +235,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -245,8 +249,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest( @@ -312,7 +318,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -326,8 +332,10 @@ def __init__( 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, 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`. """ self._method = method self._request = os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest( @@ -397,7 +405,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -411,8 +419,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -486,7 +496,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -500,8 +510,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -576,7 +588,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -590,8 +602,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -661,7 +675,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -675,8 +689,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( @@ -747,7 +763,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -761,8 +777,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = inventory.ListInventoriesRequest(request) @@ -821,7 +839,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -835,8 +853,10 @@ def __init__( 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, 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`. """ self._method = method self._request = inventory.ListInventoriesRequest(request) @@ -899,7 +919,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -913,8 +933,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = vulnerability.ListVulnerabilityReportsRequest(request) @@ -975,7 +997,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -989,8 +1011,10 @@ def __init__( 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, 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`. """ self._method = method self._request = vulnerability.ListVulnerabilityReportsRequest(request) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py index e76fe82fc2bc..9d28ab5a30b1 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1alpha.types import ( instance_os_policies_compliance, @@ -33,6 +39,81 @@ from .base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport +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.osconfig.v1alpha.OsConfigZonalService", + "rpcName": 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.osconfig.v1alpha.OsConfigZonalService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigZonalServiceGrpcTransport(OsConfigZonalServiceTransport): """gRPC backend transport for OsConfigZonalService. @@ -191,7 +272,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -255,7 +341,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -292,7 +380,9 @@ def create_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_os_policy_assignment" not in self._stubs: - self._stubs["create_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/CreateOSPolicyAssignment", request_serializer=os_policy_assignments.CreateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -330,7 +420,9 @@ def update_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_os_policy_assignment" not in self._stubs: - self._stubs["update_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/UpdateOSPolicyAssignment", request_serializer=os_policy_assignments.UpdateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -363,7 +455,7 @@ def get_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_os_policy_assignment" not in self._stubs: - self._stubs["get_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs["get_os_policy_assignment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignment", request_serializer=os_policy_assignments.GetOSPolicyAssignmentRequest.serialize, response_deserializer=os_policy_assignments.OSPolicyAssignment.deserialize, @@ -395,7 +487,9 @@ def list_os_policy_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_policy_assignments" not in self._stubs: - self._stubs["list_os_policy_assignments"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_os_policy_assignments" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignments", request_serializer=os_policy_assignments.ListOSPolicyAssignmentsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentsResponse.deserialize, @@ -428,7 +522,7 @@ def list_os_policy_assignment_revisions( if "list_os_policy_assignment_revisions" not in self._stubs: self._stubs[ "list_os_policy_assignment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentRevisions", request_serializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.deserialize, @@ -469,7 +563,9 @@ def delete_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_os_policy_assignment" not in self._stubs: - self._stubs["delete_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/DeleteOSPolicyAssignment", request_serializer=os_policy_assignments.DeleteOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -502,7 +598,7 @@ def get_instance_os_policies_compliance( if "get_instance_os_policies_compliance" not in self._stubs: self._stubs[ "get_instance_os_policies_compliance" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInstanceOSPoliciesCompliance", request_serializer=instance_os_policies_compliance.GetInstanceOSPoliciesComplianceRequest.serialize, response_deserializer=instance_os_policies_compliance.InstanceOSPoliciesCompliance.deserialize, @@ -535,7 +631,7 @@ def list_instance_os_policies_compliances( if "list_instance_os_policies_compliances" not in self._stubs: self._stubs[ "list_instance_os_policies_compliances" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInstanceOSPoliciesCompliances", request_serializer=instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesRequest.serialize, response_deserializer=instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse.deserialize, @@ -568,7 +664,7 @@ def get_os_policy_assignment_report( if "get_os_policy_assignment_report" not in self._stubs: self._stubs[ "get_os_policy_assignment_report" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignmentReport", request_serializer=os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest.serialize, response_deserializer=os_policy_assignment_reports.OSPolicyAssignmentReport.deserialize, @@ -601,7 +697,7 @@ def list_os_policy_assignment_reports( if "list_os_policy_assignment_reports" not in self._stubs: self._stubs[ "list_os_policy_assignment_reports" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentReports", request_serializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest.serialize, response_deserializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.deserialize, @@ -628,7 +724,7 @@ def get_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_inventory" not in self._stubs: - self._stubs["get_inventory"] = self.grpc_channel.unary_unary( + self._stubs["get_inventory"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInventory", request_serializer=inventory.GetInventoryRequest.serialize, response_deserializer=inventory.Inventory.deserialize, @@ -657,7 +753,7 @@ def list_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inventories" not in self._stubs: - self._stubs["list_inventories"] = self.grpc_channel.unary_unary( + self._stubs["list_inventories"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInventories", request_serializer=inventory.ListInventoriesRequest.serialize, response_deserializer=inventory.ListInventoriesResponse.deserialize, @@ -687,7 +783,7 @@ def get_vulnerability_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vulnerability_report" not in self._stubs: - self._stubs["get_vulnerability_report"] = self.grpc_channel.unary_unary( + self._stubs["get_vulnerability_report"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetVulnerabilityReport", request_serializer=vulnerability.GetVulnerabilityReportRequest.serialize, response_deserializer=vulnerability.VulnerabilityReport.deserialize, @@ -717,7 +813,9 @@ def list_vulnerability_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vulnerability_reports" not in self._stubs: - self._stubs["list_vulnerability_reports"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vulnerability_reports" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListVulnerabilityReports", request_serializer=vulnerability.ListVulnerabilityReportsRequest.serialize, response_deserializer=vulnerability.ListVulnerabilityReportsResponse.deserialize, @@ -725,7 +823,7 @@ def list_vulnerability_reports( return self._stubs["list_vulnerability_reports"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py index 01204ee9b885..342250fd1b84 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.osconfig_v1alpha.types import ( instance_os_policies_compliance, @@ -37,6 +43,82 @@ from .base import DEFAULT_CLIENT_INFO, OsConfigZonalServiceTransport from .grpc import OsConfigZonalServiceGrpcTransport +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.osconfig.v1alpha.OsConfigZonalService", + "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.osconfig.v1alpha.OsConfigZonalService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsConfigZonalServiceGrpcAsyncIOTransport(OsConfigZonalServiceTransport): """gRPC AsyncIO backend transport for OsConfigZonalService. @@ -238,10 +320,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -264,7 +349,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -302,7 +387,9 @@ def create_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_os_policy_assignment" not in self._stubs: - self._stubs["create_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/CreateOSPolicyAssignment", request_serializer=os_policy_assignments.CreateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -340,7 +427,9 @@ def update_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_os_policy_assignment" not in self._stubs: - self._stubs["update_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/UpdateOSPolicyAssignment", request_serializer=os_policy_assignments.UpdateOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +462,7 @@ def get_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_os_policy_assignment" not in self._stubs: - self._stubs["get_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs["get_os_policy_assignment"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignment", request_serializer=os_policy_assignments.GetOSPolicyAssignmentRequest.serialize, response_deserializer=os_policy_assignments.OSPolicyAssignment.deserialize, @@ -405,7 +494,9 @@ def list_os_policy_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_policy_assignments" not in self._stubs: - self._stubs["list_os_policy_assignments"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_os_policy_assignments" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignments", request_serializer=os_policy_assignments.ListOSPolicyAssignmentsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentsResponse.deserialize, @@ -438,7 +529,7 @@ def list_os_policy_assignment_revisions( if "list_os_policy_assignment_revisions" not in self._stubs: self._stubs[ "list_os_policy_assignment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentRevisions", request_serializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest.serialize, response_deserializer=os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.deserialize, @@ -479,7 +570,9 @@ def delete_os_policy_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_os_policy_assignment" not in self._stubs: - self._stubs["delete_os_policy_assignment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_os_policy_assignment" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/DeleteOSPolicyAssignment", request_serializer=os_policy_assignments.DeleteOSPolicyAssignmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -512,7 +605,7 @@ def get_instance_os_policies_compliance( if "get_instance_os_policies_compliance" not in self._stubs: self._stubs[ "get_instance_os_policies_compliance" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInstanceOSPoliciesCompliance", request_serializer=instance_os_policies_compliance.GetInstanceOSPoliciesComplianceRequest.serialize, response_deserializer=instance_os_policies_compliance.InstanceOSPoliciesCompliance.deserialize, @@ -547,7 +640,7 @@ def list_instance_os_policies_compliances( if "list_instance_os_policies_compliances" not in self._stubs: self._stubs[ "list_instance_os_policies_compliances" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInstanceOSPoliciesCompliances", request_serializer=instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesRequest.serialize, response_deserializer=instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse.deserialize, @@ -580,7 +673,7 @@ def get_os_policy_assignment_report( if "get_os_policy_assignment_report" not in self._stubs: self._stubs[ "get_os_policy_assignment_report" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignmentReport", request_serializer=os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest.serialize, response_deserializer=os_policy_assignment_reports.OSPolicyAssignmentReport.deserialize, @@ -613,7 +706,7 @@ def list_os_policy_assignment_reports( if "list_os_policy_assignment_reports" not in self._stubs: self._stubs[ "list_os_policy_assignment_reports" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentReports", request_serializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest.serialize, response_deserializer=os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.deserialize, @@ -640,7 +733,7 @@ def get_inventory( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_inventory" not in self._stubs: - self._stubs["get_inventory"] = self.grpc_channel.unary_unary( + self._stubs["get_inventory"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInventory", request_serializer=inventory.GetInventoryRequest.serialize, response_deserializer=inventory.Inventory.deserialize, @@ -669,7 +762,7 @@ def list_inventories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_inventories" not in self._stubs: - self._stubs["list_inventories"] = self.grpc_channel.unary_unary( + self._stubs["list_inventories"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInventories", request_serializer=inventory.ListInventoriesRequest.serialize, response_deserializer=inventory.ListInventoriesResponse.deserialize, @@ -700,7 +793,7 @@ def get_vulnerability_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vulnerability_report" not in self._stubs: - self._stubs["get_vulnerability_report"] = self.grpc_channel.unary_unary( + self._stubs["get_vulnerability_report"] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/GetVulnerabilityReport", request_serializer=vulnerability.GetVulnerabilityReportRequest.serialize, response_deserializer=vulnerability.VulnerabilityReport.deserialize, @@ -730,7 +823,9 @@ def list_vulnerability_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_vulnerability_reports" not in self._stubs: - self._stubs["list_vulnerability_reports"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_vulnerability_reports" + ] = self._logged_channel.unary_unary( "/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListVulnerabilityReports", request_serializer=vulnerability.ListVulnerabilityReportsRequest.serialize, response_deserializer=vulnerability.ListVulnerabilityReportsResponse.deserialize, @@ -818,7 +913,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/rest.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/rest.py index 2985b984d4d2..920c5843c069 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/rest.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -44,6 +44,14 @@ 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, @@ -188,9 +196,10 @@ def post_update_os_policy_assignment(self, response): def pre_create_os_policy_assignment( self, request: os_policy_assignments.CreateOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.CreateOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.CreateOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_os_policy_assignment @@ -213,9 +222,10 @@ def post_create_os_policy_assignment( def pre_delete_os_policy_assignment( self, request: os_policy_assignments.DeleteOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.DeleteOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.DeleteOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_os_policy_assignment @@ -238,10 +248,10 @@ def post_delete_os_policy_assignment( def pre_get_instance_os_policies_compliance( self, request: instance_os_policies_compliance.GetInstanceOSPoliciesComplianceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ instance_os_policies_compliance.GetInstanceOSPoliciesComplianceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_instance_os_policies_compliance @@ -264,8 +274,8 @@ def post_get_instance_os_policies_compliance( def pre_get_inventory( self, request: inventory.GetInventoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[inventory.GetInventoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[inventory.GetInventoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_inventory Override in a subclass to manipulate the request or metadata @@ -285,9 +295,10 @@ def post_get_inventory(self, response: inventory.Inventory) -> inventory.Invento def pre_get_os_policy_assignment( self, request: os_policy_assignments.GetOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.GetOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.GetOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_os_policy_assignment @@ -310,10 +321,10 @@ def post_get_os_policy_assignment( def pre_get_os_policy_assignment_report( self, request: os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignment_reports.GetOSPolicyAssignmentReportRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_os_policy_assignment_report @@ -336,8 +347,11 @@ def post_get_os_policy_assignment_report( def pre_get_vulnerability_report( self, request: vulnerability.GetVulnerabilityReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vulnerability.GetVulnerabilityReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vulnerability.GetVulnerabilityReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_vulnerability_report Override in a subclass to manipulate the request or metadata @@ -359,10 +373,10 @@ def post_get_vulnerability_report( def pre_list_instance_os_policies_compliances( self, request: instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_instance_os_policies_compliances @@ -386,8 +400,10 @@ def post_list_instance_os_policies_compliances( def pre_list_inventories( self, request: inventory.ListInventoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[inventory.ListInventoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + inventory.ListInventoriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_inventories Override in a subclass to manipulate the request or metadata @@ -409,10 +425,10 @@ def post_list_inventories( def pre_list_os_policy_assignment_reports( self, request: os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignment_reports.ListOSPolicyAssignmentReportsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignment_reports @@ -436,10 +452,10 @@ def post_list_os_policy_assignment_reports( def pre_list_os_policy_assignment_revisions( self, request: os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ os_policy_assignments.ListOSPolicyAssignmentRevisionsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignment_revisions @@ -462,9 +478,10 @@ def post_list_os_policy_assignment_revisions( def pre_list_os_policy_assignments( self, request: os_policy_assignments.ListOSPolicyAssignmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.ListOSPolicyAssignmentsRequest, Sequence[Tuple[str, str]] + os_policy_assignments.ListOSPolicyAssignmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_os_policy_assignments @@ -487,9 +504,10 @@ def post_list_os_policy_assignments( def pre_list_vulnerability_reports( self, request: vulnerability.ListVulnerabilityReportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - vulnerability.ListVulnerabilityReportsRequest, Sequence[Tuple[str, str]] + vulnerability.ListVulnerabilityReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_vulnerability_reports @@ -512,9 +530,10 @@ def post_list_vulnerability_reports( def pre_update_os_policy_assignment( self, request: os_policy_assignments.UpdateOSPolicyAssignmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - os_policy_assignments.UpdateOSPolicyAssignmentRequest, Sequence[Tuple[str, str]] + os_policy_assignments.UpdateOSPolicyAssignmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_os_policy_assignment @@ -703,7 +722,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create os policy assignment method over HTTP. @@ -715,8 +734,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -729,6 +750,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseCreateOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_create_os_policy_assignment( request, metadata ) @@ -745,6 +767,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.CreateOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "CreateOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._CreateOSPolicyAssignment._get_response( self._host, @@ -764,7 +813,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_os_policy_assignment(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.osconfig_v1alpha.OsConfigZonalServiceClient.create_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "CreateOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteOSPolicyAssignment( @@ -802,7 +873,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete os policy assignment method over HTTP. @@ -814,8 +885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -828,6 +901,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseDeleteOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_os_policy_assignment( request, metadata ) @@ -840,6 +914,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.DeleteOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "DeleteOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._DeleteOSPolicyAssignment._get_response( self._host, @@ -858,7 +959,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_os_policy_assignment(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.osconfig_v1alpha.OsConfigZonalServiceClient.delete_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "DeleteOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstanceOSPoliciesCompliance( @@ -898,7 +1021,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance_os_policies_compliance.InstanceOSPoliciesCompliance: r"""Call the get instance os policies compliance method over HTTP. @@ -911,8 +1034,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.instance_os_policies_compliance.InstanceOSPoliciesCompliance: @@ -937,6 +1062,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetInstanceOSPoliciesCompliance._get_http_options() ) + ( request, metadata, @@ -952,6 +1078,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.GetInstanceOSPoliciesCompliance", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetInstanceOSPoliciesCompliance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._GetInstanceOSPoliciesCompliance._get_response( self._host, @@ -974,7 +1127,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance_os_policies_compliance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = instance_os_policies_compliance.InstanceOSPoliciesCompliance.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.osconfig_v1alpha.OsConfigZonalServiceClient.get_instance_os_policies_compliance", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetInstanceOSPoliciesCompliance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInventory( @@ -1012,7 +1189,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.Inventory: r"""Call the get inventory method over HTTP. @@ -1023,8 +1200,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.inventory.Inventory: @@ -1044,6 +1223,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetInventory._get_http_options() ) + request, metadata = self._interceptor.pre_get_inventory(request, metadata) transcoded_request = _BaseOsConfigZonalServiceRestTransport._BaseGetInventory._get_transcoded_request( http_options, request @@ -1054,6 +1234,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.GetInventory", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetInventory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._GetInventory._get_response( self._host, @@ -1074,7 +1281,29 @@ def __call__( pb_resp = inventory.Inventory.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_inventory(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = inventory.Inventory.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.osconfig_v1alpha.OsConfigZonalServiceClient.get_inventory", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetInventory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOSPolicyAssignment( @@ -1112,7 +1341,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.OSPolicyAssignment: r"""Call the get os policy assignment method over HTTP. @@ -1123,8 +1352,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.OSPolicyAssignment: @@ -1146,6 +1377,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_get_os_policy_assignment( request, metadata ) @@ -1158,6 +1390,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.GetOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigZonalServiceRestTransport._GetOSPolicyAssignment._get_response( @@ -1180,7 +1439,31 @@ def __call__( pb_resp = os_policy_assignments.OSPolicyAssignment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_os_policy_assignment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignments.OSPolicyAssignment.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.osconfig_v1alpha.OsConfigZonalServiceClient.get_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOSPolicyAssignmentReport( @@ -1218,7 +1501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.OSPolicyAssignmentReport: r"""Call the get os policy assignment report method over HTTP. @@ -1230,8 +1513,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignment_reports.OSPolicyAssignmentReport: @@ -1243,6 +1528,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetOSPolicyAssignmentReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_os_policy_assignment_report( request, metadata ) @@ -1255,6 +1541,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.GetOSPolicyAssignmentReport", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignmentReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._GetOSPolicyAssignmentReport._get_response( self._host, @@ -1275,7 +1588,33 @@ def __call__( pb_resp = os_policy_assignment_reports.OSPolicyAssignmentReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_os_policy_assignment_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + os_policy_assignment_reports.OSPolicyAssignmentReport.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.osconfig_v1alpha.OsConfigZonalServiceClient.get_os_policy_assignment_report", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetOSPolicyAssignmentReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVulnerabilityReport( @@ -1313,7 +1652,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.VulnerabilityReport: r"""Call the get vulnerability report method over HTTP. @@ -1325,8 +1664,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vulnerability.VulnerabilityReport: @@ -1342,6 +1683,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseGetVulnerabilityReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_vulnerability_report( request, metadata ) @@ -1354,6 +1696,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.GetVulnerabilityReport", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetVulnerabilityReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OsConfigZonalServiceRestTransport._GetVulnerabilityReport._get_response( @@ -1376,7 +1745,31 @@ def __call__( pb_resp = vulnerability.VulnerabilityReport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_vulnerability_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vulnerability.VulnerabilityReport.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.osconfig_v1alpha.OsConfigZonalServiceClient.get_vulnerability_report", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "GetVulnerabilityReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstanceOSPoliciesCompliances( @@ -1416,7 +1809,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse: r"""Call the list instance os policies compliances method over HTTP. @@ -1429,8 +1822,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse: @@ -1443,6 +1838,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListInstanceOSPoliciesCompliances._get_http_options() ) + ( request, metadata, @@ -1458,6 +1854,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListInstanceOSPoliciesCompliances", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListInstanceOSPoliciesCompliances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListInstanceOSPoliciesCompliances._get_response( self._host, @@ -1482,7 +1905,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instance_os_policies_compliances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_instance_os_policies_compliances", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListInstanceOSPoliciesCompliances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInventories( @@ -1520,7 +1967,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> inventory.ListInventoriesResponse: r"""Call the list inventories method over HTTP. @@ -1532,8 +1979,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.inventory.ListInventoriesResponse: @@ -1546,6 +1995,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListInventories._get_http_options() ) + request, metadata = self._interceptor.pre_list_inventories( request, metadata ) @@ -1558,6 +2008,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListInventories", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListInventories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListInventories._get_response( self._host, @@ -1578,7 +2055,31 @@ def __call__( pb_resp = inventory.ListInventoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_inventories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = inventory.ListInventoriesResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_inventories", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListInventories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignmentReports( @@ -1618,7 +2119,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse: r"""Call the list os policy assignment reports method over HTTP. @@ -1630,8 +2131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse: @@ -1644,6 +2147,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignmentReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_os_policy_assignment_reports( request, metadata ) @@ -1656,6 +2160,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentReports", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignmentReports._get_response( self._host, @@ -1680,7 +2211,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignment_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_os_policy_assignment_reports", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignmentRevisions( @@ -1720,7 +2275,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse: r"""Call the list os policy assignment revisions method over HTTP. @@ -1732,8 +2287,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse: @@ -1745,6 +2302,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignmentRevisions._get_http_options() ) + ( request, metadata, @@ -1760,6 +2318,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisions", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignmentRevisions._get_response( self._host, @@ -1782,7 +2367,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_os_policy_assignment_revisions", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignmentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSPolicyAssignments( @@ -1820,7 +2429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> os_policy_assignments.ListOSPolicyAssignmentsResponse: r"""Call the list os policy assignments method over HTTP. @@ -1832,8 +2441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.os_policy_assignments.ListOSPolicyAssignmentsResponse: @@ -1845,6 +2456,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListOSPolicyAssignments._get_http_options() ) + request, metadata = self._interceptor.pre_list_os_policy_assignments( request, metadata ) @@ -1857,6 +2469,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignments", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListOSPolicyAssignments._get_response( self._host, @@ -1877,7 +2516,33 @@ def __call__( pb_resp = os_policy_assignments.ListOSPolicyAssignmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_policy_assignments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + os_policy_assignments.ListOSPolicyAssignmentsResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_os_policy_assignments", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListOSPolicyAssignments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVulnerabilityReports( @@ -1915,7 +2580,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vulnerability.ListVulnerabilityReportsResponse: r"""Call the list vulnerability reports method over HTTP. @@ -1928,8 +2593,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.vulnerability.ListVulnerabilityReportsResponse: @@ -1942,6 +2609,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseListVulnerabilityReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_vulnerability_reports( request, metadata ) @@ -1954,6 +2622,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.ListVulnerabilityReports", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListVulnerabilityReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._ListVulnerabilityReports._get_response( self._host, @@ -1974,7 +2669,31 @@ def __call__( pb_resp = vulnerability.ListVulnerabilityReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_vulnerability_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + vulnerability.ListVulnerabilityReportsResponse.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.osconfig_v1alpha.OsConfigZonalServiceClient.list_vulnerability_reports", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "ListVulnerabilityReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateOSPolicyAssignment( @@ -2013,7 +2732,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update os policy assignment method over HTTP. @@ -2025,8 +2744,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2039,6 +2760,7 @@ def __call__( http_options = ( _BaseOsConfigZonalServiceRestTransport._BaseUpdateOSPolicyAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_update_os_policy_assignment( request, metadata ) @@ -2055,6 +2777,33 @@ def __call__( 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.osconfig_v1alpha.OsConfigZonalServiceClient.UpdateOSPolicyAssignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "UpdateOSPolicyAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsConfigZonalServiceRestTransport._UpdateOSPolicyAssignment._get_response( self._host, @@ -2074,7 +2823,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_os_policy_assignment(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.osconfig_v1alpha.OsConfigZonalServiceClient.update_os_policy_assignment", + extra={ + "serviceName": "google.cloud.osconfig.v1alpha.OsConfigZonalService", + "rpcName": "UpdateOSPolicyAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1.json b/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1.json index f8be9de4a395..c2cae7c3fa77 100644 --- a/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1.json +++ b/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-os-config", - "version": "1.18.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_patch_deployment" @@ -454,7 +454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_patch_deployment" @@ -528,7 +528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -604,7 +604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -685,7 +685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -846,7 +846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -926,7 +926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchJob", @@ -1007,7 +1007,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchDeploymentsAsyncPager", @@ -1087,7 +1087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchDeploymentsPager", @@ -1168,7 +1168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobInstanceDetailsAsyncPager", @@ -1248,7 +1248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobInstanceDetailsPager", @@ -1329,7 +1329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobsAsyncPager", @@ -1409,7 +1409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_service.pagers.ListPatchJobsPager", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1570,7 +1570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1651,7 +1651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1731,7 +1731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1816,7 +1816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1900,7 +1900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.PatchDeployment", @@ -1989,7 +1989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2158,7 +2158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2238,7 +2238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2319,7 +2319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.Inventory", @@ -2399,7 +2399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.Inventory", @@ -2480,7 +2480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.OSPolicyAssignmentReport", @@ -2560,7 +2560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.OSPolicyAssignmentReport", @@ -2641,7 +2641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.OSPolicyAssignment", @@ -2721,7 +2721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.OSPolicyAssignment", @@ -2802,7 +2802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.VulnerabilityReport", @@ -2882,7 +2882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.types.VulnerabilityReport", @@ -2963,7 +2963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListInventoriesAsyncPager", @@ -3043,7 +3043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListInventoriesPager", @@ -3124,7 +3124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsAsyncPager", @@ -3204,7 +3204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsPager", @@ -3285,7 +3285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsAsyncPager", @@ -3365,7 +3365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsPager", @@ -3446,7 +3446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsAsyncPager", @@ -3526,7 +3526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsPager", @@ -3607,7 +3607,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListVulnerabilityReportsAsyncPager", @@ -3687,7 +3687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1.services.os_config_zonal_service.pagers.ListVulnerabilityReportsPager", @@ -3772,7 +3772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3856,7 +3856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1alpha.json b/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1alpha.json index 30756b79695a..f8c8df434837 100644 --- a/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1alpha.json +++ b/packages/google-cloud-os-config/samples/generated_samples/snippet_metadata_google.cloud.osconfig.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-os-config", - "version": "1.18.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.InstanceOSPoliciesCompliance", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.InstanceOSPoliciesCompliance", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.Inventory", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.Inventory", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.OSPolicyAssignmentReport", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.OSPolicyAssignmentReport", @@ -868,7 +868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.OSPolicyAssignment", @@ -948,7 +948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.OSPolicyAssignment", @@ -1029,7 +1029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.VulnerabilityReport", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.types.VulnerabilityReport", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInstanceOSPoliciesCompliancesAsyncPager", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInstanceOSPoliciesCompliancesPager", @@ -1351,7 +1351,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInventoriesAsyncPager", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListInventoriesPager", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsAsyncPager", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentReportsPager", @@ -1673,7 +1673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsAsyncPager", @@ -1753,7 +1753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentRevisionsPager", @@ -1834,7 +1834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsAsyncPager", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListOSPolicyAssignmentsPager", @@ -1995,7 +1995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListVulnerabilityReportsAsyncPager", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.osconfig_v1alpha.services.os_config_zonal_service.pagers.ListVulnerabilityReportsPager", @@ -2160,7 +2160,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2244,7 +2244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py index d4c9a433c90a..8886f601a114 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py @@ -5830,6 +5830,7 @@ def test_execute_patch_job_rest_required_fields( response_value._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.execute_patch_job(request) @@ -5955,6 +5956,7 @@ def test_get_patch_job_rest_required_fields(request_type=patch_jobs.GetPatchJobR response_value._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_patch_job(request) @@ -6000,6 +6002,7 @@ def test_get_patch_job_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_job(**mock_args) @@ -6132,6 +6135,7 @@ def test_cancel_patch_job_rest_required_fields( response_value._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_patch_job(request) @@ -6259,6 +6263,7 @@ def test_list_patch_jobs_rest_required_fields( response_value._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_patch_jobs(request) @@ -6313,6 +6318,7 @@ def test_list_patch_jobs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_jobs(**mock_args) @@ -6518,6 +6524,7 @@ def test_list_patch_job_instance_details_rest_required_fields( response_value._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_patch_job_instance_details(request) @@ -6574,6 +6581,7 @@ def test_list_patch_job_instance_details_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_job_instance_details(**mock_args) @@ -6785,6 +6793,7 @@ def test_create_patch_deployment_rest_required_fields( response_value._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_patch_deployment(request) @@ -6847,6 +6856,7 @@ def test_create_patch_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_deployment(**mock_args) @@ -6983,6 +6993,7 @@ def test_get_patch_deployment_rest_required_fields( response_value._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_patch_deployment(request) @@ -7028,6 +7039,7 @@ def test_get_patch_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_deployment(**mock_args) @@ -7172,6 +7184,7 @@ def test_list_patch_deployments_rest_required_fields( response_value._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_patch_deployments(request) @@ -7225,6 +7238,7 @@ def test_list_patch_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_deployments(**mock_args) @@ -7420,6 +7434,7 @@ def test_delete_patch_deployment_rest_required_fields( response_value._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_patch_deployment(request) @@ -7463,6 +7478,7 @@ def test_delete_patch_deployment_rest_flattened(): 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"} client.delete_patch_deployment(**mock_args) @@ -7596,6 +7612,7 @@ def test_update_patch_deployment_rest_required_fields( response_value._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_patch_deployment(request) @@ -7644,6 +7661,7 @@ def test_update_patch_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_patch_deployment(**mock_args) @@ -7782,6 +7800,7 @@ def test_pause_patch_deployment_rest_required_fields( response_value._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.pause_patch_deployment(request) @@ -7827,6 +7846,7 @@ def test_pause_patch_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_patch_deployment(**mock_args) @@ -7963,6 +7983,7 @@ def test_resume_patch_deployment_rest_required_fields( response_value._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.resume_patch_deployment(request) @@ -8008,6 +8029,7 @@ def test_resume_patch_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_patch_deployment(**mock_args) @@ -8824,6 +8846,7 @@ def test_execute_patch_job_rest_bad_request( 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.execute_patch_job(request) @@ -8866,6 +8889,7 @@ def test_execute_patch_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.execute_patch_job(request) # Establish that the response is the type that we expect. @@ -8913,6 +8937,7 @@ def test_execute_patch_job_rest_interceptors(null_interceptor): 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 = patch_jobs.PatchJob.to_json(patch_jobs.PatchJob()) req.return_value.content = return_value @@ -8955,6 +8980,7 @@ def test_get_patch_job_rest_bad_request(request_type=patch_jobs.GetPatchJobReque 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_patch_job(request) @@ -8997,6 +9023,7 @@ def test_get_patch_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_job(request) # Establish that the response is the type that we expect. @@ -9042,6 +9069,7 @@ def test_get_patch_job_rest_interceptors(null_interceptor): 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 = patch_jobs.PatchJob.to_json(patch_jobs.PatchJob()) req.return_value.content = return_value @@ -9086,6 +9114,7 @@ def test_cancel_patch_job_rest_bad_request( 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.cancel_patch_job(request) @@ -9128,6 +9157,7 @@ def test_cancel_patch_job_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_job(request) # Establish that the response is the type that we expect. @@ -9175,6 +9205,7 @@ def test_cancel_patch_job_rest_interceptors(null_interceptor): 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 = patch_jobs.PatchJob.to_json(patch_jobs.PatchJob()) req.return_value.content = return_value @@ -9217,6 +9248,7 @@ def test_list_patch_jobs_rest_bad_request(request_type=patch_jobs.ListPatchJobsR 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_patch_jobs(request) @@ -9252,6 +9284,7 @@ def test_list_patch_jobs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_jobs(request) # Establish that the response is the type that we expect. @@ -9292,6 +9325,7 @@ def test_list_patch_jobs_rest_interceptors(null_interceptor): 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 = patch_jobs.ListPatchJobsResponse.to_json( patch_jobs.ListPatchJobsResponse() ) @@ -9338,6 +9372,7 @@ def test_list_patch_job_instance_details_rest_bad_request( 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_patch_job_instance_details(request) @@ -9373,6 +9408,7 @@ def test_list_patch_job_instance_details_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_job_instance_details(request) # Establish that the response is the type that we expect. @@ -9414,6 +9450,7 @@ def test_list_patch_job_instance_details_rest_interceptors(null_interceptor): 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 = patch_jobs.ListPatchJobInstanceDetailsResponse.to_json( patch_jobs.ListPatchJobInstanceDetailsResponse() ) @@ -9460,6 +9497,7 @@ def test_create_patch_deployment_rest_bad_request( 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_patch_deployment(request) @@ -9660,6 +9698,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_deployment(request) # Establish that the response is the type that we expect. @@ -9702,6 +9741,7 @@ def test_create_patch_deployment_rest_interceptors(null_interceptor): 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 = patch_deployments.PatchDeployment.to_json( patch_deployments.PatchDeployment() ) @@ -9748,6 +9788,7 @@ def test_get_patch_deployment_rest_bad_request( 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_patch_deployment(request) @@ -9785,6 +9826,7 @@ def test_get_patch_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_deployment(request) # Establish that the response is the type that we expect. @@ -9827,6 +9869,7 @@ def test_get_patch_deployment_rest_interceptors(null_interceptor): 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 = patch_deployments.PatchDeployment.to_json( patch_deployments.PatchDeployment() ) @@ -9873,6 +9916,7 @@ def test_list_patch_deployments_rest_bad_request( 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_patch_deployments(request) @@ -9908,6 +9952,7 @@ def test_list_patch_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_deployments(request) # Establish that the response is the type that we expect. @@ -9948,6 +9993,7 @@ def test_list_patch_deployments_rest_interceptors(null_interceptor): 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 = patch_deployments.ListPatchDeploymentsResponse.to_json( patch_deployments.ListPatchDeploymentsResponse() ) @@ -9994,6 +10040,7 @@ def test_delete_patch_deployment_rest_bad_request( 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_patch_deployment(request) @@ -10024,6 +10071,7 @@ def test_delete_patch_deployment_rest_call_success(request_type): 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_patch_deployment(request) # Establish that the response is the type that we expect. @@ -10060,6 +10108,7 @@ def test_delete_patch_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = patch_deployments.DeletePatchDeploymentRequest() metadata = [ @@ -10102,6 +10151,7 @@ def test_update_patch_deployment_rest_bad_request( 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_patch_deployment(request) @@ -10304,6 +10354,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_patch_deployment(request) # Establish that the response is the type that we expect. @@ -10346,6 +10397,7 @@ def test_update_patch_deployment_rest_interceptors(null_interceptor): 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 = patch_deployments.PatchDeployment.to_json( patch_deployments.PatchDeployment() ) @@ -10392,6 +10444,7 @@ def test_pause_patch_deployment_rest_bad_request( 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.pause_patch_deployment(request) @@ -10429,6 +10482,7 @@ def test_pause_patch_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_patch_deployment(request) # Establish that the response is the type that we expect. @@ -10471,6 +10525,7 @@ def test_pause_patch_deployment_rest_interceptors(null_interceptor): 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 = patch_deployments.PatchDeployment.to_json( patch_deployments.PatchDeployment() ) @@ -10517,6 +10572,7 @@ def test_resume_patch_deployment_rest_bad_request( 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.resume_patch_deployment(request) @@ -10554,6 +10610,7 @@ def test_resume_patch_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_patch_deployment(request) # Establish that the response is the type that we expect. @@ -10596,6 +10653,7 @@ def test_resume_patch_deployment_rest_interceptors(null_interceptor): 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 = patch_deployments.PatchDeployment.to_json( patch_deployments.PatchDeployment() ) diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py index bfedb455d101..204dba80482c 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py @@ -6502,6 +6502,7 @@ def test_create_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -6564,6 +6565,7 @@ def test_create_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -6703,6 +6705,7 @@ def test_update_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -6753,6 +6756,7 @@ def test_update_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -6892,6 +6896,7 @@ def test_get_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -6939,6 +6944,7 @@ def test_get_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -7084,6 +7090,7 @@ def test_list_os_policy_assignments_rest_required_fields( response_value._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_os_policy_assignments(request) @@ -7139,6 +7146,7 @@ def test_list_os_policy_assignments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignments(**mock_args) @@ -7352,6 +7360,7 @@ def test_list_os_policy_assignment_revisions_rest_required_fields( response_value._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_os_policy_assignment_revisions(request) @@ -7411,6 +7420,7 @@ def test_list_os_policy_assignment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_revisions(**mock_args) @@ -7620,6 +7630,7 @@ def test_delete_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -7665,6 +7676,7 @@ def test_delete_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -7803,6 +7815,7 @@ def test_get_os_policy_assignment_report_rest_required_fields( response_value._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_os_policy_assignment_report(request) @@ -7854,6 +7867,7 @@ def test_get_os_policy_assignment_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_report(**mock_args) @@ -8002,6 +8016,7 @@ def test_list_os_policy_assignment_reports_rest_required_fields( response_value._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_os_policy_assignment_reports(request) @@ -8066,6 +8081,7 @@ def test_list_os_policy_assignment_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_reports(**mock_args) @@ -8272,6 +8288,7 @@ def test_get_inventory_rest_required_fields(request_type=inventory.GetInventoryR response_value._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_inventory(request) @@ -8319,6 +8336,7 @@ def test_get_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_inventory(**mock_args) @@ -8461,6 +8479,7 @@ def test_list_inventories_rest_required_fields( response_value._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_inventories(request) @@ -8518,6 +8537,7 @@ def test_list_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_inventories(**mock_args) @@ -8717,6 +8737,7 @@ def test_get_vulnerability_report_rest_required_fields( response_value._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_vulnerability_report(request) @@ -8764,6 +8785,7 @@ def test_get_vulnerability_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vulnerability_report(**mock_args) @@ -8910,6 +8932,7 @@ def test_list_vulnerability_reports_rest_required_fields( response_value._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_vulnerability_reports(request) @@ -8966,6 +8989,7 @@ def test_list_vulnerability_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vulnerability_reports(**mock_args) @@ -9837,6 +9861,7 @@ def test_create_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -10067,6 +10092,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -10110,6 +10136,7 @@ def test_create_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -10158,6 +10185,7 @@ def test_update_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -10392,6 +10420,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -10435,6 +10464,7 @@ def test_update_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -10481,6 +10511,7 @@ def test_get_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -10526,6 +10557,7 @@ def test_get_os_policy_assignment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -10577,6 +10609,7 @@ def test_get_os_policy_assignment_rest_interceptors(null_interceptor): 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 = os_policy_assignments.OSPolicyAssignment.to_json( os_policy_assignments.OSPolicyAssignment() ) @@ -10623,6 +10656,7 @@ def test_list_os_policy_assignments_rest_bad_request( 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_os_policy_assignments(request) @@ -10660,6 +10694,7 @@ def test_list_os_policy_assignments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignments(request) # Establish that the response is the type that we expect. @@ -10701,6 +10736,7 @@ def test_list_os_policy_assignments_rest_interceptors(null_interceptor): 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 = os_policy_assignments.ListOSPolicyAssignmentsResponse.to_json( os_policy_assignments.ListOSPolicyAssignmentsResponse() ) @@ -10749,6 +10785,7 @@ def test_list_os_policy_assignment_revisions_rest_bad_request( 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_os_policy_assignment_revisions(request) @@ -10788,6 +10825,7 @@ def test_list_os_policy_assignment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_revisions(request) # Establish that the response is the type that we expect. @@ -10830,6 +10868,7 @@ def test_list_os_policy_assignment_revisions_rest_interceptors(null_interceptor) 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 = ( os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.to_json( os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse() @@ -10882,6 +10921,7 @@ def test_delete_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -10914,6 +10954,7 @@ def test_delete_os_policy_assignment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -10957,6 +10998,7 @@ def test_delete_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -11003,6 +11045,7 @@ def test_get_os_policy_assignment_report_rest_bad_request( 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_os_policy_assignment_report(request) @@ -11045,6 +11088,7 @@ def test_get_os_policy_assignment_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_report(request) # Establish that the response is the type that we expect. @@ -11090,6 +11134,7 @@ def test_get_os_policy_assignment_report_rest_interceptors(null_interceptor): 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 = os_policy_assignment_reports.OSPolicyAssignmentReport.to_json( os_policy_assignment_reports.OSPolicyAssignmentReport() ) @@ -11138,6 +11183,7 @@ def test_list_os_policy_assignment_reports_rest_bad_request( 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_os_policy_assignment_reports(request) @@ -11181,6 +11227,7 @@ def test_list_os_policy_assignment_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_reports(request) # Establish that the response is the type that we expect. @@ -11225,6 +11272,7 @@ def test_list_os_policy_assignment_reports_rest_interceptors(null_interceptor): 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 = ( os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.to_json( os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse() @@ -11275,6 +11323,7 @@ def test_get_inventory_rest_bad_request(request_type=inventory.GetInventoryReque 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_inventory(request) @@ -11312,6 +11361,7 @@ def test_get_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_inventory(request) # Establish that the response is the type that we expect. @@ -11350,6 +11400,7 @@ def test_get_inventory_rest_interceptors(null_interceptor): 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 = inventory.Inventory.to_json(inventory.Inventory()) req.return_value.content = return_value @@ -11394,6 +11445,7 @@ def test_list_inventories_rest_bad_request( 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_inventories(request) @@ -11429,6 +11481,7 @@ def test_list_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_inventories(request) # Establish that the response is the type that we expect. @@ -11469,6 +11522,7 @@ def test_list_inventories_rest_interceptors(null_interceptor): 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 = inventory.ListInventoriesResponse.to_json( inventory.ListInventoriesResponse() ) @@ -11517,6 +11571,7 @@ def test_get_vulnerability_report_rest_bad_request( 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_vulnerability_report(request) @@ -11554,6 +11609,7 @@ def test_get_vulnerability_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vulnerability_report(request) # Establish that the response is the type that we expect. @@ -11594,6 +11650,7 @@ def test_get_vulnerability_report_rest_interceptors(null_interceptor): 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 = vulnerability.VulnerabilityReport.to_json( vulnerability.VulnerabilityReport() ) @@ -11640,6 +11697,7 @@ def test_list_vulnerability_reports_rest_bad_request( 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_vulnerability_reports(request) @@ -11675,6 +11733,7 @@ def test_list_vulnerability_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vulnerability_reports(request) # Establish that the response is the type that we expect. @@ -11716,6 +11775,7 @@ def test_list_vulnerability_reports_rest_interceptors(null_interceptor): 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 = vulnerability.ListVulnerabilityReportsResponse.to_json( vulnerability.ListVulnerabilityReportsResponse() ) diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py index 7959347c0bd4..aeb30b77eb53 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py @@ -7456,6 +7456,7 @@ def test_create_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -7518,6 +7519,7 @@ def test_create_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -7657,6 +7659,7 @@ def test_update_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -7707,6 +7710,7 @@ def test_update_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -7846,6 +7850,7 @@ def test_get_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -7893,6 +7898,7 @@ def test_get_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -8038,6 +8044,7 @@ def test_list_os_policy_assignments_rest_required_fields( response_value._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_os_policy_assignments(request) @@ -8093,6 +8100,7 @@ def test_list_os_policy_assignments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignments(**mock_args) @@ -8306,6 +8314,7 @@ def test_list_os_policy_assignment_revisions_rest_required_fields( response_value._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_os_policy_assignment_revisions(request) @@ -8365,6 +8374,7 @@ def test_list_os_policy_assignment_revisions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_revisions(**mock_args) @@ -8574,6 +8584,7 @@ def test_delete_os_policy_assignment_rest_required_fields( response_value._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_os_policy_assignment(request) @@ -8619,6 +8630,7 @@ def test_delete_os_policy_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment(**mock_args) @@ -8759,6 +8771,7 @@ def test_get_instance_os_policies_compliance_rest_required_fields( response_value._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_instance_os_policies_compliance(request) @@ -8810,6 +8823,7 @@ def test_get_instance_os_policies_compliance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance_os_policies_compliance(**mock_args) @@ -8964,6 +8978,7 @@ def test_list_instance_os_policies_compliances_rest_required_fields( response_value._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_instance_os_policies_compliances(request) @@ -9024,6 +9039,7 @@ def test_list_instance_os_policies_compliances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance_os_policies_compliances(**mock_args) @@ -9235,6 +9251,7 @@ def test_get_os_policy_assignment_report_rest_required_fields( response_value._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_os_policy_assignment_report(request) @@ -9286,6 +9303,7 @@ def test_get_os_policy_assignment_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_report(**mock_args) @@ -9434,6 +9452,7 @@ def test_list_os_policy_assignment_reports_rest_required_fields( response_value._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_os_policy_assignment_reports(request) @@ -9498,6 +9517,7 @@ def test_list_os_policy_assignment_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_os_policy_assignment_reports(**mock_args) @@ -9704,6 +9724,7 @@ def test_get_inventory_rest_required_fields(request_type=inventory.GetInventoryR response_value._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_inventory(request) @@ -9751,6 +9772,7 @@ def test_get_inventory_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_inventory(**mock_args) @@ -9893,6 +9915,7 @@ def test_list_inventories_rest_required_fields( response_value._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_inventories(request) @@ -9950,6 +9973,7 @@ def test_list_inventories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_inventories(**mock_args) @@ -10149,6 +10173,7 @@ def test_get_vulnerability_report_rest_required_fields( response_value._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_vulnerability_report(request) @@ -10196,6 +10221,7 @@ def test_get_vulnerability_report_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vulnerability_report(**mock_args) @@ -10342,6 +10368,7 @@ def test_list_vulnerability_reports_rest_required_fields( response_value._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_vulnerability_reports(request) @@ -10398,6 +10425,7 @@ def test_list_vulnerability_reports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_vulnerability_reports(**mock_args) @@ -11390,6 +11418,7 @@ def test_create_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -11625,6 +11654,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -11668,6 +11698,7 @@ def test_create_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -11716,6 +11747,7 @@ def test_update_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -11955,6 +11987,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -11998,6 +12031,7 @@ def test_update_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -12044,6 +12078,7 @@ def test_get_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -12089,6 +12124,7 @@ def test_get_os_policy_assignment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -12140,6 +12176,7 @@ def test_get_os_policy_assignment_rest_interceptors(null_interceptor): 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 = os_policy_assignments.OSPolicyAssignment.to_json( os_policy_assignments.OSPolicyAssignment() ) @@ -12186,6 +12223,7 @@ def test_list_os_policy_assignments_rest_bad_request( 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_os_policy_assignments(request) @@ -12223,6 +12261,7 @@ def test_list_os_policy_assignments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignments(request) # Establish that the response is the type that we expect. @@ -12264,6 +12303,7 @@ def test_list_os_policy_assignments_rest_interceptors(null_interceptor): 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 = os_policy_assignments.ListOSPolicyAssignmentsResponse.to_json( os_policy_assignments.ListOSPolicyAssignmentsResponse() ) @@ -12312,6 +12352,7 @@ def test_list_os_policy_assignment_revisions_rest_bad_request( 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_os_policy_assignment_revisions(request) @@ -12351,6 +12392,7 @@ def test_list_os_policy_assignment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_revisions(request) # Establish that the response is the type that we expect. @@ -12393,6 +12435,7 @@ def test_list_os_policy_assignment_revisions_rest_interceptors(null_interceptor) 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 = ( os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse.to_json( os_policy_assignments.ListOSPolicyAssignmentRevisionsResponse() @@ -12445,6 +12488,7 @@ def test_delete_os_policy_assignment_rest_bad_request( 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_os_policy_assignment(request) @@ -12477,6 +12521,7 @@ def test_delete_os_policy_assignment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment(request) # Establish that the response is the type that we expect. @@ -12520,6 +12565,7 @@ def test_delete_os_policy_assignment_rest_interceptors(null_interceptor): 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 @@ -12566,6 +12612,7 @@ def test_get_instance_os_policies_compliance_rest_bad_request( 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_instance_os_policies_compliance(request) @@ -12610,6 +12657,7 @@ def test_get_instance_os_policies_compliance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance_os_policies_compliance(request) # Establish that the response is the type that we expect. @@ -12661,6 +12709,7 @@ def test_get_instance_os_policies_compliance_rest_interceptors(null_interceptor) 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 = ( instance_os_policies_compliance.InstanceOSPoliciesCompliance.to_json( instance_os_policies_compliance.InstanceOSPoliciesCompliance() @@ -12713,6 +12762,7 @@ def test_list_instance_os_policies_compliances_rest_bad_request( 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_instance_os_policies_compliances(request) @@ -12752,6 +12802,7 @@ def test_list_instance_os_policies_compliances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance_os_policies_compliances(request) # Establish that the response is the type that we expect. @@ -12794,6 +12845,7 @@ def test_list_instance_os_policies_compliances_rest_interceptors(null_intercepto 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 = instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse.to_json( instance_os_policies_compliance.ListInstanceOSPoliciesCompliancesResponse() ) @@ -12846,6 +12898,7 @@ def test_get_os_policy_assignment_report_rest_bad_request( 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_os_policy_assignment_report(request) @@ -12888,6 +12941,7 @@ def test_get_os_policy_assignment_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_report(request) # Establish that the response is the type that we expect. @@ -12933,6 +12987,7 @@ def test_get_os_policy_assignment_report_rest_interceptors(null_interceptor): 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 = os_policy_assignment_reports.OSPolicyAssignmentReport.to_json( os_policy_assignment_reports.OSPolicyAssignmentReport() ) @@ -12981,6 +13036,7 @@ def test_list_os_policy_assignment_reports_rest_bad_request( 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_os_policy_assignment_reports(request) @@ -13024,6 +13080,7 @@ def test_list_os_policy_assignment_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_os_policy_assignment_reports(request) # Establish that the response is the type that we expect. @@ -13068,6 +13125,7 @@ def test_list_os_policy_assignment_reports_rest_interceptors(null_interceptor): 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 = ( os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse.to_json( os_policy_assignment_reports.ListOSPolicyAssignmentReportsResponse() @@ -13118,6 +13176,7 @@ def test_get_inventory_rest_bad_request(request_type=inventory.GetInventoryReque 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_inventory(request) @@ -13155,6 +13214,7 @@ def test_get_inventory_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_inventory(request) # Establish that the response is the type that we expect. @@ -13193,6 +13253,7 @@ def test_get_inventory_rest_interceptors(null_interceptor): 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 = inventory.Inventory.to_json(inventory.Inventory()) req.return_value.content = return_value @@ -13237,6 +13298,7 @@ def test_list_inventories_rest_bad_request( 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_inventories(request) @@ -13272,6 +13334,7 @@ def test_list_inventories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_inventories(request) # Establish that the response is the type that we expect. @@ -13312,6 +13375,7 @@ def test_list_inventories_rest_interceptors(null_interceptor): 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 = inventory.ListInventoriesResponse.to_json( inventory.ListInventoriesResponse() ) @@ -13360,6 +13424,7 @@ def test_get_vulnerability_report_rest_bad_request( 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_vulnerability_report(request) @@ -13397,6 +13462,7 @@ def test_get_vulnerability_report_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vulnerability_report(request) # Establish that the response is the type that we expect. @@ -13437,6 +13503,7 @@ def test_get_vulnerability_report_rest_interceptors(null_interceptor): 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 = vulnerability.VulnerabilityReport.to_json( vulnerability.VulnerabilityReport() ) @@ -13483,6 +13550,7 @@ def test_list_vulnerability_reports_rest_bad_request( 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_vulnerability_reports(request) @@ -13518,6 +13586,7 @@ def test_list_vulnerability_reports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_vulnerability_reports(request) # Establish that the response is the type that we expect. @@ -13559,6 +13628,7 @@ def test_list_vulnerability_reports_rest_interceptors(null_interceptor): 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 = vulnerability.ListVulnerabilityReportsResponse.to_json( vulnerability.ListVulnerabilityReportsResponse() ) diff --git a/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py b/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py index c7d2e6b06092..558c8aab67c5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py index c7d2e6b06092..558c8aab67c5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/async_client.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/async_client.py index d3f4d4cc7247..997e490841fc 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/async_client.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, OsLoginServiceTransport from .transports.grpc_asyncio import OsLoginServiceGrpcAsyncIOTransport +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 OsLoginServiceAsyncClient: """Cloud OS Login API @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.oslogin_v1.OsLoginServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "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.oslogin.v1.OsLoginService", + "credentialsType": None, + }, + ) + async def create_ssh_public_key( self, request: Optional[Union[oslogin.CreateSshPublicKeyRequest, dict]] = None, @@ -275,7 +307,7 @@ async def create_ssh_public_key( ssh_public_key: Optional[common.SshPublicKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Create an SSH public key @@ -326,8 +358,10 @@ async def sample_create_ssh_public_key(): 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, 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: google.cloud.oslogin_v1.common.types.SshPublicKey: @@ -390,7 +424,7 @@ async def delete_posix_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a POSIX account. @@ -433,8 +467,10 @@ async def sample_delete_posix_account(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -486,7 +522,7 @@ async def delete_ssh_public_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an SSH public key. @@ -529,8 +565,10 @@ async def sample_delete_ssh_public_key(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -582,7 +620,7 @@ async def get_login_profile( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.LoginProfile: r"""Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine. @@ -627,8 +665,10 @@ async def sample_get_login_profile(): 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, 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: google.cloud.oslogin_v1.types.LoginProfile: @@ -690,7 +730,7 @@ async def get_ssh_public_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Retrieves an SSH public key. @@ -736,8 +776,10 @@ async def sample_get_ssh_public_key(): 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, 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: google.cloud.oslogin_v1.common.types.SshPublicKey: @@ -800,7 +842,7 @@ async def import_ssh_public_key( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.ImportSshPublicKeyResponse: r"""Adds an SSH public key and returns the profile information. Default POSIX account information is set @@ -861,8 +903,10 @@ async def sample_import_ssh_public_key(): 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, 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: google.cloud.oslogin_v1.types.ImportSshPublicKeyResponse: @@ -929,7 +973,7 @@ async def update_ssh_public_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Updates an SSH public key and returns the profile information. This method supports patch semantics. @@ -990,8 +1034,10 @@ async def sample_update_ssh_public_key(): 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, 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: google.cloud.oslogin_v1.common.types.SshPublicKey: diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/client.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/client.py index eaef1d103a71..f29353952e1f 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/client.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.cloud.oslogin_v1.common.types import common @@ -597,6 +607,10 @@ def __init__( # 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( @@ -662,6 +676,29 @@ def __init__( 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.oslogin_v1.OsLoginServiceClient`.", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "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.oslogin.v1.OsLoginService", + "credentialsType": None, + }, + ) + def create_ssh_public_key( self, request: Optional[Union[oslogin.CreateSshPublicKeyRequest, dict]] = None, @@ -670,7 +707,7 @@ def create_ssh_public_key( ssh_public_key: Optional[common.SshPublicKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Create an SSH public key @@ -721,8 +758,10 @@ def sample_create_ssh_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.oslogin_v1.common.types.SshPublicKey: @@ -782,7 +821,7 @@ def delete_posix_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a POSIX account. @@ -825,8 +864,10 @@ def sample_delete_posix_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -875,7 +916,7 @@ def delete_ssh_public_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an SSH public key. @@ -918,8 +959,10 @@ def sample_delete_ssh_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -968,7 +1011,7 @@ def get_login_profile( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.LoginProfile: r"""Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine. @@ -1013,8 +1056,10 @@ def sample_get_login_profile(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.oslogin_v1.types.LoginProfile: @@ -1073,7 +1118,7 @@ def get_ssh_public_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Retrieves an SSH public key. @@ -1119,8 +1164,10 @@ def sample_get_ssh_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.oslogin_v1.common.types.SshPublicKey: @@ -1180,7 +1227,7 @@ def import_ssh_public_key( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.ImportSshPublicKeyResponse: r"""Adds an SSH public key and returns the profile information. Default POSIX account information is set @@ -1241,8 +1288,10 @@ def sample_import_ssh_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.oslogin_v1.types.ImportSshPublicKeyResponse: @@ -1306,7 +1355,7 @@ def update_ssh_public_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Updates an SSH public key and returns the profile information. This method supports patch semantics. @@ -1367,8 +1416,10 @@ def sample_update_ssh_public_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.oslogin_v1.common.types.SshPublicKey: diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py index c039c044aad3..4748cd6419d5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,13 +24,91 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.oslogin_v1.common.types import common from google.cloud.oslogin_v1.types import oslogin from .base import DEFAULT_CLIENT_INFO, OsLoginServiceTransport +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.oslogin.v1.OsLoginService", + "rpcName": 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.oslogin.v1.OsLoginService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsLoginServiceGrpcTransport(OsLoginServiceTransport): """gRPC backend transport for OsLoginService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def create_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ssh_public_key" not in self._stubs: - self._stubs["create_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["create_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey", request_serializer=oslogin.CreateSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -285,7 +371,7 @@ def delete_posix_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_posix_account" not in self._stubs: - self._stubs["delete_posix_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_posix_account"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount", request_serializer=oslogin.DeletePosixAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -311,7 +397,7 @@ def delete_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ssh_public_key" not in self._stubs: - self._stubs["delete_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey", request_serializer=oslogin.DeleteSshPublicKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -338,7 +424,7 @@ def get_login_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_login_profile" not in self._stubs: - self._stubs["get_login_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_login_profile"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/GetLoginProfile", request_serializer=oslogin.GetLoginProfileRequest.serialize, response_deserializer=oslogin.LoginProfile.deserialize, @@ -364,7 +450,7 @@ def get_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ssh_public_key" not in self._stubs: - self._stubs["get_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["get_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/GetSshPublicKey", request_serializer=oslogin.GetSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -395,7 +481,7 @@ def import_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_ssh_public_key" not in self._stubs: - self._stubs["import_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["import_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey", request_serializer=oslogin.ImportSshPublicKeyRequest.serialize, response_deserializer=oslogin.ImportSshPublicKeyResponse.deserialize, @@ -422,7 +508,7 @@ def update_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ssh_public_key" not in self._stubs: - self._stubs["update_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["update_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey", request_serializer=oslogin.UpdateSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -430,7 +516,7 @@ def update_ssh_public_key( return self._stubs["update_ssh_public_key"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py index 0dad331f6072..742736979e91 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.oslogin_v1.common.types import common from google.cloud.oslogin_v1.types import oslogin @@ -32,6 +38,82 @@ from .base import DEFAULT_CLIENT_INFO, OsLoginServiceTransport from .grpc import OsLoginServiceGrpcTransport +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.oslogin.v1.OsLoginService", + "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.oslogin.v1.OsLoginService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OsLoginServiceGrpcAsyncIOTransport(OsLoginServiceTransport): """gRPC AsyncIO backend transport for OsLoginService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def create_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ssh_public_key" not in self._stubs: - self._stubs["create_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["create_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey", request_serializer=oslogin.CreateSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -293,7 +378,7 @@ def delete_posix_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_posix_account" not in self._stubs: - self._stubs["delete_posix_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_posix_account"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount", request_serializer=oslogin.DeletePosixAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -319,7 +404,7 @@ def delete_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ssh_public_key" not in self._stubs: - self._stubs["delete_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey", request_serializer=oslogin.DeleteSshPublicKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -346,7 +431,7 @@ def get_login_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_login_profile" not in self._stubs: - self._stubs["get_login_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_login_profile"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/GetLoginProfile", request_serializer=oslogin.GetLoginProfileRequest.serialize, response_deserializer=oslogin.LoginProfile.deserialize, @@ -372,7 +457,7 @@ def get_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ssh_public_key" not in self._stubs: - self._stubs["get_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["get_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/GetSshPublicKey", request_serializer=oslogin.GetSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -404,7 +489,7 @@ def import_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_ssh_public_key" not in self._stubs: - self._stubs["import_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["import_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey", request_serializer=oslogin.ImportSshPublicKeyRequest.serialize, response_deserializer=oslogin.ImportSshPublicKeyResponse.deserialize, @@ -431,7 +516,7 @@ def update_ssh_public_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ssh_public_key" not in self._stubs: - self._stubs["update_ssh_public_key"] = self.grpc_channel.unary_unary( + self._stubs["update_ssh_public_key"] = self._logged_channel.unary_unary( "/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey", request_serializer=oslogin.UpdateSshPublicKeyRequest.serialize, response_deserializer=common.SshPublicKey.deserialize, @@ -544,7 +629,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/rest.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/rest.py index 9ffc4c72b296..ed3f88558628 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/rest.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -119,8 +127,10 @@ def post_update_ssh_public_key(self, response): def pre_create_ssh_public_key( self, request: oslogin.CreateSshPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.CreateSshPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oslogin.CreateSshPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_ssh_public_key Override in a subclass to manipulate the request or metadata @@ -142,8 +152,10 @@ def post_create_ssh_public_key( def pre_delete_posix_account( self, request: oslogin.DeletePosixAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.DeletePosixAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oslogin.DeletePosixAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_posix_account Override in a subclass to manipulate the request or metadata @@ -154,8 +166,10 @@ def pre_delete_posix_account( def pre_delete_ssh_public_key( self, request: oslogin.DeleteSshPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.DeleteSshPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oslogin.DeleteSshPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_ssh_public_key Override in a subclass to manipulate the request or metadata @@ -166,8 +180,8 @@ def pre_delete_ssh_public_key( def pre_get_login_profile( self, request: oslogin.GetLoginProfileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.GetLoginProfileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[oslogin.GetLoginProfileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_login_profile Override in a subclass to manipulate the request or metadata @@ -189,8 +203,8 @@ def post_get_login_profile( def pre_get_ssh_public_key( self, request: oslogin.GetSshPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.GetSshPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[oslogin.GetSshPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_ssh_public_key Override in a subclass to manipulate the request or metadata @@ -212,8 +226,10 @@ def post_get_ssh_public_key( def pre_import_ssh_public_key( self, request: oslogin.ImportSshPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.ImportSshPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oslogin.ImportSshPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_ssh_public_key Override in a subclass to manipulate the request or metadata @@ -235,8 +251,10 @@ def post_import_ssh_public_key( def pre_update_ssh_public_key( self, request: oslogin.UpdateSshPublicKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oslogin.UpdateSshPublicKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oslogin.UpdateSshPublicKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_ssh_public_key Override in a subclass to manipulate the request or metadata @@ -381,7 +399,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Call the create ssh public key method over HTTP. @@ -392,8 +410,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.SshPublicKey: @@ -405,6 +425,7 @@ def __call__( http_options = ( _BaseOsLoginServiceRestTransport._BaseCreateSshPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_ssh_public_key( request, metadata ) @@ -421,6 +442,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.CreateSshPublicKey", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "CreateSshPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._CreateSshPublicKey._get_response( self._host, @@ -442,7 +490,29 @@ def __call__( pb_resp = common.SshPublicKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ssh_public_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.SshPublicKey.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.oslogin_v1.OsLoginServiceClient.create_ssh_public_key", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "CreateSshPublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePosixAccount( @@ -479,7 +549,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete posix account method over HTTP. @@ -490,13 +560,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseOsLoginServiceRestTransport._BaseDeletePosixAccount._get_http_options() ) + request, metadata = self._interceptor.pre_delete_posix_account( request, metadata ) @@ -509,6 +582,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.DeletePosixAccount", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "DeletePosixAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._DeletePosixAccount._get_response( self._host, @@ -558,7 +658,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete ssh public key method over HTTP. @@ -569,13 +669,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseOsLoginServiceRestTransport._BaseDeleteSshPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_delete_ssh_public_key( request, metadata ) @@ -588,6 +691,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.DeleteSshPublicKey", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "DeleteSshPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._DeleteSshPublicKey._get_response( self._host, @@ -637,7 +767,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.LoginProfile: r"""Call the get login profile method over HTTP. @@ -648,8 +778,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.oslogin.LoginProfile: @@ -662,6 +794,7 @@ def __call__( http_options = ( _BaseOsLoginServiceRestTransport._BaseGetLoginProfile._get_http_options() ) + request, metadata = self._interceptor.pre_get_login_profile( request, metadata ) @@ -674,6 +807,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.GetLoginProfile", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "GetLoginProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._GetLoginProfile._get_response( self._host, @@ -694,7 +854,29 @@ def __call__( pb_resp = oslogin.LoginProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_login_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oslogin.LoginProfile.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.oslogin_v1.OsLoginServiceClient.get_login_profile", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "GetLoginProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSshPublicKey( @@ -731,7 +913,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Call the get ssh public key method over HTTP. @@ -742,8 +924,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.SshPublicKey: @@ -755,6 +939,7 @@ def __call__( http_options = ( _BaseOsLoginServiceRestTransport._BaseGetSshPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_get_ssh_public_key( request, metadata ) @@ -767,6 +952,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.GetSshPublicKey", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "GetSshPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._GetSshPublicKey._get_response( self._host, @@ -787,7 +999,29 @@ def __call__( pb_resp = common.SshPublicKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ssh_public_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.SshPublicKey.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.oslogin_v1.OsLoginServiceClient.get_ssh_public_key", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "GetSshPublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportSshPublicKey( @@ -825,7 +1059,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> oslogin.ImportSshPublicKeyResponse: r"""Call the import ssh public key method over HTTP. @@ -836,8 +1070,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.oslogin.ImportSshPublicKeyResponse: @@ -849,6 +1085,7 @@ def __call__( http_options = ( _BaseOsLoginServiceRestTransport._BaseImportSshPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_import_ssh_public_key( request, metadata ) @@ -865,6 +1102,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.ImportSshPublicKey", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "ImportSshPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._ImportSshPublicKey._get_response( self._host, @@ -886,7 +1150,31 @@ def __call__( pb_resp = oslogin.ImportSshPublicKeyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_ssh_public_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oslogin.ImportSshPublicKeyResponse.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.oslogin_v1.OsLoginServiceClient.import_ssh_public_key", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "ImportSshPublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSshPublicKey( @@ -924,7 +1212,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common.SshPublicKey: r"""Call the update ssh public key method over HTTP. @@ -935,8 +1223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.common.SshPublicKey: @@ -948,6 +1238,7 @@ def __call__( http_options = ( _BaseOsLoginServiceRestTransport._BaseUpdateSshPublicKey._get_http_options() ) + request, metadata = self._interceptor.pre_update_ssh_public_key( request, metadata ) @@ -964,6 +1255,33 @@ def __call__( 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.oslogin_v1.OsLoginServiceClient.UpdateSshPublicKey", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "UpdateSshPublicKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OsLoginServiceRestTransport._UpdateSshPublicKey._get_response( self._host, @@ -985,7 +1303,29 @@ def __call__( pb_resp = common.SshPublicKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_ssh_public_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common.SshPublicKey.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.oslogin_v1.OsLoginServiceClient.update_ssh_public_key", + extra={ + "serviceName": "google.cloud.oslogin.v1.OsLoginService", + "rpcName": "UpdateSshPublicKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json b/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json index 51fdc812ebb0..7e2657df02a7 100644 --- a/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json +++ b/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-os-login", - "version": "2.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_posix_account" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_posix_account" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ssh_public_key" @@ -448,7 +448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ssh_public_key" @@ -526,7 +526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin_v1.types.LoginProfile", @@ -606,7 +606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin_v1.types.LoginProfile", @@ -687,7 +687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", @@ -767,7 +767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin_v1.types.ImportSshPublicKeyResponse", @@ -944,7 +944,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin_v1.types.ImportSshPublicKeyResponse", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", @@ -1121,7 +1121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oslogin.common.types.SshPublicKey", diff --git a/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py b/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py index 89dd5a35107d..d7e554e2740b 100644 --- a/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py +++ b/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py @@ -3623,6 +3623,7 @@ def test_create_ssh_public_key_rest_required_fields( response_value._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_ssh_public_key(request) @@ -3677,6 +3678,7 @@ def test_create_ssh_public_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ssh_public_key(**mock_args) @@ -3808,6 +3810,7 @@ def test_delete_posix_account_rest_required_fields( response_value._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_posix_account(request) @@ -3851,6 +3854,7 @@ def test_delete_posix_account_rest_flattened(): 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"} client.delete_posix_account(**mock_args) @@ -3982,6 +3986,7 @@ def test_delete_ssh_public_key_rest_required_fields( response_value._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_ssh_public_key(request) @@ -4025,6 +4030,7 @@ def test_delete_ssh_public_key_rest_flattened(): 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"} client.delete_ssh_public_key(**mock_args) @@ -4163,6 +4169,7 @@ def test_get_login_profile_rest_required_fields( response_value._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_login_profile(request) @@ -4216,6 +4223,7 @@ def test_get_login_profile_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_login_profile(**mock_args) @@ -4349,6 +4357,7 @@ def test_get_ssh_public_key_rest_required_fields( response_value._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_ssh_public_key(request) @@ -4394,6 +4403,7 @@ def test_get_ssh_public_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ssh_public_key(**mock_args) @@ -4536,6 +4546,7 @@ def test_import_ssh_public_key_rest_required_fields( response_value._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.import_ssh_public_key(request) @@ -4591,6 +4602,7 @@ def test_import_ssh_public_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_ssh_public_key(**mock_args) @@ -4731,6 +4743,7 @@ def test_update_ssh_public_key_rest_required_fields( response_value._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_ssh_public_key(request) @@ -4786,6 +4799,7 @@ def test_update_ssh_public_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ssh_public_key(**mock_args) @@ -5328,6 +5342,7 @@ def test_create_ssh_public_key_rest_bad_request( 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_ssh_public_key(request) @@ -5439,6 +5454,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_ssh_public_key(request) # Establish that the response is the type that we expect. @@ -5482,6 +5498,7 @@ def test_create_ssh_public_key_rest_interceptors(null_interceptor): 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 = common.SshPublicKey.to_json(common.SshPublicKey()) req.return_value.content = return_value @@ -5526,6 +5543,7 @@ def test_delete_posix_account_rest_bad_request( 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_posix_account(request) @@ -5556,6 +5574,7 @@ def test_delete_posix_account_rest_call_success(request_type): 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_posix_account(request) # Establish that the response is the type that we expect. @@ -5592,6 +5611,7 @@ def test_delete_posix_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = oslogin.DeletePosixAccountRequest() metadata = [ @@ -5632,6 +5652,7 @@ def test_delete_ssh_public_key_rest_bad_request( 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_ssh_public_key(request) @@ -5662,6 +5683,7 @@ def test_delete_ssh_public_key_rest_call_success(request_type): 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_ssh_public_key(request) # Establish that the response is the type that we expect. @@ -5698,6 +5720,7 @@ def test_delete_ssh_public_key_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = oslogin.DeleteSshPublicKeyRequest() metadata = [ @@ -5738,6 +5761,7 @@ def test_get_login_profile_rest_bad_request( 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_login_profile(request) @@ -5773,6 +5797,7 @@ def test_get_login_profile_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_login_profile(request) # Establish that the response is the type that we expect. @@ -5811,6 +5836,7 @@ def test_get_login_profile_rest_interceptors(null_interceptor): 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 = oslogin.LoginProfile.to_json(oslogin.LoginProfile()) req.return_value.content = return_value @@ -5855,6 +5881,7 @@ def test_get_ssh_public_key_rest_bad_request( 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_ssh_public_key(request) @@ -5893,6 +5920,7 @@ def test_get_ssh_public_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_ssh_public_key(request) # Establish that the response is the type that we expect. @@ -5934,6 +5962,7 @@ def test_get_ssh_public_key_rest_interceptors(null_interceptor): 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 = common.SshPublicKey.to_json(common.SshPublicKey()) req.return_value.content = return_value @@ -5978,6 +6007,7 @@ def test_import_ssh_public_key_rest_bad_request( 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.import_ssh_public_key(request) @@ -6086,6 +6116,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_ssh_public_key(request) # Establish that the response is the type that we expect. @@ -6126,6 +6157,7 @@ def test_import_ssh_public_key_rest_interceptors(null_interceptor): 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 = oslogin.ImportSshPublicKeyResponse.to_json( oslogin.ImportSshPublicKeyResponse() ) @@ -6172,6 +6204,7 @@ def test_update_ssh_public_key_rest_bad_request( 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_ssh_public_key(request) @@ -6283,6 +6316,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_ssh_public_key(request) # Establish that the response is the type that we expect. @@ -6326,6 +6360,7 @@ def test_update_ssh_public_key_rest_interceptors(null_interceptor): 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 = common.SshPublicKey.to_json(common.SshPublicKey()) req.return_value.content = return_value diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection/gapic_version.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection/gapic_version.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/gapic_version.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/gapic_version.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/async_client.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/async_client.py index dbc87ff76c1e..cab40e5883bf 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/async_client.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ PhishingProtectionServiceV1Beta1GrpcAsyncIOTransport, ) +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 PhishingProtectionServiceV1Beta1AsyncClient: """Service to report phishing URIs.""" @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.phishingprotection_v1beta1.PhishingProtectionServiceV1Beta1AsyncClient`.", + extra={ + "serviceName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "credentialsType": None, + }, + ) + async def report_phishing( self, request: Optional[Union[phishingprotection.ReportPhishingRequest, dict]] = None, @@ -276,7 +308,7 @@ async def report_phishing( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> phishingprotection.ReportPhishingResponse: r"""Reports a URI suspected of containing phishing content to be reviewed. Once the report review is complete, its result can be @@ -337,8 +369,10 @@ async def sample_report_phishing(): 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, 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: google.cloud.phishingprotection_v1beta1.types.ReportPhishingResponse: diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/client.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/client.py index 63678f3c3ceb..83a86c06083b 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/client.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.phishingprotection_v1beta1.types import phishingprotection from .transports.base import ( @@ -572,6 +582,10 @@ def __init__( # 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( @@ -642,6 +656,29 @@ def __init__( 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.phishingprotection_v1beta1.PhishingProtectionServiceV1Beta1Client`.", + extra={ + "serviceName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "credentialsType": None, + }, + ) + def report_phishing( self, request: Optional[Union[phishingprotection.ReportPhishingRequest, dict]] = None, @@ -650,7 +687,7 @@ def report_phishing( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> phishingprotection.ReportPhishingResponse: r"""Reports a URI suspected of containing phishing content to be reviewed. Once the report review is complete, its result can be @@ -711,8 +748,10 @@ def sample_report_phishing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.phishingprotection_v1beta1.types.ReportPhishingResponse: diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py index a502e62d0a3e..664f4d83f2ae 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.phishingprotection_v1beta1.types import phishingprotection from .base import DEFAULT_CLIENT_INFO, PhishingProtectionServiceV1Beta1Transport +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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "rpcName": 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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PhishingProtectionServiceV1Beta1GrpcTransport( PhishingProtectionServiceV1Beta1Transport @@ -181,7 +262,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,7 @@ def report_phishing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_phishing" not in self._stubs: - self._stubs["report_phishing"] = self.grpc_channel.unary_unary( + self._stubs["report_phishing"] = self._logged_channel.unary_unary( "/google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1/ReportPhishing", request_serializer=phishingprotection.ReportPhishingRequest.serialize, response_deserializer=phishingprotection.ReportPhishingResponse.deserialize, @@ -274,7 +360,7 @@ def report_phishing( return self._stubs["report_phishing"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py index fde362f6b51f..59a16e9bd217 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.phishingprotection_v1beta1.types import phishingprotection from .base import DEFAULT_CLIENT_INFO, PhishingProtectionServiceV1Beta1Transport from .grpc import PhishingProtectionServiceV1Beta1GrpcTransport +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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "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.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PhishingProtectionServiceV1Beta1GrpcAsyncIOTransport( PhishingProtectionServiceV1Beta1Transport @@ -228,10 +310,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def report_phishing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_phishing" not in self._stubs: - self._stubs["report_phishing"] = self.grpc_channel.unary_unary( + self._stubs["report_phishing"] = self._logged_channel.unary_unary( "/google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1/ReportPhishing", request_serializer=phishingprotection.ReportPhishingRequest.serialize, response_deserializer=phishingprotection.ReportPhishingResponse.deserialize, @@ -297,7 +382,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/rest.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/rest.py index f0dfb500d92d..9cfcab23d3e4 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/rest.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,11 @@ def post_report_phishing(self, response): def pre_report_phishing( self, request: phishingprotection.ReportPhishingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[phishingprotection.ReportPhishingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + phishingprotection.ReportPhishingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for report_phishing Override in a subclass to manipulate the request or metadata @@ -224,7 +235,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> phishingprotection.ReportPhishingResponse: r"""Call the report phishing method over HTTP. @@ -234,8 +245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.phishingprotection.ReportPhishingResponse: @@ -247,6 +260,7 @@ def __call__( http_options = ( _BasePhishingProtectionServiceV1Beta1RestTransport._BaseReportPhishing._get_http_options() ) + request, metadata = self._interceptor.pre_report_phishing(request, metadata) transcoded_request = _BasePhishingProtectionServiceV1Beta1RestTransport._BaseReportPhishing._get_transcoded_request( http_options, request @@ -261,6 +275,33 @@ def __call__( 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.phishingprotection_v1beta1.PhishingProtectionServiceV1Beta1Client.ReportPhishing", + extra={ + "serviceName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "rpcName": "ReportPhishing", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PhishingProtectionServiceV1Beta1RestTransport._ReportPhishing._get_response( self._host, @@ -282,7 +323,31 @@ def __call__( pb_resp = phishingprotection.ReportPhishingResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_report_phishing(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + phishingprotection.ReportPhishingResponse.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.phishingprotection_v1beta1.PhishingProtectionServiceV1Beta1Client.report_phishing", + extra={ + "serviceName": "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1", + "rpcName": "ReportPhishing", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-phishing-protection/samples/generated_samples/snippet_metadata_google.cloud.phishingprotection.v1beta1.json b/packages/google-cloud-phishing-protection/samples/generated_samples/snippet_metadata_google.cloud.phishingprotection.v1beta1.json index 18e8fed56b57..18460381eb04 100644 --- a/packages/google-cloud-phishing-protection/samples/generated_samples/snippet_metadata_google.cloud.phishingprotection.v1beta1.json +++ b/packages/google-cloud-phishing-protection/samples/generated_samples/snippet_metadata_google.cloud.phishingprotection.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-phishing-protection", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.phishingprotection_v1beta1.types.ReportPhishingResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.phishingprotection_v1beta1.types.ReportPhishingResponse", diff --git a/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py b/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py index 879cf5d039d4..c1a7c97aff17 100644 --- a/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py +++ b/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py @@ -1598,6 +1598,7 @@ def test_report_phishing_rest_required_fields( response_value._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.report_phishing(request) @@ -1652,6 +1653,7 @@ def test_report_phishing_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.report_phishing(**mock_args) @@ -1875,6 +1877,7 @@ def test_report_phishing_rest_bad_request( 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.report_phishing(request) @@ -1908,6 +1911,7 @@ def test_report_phishing_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.report_phishing(request) # Establish that the response is the type that we expect. @@ -1949,6 +1953,7 @@ def test_report_phishing_rest_interceptors(null_interceptor): 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 = phishingprotection.ReportPhishingResponse.to_json( phishingprotection.ReportPhishingResponse() ) diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter/gapic_version.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter/gapic_version.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/gapic_version.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/gapic_version.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/async_client.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/async_client.py index 16a70165f089..ea1a414ac6ba 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/async_client.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, IamCheckerTransport from .transports.grpc_asyncio import IamCheckerGrpcAsyncIOTransport +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 IamCheckerAsyncClient: """IAM Policy Troubleshooter service. @@ -251,13 +261,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.policytroubleshooter_v1.IamCheckerAsyncClient`.", + extra={ + "serviceName": "google.cloud.policytroubleshooter.v1.IamChecker", + "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.policytroubleshooter.v1.IamChecker", + "credentialsType": None, + }, + ) + async def troubleshoot_iam_policy( self, request: Optional[Union[checker.TroubleshootIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> checker.TroubleshootIamPolicyResponse: r"""Checks whether a principal has a specific permission for a specific resource, and explains why the principal @@ -295,8 +327,10 @@ async def sample_troubleshoot_iam_policy(): 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, 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: google.cloud.policytroubleshooter_v1.types.TroubleshootIamPolicyResponse: diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/client.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/client.py index 8de6f3d62d51..7b4813324e3a 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/client.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.rpc import status_pb2 # type: ignore from google.cloud.policytroubleshooter_v1.types import checker, explanations @@ -559,6 +569,10 @@ def __init__( # 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( @@ -621,13 +635,36 @@ def __init__( 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.policytroubleshooter_v1.IamCheckerClient`.", + extra={ + "serviceName": "google.cloud.policytroubleshooter.v1.IamChecker", + "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.policytroubleshooter.v1.IamChecker", + "credentialsType": None, + }, + ) + def troubleshoot_iam_policy( self, request: Optional[Union[checker.TroubleshootIamPolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> checker.TroubleshootIamPolicyResponse: r"""Checks whether a principal has a specific permission for a specific resource, and explains why the principal @@ -665,8 +702,10 @@ def sample_troubleshoot_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.policytroubleshooter_v1.types.TroubleshootIamPolicyResponse: diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py index c89ebf478473..0783f5eaaa9d 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.policytroubleshooter_v1.types import checker from .base import DEFAULT_CLIENT_INFO, IamCheckerTransport +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.policytroubleshooter.v1.IamChecker", + "rpcName": 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.policytroubleshooter.v1.IamChecker", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IamCheckerGrpcTransport(IamCheckerTransport): """gRPC backend transport for IamChecker. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +346,7 @@ def troubleshoot_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "troubleshoot_iam_policy" not in self._stubs: - self._stubs["troubleshoot_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["troubleshoot_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.policytroubleshooter.v1.IamChecker/TroubleshootIamPolicy", request_serializer=checker.TroubleshootIamPolicyRequest.serialize, response_deserializer=checker.TroubleshootIamPolicyResponse.deserialize, @@ -268,7 +354,7 @@ def troubleshoot_iam_policy( return self._stubs["troubleshoot_iam_policy"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py index 3561b9e2026e..6c210723d261 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.policytroubleshooter_v1.types import checker from .base import DEFAULT_CLIENT_INFO, IamCheckerTransport from .grpc import IamCheckerGrpcTransport +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.policytroubleshooter.v1.IamChecker", + "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.policytroubleshooter.v1.IamChecker", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IamCheckerGrpcAsyncIOTransport(IamCheckerTransport): """gRPC AsyncIO backend transport for IamChecker. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def troubleshoot_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "troubleshoot_iam_policy" not in self._stubs: - self._stubs["troubleshoot_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["troubleshoot_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.policytroubleshooter.v1.IamChecker/TroubleshootIamPolicy", request_serializer=checker.TroubleshootIamPolicyRequest.serialize, response_deserializer=checker.TroubleshootIamPolicyResponse.deserialize, @@ -292,7 +377,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/rest.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/rest.py index c84a6ae8466a..90722d7080de 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/rest.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,10 @@ def post_troubleshoot_iam_policy(self, response): def pre_troubleshoot_iam_policy( self, request: checker.TroubleshootIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[checker.TroubleshootIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + checker.TroubleshootIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for troubleshoot_iam_policy Override in a subclass to manipulate the request or metadata @@ -222,7 +232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> checker.TroubleshootIamPolicyResponse: r"""Call the troubleshoot iam policy method over HTTP. @@ -233,8 +243,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.checker.TroubleshootIamPolicyResponse: @@ -246,6 +258,7 @@ def __call__( http_options = ( _BaseIamCheckerRestTransport._BaseTroubleshootIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_troubleshoot_iam_policy( request, metadata ) @@ -262,6 +275,33 @@ def __call__( 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.policytroubleshooter_v1.IamCheckerClient.TroubleshootIamPolicy", + extra={ + "serviceName": "google.cloud.policytroubleshooter.v1.IamChecker", + "rpcName": "TroubleshootIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IamCheckerRestTransport._TroubleshootIamPolicy._get_response( self._host, @@ -283,7 +323,31 @@ def __call__( pb_resp = checker.TroubleshootIamPolicyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_troubleshoot_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = checker.TroubleshootIamPolicyResponse.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.policytroubleshooter_v1.IamCheckerClient.troubleshoot_iam_policy", + extra={ + "serviceName": "google.cloud.policytroubleshooter.v1.IamChecker", + "rpcName": "TroubleshootIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-policy-troubleshooter/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.v1.json b/packages/google-cloud-policy-troubleshooter/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.v1.json index d5a69310b8ab..24a7fb5b901c 100644 --- a/packages/google-cloud-policy-troubleshooter/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.v1.json +++ b/packages/google-cloud-policy-troubleshooter/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-policy-troubleshooter", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policytroubleshooter_v1.types.TroubleshootIamPolicyResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policytroubleshooter_v1.types.TroubleshootIamPolicyResponse", diff --git a/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py b/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py index c58aad91cc79..de24ce06f458 100644 --- a/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py +++ b/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py @@ -1447,6 +1447,7 @@ def test_troubleshoot_iam_policy_rest_bad_request( 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.troubleshoot_iam_policy(request) @@ -1482,6 +1483,7 @@ def test_troubleshoot_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.troubleshoot_iam_policy(request) # Establish that the response is the type that we expect. @@ -1522,6 +1524,7 @@ def test_troubleshoot_iam_policy_rest_interceptors(null_interceptor): 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 = checker.TroubleshootIamPolicyResponse.to_json( checker.TroubleshootIamPolicyResponse() ) diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator/gapic_version.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator/gapic_version.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/gapic_version.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/gapic_version.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/async_client.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/async_client.py index 55c1eefd489a..08ab0d089932 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/async_client.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SimulatorTransport from .transports.grpc_asyncio import SimulatorGrpcAsyncIOTransport +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 SimulatorAsyncClient: """Policy Simulator API service. @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.policysimulator_v1.SimulatorAsyncClient`.", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "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.policysimulator.v1.Simulator", + "credentialsType": None, + }, + ) + async def get_replay( self, request: Optional[Union[simulator.GetReplayRequest, dict]] = None, @@ -274,7 +306,7 @@ async def get_replay( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulator.Replay: r"""Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each @@ -328,8 +360,10 @@ async def sample_get_replay(): 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, 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: google.cloud.policysimulator_v1.types.Replay: @@ -389,7 +423,7 @@ async def create_replay( replay: Optional[simulator.Replay] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given @@ -453,8 +487,10 @@ async def sample_create_replay(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -528,7 +564,7 @@ async def list_replay_results( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReplayResultsAsyncPager: r"""Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay]. @@ -580,8 +616,10 @@ async def sample_list_replay_results(): 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, 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: google.cloud.policysimulator_v1.services.simulator.pagers.ListReplayResultsAsyncPager: @@ -655,7 +693,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -666,8 +704,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -708,7 +748,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -719,8 +759,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/client.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/client.py index 5106ff800f25..b0f78f897d30 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/client.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -617,6 +627,10 @@ def __init__( # 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( @@ -679,6 +693,29 @@ def __init__( 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.policysimulator_v1.SimulatorClient`.", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "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.policysimulator.v1.Simulator", + "credentialsType": None, + }, + ) + def get_replay( self, request: Optional[Union[simulator.GetReplayRequest, dict]] = None, @@ -686,7 +723,7 @@ def get_replay( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulator.Replay: r"""Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each @@ -740,8 +777,10 @@ def sample_get_replay(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.policysimulator_v1.types.Replay: @@ -798,7 +837,7 @@ def create_replay( replay: Optional[simulator.Replay] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given @@ -862,8 +901,10 @@ def sample_create_replay(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -934,7 +975,7 @@ def list_replay_results( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReplayResultsPager: r"""Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay]. @@ -986,8 +1027,10 @@ def sample_list_replay_results(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.policysimulator_v1.services.simulator.pagers.ListReplayResultsPager: @@ -1071,7 +1114,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1082,8 +1125,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1124,7 +1169,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1135,8 +1180,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/pagers.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/pagers.py index b5a674919b2d..f2b980adda58 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/pagers.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = simulator.ListReplayResultsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = simulator.ListReplayResultsRequest(request) diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py index 155223150c30..b918bac76323 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.policysimulator_v1.types import simulator from .base import DEFAULT_CLIENT_INFO, SimulatorTransport +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.policysimulator.v1.Simulator", + "rpcName": 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.policysimulator.v1.Simulator", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SimulatorGrpcTransport(SimulatorTransport): """gRPC backend transport for Simulator. @@ -193,7 +274,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def get_replay(self) -> Callable[[simulator.GetReplayRequest], simulator.Replay] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replay" not in self._stubs: - self._stubs["get_replay"] = self.grpc_channel.unary_unary( + self._stubs["get_replay"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/GetReplay", request_serializer=simulator.GetReplayRequest.serialize, response_deserializer=simulator.Replay.deserialize, @@ -309,7 +397,7 @@ def create_replay( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_replay" not in self._stubs: - self._stubs["create_replay"] = self.grpc_channel.unary_unary( + self._stubs["create_replay"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/CreateReplay", request_serializer=simulator.CreateReplayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -338,7 +426,7 @@ def list_replay_results( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replay_results" not in self._stubs: - self._stubs["list_replay_results"] = self.grpc_channel.unary_unary( + self._stubs["list_replay_results"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/ListReplayResults", request_serializer=simulator.ListReplayResultsRequest.serialize, response_deserializer=simulator.ListReplayResultsResponse.deserialize, @@ -346,7 +434,7 @@ def list_replay_results( return self._stubs["list_replay_results"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -358,7 +446,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -377,7 +465,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py index 4bda0d77dc28..7dcbbb9d7695 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.policysimulator_v1.types import simulator from .base import DEFAULT_CLIENT_INFO, SimulatorTransport from .grpc import SimulatorGrpcTransport +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.policysimulator.v1.Simulator", + "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.policysimulator.v1.Simulator", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SimulatorGrpcAsyncIOTransport(SimulatorTransport): """gRPC AsyncIO backend transport for Simulator. @@ -240,10 +322,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +351,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -293,7 +378,7 @@ def get_replay( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_replay" not in self._stubs: - self._stubs["get_replay"] = self.grpc_channel.unary_unary( + self._stubs["get_replay"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/GetReplay", request_serializer=simulator.GetReplayRequest.serialize, response_deserializer=simulator.Replay.deserialize, @@ -321,7 +406,7 @@ def create_replay( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_replay" not in self._stubs: - self._stubs["create_replay"] = self.grpc_channel.unary_unary( + self._stubs["create_replay"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/CreateReplay", request_serializer=simulator.CreateReplayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -351,7 +436,7 @@ def list_replay_results( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_replay_results" not in self._stubs: - self._stubs["list_replay_results"] = self.grpc_channel.unary_unary( + self._stubs["list_replay_results"] = self._logged_channel.unary_unary( "/google.cloud.policysimulator.v1.Simulator/ListReplayResults", request_serializer=simulator.ListReplayResultsRequest.serialize, response_deserializer=simulator.ListReplayResultsResponse.deserialize, @@ -412,7 +497,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -428,7 +513,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -447,7 +532,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/rest.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/rest.py index d194f4187e37..a33fc9056af4 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/rest.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -94,8 +102,8 @@ def post_list_replay_results(self, response): def pre_create_replay( self, request: simulator.CreateReplayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[simulator.CreateReplayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[simulator.CreateReplayRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_replay Override in a subclass to manipulate the request or metadata @@ -115,8 +123,10 @@ def post_create_replay( return response def pre_get_replay( - self, request: simulator.GetReplayRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[simulator.GetReplayRequest, Sequence[Tuple[str, str]]]: + self, + request: simulator.GetReplayRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[simulator.GetReplayRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_replay Override in a subclass to manipulate the request or metadata @@ -136,8 +146,10 @@ def post_get_replay(self, response: simulator.Replay) -> simulator.Replay: def pre_list_replay_results( self, request: simulator.ListReplayResultsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[simulator.ListReplayResultsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + simulator.ListReplayResultsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_replay_results Override in a subclass to manipulate the request or metadata @@ -159,8 +171,10 @@ def post_list_replay_results( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -182,8 +196,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -401,7 +417,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create replay method over HTTP. @@ -412,8 +428,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -426,6 +444,7 @@ def __call__( http_options = ( _BaseSimulatorRestTransport._BaseCreateReplay._get_http_options() ) + request, metadata = self._interceptor.pre_create_replay(request, metadata) transcoded_request = ( _BaseSimulatorRestTransport._BaseCreateReplay._get_transcoded_request( @@ -444,6 +463,33 @@ def __call__( ) ) + 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.policysimulator_v1.SimulatorClient.CreateReplay", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "CreateReplay", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SimulatorRestTransport._CreateReplay._get_response( self._host, @@ -463,7 +509,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_replay(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.policysimulator_v1.SimulatorClient.create_replay", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "CreateReplay", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReplay(_BaseSimulatorRestTransport._BaseGetReplay, SimulatorRestStub): @@ -498,7 +566,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulator.Replay: r"""Call the get replay method over HTTP. @@ -509,8 +577,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.simulator.Replay: @@ -520,6 +590,7 @@ def __call__( http_options = ( _BaseSimulatorRestTransport._BaseGetReplay._get_http_options() ) + request, metadata = self._interceptor.pre_get_replay(request, metadata) transcoded_request = ( _BaseSimulatorRestTransport._BaseGetReplay._get_transcoded_request( @@ -534,6 +605,33 @@ def __call__( ) ) + 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.policysimulator_v1.SimulatorClient.GetReplay", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "GetReplay", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SimulatorRestTransport._GetReplay._get_response( self._host, @@ -554,7 +652,29 @@ def __call__( pb_resp = simulator.Replay.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_replay(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = simulator.Replay.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.policysimulator_v1.SimulatorClient.get_replay", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "GetReplay", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReplayResults( @@ -591,7 +711,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> simulator.ListReplayResultsResponse: r"""Call the list replay results method over HTTP. @@ -602,8 +722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.simulator.ListReplayResultsResponse: @@ -615,6 +737,7 @@ def __call__( http_options = ( _BaseSimulatorRestTransport._BaseListReplayResults._get_http_options() ) + request, metadata = self._interceptor.pre_list_replay_results( request, metadata ) @@ -627,6 +750,33 @@ def __call__( 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.policysimulator_v1.SimulatorClient.ListReplayResults", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "ListReplayResults", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SimulatorRestTransport._ListReplayResults._get_response( self._host, @@ -647,7 +797,31 @@ def __call__( pb_resp = simulator.ListReplayResultsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_replay_results(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = simulator.ListReplayResultsResponse.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.policysimulator_v1.SimulatorClient.list_replay_results", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "ListReplayResults", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -712,7 +886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -722,8 +896,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -732,6 +908,7 @@ def __call__( http_options = ( _BaseSimulatorRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSimulatorRestTransport._BaseGetOperation._get_transcoded_request( @@ -746,6 +923,33 @@ def __call__( ) ) + 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.policysimulator_v1.SimulatorClient.GetOperation", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SimulatorRestTransport._GetOperation._get_response( self._host, @@ -765,6 +969,27 @@ def __call__( 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.policysimulator_v1.SimulatorAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -805,7 +1030,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -815,8 +1040,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -825,6 +1052,7 @@ def __call__( http_options = ( _BaseSimulatorRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSimulatorRestTransport._BaseListOperations._get_transcoded_request( @@ -839,6 +1067,33 @@ def __call__( ) ) + 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.policysimulator_v1.SimulatorClient.ListOperations", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SimulatorRestTransport._ListOperations._get_response( self._host, @@ -858,6 +1113,27 @@ def __call__( 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.policysimulator_v1.SimulatorAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.policysimulator.v1.Simulator", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-policysimulator/samples/generated_samples/snippet_metadata_google.cloud.policysimulator.v1.json b/packages/google-cloud-policysimulator/samples/generated_samples/snippet_metadata_google.cloud.policysimulator.v1.json index 602d543b880d..a6025abb1eff 100644 --- a/packages/google-cloud-policysimulator/samples/generated_samples/snippet_metadata_google.cloud.policysimulator.v1.json +++ b/packages/google-cloud-policysimulator/samples/generated_samples/snippet_metadata_google.cloud.policysimulator.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-policysimulator", - "version": "0.1.10" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policysimulator_v1.types.Replay", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policysimulator_v1.types.Replay", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policysimulator_v1.services.simulator.pagers.ListReplayResultsAsyncPager", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policysimulator_v1.services.simulator.pagers.ListReplayResultsPager", diff --git a/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py b/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py index 978b0c0036c1..f480031f602e 100644 --- a/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py +++ b/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py @@ -2331,6 +2331,7 @@ def test_get_replay_rest_required_fields(request_type=simulator.GetReplayRequest response_value._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_replay(request) @@ -2376,6 +2377,7 @@ def test_get_replay_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_replay(**mock_args) @@ -2506,6 +2508,7 @@ def test_create_replay_rest_required_fields(request_type=simulator.CreateReplayR response_value._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_replay(request) @@ -2558,6 +2561,7 @@ def test_create_replay_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_replay(**mock_args) @@ -2700,6 +2704,7 @@ def test_list_replay_results_rest_required_fields( response_value._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_replay_results(request) @@ -2755,6 +2760,7 @@ def test_list_replay_results_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_replay_results(**mock_args) @@ -3142,6 +3148,7 @@ def test_get_replay_rest_bad_request(request_type=simulator.GetReplayRequest): 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_replay(request) @@ -3178,6 +3185,7 @@ def test_get_replay_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_replay(request) # Establish that the response is the type that we expect. @@ -3215,6 +3223,7 @@ def test_get_replay_rest_interceptors(null_interceptor): 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 = simulator.Replay.to_json(simulator.Replay()) req.return_value.content = return_value @@ -3257,6 +3266,7 @@ def test_create_replay_rest_bad_request(request_type=simulator.CreateReplayReque 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_replay(request) @@ -3367,6 +3377,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_replay(request) # Establish that the response is the type that we expect. @@ -3404,6 +3415,7 @@ def test_create_replay_rest_interceptors(null_interceptor): 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 @@ -3448,6 +3460,7 @@ def test_list_replay_results_rest_bad_request( 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_replay_results(request) @@ -3483,6 +3496,7 @@ def test_list_replay_results_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_replay_results(request) # Establish that the response is the type that we expect. @@ -3521,6 +3535,7 @@ def test_list_replay_results_rest_interceptors(null_interceptor): 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 = simulator.ListReplayResultsResponse.to_json( simulator.ListReplayResultsResponse() ) @@ -3567,6 +3582,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3597,6 +3613,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -3625,6 +3642,7 @@ def test_list_operations_rest_bad_request( 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) @@ -3655,6 +3673,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam/gapic_version.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam/gapic_version.py index f8ea948a9c30..558c8aab67c5 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam/gapic_version.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.9" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/gapic_version.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/gapic_version.py index f8ea948a9c30..558c8aab67c5 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/gapic_version.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.9" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/async_client.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/async_client.py index 5911aff64219..747c37a13c4e 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/async_client.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PolicyTroubleshooterTransport from .transports.grpc_asyncio import PolicyTroubleshooterGrpcAsyncIOTransport +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 PolicyTroubleshooterAsyncClient: """IAM Policy Troubleshooter service. @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.policytroubleshooter.iam_v3.PolicyTroubleshooterAsyncClient`.", + extra={ + "serviceName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "credentialsType": None, + }, + ) + async def troubleshoot_iam_policy( self, request: Optional[ @@ -267,7 +299,7 @@ async def troubleshoot_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> troubleshooter.TroubleshootIamPolicyResponse: r"""Checks whether a principal has a specific permission for a specific resource, and explains why the principal @@ -305,8 +337,10 @@ async def sample_troubleshoot_iam_policy(): 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, 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: google.cloud.policytroubleshooter_iam_v3.types.TroubleshootIamPolicyResponse: diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/client.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/client.py index affefcd994e9..0686abdd9876 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/client.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.policytroubleshooter_iam_v3.types import troubleshooter from .transports.base import DEFAULT_CLIENT_INFO, PolicyTroubleshooterTransport @@ -563,6 +573,10 @@ def __init__( # 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( @@ -629,6 +643,29 @@ def __init__( 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.policytroubleshooter.iam_v3.PolicyTroubleshooterClient`.", + extra={ + "serviceName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "credentialsType": None, + }, + ) + def troubleshoot_iam_policy( self, request: Optional[ @@ -637,7 +674,7 @@ def troubleshoot_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> troubleshooter.TroubleshootIamPolicyResponse: r"""Checks whether a principal has a specific permission for a specific resource, and explains why the principal @@ -675,8 +712,10 @@ def sample_troubleshoot_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.policytroubleshooter_iam_v3.types.TroubleshootIamPolicyResponse: diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py index b6199bf0aee5..1ee43ff1d2f4 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.policytroubleshooter_iam_v3.types import troubleshooter from .base import DEFAULT_CLIENT_INFO, PolicyTroubleshooterTransport +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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "rpcName": 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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PolicyTroubleshooterGrpcTransport(PolicyTroubleshooterTransport): """gRPC backend transport for PolicyTroubleshooter. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,7 @@ def troubleshoot_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "troubleshoot_iam_policy" not in self._stubs: - self._stubs["troubleshoot_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["troubleshoot_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter/TroubleshootIamPolicy", request_serializer=troubleshooter.TroubleshootIamPolicyRequest.serialize, response_deserializer=troubleshooter.TroubleshootIamPolicyResponse.deserialize, @@ -269,7 +355,7 @@ def troubleshoot_iam_policy( return self._stubs["troubleshoot_iam_policy"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py index c489df56b809..2ff8ce911955 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.policytroubleshooter_iam_v3.types import troubleshooter from .base import DEFAULT_CLIENT_INFO, PolicyTroubleshooterTransport from .grpc import PolicyTroubleshooterGrpcTransport +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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "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.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PolicyTroubleshooterGrpcAsyncIOTransport(PolicyTroubleshooterTransport): """gRPC AsyncIO backend transport for PolicyTroubleshooter. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -269,7 +354,7 @@ def troubleshoot_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "troubleshoot_iam_policy" not in self._stubs: - self._stubs["troubleshoot_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["troubleshoot_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter/TroubleshootIamPolicy", request_serializer=troubleshooter.TroubleshootIamPolicyRequest.serialize, response_deserializer=troubleshooter.TroubleshootIamPolicyResponse.deserialize, @@ -301,7 +386,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/rest.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/rest.py index 04fd56e17677..b86635758a38 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/rest.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,11 @@ def post_troubleshoot_iam_policy(self, response): def pre_troubleshoot_iam_policy( self, request: troubleshooter.TroubleshootIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[troubleshooter.TroubleshootIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + troubleshooter.TroubleshootIamPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for troubleshoot_iam_policy Override in a subclass to manipulate the request or metadata @@ -223,7 +234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> troubleshooter.TroubleshootIamPolicyResponse: r"""Call the troubleshoot iam policy method over HTTP. @@ -234,8 +245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.troubleshooter.TroubleshootIamPolicyResponse: @@ -247,6 +260,7 @@ def __call__( http_options = ( _BasePolicyTroubleshooterRestTransport._BaseTroubleshootIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_troubleshoot_iam_policy( request, metadata ) @@ -263,6 +277,33 @@ def __call__( 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.policytroubleshooter.iam_v3.PolicyTroubleshooterClient.TroubleshootIamPolicy", + extra={ + "serviceName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "rpcName": "TroubleshootIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PolicyTroubleshooterRestTransport._TroubleshootIamPolicy._get_response( @@ -286,7 +327,31 @@ def __call__( pb_resp = troubleshooter.TroubleshootIamPolicyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_troubleshoot_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + troubleshooter.TroubleshootIamPolicyResponse.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.policytroubleshooter.iam_v3.PolicyTroubleshooterClient.troubleshoot_iam_policy", + extra={ + "serviceName": "google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter", + "rpcName": "TroubleshootIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-policytroubleshooter-iam/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json b/packages/google-cloud-policytroubleshooter-iam/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json index 4e1fac93718b..3ec65c7e8d34 100644 --- a/packages/google-cloud-policytroubleshooter-iam/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json +++ b/packages/google-cloud-policytroubleshooter-iam/samples/generated_samples/snippet_metadata_google.cloud.policytroubleshooter.iam.v3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-policytroubleshooter-iam", - "version": "0.1.9" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policytroubleshooter_iam_v3.types.TroubleshootIamPolicyResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.policytroubleshooter_iam_v3.types.TroubleshootIamPolicyResponse", diff --git a/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py b/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py index d4951d6a8e28..ba1ad796eeec 100644 --- a/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py +++ b/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py @@ -1555,6 +1555,7 @@ def test_troubleshoot_iam_policy_rest_bad_request( 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.troubleshoot_iam_policy(request) @@ -1590,6 +1591,7 @@ def test_troubleshoot_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.troubleshoot_iam_policy(request) # Establish that the response is the type that we expect. @@ -1633,6 +1635,7 @@ def test_troubleshoot_iam_policy_rest_interceptors(null_interceptor): 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 = troubleshooter.TroubleshootIamPolicyResponse.to_json( troubleshooter.TroubleshootIamPolicyResponse() ) diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca/gapic_version.py b/packages/google-cloud-private-ca/google/cloud/security/privateca/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca/gapic_version.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/gapic_version.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/gapic_version.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py index 46e642f28c84..177a504a6318 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -62,6 +63,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport +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 CertificateAuthorityServiceAsyncClient: """[Certificate Authority @@ -306,6 +316,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.security.privateca_v1.CertificateAuthorityServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "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.security.privateca.v1.CertificateAuthorityService", + "credentialsType": None, + }, + ) + async def create_certificate( self, request: Optional[Union[service.CreateCertificateRequest, dict]] = None, @@ -315,7 +347,7 @@ async def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Create a new [Certificate][google.cloud.security.privateca.v1.Certificate] in @@ -388,8 +420,10 @@ async def sample_create_certificate(): 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, 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: google.cloud.security.privateca_v1.types.Certificate: @@ -455,7 +489,7 @@ async def get_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Returns a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -503,8 +537,10 @@ async def sample_get_certificate(): 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, 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: google.cloud.security.privateca_v1.types.Certificate: @@ -566,7 +602,7 @@ async def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesAsyncPager: r"""Lists [Certificates][google.cloud.security.privateca.v1.Certificate]. @@ -614,8 +650,10 @@ async def sample_list_certificates(): 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, 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: @@ -690,7 +728,7 @@ async def revoke_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Revoke a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -738,8 +776,10 @@ async def sample_revoke_certificate(): 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, 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: google.cloud.security.privateca_v1.types.Certificate: @@ -802,7 +842,7 @@ async def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Update a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -861,8 +901,10 @@ async def sample_update_certificate(): 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, 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: google.cloud.security.privateca_v1.types.Certificate: @@ -930,7 +972,7 @@ async def activate_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Activate a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -994,8 +1036,10 @@ async def sample_activate_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1074,7 +1118,7 @@ async def create_certificate_authority( certificate_authority_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1148,8 +1192,10 @@ async def sample_create_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1232,7 +1278,7 @@ async def disable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Disable a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1283,8 +1329,10 @@ async def sample_disable_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1361,7 +1409,7 @@ async def enable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enable a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1412,8 +1460,10 @@ async def sample_enable_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1490,7 +1540,7 @@ async def fetch_certificate_authority_csr( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Fetch a certificate signing request (CSR) from a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1546,8 +1596,10 @@ async def sample_fetch_certificate_authority_csr(): 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, 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: google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: @@ -1608,7 +1660,7 @@ async def get_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Returns a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1656,8 +1708,10 @@ async def sample_get_certificate_authority(): 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, 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: google.cloud.security.privateca_v1.types.CertificateAuthority: @@ -1724,7 +1778,7 @@ async def list_certificate_authorities( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateAuthoritiesAsyncPager: r"""Lists [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1773,8 +1827,10 @@ async def sample_list_certificate_authorities(): 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, 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: @@ -1851,7 +1907,7 @@ async def undelete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undelete a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1903,8 +1959,10 @@ async def sample_undelete_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1981,7 +2039,7 @@ async def delete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2032,8 +2090,10 @@ async def sample_delete_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2111,7 +2171,7 @@ async def update_certificate_authority( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2172,8 +2232,10 @@ async def sample_update_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2254,7 +2316,7 @@ async def create_ca_pool( ca_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2324,8 +2386,10 @@ async def sample_create_ca_pool(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2408,7 +2472,7 @@ async def update_ca_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2467,8 +2531,10 @@ async def sample_update_ca_pool(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2550,7 +2616,7 @@ async def get_ca_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CaPool: r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2597,8 +2663,10 @@ async def sample_get_ca_pool(): 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, 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: google.cloud.security.privateca_v1.types.CaPool: @@ -2666,7 +2734,7 @@ async def list_ca_pools( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCaPoolsAsyncPager: r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. @@ -2713,8 +2781,10 @@ async def sample_list_ca_pools(): 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, 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsAsyncPager: @@ -2789,7 +2859,7 @@ async def delete_ca_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2838,8 +2908,10 @@ async def sample_delete_ca_pool(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2918,7 +2990,7 @@ async def fetch_ca_certs( ca_pool: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCaCertsResponse: r"""FetchCaCerts returns the current trust anchor for the [CaPool][google.cloud.security.privateca.v1.CaPool]. This will @@ -2966,8 +3038,10 @@ async def sample_fetch_ca_certs(): 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, 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: google.cloud.security.privateca_v1.types.FetchCaCertsResponse: @@ -3030,7 +3104,7 @@ async def get_certificate_revocation_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Returns a [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3078,8 +3152,10 @@ async def sample_get_certificate_revocation_list(): 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, 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: google.cloud.security.privateca_v1.types.CertificateRevocationList: @@ -3145,7 +3221,7 @@ async def list_certificate_revocation_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateRevocationListsAsyncPager: r"""Lists [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3194,8 +3270,10 @@ async def sample_list_certificate_revocation_lists(): 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, 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: @@ -3275,7 +3353,7 @@ async def update_certificate_revocation_list( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3331,8 +3409,10 @@ async def sample_update_certificate_revocation_list(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3417,7 +3497,7 @@ async def create_certificate_template( certificate_template_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] @@ -3485,8 +3565,10 @@ async def sample_create_certificate_template(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3565,7 +3647,7 @@ async def delete_certificate_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""DeleteCertificateTemplate deletes a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -3616,8 +3698,10 @@ async def sample_delete_certificate_template(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -3696,7 +3780,7 @@ async def get_certificate_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateTemplate: r"""Returns a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -3744,8 +3828,10 @@ async def sample_get_certificate_template(): 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, 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: google.cloud.security.privateca_v1.types.CertificateTemplate: @@ -3808,7 +3894,7 @@ async def list_certificate_templates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateTemplatesAsyncPager: r"""Lists [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -3856,8 +3942,10 @@ async def sample_list_certificate_templates(): 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, 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesAsyncPager: @@ -3933,7 +4021,7 @@ async def update_certificate_template( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -3989,8 +4077,10 @@ async def sample_update_certificate_template(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -4066,7 +4156,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4077,8 +4167,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4119,7 +4211,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4130,8 +4222,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4172,7 +4266,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4188,8 +4282,10 @@ async def delete_operation( 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, 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: None """ @@ -4226,7 +4322,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4241,8 +4337,10 @@ async def cancel_operation( 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, 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: None """ @@ -4279,7 +4377,7 @@ async def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -4292,8 +4390,10 @@ async def set_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4398,7 +4498,7 @@ async def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -4412,8 +4512,10 @@ async def get_iam_policy( 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, 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4518,7 +4620,7 @@ async def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -4533,8 +4635,10 @@ async def test_iam_permissions( 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, 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -4578,7 +4682,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -4589,8 +4693,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -4631,7 +4737,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -4642,8 +4748,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py index c5cef6e3f44f..606be23f4074 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -702,6 +712,10 @@ def __init__( # 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( @@ -770,6 +784,29 @@ def __init__( 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.security.privateca_v1.CertificateAuthorityServiceClient`.", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "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.security.privateca.v1.CertificateAuthorityService", + "credentialsType": None, + }, + ) + def create_certificate( self, request: Optional[Union[service.CreateCertificateRequest, dict]] = None, @@ -779,7 +816,7 @@ def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Create a new [Certificate][google.cloud.security.privateca.v1.Certificate] in @@ -852,8 +889,10 @@ def sample_create_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.Certificate: @@ -916,7 +955,7 @@ def get_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Returns a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -964,8 +1003,10 @@ def sample_get_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.Certificate: @@ -1024,7 +1065,7 @@ def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesPager: r"""Lists [Certificates][google.cloud.security.privateca.v1.Certificate]. @@ -1072,8 +1113,10 @@ def sample_list_certificates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesPager: @@ -1145,7 +1188,7 @@ def revoke_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Revoke a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -1193,8 +1236,10 @@ def sample_revoke_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.Certificate: @@ -1254,7 +1299,7 @@ def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Update a [Certificate][google.cloud.security.privateca.v1.Certificate]. @@ -1313,8 +1358,10 @@ def sample_update_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.Certificate: @@ -1379,7 +1426,7 @@ def activate_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Activate a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1443,8 +1490,10 @@ def sample_activate_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1522,7 +1571,7 @@ def create_certificate_authority( certificate_authority_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a new [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1596,8 +1645,10 @@ def sample_create_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1679,7 +1730,7 @@ def disable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Disable a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1730,8 +1781,10 @@ def sample_disable_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1807,7 +1860,7 @@ def enable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Enable a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -1858,8 +1911,10 @@ def sample_enable_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1935,7 +1990,7 @@ def fetch_certificate_authority_csr( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Fetch a certificate signing request (CSR) from a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -1991,8 +2046,10 @@ def sample_fetch_certificate_authority_csr(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: @@ -2052,7 +2109,7 @@ def get_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Returns a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2100,8 +2157,10 @@ def sample_get_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.CertificateAuthority: @@ -2167,7 +2226,7 @@ def list_certificate_authorities( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateAuthoritiesPager: r"""Lists [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2216,8 +2275,10 @@ def sample_list_certificate_authorities(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: @@ -2293,7 +2354,7 @@ def undelete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undelete a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] @@ -2345,8 +2406,10 @@ def sample_undelete_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2422,7 +2485,7 @@ def delete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2473,8 +2536,10 @@ def sample_delete_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2551,7 +2616,7 @@ def update_certificate_authority( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. @@ -2612,8 +2677,10 @@ def sample_update_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2693,7 +2760,7 @@ def create_ca_pool( ca_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2763,8 +2830,10 @@ def sample_create_ca_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2844,7 +2913,7 @@ def update_ca_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -2903,8 +2972,10 @@ def sample_update_ca_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2983,7 +3054,7 @@ def get_ca_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CaPool: r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -3030,8 +3101,10 @@ def sample_get_ca_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.CaPool: @@ -3096,7 +3169,7 @@ def list_ca_pools( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCaPoolsPager: r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. @@ -3143,8 +3216,10 @@ def sample_list_ca_pools(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsPager: @@ -3216,7 +3291,7 @@ def delete_ca_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -3265,8 +3340,10 @@ def sample_delete_ca_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3342,7 +3419,7 @@ def fetch_ca_certs( ca_pool: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCaCertsResponse: r"""FetchCaCerts returns the current trust anchor for the [CaPool][google.cloud.security.privateca.v1.CaPool]. This will @@ -3390,8 +3467,10 @@ def sample_fetch_ca_certs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.FetchCaCertsResponse: @@ -3451,7 +3530,7 @@ def get_certificate_revocation_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Returns a [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3499,8 +3578,10 @@ def sample_get_certificate_revocation_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.CertificateRevocationList: @@ -3565,7 +3646,7 @@ def list_certificate_revocation_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateRevocationListsPager: r"""Lists [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3614,8 +3695,10 @@ def sample_list_certificate_revocation_lists(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: @@ -3694,7 +3777,7 @@ def update_certificate_revocation_list( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. @@ -3750,8 +3833,10 @@ def sample_update_certificate_revocation_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3835,7 +3920,7 @@ def create_certificate_template( certificate_template_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a new [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] @@ -3903,8 +3988,10 @@ def sample_create_certificate_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3982,7 +4069,7 @@ def delete_certificate_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""DeleteCertificateTemplate deletes a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -4033,8 +4120,10 @@ def sample_delete_certificate_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4112,7 +4201,7 @@ def get_certificate_template( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateTemplate: r"""Returns a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -4160,8 +4249,10 @@ def sample_get_certificate_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.types.CertificateTemplate: @@ -4221,7 +4312,7 @@ def list_certificate_templates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateTemplatesPager: r"""Lists [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -4269,8 +4360,10 @@ def sample_list_certificate_templates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesPager: @@ -4345,7 +4438,7 @@ def update_certificate_template( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. @@ -4401,8 +4494,10 @@ def sample_update_certificate_template(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -4490,7 +4585,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -4501,8 +4596,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -4543,7 +4640,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -4554,8 +4651,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -4596,7 +4695,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -4612,8 +4711,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4650,7 +4751,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -4665,8 +4766,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -4703,7 +4806,7 @@ def set_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy on the specified function. @@ -4716,8 +4819,10 @@ def set_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4822,7 +4927,7 @@ def get_iam_policy( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the IAM access control policy for a function. @@ -4836,8 +4941,10 @@ def get_iam_policy( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -4942,7 +5049,7 @@ def test_iam_permissions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -4957,8 +5064,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -5000,7 +5109,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -5011,8 +5120,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -5053,7 +5164,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -5064,8 +5175,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py index 7fde73ce430a..d57a8ae02c8f 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificatesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificatesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificateAuthoritiesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificateAuthoritiesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCaPoolsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCaPoolsRequest(request) @@ -523,7 +535,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -537,8 +549,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificateRevocationListsRequest(request) @@ -599,7 +613,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -613,8 +627,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificateRevocationListsRequest(request) @@ -679,7 +695,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -693,8 +709,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificateTemplatesRequest(request) @@ -753,7 +771,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -767,8 +785,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificateTemplatesRequest(request) diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py index 8f8c6b8e9fa2..30b79efbe4de 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.security.privateca_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport +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.security.privateca.v1.CertificateAuthorityService", + "rpcName": 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.security.privateca.v1.CertificateAuthorityService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): """gRPC backend transport for CertificateAuthorityService. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate", request_serializer=service.CreateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -304,7 +392,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificate", request_serializer=service.GetCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -331,7 +419,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificates", request_serializer=service.ListCertificatesRequest.serialize, response_deserializer=service.ListCertificatesResponse.deserialize, @@ -358,7 +446,7 @@ def revoke_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_certificate" not in self._stubs: - self._stubs["revoke_certificate"] = self.grpc_channel.unary_unary( + self._stubs["revoke_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate", request_serializer=service.RevokeCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -388,7 +476,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate", request_serializer=service.UpdateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -427,7 +515,7 @@ def activate_certificate_authority( if "activate_certificate_authority" not in self._stubs: self._stubs[ "activate_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +545,9 @@ def create_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_authority" not in self._stubs: - self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -488,7 +578,7 @@ def disable_certificate_authority( if "disable_certificate_authority" not in self._stubs: self._stubs[ "disable_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +607,9 @@ def enable_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_certificate_authority" not in self._stubs: - self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "enable_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -559,7 +651,7 @@ def fetch_certificate_authority_csr( if "fetch_certificate_authority_csr" not in self._stubs: self._stubs[ "fetch_certificate_authority_csr" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr", request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, @@ -588,7 +680,7 @@ def get_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_authority" not in self._stubs: - self._stubs["get_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_authority"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority", request_serializer=service.GetCertificateAuthorityRequest.serialize, response_deserializer=resources.CertificateAuthority.deserialize, @@ -618,7 +710,9 @@ def list_certificate_authorities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_authorities" not in self._stubs: - self._stubs["list_certificate_authorities"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_authorities" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities", request_serializer=service.ListCertificateAuthoritiesRequest.serialize, response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, @@ -650,7 +744,7 @@ def undelete_certificate_authority( if "undelete_certificate_authority" not in self._stubs: self._stubs[ "undelete_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority", request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +773,9 @@ def delete_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_authority" not in self._stubs: - self._stubs["delete_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority", request_serializer=service.DeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -708,7 +804,9 @@ def update_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_authority" not in self._stubs: - self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -734,7 +832,7 @@ def create_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ca_pool" not in self._stubs: - self._stubs["create_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool", request_serializer=service.CreateCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -760,7 +858,7 @@ def update_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ca_pool" not in self._stubs: - self._stubs["update_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool", request_serializer=service.UpdateCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -784,7 +882,7 @@ def get_ca_pool(self) -> Callable[[service.GetCaPoolRequest], resources.CaPool]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ca_pool" not in self._stubs: - self._stubs["get_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool", request_serializer=service.GetCaPoolRequest.serialize, response_deserializer=resources.CaPool.deserialize, @@ -810,7 +908,7 @@ def list_ca_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ca_pools" not in self._stubs: - self._stubs["list_ca_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_ca_pools"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools", request_serializer=service.ListCaPoolsRequest.serialize, response_deserializer=service.ListCaPoolsResponse.deserialize, @@ -836,7 +934,7 @@ def delete_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ca_pool" not in self._stubs: - self._stubs["delete_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool", request_serializer=service.DeleteCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -865,7 +963,7 @@ def fetch_ca_certs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_ca_certs" not in self._stubs: - self._stubs["fetch_ca_certs"] = self.grpc_channel.unary_unary( + self._stubs["fetch_ca_certs"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts", request_serializer=service.FetchCaCertsRequest.serialize, response_deserializer=service.FetchCaCertsResponse.deserialize, @@ -898,7 +996,7 @@ def get_certificate_revocation_list( if "get_certificate_revocation_list" not in self._stubs: self._stubs[ "get_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList", request_serializer=service.GetCertificateRevocationListRequest.serialize, response_deserializer=resources.CertificateRevocationList.deserialize, @@ -931,7 +1029,7 @@ def list_certificate_revocation_lists( if "list_certificate_revocation_lists" not in self._stubs: self._stubs[ "list_certificate_revocation_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists", request_serializer=service.ListCertificateRevocationListsRequest.serialize, response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, @@ -963,7 +1061,7 @@ def update_certificate_revocation_list( if "update_certificate_revocation_list" not in self._stubs: self._stubs[ "update_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -991,7 +1089,9 @@ def create_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_template" not in self._stubs: - self._stubs["create_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate", request_serializer=service.CreateCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1018,7 +1118,9 @@ def delete_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_template" not in self._stubs: - self._stubs["delete_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate", request_serializer=service.DeleteCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1047,7 +1149,7 @@ def get_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_template" not in self._stubs: - self._stubs["get_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_template"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate", request_serializer=service.GetCertificateTemplateRequest.serialize, response_deserializer=resources.CertificateTemplate.deserialize, @@ -1077,7 +1179,9 @@ def list_certificate_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_templates" not in self._stubs: - self._stubs["list_certificate_templates"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_templates" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates", request_serializer=service.ListCertificateTemplatesRequest.serialize, response_deserializer=service.ListCertificateTemplatesResponse.deserialize, @@ -1104,7 +1208,9 @@ def update_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_template" not in self._stubs: - self._stubs["update_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate", request_serializer=service.UpdateCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1112,7 +1218,7 @@ def update_certificate_template( return self._stubs["update_certificate_template"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1124,7 +1230,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1141,7 +1247,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1158,7 +1264,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1177,7 +1283,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1196,7 +1302,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1213,7 +1319,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1238,7 +1344,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1264,7 +1370,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1293,7 +1399,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py index 4cc625ede062..79f1ff57396f 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.security.privateca_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport from .grpc import CertificateAuthorityServiceGrpcTransport +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.security.privateca.v1.CertificateAuthorityService", + "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.security.privateca.v1.CertificateAuthorityService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateAuthorityServiceGrpcAsyncIOTransport( CertificateAuthorityServiceTransport @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate", request_serializer=service.CreateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -316,7 +401,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificate", request_serializer=service.GetCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -345,7 +430,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificates", request_serializer=service.ListCertificatesRequest.serialize, response_deserializer=service.ListCertificatesResponse.deserialize, @@ -372,7 +457,7 @@ def revoke_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_certificate" not in self._stubs: - self._stubs["revoke_certificate"] = self.grpc_channel.unary_unary( + self._stubs["revoke_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate", request_serializer=service.RevokeCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -402,7 +487,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate", request_serializer=service.UpdateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -442,7 +527,7 @@ def activate_certificate_authority( if "activate_certificate_authority" not in self._stubs: self._stubs[ "activate_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +557,9 @@ def create_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_authority" not in self._stubs: - self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -504,7 +591,7 @@ def disable_certificate_authority( if "disable_certificate_authority" not in self._stubs: self._stubs[ "disable_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -533,7 +620,9 @@ def enable_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_certificate_authority" not in self._stubs: - self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "enable_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -575,7 +664,7 @@ def fetch_certificate_authority_csr( if "fetch_certificate_authority_csr" not in self._stubs: self._stubs[ "fetch_certificate_authority_csr" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr", request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, @@ -605,7 +694,7 @@ def get_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_authority" not in self._stubs: - self._stubs["get_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_authority"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority", request_serializer=service.GetCertificateAuthorityRequest.serialize, response_deserializer=resources.CertificateAuthority.deserialize, @@ -635,7 +724,9 @@ def list_certificate_authorities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_authorities" not in self._stubs: - self._stubs["list_certificate_authorities"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_authorities" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities", request_serializer=service.ListCertificateAuthoritiesRequest.serialize, response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, @@ -668,7 +759,7 @@ def undelete_certificate_authority( if "undelete_certificate_authority" not in self._stubs: self._stubs[ "undelete_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority", request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -697,7 +788,9 @@ def delete_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_authority" not in self._stubs: - self._stubs["delete_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority", request_serializer=service.DeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -726,7 +819,9 @@ def update_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_authority" not in self._stubs: - self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -752,7 +847,7 @@ def create_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ca_pool" not in self._stubs: - self._stubs["create_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool", request_serializer=service.CreateCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -778,7 +873,7 @@ def update_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ca_pool" not in self._stubs: - self._stubs["update_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool", request_serializer=service.UpdateCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -804,7 +899,7 @@ def get_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ca_pool" not in self._stubs: - self._stubs["get_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool", request_serializer=service.GetCaPoolRequest.serialize, response_deserializer=resources.CaPool.deserialize, @@ -830,7 +925,7 @@ def list_ca_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ca_pools" not in self._stubs: - self._stubs["list_ca_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_ca_pools"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools", request_serializer=service.ListCaPoolsRequest.serialize, response_deserializer=service.ListCaPoolsResponse.deserialize, @@ -856,7 +951,7 @@ def delete_ca_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ca_pool" not in self._stubs: - self._stubs["delete_ca_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_ca_pool"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool", request_serializer=service.DeleteCaPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -887,7 +982,7 @@ def fetch_ca_certs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_ca_certs" not in self._stubs: - self._stubs["fetch_ca_certs"] = self.grpc_channel.unary_unary( + self._stubs["fetch_ca_certs"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts", request_serializer=service.FetchCaCertsRequest.serialize, response_deserializer=service.FetchCaCertsResponse.deserialize, @@ -920,7 +1015,7 @@ def get_certificate_revocation_list( if "get_certificate_revocation_list" not in self._stubs: self._stubs[ "get_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList", request_serializer=service.GetCertificateRevocationListRequest.serialize, response_deserializer=resources.CertificateRevocationList.deserialize, @@ -953,7 +1048,7 @@ def list_certificate_revocation_lists( if "list_certificate_revocation_lists" not in self._stubs: self._stubs[ "list_certificate_revocation_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists", request_serializer=service.ListCertificateRevocationListsRequest.serialize, response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, @@ -986,7 +1081,7 @@ def update_certificate_revocation_list( if "update_certificate_revocation_list" not in self._stubs: self._stubs[ "update_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1016,7 +1111,9 @@ def create_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_template" not in self._stubs: - self._stubs["create_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate", request_serializer=service.CreateCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1045,7 +1142,9 @@ def delete_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_template" not in self._stubs: - self._stubs["delete_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate", request_serializer=service.DeleteCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1075,7 +1174,7 @@ def get_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_template" not in self._stubs: - self._stubs["get_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_template"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate", request_serializer=service.GetCertificateTemplateRequest.serialize, response_deserializer=resources.CertificateTemplate.deserialize, @@ -1105,7 +1204,9 @@ def list_certificate_templates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_templates" not in self._stubs: - self._stubs["list_certificate_templates"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_templates" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates", request_serializer=service.ListCertificateTemplatesRequest.serialize, response_deserializer=service.ListCertificateTemplatesResponse.deserialize, @@ -1134,7 +1235,9 @@ def update_certificate_template( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_template" not in self._stubs: - self._stubs["update_certificate_template"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_template" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate", request_serializer=service.UpdateCertificateTemplateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1342,7 +1445,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1358,7 +1461,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1375,7 +1478,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1392,7 +1495,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -1411,7 +1514,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -1430,7 +1533,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1447,7 +1550,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -1472,7 +1575,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1498,7 +1601,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1527,7 +1630,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/rest.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/rest.py index 7913b2bf5cbf..c317a66afd11 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/rest.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -305,8 +313,11 @@ def post_update_certificate_template(self, response): def pre_activate_certificate_authority( self, request: service.ActivateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ActivateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ActivateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for activate_certificate_authority Override in a subclass to manipulate the request or metadata @@ -326,8 +337,10 @@ def post_activate_certificate_authority( return response def pre_create_ca_pool( - self, request: service.CreateCaPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateCaPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateCaPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateCaPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_ca_pool Override in a subclass to manipulate the request or metadata @@ -349,8 +362,10 @@ def post_create_ca_pool( def pre_create_certificate( self, request: service.CreateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_certificate Override in a subclass to manipulate the request or metadata @@ -372,8 +387,11 @@ def post_create_certificate( def pre_create_certificate_authority( self, request: service.CreateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_certificate_authority Override in a subclass to manipulate the request or metadata @@ -395,8 +413,11 @@ def post_create_certificate_authority( def pre_create_certificate_template( self, request: service.CreateCertificateTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateCertificateTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateCertificateTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_certificate_template Override in a subclass to manipulate the request or metadata @@ -416,8 +437,10 @@ def post_create_certificate_template( return response def pre_delete_ca_pool( - self, request: service.DeleteCaPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteCaPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteCaPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteCaPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_ca_pool Override in a subclass to manipulate the request or metadata @@ -439,8 +462,11 @@ def post_delete_ca_pool( def pre_delete_certificate_authority( self, request: service.DeleteCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DeleteCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_certificate_authority Override in a subclass to manipulate the request or metadata @@ -462,8 +488,11 @@ def post_delete_certificate_authority( def pre_delete_certificate_template( self, request: service.DeleteCertificateTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteCertificateTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DeleteCertificateTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_certificate_template Override in a subclass to manipulate the request or metadata @@ -485,8 +514,11 @@ def post_delete_certificate_template( def pre_disable_certificate_authority( self, request: service.DisableCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DisableCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DisableCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for disable_certificate_authority Override in a subclass to manipulate the request or metadata @@ -508,8 +540,11 @@ def post_disable_certificate_authority( def pre_enable_certificate_authority( self, request: service.EnableCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EnableCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EnableCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for enable_certificate_authority Override in a subclass to manipulate the request or metadata @@ -529,8 +564,10 @@ def post_enable_certificate_authority( return response def pre_fetch_ca_certs( - self, request: service.FetchCaCertsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.FetchCaCertsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.FetchCaCertsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.FetchCaCertsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for fetch_ca_certs Override in a subclass to manipulate the request or metadata @@ -552,8 +589,11 @@ def post_fetch_ca_certs( def pre_fetch_certificate_authority_csr( self, request: service.FetchCertificateAuthorityCsrRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.FetchCertificateAuthorityCsrRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.FetchCertificateAuthorityCsrRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_certificate_authority_csr Override in a subclass to manipulate the request or metadata @@ -573,8 +613,10 @@ def post_fetch_certificate_authority_csr( return response def pre_get_ca_pool( - self, request: service.GetCaPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetCaPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetCaPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetCaPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_ca_pool Override in a subclass to manipulate the request or metadata @@ -594,8 +636,8 @@ def post_get_ca_pool(self, response: resources.CaPool) -> resources.CaPool: def pre_get_certificate( self, request: service.GetCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_certificate Override in a subclass to manipulate the request or metadata @@ -617,8 +659,10 @@ def post_get_certificate( def pre_get_certificate_authority( self, request: service.GetCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetCertificateAuthorityRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_certificate_authority Override in a subclass to manipulate the request or metadata @@ -640,8 +684,11 @@ def post_get_certificate_authority( def pre_get_certificate_revocation_list( self, request: service.GetCertificateRevocationListRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateRevocationListRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetCertificateRevocationListRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_certificate_revocation_list Override in a subclass to manipulate the request or metadata @@ -663,8 +710,10 @@ def post_get_certificate_revocation_list( def pre_get_certificate_template( self, request: service.GetCertificateTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetCertificateTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_certificate_template Override in a subclass to manipulate the request or metadata @@ -684,8 +733,10 @@ def post_get_certificate_template( return response def pre_list_ca_pools( - self, request: service.ListCaPoolsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListCaPoolsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListCaPoolsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListCaPoolsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_ca_pools Override in a subclass to manipulate the request or metadata @@ -707,8 +758,11 @@ def post_list_ca_pools( def pre_list_certificate_authorities( self, request: service.ListCertificateAuthoritiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListCertificateAuthoritiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListCertificateAuthoritiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_certificate_authorities Override in a subclass to manipulate the request or metadata @@ -730,9 +784,10 @@ def post_list_certificate_authorities( def pre_list_certificate_revocation_lists( self, request: service.ListCertificateRevocationListsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - service.ListCertificateRevocationListsRequest, Sequence[Tuple[str, str]] + service.ListCertificateRevocationListsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_certificate_revocation_lists @@ -755,8 +810,10 @@ def post_list_certificate_revocation_lists( def pre_list_certificates( self, request: service.ListCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListCertificatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_certificates Override in a subclass to manipulate the request or metadata @@ -778,8 +835,10 @@ def post_list_certificates( def pre_list_certificate_templates( self, request: service.ListCertificateTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListCertificateTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListCertificateTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_certificate_templates Override in a subclass to manipulate the request or metadata @@ -801,8 +860,10 @@ def post_list_certificate_templates( def pre_revoke_certificate( self, request: service.RevokeCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RevokeCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.RevokeCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for revoke_certificate Override in a subclass to manipulate the request or metadata @@ -824,8 +885,11 @@ def post_revoke_certificate( def pre_undelete_certificate_authority( self, request: service.UndeleteCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UndeleteCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UndeleteCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for undelete_certificate_authority Override in a subclass to manipulate the request or metadata @@ -845,8 +909,10 @@ def post_undelete_certificate_authority( return response def pre_update_ca_pool( - self, request: service.UpdateCaPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateCaPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateCaPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateCaPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_ca_pool Override in a subclass to manipulate the request or metadata @@ -868,8 +934,10 @@ def post_update_ca_pool( def pre_update_certificate( self, request: service.UpdateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_certificate Override in a subclass to manipulate the request or metadata @@ -891,8 +959,11 @@ def post_update_certificate( def pre_update_certificate_authority( self, request: service.UpdateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_certificate_authority Override in a subclass to manipulate the request or metadata @@ -914,9 +985,10 @@ def post_update_certificate_authority( def pre_update_certificate_revocation_list( self, request: service.UpdateCertificateRevocationListRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - service.UpdateCertificateRevocationListRequest, Sequence[Tuple[str, str]] + service.UpdateCertificateRevocationListRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_certificate_revocation_list @@ -939,8 +1011,11 @@ def post_update_certificate_revocation_list( def pre_update_certificate_template( self, request: service.UpdateCertificateTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateCertificateTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateCertificateTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_certificate_template Override in a subclass to manipulate the request or metadata @@ -962,8 +1037,10 @@ def post_update_certificate_template( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -985,8 +1062,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -1008,8 +1087,10 @@ def post_list_locations( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -1029,8 +1110,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -1050,8 +1133,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -1073,8 +1159,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1094,8 +1182,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1115,8 +1205,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1138,8 +1230,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -1341,7 +1435,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the activate certificate authority method over HTTP. @@ -1353,8 +1447,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1367,6 +1463,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseActivateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_activate_certificate_authority( request, metadata ) @@ -1383,6 +1480,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ActivateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ActivateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ActivateCertificateAuthority._get_response( self._host, @@ -1402,7 +1526,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_activate_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.activate_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ActivateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCaPool( @@ -1441,7 +1587,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create ca pool method over HTTP. @@ -1452,8 +1598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1466,6 +1614,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCaPool._get_http_options() ) + request, metadata = self._interceptor.pre_create_ca_pool(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseCreateCaPool._get_transcoded_request( http_options, request @@ -1480,6 +1629,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.CreateCaPool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCaPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._CreateCaPool._get_response( @@ -1501,7 +1677,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ca_pool(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.security.privateca_v1.CertificateAuthorityServiceClient.create_ca_pool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCaPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificate( @@ -1540,7 +1738,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the create certificate method over HTTP. @@ -1551,8 +1749,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -1566,6 +1766,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate( request, metadata ) @@ -1582,6 +1783,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.CreateCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._CreateCertificate._get_response( self._host, @@ -1603,7 +1831,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1.CertificateAuthorityServiceClient.create_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateAuthority( @@ -1644,7 +1894,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create certificate authority method over HTTP. @@ -1656,8 +1906,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1670,6 +1922,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate_authority( request, metadata ) @@ -1686,6 +1939,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.CreateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._CreateCertificateAuthority._get_response( self._host, @@ -1705,7 +1985,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.create_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateTemplate( @@ -1746,7 +2048,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create certificate template method over HTTP. @@ -1758,8 +2060,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1772,6 +2076,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCertificateTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate_template( request, metadata ) @@ -1788,6 +2093,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.CreateCertificateTemplate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificateTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._CreateCertificateTemplate._get_response( self._host, @@ -1807,7 +2139,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_template(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.security.privateca_v1.CertificateAuthorityServiceClient.create_certificate_template", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CreateCertificateTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCaPool( @@ -1845,7 +2199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete ca pool method over HTTP. @@ -1856,8 +2210,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1870,6 +2226,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDeleteCaPool._get_http_options() ) + request, metadata = self._interceptor.pre_delete_ca_pool(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseDeleteCaPool._get_transcoded_request( http_options, request @@ -1880,6 +2237,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.DeleteCaPool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCaPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._DeleteCaPool._get_response( @@ -1900,7 +2284,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_ca_pool(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.security.privateca_v1.CertificateAuthorityServiceClient.delete_ca_pool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCaPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificateAuthority( @@ -1940,7 +2346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete certificate authority method over HTTP. @@ -1952,8 +2358,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1966,6 +2374,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDeleteCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_delete_certificate_authority( request, metadata ) @@ -1978,6 +2387,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.DeleteCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._DeleteCertificateAuthority._get_response( self._host, @@ -1996,7 +2432,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.delete_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificateTemplate( @@ -2036,7 +2494,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete certificate template method over HTTP. @@ -2048,8 +2506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2062,6 +2522,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDeleteCertificateTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_delete_certificate_template( request, metadata ) @@ -2074,6 +2535,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.DeleteCertificateTemplate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCertificateTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._DeleteCertificateTemplate._get_response( self._host, @@ -2092,7 +2580,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate_template(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.security.privateca_v1.CertificateAuthorityServiceClient.delete_certificate_template", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteCertificateTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableCertificateAuthority( @@ -2133,7 +2643,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the disable certificate authority method over HTTP. @@ -2145,8 +2655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2159,6 +2671,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDisableCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_disable_certificate_authority( request, metadata ) @@ -2175,6 +2688,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.DisableCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DisableCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._DisableCertificateAuthority._get_response( self._host, @@ -2194,7 +2734,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.disable_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DisableCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableCertificateAuthority( @@ -2235,7 +2797,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the enable certificate authority method over HTTP. @@ -2247,8 +2809,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2261,6 +2825,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseEnableCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_enable_certificate_authority( request, metadata ) @@ -2277,6 +2842,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.EnableCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "EnableCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._EnableCertificateAuthority._get_response( self._host, @@ -2296,7 +2888,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.enable_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "EnableCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchCaCerts( @@ -2335,7 +2949,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCaCertsResponse: r"""Call the fetch ca certs method over HTTP. @@ -2346,8 +2960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.FetchCaCertsResponse: @@ -2359,6 +2975,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseFetchCaCerts._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_ca_certs(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseFetchCaCerts._get_transcoded_request( http_options, request @@ -2373,6 +2990,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.FetchCaCerts", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "FetchCaCerts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._FetchCaCerts._get_response( @@ -2396,7 +3040,29 @@ def __call__( pb_resp = service.FetchCaCertsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_ca_certs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.FetchCaCertsResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.fetch_ca_certs", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "FetchCaCerts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchCertificateAuthorityCsr( @@ -2436,7 +3102,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Call the fetch certificate authority csr method over HTTP. @@ -2448,8 +3114,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.FetchCertificateAuthorityCsrResponse: @@ -2461,6 +3129,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseFetchCertificateAuthorityCsr._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_certificate_authority_csr( request, metadata ) @@ -2473,6 +3142,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.FetchCertificateAuthorityCsr", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "FetchCertificateAuthorityCsr", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._FetchCertificateAuthorityCsr._get_response( self._host, @@ -2493,7 +3189,31 @@ def __call__( pb_resp = service.FetchCertificateAuthorityCsrResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_certificate_authority_csr(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.FetchCertificateAuthorityCsrResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.fetch_certificate_authority_csr", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "FetchCertificateAuthorityCsr", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCaPool( @@ -2531,7 +3251,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CaPool: r"""Call the get ca pool method over HTTP. @@ -2542,8 +3262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CaPool: @@ -2562,6 +3284,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCaPool._get_http_options() ) + request, metadata = self._interceptor.pre_get_ca_pool(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetCaPool._get_transcoded_request( http_options, request @@ -2572,6 +3295,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetCaPool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCaPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetCaPool._get_response( @@ -2594,7 +3344,29 @@ def __call__( pb_resp = resources.CaPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ca_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CaPool.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.security.privateca_v1.CertificateAuthorityServiceClient.get_ca_pool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCaPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificate( @@ -2632,7 +3404,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the get certificate method over HTTP. @@ -2643,8 +3415,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -2658,6 +3432,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificate._get_transcoded_request( http_options, request @@ -2668,6 +3443,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetCertificate._get_response( @@ -2690,7 +3492,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1.CertificateAuthorityServiceClient.get_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateAuthority( @@ -2730,7 +3554,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Call the get certificate authority method over HTTP. @@ -2741,8 +3565,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CertificateAuthority: @@ -2758,6 +3584,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_authority( request, metadata ) @@ -2770,6 +3597,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetCertificateAuthority._get_response( self._host, @@ -2790,7 +3644,29 @@ def __call__( pb_resp = resources.CertificateAuthority.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_authority(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CertificateAuthority.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.security.privateca_v1.CertificateAuthorityServiceClient.get_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateRevocationList( @@ -2830,7 +3706,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Call the get certificate revocation list method over HTTP. @@ -2842,8 +3718,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CertificateRevocationList: @@ -2858,6 +3736,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificateRevocationList._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_revocation_list( request, metadata ) @@ -2870,6 +3749,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetCertificateRevocationList", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateRevocationList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetCertificateRevocationList._get_response( self._host, @@ -2890,7 +3796,31 @@ def __call__( pb_resp = resources.CertificateRevocationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_revocation_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CertificateRevocationList.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.security.privateca_v1.CertificateAuthorityServiceClient.get_certificate_revocation_list", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateRevocationList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateTemplate( @@ -2930,7 +3860,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateTemplate: r"""Call the get certificate template method over HTTP. @@ -2941,8 +3871,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CertificateTemplate: @@ -2955,6 +3887,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificateTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_template( request, metadata ) @@ -2967,6 +3900,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetCertificateTemplate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetCertificateTemplate._get_response( self._host, @@ -2987,7 +3947,29 @@ def __call__( pb_resp = resources.CertificateTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CertificateTemplate.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.security.privateca_v1.CertificateAuthorityServiceClient.get_certificate_template", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetCertificateTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCaPools( @@ -3025,7 +4007,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCaPoolsResponse: r"""Call the list ca pools method over HTTP. @@ -3036,8 +4018,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCaPoolsResponse: @@ -3049,6 +4033,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCaPools._get_http_options() ) + request, metadata = self._interceptor.pre_list_ca_pools(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseListCaPools._get_transcoded_request( http_options, request @@ -3059,6 +4044,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListCaPools", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCaPools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._ListCaPools._get_response( @@ -3081,7 +4093,29 @@ def __call__( pb_resp = service.ListCaPoolsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ca_pools(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListCaPoolsResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.list_ca_pools", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCaPools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateAuthorities( @@ -3121,7 +4155,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificateAuthoritiesResponse: r"""Call the list certificate authorities method over HTTP. @@ -3133,8 +4167,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificateAuthoritiesResponse: @@ -3146,6 +4182,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificateAuthorities._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_authorities( request, metadata ) @@ -3158,6 +4195,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListCertificateAuthorities", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateAuthorities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificateAuthorities._get_response( self._host, @@ -3178,7 +4242,31 @@ def __call__( pb_resp = service.ListCertificateAuthoritiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_authorities(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListCertificateAuthoritiesResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.list_certificate_authorities", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateAuthorities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateRevocationLists( @@ -3218,7 +4306,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificateRevocationListsResponse: r"""Call the list certificate revocation lists method over HTTP. @@ -3230,8 +4318,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificateRevocationListsResponse: @@ -3243,6 +4333,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificateRevocationLists._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_revocation_lists( request, metadata ) @@ -3255,6 +4346,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListCertificateRevocationLists", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateRevocationLists", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificateRevocationLists._get_response( self._host, @@ -3275,7 +4393,31 @@ def __call__( pb_resp = service.ListCertificateRevocationListsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_revocation_lists(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListCertificateRevocationListsResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.list_certificate_revocation_lists", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateRevocationLists", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificates( @@ -3313,7 +4455,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificatesResponse: r"""Call the list certificates method over HTTP. @@ -3324,8 +4466,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificatesResponse: @@ -3337,6 +4481,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificates( request, metadata ) @@ -3349,6 +4494,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListCertificates", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificates._get_response( self._host, @@ -3369,7 +4541,31 @@ def __call__( pb_resp = service.ListCertificatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListCertificatesResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.list_certificates", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateTemplates( @@ -3409,7 +4605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificateTemplatesResponse: r"""Call the list certificate templates method over HTTP. @@ -3421,8 +4617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificateTemplatesResponse: @@ -3434,6 +4632,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificateTemplates._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_templates( request, metadata ) @@ -3446,6 +4645,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListCertificateTemplates", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateTemplates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificateTemplates._get_response( self._host, @@ -3466,7 +4692,31 @@ def __call__( pb_resp = service.ListCertificateTemplatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_templates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListCertificateTemplatesResponse.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.security.privateca_v1.CertificateAuthorityServiceClient.list_certificate_templates", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListCertificateTemplates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RevokeCertificate( @@ -3505,7 +4755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the revoke certificate method over HTTP. @@ -3516,8 +4766,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -3531,6 +4783,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseRevokeCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_revoke_certificate( request, metadata ) @@ -3547,6 +4800,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.RevokeCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "RevokeCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._RevokeCertificate._get_response( self._host, @@ -3568,7 +4848,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_revoke_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1.CertificateAuthorityServiceClient.revoke_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "RevokeCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteCertificateAuthority( @@ -3609,7 +4911,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete certificate authority method over HTTP. @@ -3621,8 +4923,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3635,6 +4939,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUndeleteCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_certificate_authority( request, metadata ) @@ -3651,6 +4956,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UndeleteCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UndeleteCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UndeleteCertificateAuthority._get_response( self._host, @@ -3670,7 +5002,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.undelete_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UndeleteCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCaPool( @@ -3709,7 +5063,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update ca pool method over HTTP. @@ -3720,8 +5074,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3734,6 +5090,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCaPool._get_http_options() ) + request, metadata = self._interceptor.pre_update_ca_pool(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCaPool._get_transcoded_request( http_options, request @@ -3748,6 +5105,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UpdateCaPool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCaPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._UpdateCaPool._get_response( @@ -3769,7 +5153,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_ca_pool(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.security.privateca_v1.CertificateAuthorityServiceClient.update_ca_pool", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCaPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificate( @@ -3808,7 +5214,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the update certificate method over HTTP. @@ -3819,8 +5225,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -3834,6 +5242,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate( request, metadata ) @@ -3850,6 +5259,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UpdateCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificate._get_response( self._host, @@ -3871,7 +5307,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1.CertificateAuthorityServiceClient.update_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateAuthority( @@ -3912,7 +5370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update certificate authority method over HTTP. @@ -3924,8 +5382,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -3938,6 +5398,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate_authority( request, metadata ) @@ -3954,6 +5415,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UpdateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificateAuthority._get_response( self._host, @@ -3973,7 +5461,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_authority(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.security.privateca_v1.CertificateAuthorityServiceClient.update_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateRevocationList( @@ -4014,7 +5524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update certificate revocation list method over HTTP. @@ -4026,8 +5536,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4040,6 +5552,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificateRevocationList._get_http_options() ) + ( request, metadata, @@ -4059,6 +5572,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UpdateCertificateRevocationList", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateRevocationList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificateRevocationList._get_response( self._host, @@ -4078,7 +5618,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_revocation_list(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.security.privateca_v1.CertificateAuthorityServiceClient.update_certificate_revocation_list", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateRevocationList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateTemplate( @@ -4119,7 +5681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update certificate template method over HTTP. @@ -4131,8 +5693,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -4145,6 +5709,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificateTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate_template( request, metadata ) @@ -4161,6 +5726,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.UpdateCertificateTemplate", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificateTemplate._get_response( self._host, @@ -4180,7 +5772,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_template(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.security.privateca_v1.CertificateAuthorityServiceClient.update_certificate_template", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "UpdateCertificateTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4487,7 +6101,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -4497,8 +6111,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -4507,6 +6123,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -4517,6 +6134,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetLocation._get_response( @@ -4538,6 +6182,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4579,7 +6244,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -4589,8 +6254,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -4599,6 +6266,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -4609,6 +6277,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._ListLocations._get_response( @@ -4630,6 +6325,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4671,7 +6387,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -4681,8 +6397,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -4691,6 +6409,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -4701,6 +6420,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetIamPolicy._get_response( @@ -4722,6 +6468,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_iam_policy(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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4764,7 +6531,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -4774,8 +6541,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: policy_pb2.Policy: Response from SetIamPolicy method. @@ -4784,6 +6553,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -4798,6 +6568,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._SetIamPolicy._get_response( @@ -4820,6 +6617,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) resp = self._interceptor.post_set_iam_policy(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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4862,7 +6680,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -4872,8 +6690,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -4882,6 +6702,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4898,6 +6719,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -4918,6 +6766,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_test_iam_permissions(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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4960,7 +6829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -4970,13 +6839,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4993,6 +6865,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._CancelOperation._get_response( @@ -5052,7 +6951,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -5062,13 +6961,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5081,6 +6983,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._DeleteOperation._get_response( @@ -5139,7 +7068,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -5149,8 +7078,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -5159,6 +7090,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5169,6 +7101,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetOperation._get_response( @@ -5190,6 +7149,27 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5231,7 +7211,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -5241,8 +7221,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -5251,6 +7233,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5261,6 +7244,33 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._ListOperations._get_response( @@ -5282,6 +7292,27 @@ def __call__( 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.security.privateca_v1.CertificateAuthorityServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.security.privateca.v1.CertificateAuthorityService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/gapic_version.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/gapic_version.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py index da4fbf6716a3..507f7ab0f92a 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport +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 CertificateAuthorityServiceAsyncClient: """[Certificate Authority @@ -297,6 +307,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.security.privateca_v1beta1.CertificateAuthorityServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "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.security.privateca.v1beta1.CertificateAuthorityService", + "credentialsType": None, + }, + ) + async def create_certificate( self, request: Optional[Union[service.CreateCertificateRequest, dict]] = None, @@ -306,7 +338,7 @@ async def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Create a new [Certificate][google.cloud.security.privateca.v1beta1.Certificate] @@ -381,8 +413,10 @@ async def sample_create_certificate(): 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, 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -447,7 +481,7 @@ async def get_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Returns a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -495,8 +529,10 @@ async def sample_get_certificate(): 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, 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -557,7 +593,7 @@ async def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesAsyncPager: r"""Lists [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. @@ -606,8 +642,10 @@ async def sample_list_certificates(): 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, 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: @@ -682,7 +720,7 @@ async def revoke_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Revoke a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -730,8 +768,10 @@ async def sample_revoke_certificate(): 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, 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -793,7 +833,7 @@ async def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Update a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -852,8 +892,10 @@ async def sample_update_certificate(): 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, 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -920,7 +962,7 @@ async def activate_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Activate a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -984,8 +1026,10 @@ async def sample_activate_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1063,7 +1107,7 @@ async def create_certificate_authority( certificate_authority_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1138,8 +1182,10 @@ async def sample_create_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1221,7 +1267,7 @@ async def disable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Disable a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1272,8 +1318,10 @@ async def sample_disable_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1349,7 +1397,7 @@ async def enable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enable a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1400,8 +1448,10 @@ async def sample_enable_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1477,7 +1527,7 @@ async def fetch_certificate_authority_csr( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Fetch a certificate signing request (CSR) from a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1533,8 +1583,10 @@ async def sample_fetch_certificate_authority_csr(): 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, 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: google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: @@ -1595,7 +1647,7 @@ async def get_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Returns a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1643,8 +1695,10 @@ async def sample_get_certificate_authority(): 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, 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: google.cloud.security.privateca_v1beta1.types.CertificateAuthority: @@ -1710,7 +1764,7 @@ async def list_certificate_authorities( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateAuthoritiesAsyncPager: r"""Lists [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1758,8 +1812,10 @@ async def sample_list_certificate_authorities(): 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, 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: @@ -1836,7 +1892,7 @@ async def restore_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restore a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1888,8 +1944,10 @@ async def sample_restore_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1965,7 +2023,7 @@ async def schedule_delete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Schedule a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -2017,8 +2075,10 @@ async def sample_schedule_delete_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2095,7 +2155,7 @@ async def update_certificate_authority( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -2158,8 +2218,10 @@ async def sample_update_certificate_authority(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2239,7 +2301,7 @@ async def get_certificate_revocation_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Returns a [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2287,8 +2349,10 @@ async def sample_get_certificate_revocation_list(): 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, 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: google.cloud.security.privateca_v1beta1.types.CertificateRevocationList: @@ -2353,7 +2417,7 @@ async def list_certificate_revocation_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateRevocationListsAsyncPager: r"""Lists [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2402,8 +2466,10 @@ async def sample_list_certificate_revocation_lists(): 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, 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: @@ -2483,7 +2549,7 @@ async def update_certificate_revocation_list( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update a [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2539,8 +2605,10 @@ async def sample_update_certificate_revocation_list(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -2622,7 +2690,7 @@ async def get_reusable_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ReusableConfig: r"""Returns a [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. @@ -2667,8 +2735,10 @@ async def sample_get_reusable_config(): 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, 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: google.cloud.security.privateca_v1beta1.types.ReusableConfig: @@ -2732,7 +2802,7 @@ async def list_reusable_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReusableConfigsAsyncPager: r"""Lists [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. @@ -2780,8 +2850,10 @@ async def sample_list_reusable_configs(): 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, 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsAsyncPager: diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py index 350a0a483250..51f06dda205b 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore @@ -671,6 +681,10 @@ def __init__( # 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( @@ -739,6 +753,29 @@ def __init__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient`.", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "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.security.privateca.v1beta1.CertificateAuthorityService", + "credentialsType": None, + }, + ) + def create_certificate( self, request: Optional[Union[service.CreateCertificateRequest, dict]] = None, @@ -748,7 +785,7 @@ def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Create a new [Certificate][google.cloud.security.privateca.v1beta1.Certificate] @@ -823,8 +860,10 @@ def sample_create_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -886,7 +925,7 @@ def get_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Returns a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -934,8 +973,10 @@ def sample_get_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -993,7 +1034,7 @@ def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesPager: r"""Lists [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. @@ -1042,8 +1083,10 @@ def sample_list_certificates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesPager: @@ -1115,7 +1158,7 @@ def revoke_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Revoke a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -1163,8 +1206,10 @@ def sample_revoke_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -1223,7 +1268,7 @@ def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Update a [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. @@ -1282,8 +1327,10 @@ def sample_update_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.Certificate: @@ -1347,7 +1394,7 @@ def activate_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Activate a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1411,8 +1458,10 @@ def sample_activate_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1489,7 +1538,7 @@ def create_certificate_authority( certificate_authority_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a new [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1564,8 +1613,10 @@ def sample_create_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1646,7 +1697,7 @@ def disable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Disable a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1697,8 +1748,10 @@ def sample_disable_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1773,7 +1826,7 @@ def enable_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Enable a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -1824,8 +1877,10 @@ def sample_enable_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1900,7 +1955,7 @@ def fetch_certificate_authority_csr( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Fetch a certificate signing request (CSR) from a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -1956,8 +2011,10 @@ def sample_fetch_certificate_authority_csr(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: @@ -2017,7 +2074,7 @@ def get_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Returns a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -2065,8 +2122,10 @@ def sample_get_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.CertificateAuthority: @@ -2131,7 +2190,7 @@ def list_certificate_authorities( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateAuthoritiesPager: r"""Lists [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -2179,8 +2238,10 @@ def sample_list_certificate_authorities(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: @@ -2256,7 +2317,7 @@ def restore_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restore a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -2308,8 +2369,10 @@ def sample_restore_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2384,7 +2447,7 @@ def schedule_delete_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Schedule a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] @@ -2436,8 +2499,10 @@ def sample_schedule_delete_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2513,7 +2578,7 @@ def update_certificate_authority( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. @@ -2576,8 +2641,10 @@ def sample_update_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2656,7 +2723,7 @@ def get_certificate_revocation_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Returns a [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2704,8 +2771,10 @@ def sample_get_certificate_revocation_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.CertificateRevocationList: @@ -2769,7 +2838,7 @@ def list_certificate_revocation_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateRevocationListsPager: r"""Lists [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2818,8 +2887,10 @@ def sample_list_certificate_revocation_lists(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: @@ -2898,7 +2969,7 @@ def update_certificate_revocation_list( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update a [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. @@ -2954,8 +3025,10 @@ def sample_update_certificate_revocation_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -3036,7 +3109,7 @@ def get_reusable_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ReusableConfig: r"""Returns a [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. @@ -3081,8 +3154,10 @@ def sample_get_reusable_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.types.ReusableConfig: @@ -3143,7 +3218,7 @@ def list_reusable_configs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReusableConfigsPager: r"""Lists [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. @@ -3191,8 +3266,10 @@ def sample_list_reusable_configs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsPager: diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py index 947ede3f61f1..b7bbb8284cd7 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificatesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificatesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificateAuthoritiesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificateAuthoritiesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListCertificateRevocationListsRequest(request) @@ -447,7 +457,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -461,8 +471,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListCertificateRevocationListsRequest(request) @@ -527,7 +539,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -541,8 +553,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = service.ListReusableConfigsRequest(request) @@ -601,7 +615,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -615,8 +629,10 @@ def __init__( 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, 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`. """ self._method = method self._request = service.ListReusableConfigsRequest(request) diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py index 307cf82aff76..08e83a91c156 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.security.privateca_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport +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.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": 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.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): """gRPC backend transport for CertificateAuthorityService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate", request_serializer=service.CreateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -301,7 +389,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate", request_serializer=service.GetCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -328,7 +416,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates", request_serializer=service.ListCertificatesRequest.serialize, response_deserializer=service.ListCertificatesResponse.deserialize, @@ -355,7 +443,7 @@ def revoke_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_certificate" not in self._stubs: - self._stubs["revoke_certificate"] = self.grpc_channel.unary_unary( + self._stubs["revoke_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate", request_serializer=service.RevokeCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -385,7 +473,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate", request_serializer=service.UpdateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -424,7 +512,7 @@ def activate_certificate_authority( if "activate_certificate_authority" not in self._stubs: self._stubs[ "activate_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -454,7 +542,9 @@ def create_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_authority" not in self._stubs: - self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +575,7 @@ def disable_certificate_authority( if "disable_certificate_authority" not in self._stubs: self._stubs[ "disable_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -514,7 +604,9 @@ def enable_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_certificate_authority" not in self._stubs: - self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "enable_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +648,7 @@ def fetch_certificate_authority_csr( if "fetch_certificate_authority_csr" not in self._stubs: self._stubs[ "fetch_certificate_authority_csr" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr", request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, @@ -585,7 +677,7 @@ def get_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_authority" not in self._stubs: - self._stubs["get_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_authority"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority", request_serializer=service.GetCertificateAuthorityRequest.serialize, response_deserializer=resources.CertificateAuthority.deserialize, @@ -615,7 +707,9 @@ def list_certificate_authorities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_authorities" not in self._stubs: - self._stubs["list_certificate_authorities"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_authorities" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities", request_serializer=service.ListCertificateAuthoritiesRequest.serialize, response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, @@ -647,7 +741,7 @@ def restore_certificate_authority( if "restore_certificate_authority" not in self._stubs: self._stubs[ "restore_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority", request_serializer=service.RestoreCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -680,7 +774,7 @@ def schedule_delete_certificate_authority( if "schedule_delete_certificate_authority" not in self._stubs: self._stubs[ "schedule_delete_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority", request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -709,7 +803,9 @@ def update_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_authority" not in self._stubs: - self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -742,7 +838,7 @@ def get_certificate_revocation_list( if "get_certificate_revocation_list" not in self._stubs: self._stubs[ "get_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList", request_serializer=service.GetCertificateRevocationListRequest.serialize, response_deserializer=resources.CertificateRevocationList.deserialize, @@ -775,7 +871,7 @@ def list_certificate_revocation_lists( if "list_certificate_revocation_lists" not in self._stubs: self._stubs[ "list_certificate_revocation_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists", request_serializer=service.ListCertificateRevocationListsRequest.serialize, response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, @@ -807,7 +903,7 @@ def update_certificate_revocation_list( if "update_certificate_revocation_list" not in self._stubs: self._stubs[ "update_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -834,7 +930,7 @@ def get_reusable_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reusable_config" not in self._stubs: - self._stubs["get_reusable_config"] = self.grpc_channel.unary_unary( + self._stubs["get_reusable_config"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig", request_serializer=service.GetReusableConfigRequest.serialize, response_deserializer=resources.ReusableConfig.deserialize, @@ -863,7 +959,7 @@ def list_reusable_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reusable_configs" not in self._stubs: - self._stubs["list_reusable_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_reusable_configs"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs", request_serializer=service.ListReusableConfigsRequest.serialize, response_deserializer=service.ListReusableConfigsResponse.deserialize, @@ -871,7 +967,7 @@ def list_reusable_configs( return self._stubs["list_reusable_configs"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py index 2f04d947c6b0..d27586c7c883 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.security.privateca_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, CertificateAuthorityServiceTransport from .grpc import CertificateAuthorityServiceGrpcTransport +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.security.privateca.v1beta1.CertificateAuthorityService", + "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.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateAuthorityServiceGrpcAsyncIOTransport( CertificateAuthorityServiceTransport @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -286,7 +371,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate", request_serializer=service.CreateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -313,7 +398,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate", request_serializer=service.GetCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -342,7 +427,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates", request_serializer=service.ListCertificatesRequest.serialize, response_deserializer=service.ListCertificatesResponse.deserialize, @@ -369,7 +454,7 @@ def revoke_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_certificate" not in self._stubs: - self._stubs["revoke_certificate"] = self.grpc_channel.unary_unary( + self._stubs["revoke_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate", request_serializer=service.RevokeCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -399,7 +484,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate", request_serializer=service.UpdateCertificateRequest.serialize, response_deserializer=resources.Certificate.deserialize, @@ -439,7 +524,7 @@ def activate_certificate_authority( if "activate_certificate_authority" not in self._stubs: self._stubs[ "activate_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,7 +554,9 @@ def create_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_authority" not in self._stubs: - self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -501,7 +588,7 @@ def disable_certificate_authority( if "disable_certificate_authority" not in self._stubs: self._stubs[ "disable_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -530,7 +617,9 @@ def enable_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enable_certificate_authority" not in self._stubs: - self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "enable_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -572,7 +661,7 @@ def fetch_certificate_authority_csr( if "fetch_certificate_authority_csr" not in self._stubs: self._stubs[ "fetch_certificate_authority_csr" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr", request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, @@ -602,7 +691,7 @@ def get_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_authority" not in self._stubs: - self._stubs["get_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_authority"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority", request_serializer=service.GetCertificateAuthorityRequest.serialize, response_deserializer=resources.CertificateAuthority.deserialize, @@ -632,7 +721,9 @@ def list_certificate_authorities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_authorities" not in self._stubs: - self._stubs["list_certificate_authorities"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_authorities" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities", request_serializer=service.ListCertificateAuthoritiesRequest.serialize, response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, @@ -665,7 +756,7 @@ def restore_certificate_authority( if "restore_certificate_authority" not in self._stubs: self._stubs[ "restore_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority", request_serializer=service.RestoreCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -699,7 +790,7 @@ def schedule_delete_certificate_authority( if "schedule_delete_certificate_authority" not in self._stubs: self._stubs[ "schedule_delete_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority", request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -728,7 +819,9 @@ def update_certificate_authority( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_authority" not in self._stubs: - self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_authority" + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -761,7 +854,7 @@ def get_certificate_revocation_list( if "get_certificate_revocation_list" not in self._stubs: self._stubs[ "get_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList", request_serializer=service.GetCertificateRevocationListRequest.serialize, response_deserializer=resources.CertificateRevocationList.deserialize, @@ -794,7 +887,7 @@ def list_certificate_revocation_lists( if "list_certificate_revocation_lists" not in self._stubs: self._stubs[ "list_certificate_revocation_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists", request_serializer=service.ListCertificateRevocationListsRequest.serialize, response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, @@ -827,7 +920,7 @@ def update_certificate_revocation_list( if "update_certificate_revocation_list" not in self._stubs: self._stubs[ "update_certificate_revocation_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -856,7 +949,7 @@ def get_reusable_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reusable_config" not in self._stubs: - self._stubs["get_reusable_config"] = self.grpc_channel.unary_unary( + self._stubs["get_reusable_config"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig", request_serializer=service.GetReusableConfigRequest.serialize, response_deserializer=resources.ReusableConfig.deserialize, @@ -886,7 +979,7 @@ def list_reusable_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reusable_configs" not in self._stubs: - self._stubs["list_reusable_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_reusable_configs"] = self._logged_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs", request_serializer=service.ListReusableConfigsRequest.serialize, response_deserializer=service.ListReusableConfigsResponse.deserialize, @@ -1004,7 +1097,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/rest.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/rest.py index e73d9027b4f4..3c171c10269a 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/rest.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -230,8 +238,11 @@ def post_update_certificate_revocation_list(self, response): def pre_activate_certificate_authority( self, request: service.ActivateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ActivateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ActivateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for activate_certificate_authority Override in a subclass to manipulate the request or metadata @@ -253,8 +264,10 @@ def post_activate_certificate_authority( def pre_create_certificate( self, request: service.CreateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_certificate Override in a subclass to manipulate the request or metadata @@ -276,8 +289,11 @@ def post_create_certificate( def pre_create_certificate_authority( self, request: service.CreateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_certificate_authority Override in a subclass to manipulate the request or metadata @@ -299,8 +315,11 @@ def post_create_certificate_authority( def pre_disable_certificate_authority( self, request: service.DisableCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DisableCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.DisableCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for disable_certificate_authority Override in a subclass to manipulate the request or metadata @@ -322,8 +341,11 @@ def post_disable_certificate_authority( def pre_enable_certificate_authority( self, request: service.EnableCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EnableCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EnableCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for enable_certificate_authority Override in a subclass to manipulate the request or metadata @@ -345,8 +367,11 @@ def post_enable_certificate_authority( def pre_fetch_certificate_authority_csr( self, request: service.FetchCertificateAuthorityCsrRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.FetchCertificateAuthorityCsrRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.FetchCertificateAuthorityCsrRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_certificate_authority_csr Override in a subclass to manipulate the request or metadata @@ -368,8 +393,8 @@ def post_fetch_certificate_authority_csr( def pre_get_certificate( self, request: service.GetCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_certificate Override in a subclass to manipulate the request or metadata @@ -391,8 +416,10 @@ def post_get_certificate( def pre_get_certificate_authority( self, request: service.GetCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetCertificateAuthorityRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_certificate_authority Override in a subclass to manipulate the request or metadata @@ -414,8 +441,11 @@ def post_get_certificate_authority( def pre_get_certificate_revocation_list( self, request: service.GetCertificateRevocationListRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetCertificateRevocationListRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetCertificateRevocationListRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_certificate_revocation_list Override in a subclass to manipulate the request or metadata @@ -437,8 +467,10 @@ def post_get_certificate_revocation_list( def pre_get_reusable_config( self, request: service.GetReusableConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetReusableConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetReusableConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_reusable_config Override in a subclass to manipulate the request or metadata @@ -460,8 +492,11 @@ def post_get_reusable_config( def pre_list_certificate_authorities( self, request: service.ListCertificateAuthoritiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListCertificateAuthoritiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListCertificateAuthoritiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_certificate_authorities Override in a subclass to manipulate the request or metadata @@ -483,9 +518,10 @@ def post_list_certificate_authorities( def pre_list_certificate_revocation_lists( self, request: service.ListCertificateRevocationListsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - service.ListCertificateRevocationListsRequest, Sequence[Tuple[str, str]] + service.ListCertificateRevocationListsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_certificate_revocation_lists @@ -508,8 +544,10 @@ def post_list_certificate_revocation_lists( def pre_list_certificates( self, request: service.ListCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListCertificatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_certificates Override in a subclass to manipulate the request or metadata @@ -531,8 +569,10 @@ def post_list_certificates( def pre_list_reusable_configs( self, request: service.ListReusableConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListReusableConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListReusableConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_reusable_configs Override in a subclass to manipulate the request or metadata @@ -554,8 +594,11 @@ def post_list_reusable_configs( def pre_restore_certificate_authority( self, request: service.RestoreCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestoreCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.RestoreCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for restore_certificate_authority Override in a subclass to manipulate the request or metadata @@ -577,8 +620,10 @@ def post_restore_certificate_authority( def pre_revoke_certificate( self, request: service.RevokeCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RevokeCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.RevokeCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for revoke_certificate Override in a subclass to manipulate the request or metadata @@ -600,9 +645,10 @@ def post_revoke_certificate( def pre_schedule_delete_certificate_authority( self, request: service.ScheduleDeleteCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - service.ScheduleDeleteCertificateAuthorityRequest, Sequence[Tuple[str, str]] + service.ScheduleDeleteCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for schedule_delete_certificate_authority @@ -625,8 +671,10 @@ def post_schedule_delete_certificate_authority( def pre_update_certificate( self, request: service.UpdateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_certificate Override in a subclass to manipulate the request or metadata @@ -648,8 +696,11 @@ def post_update_certificate( def pre_update_certificate_authority( self, request: service.UpdateCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateCertificateAuthorityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateCertificateAuthorityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_certificate_authority Override in a subclass to manipulate the request or metadata @@ -671,9 +722,10 @@ def post_update_certificate_authority( def pre_update_certificate_revocation_list( self, request: service.UpdateCertificateRevocationListRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - service.UpdateCertificateRevocationListRequest, Sequence[Tuple[str, str]] + service.UpdateCertificateRevocationListRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_certificate_revocation_list @@ -876,7 +928,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the activate certificate authority method over HTTP. @@ -888,8 +940,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -902,6 +956,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseActivateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_activate_certificate_authority( request, metadata ) @@ -918,6 +973,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ActivateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ActivateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ActivateCertificateAuthority._get_response( self._host, @@ -937,7 +1019,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_activate_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.activate_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ActivateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificate( @@ -976,7 +1080,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the create certificate method over HTTP. @@ -987,8 +1091,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -1002,6 +1108,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate( request, metadata ) @@ -1018,6 +1125,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.CreateCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "CreateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._CreateCertificate._get_response( self._host, @@ -1039,7 +1173,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.create_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "CreateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateAuthority( @@ -1080,7 +1236,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create certificate authority method over HTTP. @@ -1092,8 +1248,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1106,6 +1264,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseCreateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate_authority( request, metadata ) @@ -1122,6 +1281,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.CreateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "CreateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._CreateCertificateAuthority._get_response( self._host, @@ -1141,7 +1327,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.create_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "CreateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableCertificateAuthority( @@ -1182,7 +1390,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the disable certificate authority method over HTTP. @@ -1194,8 +1402,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1208,6 +1418,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseDisableCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_disable_certificate_authority( request, metadata ) @@ -1224,6 +1435,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.DisableCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "DisableCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._DisableCertificateAuthority._get_response( self._host, @@ -1243,7 +1481,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.disable_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "DisableCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableCertificateAuthority( @@ -1284,7 +1544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the enable certificate authority method over HTTP. @@ -1296,8 +1556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1310,6 +1572,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseEnableCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_enable_certificate_authority( request, metadata ) @@ -1326,6 +1589,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.EnableCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "EnableCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._EnableCertificateAuthority._get_response( self._host, @@ -1345,7 +1635,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.enable_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "EnableCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchCertificateAuthorityCsr( @@ -1385,7 +1697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.FetchCertificateAuthorityCsrResponse: r"""Call the fetch certificate authority csr method over HTTP. @@ -1397,8 +1709,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.FetchCertificateAuthorityCsrResponse: @@ -1410,6 +1724,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseFetchCertificateAuthorityCsr._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_certificate_authority_csr( request, metadata ) @@ -1422,6 +1737,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.FetchCertificateAuthorityCsr", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "FetchCertificateAuthorityCsr", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._FetchCertificateAuthorityCsr._get_response( self._host, @@ -1442,7 +1784,31 @@ def __call__( pb_resp = service.FetchCertificateAuthorityCsrResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_certificate_authority_csr(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.FetchCertificateAuthorityCsrResponse.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.fetch_certificate_authority_csr", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "FetchCertificateAuthorityCsr", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificate( @@ -1480,7 +1846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the get certificate method over HTTP. @@ -1491,8 +1857,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -1506,6 +1874,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate(request, metadata) transcoded_request = _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificate._get_transcoded_request( http_options, request @@ -1516,6 +1885,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.GetCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateAuthorityServiceRestTransport._GetCertificate._get_response( @@ -1538,7 +1934,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.get_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateAuthority( @@ -1578,7 +1996,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateAuthority: r"""Call the get certificate authority method over HTTP. @@ -1589,8 +2007,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CertificateAuthority: @@ -1606,6 +2026,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_authority( request, metadata ) @@ -1618,6 +2039,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.GetCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetCertificateAuthority._get_response( self._host, @@ -1638,7 +2086,29 @@ def __call__( pb_resp = resources.CertificateAuthority.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_authority(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CertificateAuthority.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.get_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateRevocationList( @@ -1678,7 +2148,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CertificateRevocationList: r"""Call the get certificate revocation list method over HTTP. @@ -1690,8 +2160,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.CertificateRevocationList: @@ -1706,6 +2178,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetCertificateRevocationList._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_revocation_list( request, metadata ) @@ -1718,6 +2191,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.GetCertificateRevocationList", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificateRevocationList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetCertificateRevocationList._get_response( self._host, @@ -1738,7 +2238,31 @@ def __call__( pb_resp = resources.CertificateRevocationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_revocation_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CertificateRevocationList.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.get_certificate_revocation_list", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetCertificateRevocationList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReusableConfig( @@ -1776,7 +2300,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ReusableConfig: r"""Call the get reusable config method over HTTP. @@ -1787,8 +2311,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.ReusableConfig: @@ -1806,6 +2332,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseGetReusableConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_reusable_config( request, metadata ) @@ -1818,6 +2345,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.GetReusableConfig", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetReusableConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._GetReusableConfig._get_response( self._host, @@ -1838,7 +2392,29 @@ def __call__( pb_resp = resources.ReusableConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reusable_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ReusableConfig.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.get_reusable_config", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "GetReusableConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateAuthorities( @@ -1878,7 +2454,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificateAuthoritiesResponse: r"""Call the list certificate authorities method over HTTP. @@ -1890,8 +2466,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificateAuthoritiesResponse: @@ -1903,6 +2481,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificateAuthorities._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_authorities( request, metadata ) @@ -1915,6 +2494,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ListCertificateAuthorities", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificateAuthorities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificateAuthorities._get_response( self._host, @@ -1935,7 +2541,31 @@ def __call__( pb_resp = service.ListCertificateAuthoritiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_authorities(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListCertificateAuthoritiesResponse.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.list_certificate_authorities", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificateAuthorities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateRevocationLists( @@ -1975,7 +2605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificateRevocationListsResponse: r"""Call the list certificate revocation lists method over HTTP. @@ -1987,8 +2617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificateRevocationListsResponse: @@ -2000,6 +2632,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificateRevocationLists._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_revocation_lists( request, metadata ) @@ -2012,6 +2645,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ListCertificateRevocationLists", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificateRevocationLists", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificateRevocationLists._get_response( self._host, @@ -2032,7 +2692,31 @@ def __call__( pb_resp = service.ListCertificateRevocationListsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_revocation_lists(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListCertificateRevocationListsResponse.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.list_certificate_revocation_lists", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificateRevocationLists", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificates( @@ -2070,7 +2754,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListCertificatesResponse: r"""Call the list certificates method over HTTP. @@ -2081,8 +2765,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListCertificatesResponse: @@ -2094,6 +2780,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificates( request, metadata ) @@ -2106,6 +2793,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ListCertificates", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListCertificates._get_response( self._host, @@ -2126,7 +2840,31 @@ def __call__( pb_resp = service.ListCertificatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListCertificatesResponse.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.list_certificates", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReusableConfigs( @@ -2164,7 +2902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListReusableConfigsResponse: r"""Call the list reusable configs method over HTTP. @@ -2175,8 +2913,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.service.ListReusableConfigsResponse: @@ -2188,6 +2928,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseListReusableConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_reusable_configs( request, metadata ) @@ -2200,6 +2941,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ListReusableConfigs", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListReusableConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ListReusableConfigs._get_response( self._host, @@ -2220,7 +2988,31 @@ def __call__( pb_resp = service.ListReusableConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reusable_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListReusableConfigsResponse.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.list_reusable_configs", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ListReusableConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreCertificateAuthority( @@ -2261,7 +3053,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restore certificate authority method over HTTP. @@ -2273,8 +3065,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2287,6 +3081,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseRestoreCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_restore_certificate_authority( request, metadata ) @@ -2303,6 +3098,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.RestoreCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "RestoreCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._RestoreCertificateAuthority._get_response( self._host, @@ -2322,7 +3144,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.restore_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "RestoreCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RevokeCertificate( @@ -2361,7 +3205,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the revoke certificate method over HTTP. @@ -2372,8 +3216,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -2387,6 +3233,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseRevokeCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_revoke_certificate( request, metadata ) @@ -2403,6 +3250,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.RevokeCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "RevokeCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._RevokeCertificate._get_response( self._host, @@ -2424,7 +3298,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_revoke_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.revoke_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "RevokeCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ScheduleDeleteCertificateAuthority( @@ -2465,7 +3361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the schedule delete certificate authority method over HTTP. @@ -2477,8 +3373,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2491,6 +3389,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseScheduleDeleteCertificateAuthority._get_http_options() ) + ( request, metadata, @@ -2510,6 +3409,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.ScheduleDeleteCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ScheduleDeleteCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._ScheduleDeleteCertificateAuthority._get_response( self._host, @@ -2529,7 +3455,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_schedule_delete_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.schedule_delete_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "ScheduleDeleteCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificate( @@ -2568,7 +3516,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Certificate: r"""Call the update certificate method over HTTP. @@ -2579,8 +3527,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.Certificate: @@ -2594,6 +3544,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate( request, metadata ) @@ -2610,6 +3561,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.UpdateCertificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificate._get_response( self._host, @@ -2631,7 +3609,29 @@ def __call__( pb_resp = resources.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Certificate.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.security.privateca_v1beta1.CertificateAuthorityServiceClient.update_certificate", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateAuthority( @@ -2672,7 +3672,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update certificate authority method over HTTP. @@ -2684,8 +3684,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2698,6 +3700,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate_authority( request, metadata ) @@ -2714,6 +3717,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.UpdateCertificateAuthority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificateAuthority._get_response( self._host, @@ -2733,7 +3763,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_authority(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.update_certificate_authority", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateRevocationList( @@ -2774,7 +3826,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update certificate revocation list method over HTTP. @@ -2786,8 +3838,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2800,6 +3854,7 @@ def __call__( http_options = ( _BaseCertificateAuthorityServiceRestTransport._BaseUpdateCertificateRevocationList._get_http_options() ) + ( request, metadata, @@ -2819,6 +3874,33 @@ def __call__( 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.security.privateca_v1beta1.CertificateAuthorityServiceClient.UpdateCertificateRevocationList", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificateRevocationList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateAuthorityServiceRestTransport._UpdateCertificateRevocationList._get_response( self._host, @@ -2838,7 +3920,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_revocation_list(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.security.privateca_v1beta1.CertificateAuthorityServiceClient.update_certificate_revocation_list", + extra={ + "serviceName": "google.cloud.security.privateca.v1beta1.CertificateAuthorityService", + "rpcName": "UpdateCertificateRevocationList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1.json b/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1.json index 3f935dd6299b..ca2ab4a8547d 100644 --- a/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1.json +++ b/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-private-ca", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -570,7 +570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -747,7 +747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -835,7 +835,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -996,7 +996,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1077,7 +1077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1157,7 +1157,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1238,7 +1238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1318,7 +1318,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1399,7 +1399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1479,7 +1479,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1560,7 +1560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1640,7 +1640,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1721,7 +1721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.FetchCaCertsResponse", @@ -1801,7 +1801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.FetchCaCertsResponse", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse", @@ -1962,7 +1962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse", @@ -2043,7 +2043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CaPool", @@ -2123,7 +2123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CaPool", @@ -2204,7 +2204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateAuthority", @@ -2284,7 +2284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateAuthority", @@ -2365,7 +2365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateRevocationList", @@ -2445,7 +2445,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateRevocationList", @@ -2526,7 +2526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateTemplate", @@ -2606,7 +2606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.CertificateTemplate", @@ -2687,7 +2687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -2767,7 +2767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -2848,7 +2848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsAsyncPager", @@ -2928,7 +2928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsPager", @@ -3009,7 +3009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager", @@ -3170,7 +3170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager", @@ -3250,7 +3250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager", @@ -3331,7 +3331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesAsyncPager", @@ -3411,7 +3411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesPager", @@ -3492,7 +3492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager", @@ -3572,7 +3572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesPager", @@ -3653,7 +3653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -3733,7 +3733,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -3814,7 +3814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3894,7 +3894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3979,7 +3979,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4063,7 +4063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4148,7 +4148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4232,7 +4232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4317,7 +4317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4401,7 +4401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4486,7 +4486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4570,7 +4570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4655,7 +4655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", @@ -4739,7 +4739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1.types.Certificate", diff --git a/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1beta1.json b/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1beta1.json index 649b113e1de2..a2c343c16a72 100644 --- a/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1beta1.json +++ b/packages/google-cloud-private-ca/samples/generated_samples/snippet_metadata_google.cloud.security.privateca.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-private-ca", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse", @@ -1045,7 +1045,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.CertificateAuthority", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.CertificateAuthority", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.CertificateRevocationList", @@ -1286,7 +1286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.CertificateRevocationList", @@ -1367,7 +1367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.ReusableConfig", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.ReusableConfig", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager", @@ -1850,7 +1850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager", @@ -1930,7 +1930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager", @@ -2011,7 +2011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager", @@ -2091,7 +2091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesPager", @@ -2172,7 +2172,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsAsyncPager", @@ -2252,7 +2252,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsPager", @@ -2333,7 +2333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2413,7 +2413,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2494,7 +2494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -2574,7 +2574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -2655,7 +2655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2735,7 +2735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2820,7 +2820,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2904,7 +2904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2989,7 +2989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3158,7 +3158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", @@ -3242,7 +3242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.privateca_v1beta1.types.Certificate", diff --git a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py index 4389336bf602..d0c66d880a29 100644 --- a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py +++ b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py @@ -12484,6 +12484,7 @@ def test_create_certificate_rest_required_fields( response_value._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_certificate(request) @@ -12548,6 +12549,7 @@ def test_create_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -12681,6 +12683,7 @@ def test_get_certificate_rest_required_fields( response_value._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_certificate(request) @@ -12728,6 +12731,7 @@ def test_get_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -12870,6 +12874,7 @@ def test_list_certificates_rest_required_fields( response_value._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_certificates(request) @@ -12927,6 +12932,7 @@ def test_list_certificates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificates(**mock_args) @@ -13126,6 +13132,7 @@ def test_revoke_certificate_rest_required_fields( response_value._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.revoke_certificate(request) @@ -13181,6 +13188,7 @@ def test_revoke_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.revoke_certificate(**mock_args) @@ -13319,6 +13327,7 @@ def test_update_certificate_rest_required_fields( response_value._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_certificate(request) @@ -13382,6 +13391,7 @@ def test_update_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -13525,6 +13535,7 @@ def test_activate_certificate_authority_rest_required_fields( response_value._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.activate_certificate_authority(request) @@ -13581,6 +13592,7 @@ def test_activate_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.activate_certificate_authority(**mock_args) @@ -13738,6 +13750,7 @@ def test_create_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -13805,6 +13818,7 @@ def test_create_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -13945,6 +13959,7 @@ def test_disable_certificate_authority_rest_required_fields( response_value._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.disable_certificate_authority(request) @@ -13992,6 +14007,7 @@ def test_disable_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.disable_certificate_authority(**mock_args) @@ -14130,6 +14146,7 @@ def test_enable_certificate_authority_rest_required_fields( response_value._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.enable_certificate_authority(request) @@ -14175,6 +14192,7 @@ def test_enable_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.enable_certificate_authority(**mock_args) @@ -14311,6 +14329,7 @@ def test_fetch_certificate_authority_csr_rest_required_fields( response_value._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.fetch_certificate_authority_csr(request) @@ -14360,6 +14379,7 @@ def test_fetch_certificate_authority_csr_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.fetch_certificate_authority_csr(**mock_args) @@ -14496,6 +14516,7 @@ def test_get_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -14543,6 +14564,7 @@ def test_get_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -14688,6 +14710,7 @@ def test_list_certificate_authorities_rest_required_fields( response_value._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_certificate_authorities(request) @@ -14745,6 +14768,7 @@ def test_list_certificate_authorities_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authorities(**mock_args) @@ -14948,6 +14972,7 @@ def test_undelete_certificate_authority_rest_required_fields( response_value._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.undelete_certificate_authority(request) @@ -14995,6 +15020,7 @@ def test_undelete_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_certificate_authority(**mock_args) @@ -15141,6 +15167,7 @@ def test_delete_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -15196,6 +15223,7 @@ def test_delete_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -15336,6 +15364,7 @@ def test_update_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -15397,6 +15426,7 @@ def test_update_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -15543,6 +15573,7 @@ def test_create_ca_pool_rest_required_fields(request_type=service.CreateCaPoolRe response_value._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_ca_pool(request) @@ -15608,6 +15639,7 @@ def test_create_ca_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ca_pool(**mock_args) @@ -15742,6 +15774,7 @@ def test_update_ca_pool_rest_required_fields(request_type=service.UpdateCaPoolRe response_value._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_ca_pool(request) @@ -15801,6 +15834,7 @@ def test_update_ca_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ca_pool(**mock_args) @@ -15931,6 +15965,7 @@ def test_get_ca_pool_rest_required_fields(request_type=service.GetCaPoolRequest) response_value._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_ca_pool(request) @@ -15976,6 +16011,7 @@ def test_get_ca_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ca_pool(**mock_args) @@ -16113,6 +16149,7 @@ def test_list_ca_pools_rest_required_fields(request_type=service.ListCaPoolsRequ response_value._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_ca_pools(request) @@ -16168,6 +16205,7 @@ def test_list_ca_pools_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ca_pools(**mock_args) @@ -16365,6 +16403,7 @@ def test_delete_ca_pool_rest_required_fields(request_type=service.DeleteCaPoolRe response_value._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_ca_pool(request) @@ -16416,6 +16455,7 @@ def test_delete_ca_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_ca_pool(**mock_args) @@ -16545,6 +16585,7 @@ def test_fetch_ca_certs_rest_required_fields(request_type=service.FetchCaCertsRe response_value._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.fetch_ca_certs(request) @@ -16592,6 +16633,7 @@ def test_fetch_ca_certs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.fetch_ca_certs(**mock_args) @@ -16728,6 +16770,7 @@ def test_get_certificate_revocation_list_rest_required_fields( response_value._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_certificate_revocation_list(request) @@ -16777,6 +16820,7 @@ def test_get_certificate_revocation_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_list(**mock_args) @@ -16924,6 +16968,7 @@ def test_list_certificate_revocation_lists_rest_required_fields( response_value._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_certificate_revocation_lists(request) @@ -16983,6 +17028,7 @@ def test_list_certificate_revocation_lists_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_lists(**mock_args) @@ -17192,6 +17238,7 @@ def test_update_certificate_revocation_list_rest_required_fields( response_value._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_certificate_revocation_list(request) @@ -17257,6 +17304,7 @@ def test_update_certificate_revocation_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_list(**mock_args) @@ -17417,6 +17465,7 @@ def test_create_certificate_template_rest_required_fields( response_value._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_certificate_template(request) @@ -17482,6 +17531,7 @@ def test_create_certificate_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_template(**mock_args) @@ -17623,6 +17673,7 @@ def test_delete_certificate_template_rest_required_fields( response_value._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_certificate_template(request) @@ -17668,6 +17719,7 @@ def test_delete_certificate_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_template(**mock_args) @@ -17804,6 +17856,7 @@ def test_get_certificate_template_rest_required_fields( response_value._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_certificate_template(request) @@ -17851,6 +17904,7 @@ def test_get_certificate_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_template(**mock_args) @@ -17996,6 +18050,7 @@ def test_list_certificate_templates_rest_required_fields( response_value._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_certificate_templates(request) @@ -18051,6 +18106,7 @@ def test_list_certificate_templates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_templates(**mock_args) @@ -18254,6 +18310,7 @@ def test_update_certificate_template_rest_required_fields( response_value._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_certificate_template(request) @@ -18315,6 +18372,7 @@ def test_update_certificate_template_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_template(**mock_args) @@ -19980,6 +20038,7 @@ def test_create_certificate_rest_bad_request( 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_certificate(request) @@ -20226,6 +20285,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -20271,6 +20331,7 @@ def test_create_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -20315,6 +20376,7 @@ def test_get_certificate_rest_bad_request(request_type=service.GetCertificateReq 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_certificate(request) @@ -20358,6 +20420,7 @@ def test_get_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -20401,6 +20464,7 @@ def test_get_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -20445,6 +20509,7 @@ def test_list_certificates_rest_bad_request( 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_certificates(request) @@ -20481,6 +20546,7 @@ def test_list_certificates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificates(request) # Establish that the response is the type that we expect. @@ -20522,6 +20588,7 @@ def test_list_certificates_rest_interceptors(null_interceptor): 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 = service.ListCertificatesResponse.to_json( service.ListCertificatesResponse() ) @@ -20570,6 +20637,7 @@ def test_revoke_certificate_rest_bad_request( 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.revoke_certificate(request) @@ -20613,6 +20681,7 @@ def test_revoke_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.revoke_certificate(request) # Establish that the response is the type that we expect. @@ -20658,6 +20727,7 @@ def test_revoke_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -20706,6 +20776,7 @@ def test_update_certificate_rest_bad_request( 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_certificate(request) @@ -20956,6 +21027,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -21001,6 +21073,7 @@ def test_update_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -21047,6 +21120,7 @@ def test_activate_certificate_authority_rest_bad_request( 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.activate_certificate_authority(request) @@ -21079,6 +21153,7 @@ def test_activate_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.activate_certificate_authority(request) # Establish that the response is the type that we expect. @@ -21122,6 +21197,7 @@ def test_activate_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -21166,6 +21242,7 @@ def test_create_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -21421,6 +21498,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -21464,6 +21542,7 @@ def test_create_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -21510,6 +21589,7 @@ def test_disable_certificate_authority_rest_bad_request( 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.disable_certificate_authority(request) @@ -21542,6 +21622,7 @@ def test_disable_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_certificate_authority(request) # Establish that the response is the type that we expect. @@ -21585,6 +21666,7 @@ def test_disable_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -21631,6 +21713,7 @@ def test_enable_certificate_authority_rest_bad_request( 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.enable_certificate_authority(request) @@ -21663,6 +21746,7 @@ def test_enable_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_certificate_authority(request) # Establish that the response is the type that we expect. @@ -21706,6 +21790,7 @@ def test_enable_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -21752,6 +21837,7 @@ def test_fetch_certificate_authority_csr_rest_bad_request( 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.fetch_certificate_authority_csr(request) @@ -21789,6 +21875,7 @@ def test_fetch_certificate_authority_csr_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.fetch_certificate_authority_csr(request) # Establish that the response is the type that we expect. @@ -21831,6 +21918,7 @@ def test_fetch_certificate_authority_csr_rest_interceptors(null_interceptor): 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 = service.FetchCertificateAuthorityCsrResponse.to_json( service.FetchCertificateAuthorityCsrResponse() ) @@ -21879,6 +21967,7 @@ def test_get_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -21921,6 +22010,7 @@ def test_get_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -21968,6 +22058,7 @@ def test_get_certificate_authority_rest_interceptors(null_interceptor): 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 = resources.CertificateAuthority.to_json( resources.CertificateAuthority() ) @@ -22014,6 +22105,7 @@ def test_list_certificate_authorities_rest_bad_request( 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_certificate_authorities(request) @@ -22050,6 +22142,7 @@ def test_list_certificate_authorities_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authorities(request) # Establish that the response is the type that we expect. @@ -22093,6 +22186,7 @@ def test_list_certificate_authorities_rest_interceptors(null_interceptor): 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 = service.ListCertificateAuthoritiesResponse.to_json( service.ListCertificateAuthoritiesResponse() ) @@ -22141,6 +22235,7 @@ def test_undelete_certificate_authority_rest_bad_request( 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.undelete_certificate_authority(request) @@ -22173,6 +22268,7 @@ def test_undelete_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_certificate_authority(request) # Establish that the response is the type that we expect. @@ -22216,6 +22312,7 @@ def test_undelete_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -22262,6 +22359,7 @@ def test_delete_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -22294,6 +22392,7 @@ def test_delete_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -22337,6 +22436,7 @@ def test_delete_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -22385,6 +22485,7 @@ def test_update_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -22644,6 +22745,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -22687,6 +22789,7 @@ def test_update_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -22729,6 +22832,7 @@ def test_create_ca_pool_rest_bad_request(request_type=service.CreateCaPoolReques 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_ca_pool(request) @@ -22928,6 +23032,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_ca_pool(request) # Establish that the response is the type that we expect. @@ -22967,6 +23072,7 @@ def test_create_ca_pool_rest_interceptors(null_interceptor): 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 @@ -23011,6 +23117,7 @@ def test_update_ca_pool_rest_bad_request(request_type=service.UpdateCaPoolReques 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_ca_pool(request) @@ -23212,6 +23319,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_ca_pool(request) # Establish that the response is the type that we expect. @@ -23251,6 +23359,7 @@ def test_update_ca_pool_rest_interceptors(null_interceptor): 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 @@ -23293,6 +23402,7 @@ def test_get_ca_pool_rest_bad_request(request_type=service.GetCaPoolRequest): 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_ca_pool(request) @@ -23329,6 +23439,7 @@ def test_get_ca_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_ca_pool(request) # Establish that the response is the type that we expect. @@ -23368,6 +23479,7 @@ def test_get_ca_pool_rest_interceptors(null_interceptor): 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 = resources.CaPool.to_json(resources.CaPool()) req.return_value.content = return_value @@ -23410,6 +23522,7 @@ def test_list_ca_pools_rest_bad_request(request_type=service.ListCaPoolsRequest) 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_ca_pools(request) @@ -23446,6 +23559,7 @@ def test_list_ca_pools_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_ca_pools(request) # Establish that the response is the type that we expect. @@ -23485,6 +23599,7 @@ def test_list_ca_pools_rest_interceptors(null_interceptor): 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 = service.ListCaPoolsResponse.to_json( service.ListCaPoolsResponse() ) @@ -23529,6 +23644,7 @@ def test_delete_ca_pool_rest_bad_request(request_type=service.DeleteCaPoolReques 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_ca_pool(request) @@ -23559,6 +23675,7 @@ def test_delete_ca_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_ca_pool(request) # Establish that the response is the type that we expect. @@ -23598,6 +23715,7 @@ def test_delete_ca_pool_rest_interceptors(null_interceptor): 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 @@ -23640,6 +23758,7 @@ def test_fetch_ca_certs_rest_bad_request(request_type=service.FetchCaCertsReques 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.fetch_ca_certs(request) @@ -23673,6 +23792,7 @@ def test_fetch_ca_certs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.fetch_ca_certs(request) # Establish that the response is the type that we expect. @@ -23710,6 +23830,7 @@ def test_fetch_ca_certs_rest_interceptors(null_interceptor): 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 = service.FetchCaCertsResponse.to_json( service.FetchCaCertsResponse() ) @@ -23758,6 +23879,7 @@ def test_get_certificate_revocation_list_rest_bad_request( 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_certificate_revocation_list(request) @@ -23800,6 +23922,7 @@ def test_get_certificate_revocation_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_list(request) # Establish that the response is the type that we expect. @@ -23847,6 +23970,7 @@ def test_get_certificate_revocation_list_rest_interceptors(null_interceptor): 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 = resources.CertificateRevocationList.to_json( resources.CertificateRevocationList() ) @@ -23895,6 +24019,7 @@ def test_list_certificate_revocation_lists_rest_bad_request( 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_certificate_revocation_lists(request) @@ -23933,6 +24058,7 @@ def test_list_certificate_revocation_lists_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_lists(request) # Establish that the response is the type that we expect. @@ -23976,6 +24102,7 @@ def test_list_certificate_revocation_lists_rest_interceptors(null_interceptor): 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 = service.ListCertificateRevocationListsResponse.to_json( service.ListCertificateRevocationListsResponse() ) @@ -24026,6 +24153,7 @@ def test_update_certificate_revocation_list_rest_bad_request( 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_certificate_revocation_list(request) @@ -24151,6 +24279,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_list(request) # Establish that the response is the type that we expect. @@ -24194,6 +24323,7 @@ def test_update_certificate_revocation_list_rest_interceptors(null_interceptor): 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 @@ -24238,6 +24368,7 @@ def test_create_certificate_template_rest_bad_request( 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_certificate_template(request) @@ -24420,6 +24551,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_template(request) # Establish that the response is the type that we expect. @@ -24463,6 +24595,7 @@ def test_create_certificate_template_rest_interceptors(null_interceptor): 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 @@ -24509,6 +24642,7 @@ def test_delete_certificate_template_rest_bad_request( 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_certificate_template(request) @@ -24541,6 +24675,7 @@ def test_delete_certificate_template_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_template(request) # Establish that the response is the type that we expect. @@ -24584,6 +24719,7 @@ def test_delete_certificate_template_rest_interceptors(null_interceptor): 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 @@ -24630,6 +24766,7 @@ def test_get_certificate_template_rest_bad_request( 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_certificate_template(request) @@ -24668,6 +24805,7 @@ def test_get_certificate_template_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_template(request) # Establish that the response is the type that we expect. @@ -24711,6 +24849,7 @@ def test_get_certificate_template_rest_interceptors(null_interceptor): 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 = resources.CertificateTemplate.to_json( resources.CertificateTemplate() ) @@ -24757,6 +24896,7 @@ def test_list_certificate_templates_rest_bad_request( 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_certificate_templates(request) @@ -24793,6 +24933,7 @@ def test_list_certificate_templates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_templates(request) # Establish that the response is the type that we expect. @@ -24836,6 +24977,7 @@ def test_list_certificate_templates_rest_interceptors(null_interceptor): 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 = service.ListCertificateTemplatesResponse.to_json( service.ListCertificateTemplatesResponse() ) @@ -24886,6 +25028,7 @@ def test_update_certificate_template_rest_bad_request( 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_certificate_template(request) @@ -25072,6 +25215,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_template(request) # Establish that the response is the type that we expect. @@ -25115,6 +25259,7 @@ def test_update_certificate_template_rest_interceptors(null_interceptor): 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 @@ -25159,6 +25304,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -25189,6 +25335,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -25217,6 +25364,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -25247,6 +25395,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -25277,6 +25426,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -25307,6 +25457,7 @@ def test_get_iam_policy_rest(request_type): response_value.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_iam_policy(request) @@ -25337,6 +25488,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -25367,6 +25519,7 @@ def test_set_iam_policy_rest(request_type): response_value.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.set_iam_policy(request) @@ -25397,6 +25550,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -25427,6 +25581,7 @@ def test_test_iam_permissions_rest(request_type): response_value.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.test_iam_permissions(request) @@ -25457,6 +25612,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -25487,6 +25643,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -25517,6 +25674,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -25547,6 +25705,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -25577,6 +25736,7 @@ def test_get_operation_rest_bad_request( 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) @@ -25607,6 +25767,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -25637,6 +25798,7 @@ def test_list_operations_rest_bad_request( 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) @@ -25667,6 +25829,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py index 10e9b00d8635..6cb3ffdafd03 100644 --- a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py +++ b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py @@ -9156,6 +9156,7 @@ def test_create_certificate_rest_required_fields( response_value._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_certificate(request) @@ -9218,6 +9219,7 @@ def test_create_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -9351,6 +9353,7 @@ def test_get_certificate_rest_required_fields( response_value._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_certificate(request) @@ -9398,6 +9401,7 @@ def test_get_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -9540,6 +9544,7 @@ def test_list_certificates_rest_required_fields( response_value._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_certificates(request) @@ -9597,6 +9602,7 @@ def test_list_certificates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificates(**mock_args) @@ -9796,6 +9802,7 @@ def test_revoke_certificate_rest_required_fields( response_value._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.revoke_certificate(request) @@ -9851,6 +9858,7 @@ def test_revoke_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.revoke_certificate(**mock_args) @@ -9989,6 +9997,7 @@ def test_update_certificate_rest_required_fields( response_value._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_certificate(request) @@ -10052,6 +10061,7 @@ def test_update_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate(**mock_args) @@ -10195,6 +10205,7 @@ def test_activate_certificate_authority_rest_required_fields( response_value._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.activate_certificate_authority(request) @@ -10251,6 +10262,7 @@ def test_activate_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.activate_certificate_authority(**mock_args) @@ -10408,6 +10420,7 @@ def test_create_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -10473,6 +10486,7 @@ def test_create_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -10613,6 +10627,7 @@ def test_disable_certificate_authority_rest_required_fields( response_value._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.disable_certificate_authority(request) @@ -10660,6 +10675,7 @@ def test_disable_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.disable_certificate_authority(**mock_args) @@ -10798,6 +10814,7 @@ def test_enable_certificate_authority_rest_required_fields( response_value._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.enable_certificate_authority(request) @@ -10843,6 +10860,7 @@ def test_enable_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.enable_certificate_authority(**mock_args) @@ -10979,6 +10997,7 @@ def test_fetch_certificate_authority_csr_rest_required_fields( response_value._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.fetch_certificate_authority_csr(request) @@ -11028,6 +11047,7 @@ def test_fetch_certificate_authority_csr_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.fetch_certificate_authority_csr(**mock_args) @@ -11164,6 +11184,7 @@ def test_get_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -11211,6 +11232,7 @@ def test_get_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -11356,6 +11378,7 @@ def test_list_certificate_authorities_rest_required_fields( response_value._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_certificate_authorities(request) @@ -11411,6 +11434,7 @@ def test_list_certificate_authorities_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authorities(**mock_args) @@ -11612,6 +11636,7 @@ def test_restore_certificate_authority_rest_required_fields( response_value._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.restore_certificate_authority(request) @@ -11659,6 +11684,7 @@ def test_restore_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.restore_certificate_authority(**mock_args) @@ -11801,6 +11827,7 @@ def test_schedule_delete_certificate_authority_rest_required_fields( response_value._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.schedule_delete_certificate_authority(request) @@ -11848,6 +11875,7 @@ def test_schedule_delete_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.schedule_delete_certificate_authority(**mock_args) @@ -11990,6 +12018,7 @@ def test_update_certificate_authority_rest_required_fields( response_value._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_certificate_authority(request) @@ -12051,6 +12080,7 @@ def test_update_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_authority(**mock_args) @@ -12188,6 +12218,7 @@ def test_get_certificate_revocation_list_rest_required_fields( response_value._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_certificate_revocation_list(request) @@ -12237,6 +12268,7 @@ def test_get_certificate_revocation_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_list(**mock_args) @@ -12384,6 +12416,7 @@ def test_list_certificate_revocation_lists_rest_required_fields( response_value._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_certificate_revocation_lists(request) @@ -12443,6 +12476,7 @@ def test_list_certificate_revocation_lists_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_lists(**mock_args) @@ -12652,6 +12686,7 @@ def test_update_certificate_revocation_list_rest_required_fields( response_value._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_certificate_revocation_list(request) @@ -12717,6 +12752,7 @@ def test_update_certificate_revocation_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_certificate_revocation_list(**mock_args) @@ -12857,6 +12893,7 @@ def test_get_reusable_config_rest_required_fields( response_value._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_reusable_config(request) @@ -12904,6 +12941,7 @@ def test_get_reusable_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reusable_config(**mock_args) @@ -13049,6 +13087,7 @@ def test_list_reusable_configs_rest_required_fields( response_value._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_reusable_configs(request) @@ -13104,6 +13143,7 @@ def test_list_reusable_configs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_reusable_configs(**mock_args) @@ -14388,6 +14428,7 @@ def test_create_certificate_rest_bad_request( 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_certificate(request) @@ -14604,6 +14645,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -14646,6 +14688,7 @@ def test_create_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -14690,6 +14733,7 @@ def test_get_certificate_rest_bad_request(request_type=service.GetCertificateReq 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_certificate(request) @@ -14730,6 +14774,7 @@ def test_get_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -14770,6 +14815,7 @@ def test_get_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -14816,6 +14862,7 @@ def test_list_certificates_rest_bad_request( 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_certificates(request) @@ -14854,6 +14901,7 @@ def test_list_certificates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificates(request) # Establish that the response is the type that we expect. @@ -14895,6 +14943,7 @@ def test_list_certificates_rest_interceptors(null_interceptor): 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 = service.ListCertificatesResponse.to_json( service.ListCertificatesResponse() ) @@ -14943,6 +14992,7 @@ def test_revoke_certificate_rest_bad_request( 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.revoke_certificate(request) @@ -14983,6 +15033,7 @@ def test_revoke_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.revoke_certificate(request) # Establish that the response is the type that we expect. @@ -15025,6 +15076,7 @@ def test_revoke_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -15073,6 +15125,7 @@ def test_update_certificate_rest_bad_request( 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_certificate(request) @@ -15291,6 +15344,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate(request) # Establish that the response is the type that we expect. @@ -15333,6 +15387,7 @@ def test_update_certificate_rest_interceptors(null_interceptor): 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 = resources.Certificate.to_json(resources.Certificate()) req.return_value.content = return_value @@ -15379,6 +15434,7 @@ def test_activate_certificate_authority_rest_bad_request( 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.activate_certificate_authority(request) @@ -15411,6 +15467,7 @@ def test_activate_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.activate_certificate_authority(request) # Establish that the response is the type that we expect. @@ -15454,6 +15511,7 @@ def test_activate_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -15498,6 +15556,7 @@ def test_create_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -15758,6 +15817,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -15801,6 +15861,7 @@ def test_create_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -15847,6 +15908,7 @@ def test_disable_certificate_authority_rest_bad_request( 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.disable_certificate_authority(request) @@ -15879,6 +15941,7 @@ def test_disable_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.disable_certificate_authority(request) # Establish that the response is the type that we expect. @@ -15922,6 +15985,7 @@ def test_disable_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -15968,6 +16032,7 @@ def test_enable_certificate_authority_rest_bad_request( 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.enable_certificate_authority(request) @@ -16000,6 +16065,7 @@ def test_enable_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.enable_certificate_authority(request) # Establish that the response is the type that we expect. @@ -16043,6 +16109,7 @@ def test_enable_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -16089,6 +16156,7 @@ def test_fetch_certificate_authority_csr_rest_bad_request( 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.fetch_certificate_authority_csr(request) @@ -16126,6 +16194,7 @@ def test_fetch_certificate_authority_csr_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.fetch_certificate_authority_csr(request) # Establish that the response is the type that we expect. @@ -16168,6 +16237,7 @@ def test_fetch_certificate_authority_csr_rest_interceptors(null_interceptor): 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 = service.FetchCertificateAuthorityCsrResponse.to_json( service.FetchCertificateAuthorityCsrResponse() ) @@ -16216,6 +16286,7 @@ def test_get_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -16258,6 +16329,7 @@ def test_get_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -16305,6 +16377,7 @@ def test_get_certificate_authority_rest_interceptors(null_interceptor): 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 = resources.CertificateAuthority.to_json( resources.CertificateAuthority() ) @@ -16351,6 +16424,7 @@ def test_list_certificate_authorities_rest_bad_request( 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_certificate_authorities(request) @@ -16387,6 +16461,7 @@ def test_list_certificate_authorities_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authorities(request) # Establish that the response is the type that we expect. @@ -16430,6 +16505,7 @@ def test_list_certificate_authorities_rest_interceptors(null_interceptor): 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 = service.ListCertificateAuthoritiesResponse.to_json( service.ListCertificateAuthoritiesResponse() ) @@ -16478,6 +16554,7 @@ def test_restore_certificate_authority_rest_bad_request( 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.restore_certificate_authority(request) @@ -16510,6 +16587,7 @@ def test_restore_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.restore_certificate_authority(request) # Establish that the response is the type that we expect. @@ -16553,6 +16631,7 @@ def test_restore_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -16599,6 +16678,7 @@ def test_schedule_delete_certificate_authority_rest_bad_request( 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.schedule_delete_certificate_authority(request) @@ -16631,6 +16711,7 @@ def test_schedule_delete_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.schedule_delete_certificate_authority(request) # Establish that the response is the type that we expect. @@ -16674,6 +16755,7 @@ def test_schedule_delete_certificate_authority_rest_interceptors(null_intercepto 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 @@ -16722,6 +16804,7 @@ def test_update_certificate_authority_rest_bad_request( 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_certificate_authority(request) @@ -16986,6 +17069,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_authority(request) # Establish that the response is the type that we expect. @@ -17029,6 +17113,7 @@ def test_update_certificate_authority_rest_interceptors(null_interceptor): 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 @@ -17075,6 +17160,7 @@ def test_get_certificate_revocation_list_rest_bad_request( 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_certificate_revocation_list(request) @@ -17116,6 +17202,7 @@ def test_get_certificate_revocation_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_list(request) # Establish that the response is the type that we expect. @@ -17162,6 +17249,7 @@ def test_get_certificate_revocation_list_rest_interceptors(null_interceptor): 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 = resources.CertificateRevocationList.to_json( resources.CertificateRevocationList() ) @@ -17210,6 +17298,7 @@ def test_list_certificate_revocation_lists_rest_bad_request( 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_certificate_revocation_lists(request) @@ -17248,6 +17337,7 @@ def test_list_certificate_revocation_lists_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_lists(request) # Establish that the response is the type that we expect. @@ -17291,6 +17381,7 @@ def test_list_certificate_revocation_lists_rest_interceptors(null_interceptor): 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 = service.ListCertificateRevocationListsResponse.to_json( service.ListCertificateRevocationListsResponse() ) @@ -17341,6 +17432,7 @@ def test_update_certificate_revocation_list_rest_bad_request( 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_certificate_revocation_list(request) @@ -17465,6 +17557,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_certificate_revocation_list(request) # Establish that the response is the type that we expect. @@ -17508,6 +17601,7 @@ def test_update_certificate_revocation_list_rest_interceptors(null_interceptor): 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 @@ -17554,6 +17648,7 @@ def test_get_reusable_config_rest_bad_request( 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_reusable_config(request) @@ -17592,6 +17687,7 @@ def test_get_reusable_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reusable_config(request) # Establish that the response is the type that we expect. @@ -17634,6 +17730,7 @@ def test_get_reusable_config_rest_interceptors(null_interceptor): 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 = resources.ReusableConfig.to_json(resources.ReusableConfig()) req.return_value.content = return_value @@ -17678,6 +17775,7 @@ def test_list_reusable_configs_rest_bad_request( 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_reusable_configs(request) @@ -17714,6 +17812,7 @@ def test_list_reusable_configs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_reusable_configs(request) # Establish that the response is the type that we expect. @@ -17757,6 +17856,7 @@ def test_list_reusable_configs_rest_interceptors(null_interceptor): 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 = service.ListReusableConfigsResponse.to_json( service.ListReusableConfigsResponse() ) diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog/gapic_version.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog/gapic_version.py index f8e3c3e8278e..558c8aab67c5 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog/gapic_version.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.9.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/gapic_version.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/gapic_version.py index f8e3c3e8278e..558c8aab67c5 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/gapic_version.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.9.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/async_client.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/async_client.py index 2521b1a30e1e..e8cbbc64d5d3 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/async_client.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PrivateCatalogTransport from .transports.grpc_asyncio import PrivateCatalogGrpcAsyncIOTransport +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 PrivateCatalogAsyncClient: """``PrivateCatalog`` allows catalog consumers to retrieve ``Catalog``, @@ -280,13 +290,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.privatecatalog_v1beta1.PrivateCatalogAsyncClient`.", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "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.privatecatalog.v1beta1.PrivateCatalog", + "credentialsType": None, + }, + ) + async def search_catalogs( self, request: Optional[Union[private_catalog.SearchCatalogsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCatalogsAsyncPager: r"""Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the scope of the @@ -326,8 +358,10 @@ async def sample_search_catalogs(): 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, 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchCatalogsAsyncPager: @@ -387,7 +421,7 @@ async def search_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchProductsAsyncPager: r"""Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the scope of the @@ -427,8 +461,10 @@ async def sample_search_products(): 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, 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchProductsAsyncPager: @@ -488,7 +524,7 @@ async def search_versions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchVersionsAsyncPager: r"""Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the scope of the @@ -529,8 +565,10 @@ async def sample_search_versions(): 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, 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchVersionsAsyncPager: diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/client.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/client.py index 38082d58d008..e73aecb00d01 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/client.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.privatecatalog_v1beta1.services.private_catalog import pagers from google.cloud.privatecatalog_v1beta1.types import private_catalog @@ -630,6 +640,10 @@ def __init__( # 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( @@ -695,13 +709,36 @@ def __init__( 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.privatecatalog_v1beta1.PrivateCatalogClient`.", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "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.privatecatalog.v1beta1.PrivateCatalog", + "credentialsType": None, + }, + ) + def search_catalogs( self, request: Optional[Union[private_catalog.SearchCatalogsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchCatalogsPager: r"""Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the scope of the @@ -741,8 +778,10 @@ def sample_search_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchCatalogsPager: @@ -800,7 +839,7 @@ def search_products( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchProductsPager: r"""Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the scope of the @@ -840,8 +879,10 @@ def sample_search_products(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchProductsPager: @@ -899,7 +940,7 @@ def search_versions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchVersionsPager: r"""Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the scope of the @@ -940,8 +981,10 @@ def sample_search_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchVersionsPager: diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/pagers.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/pagers.py index 28b20da2509d..2dd9fedeb7bc 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/pagers.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = private_catalog.SearchCatalogsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = private_catalog.SearchCatalogsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = private_catalog.SearchProductsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = private_catalog.SearchProductsRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = private_catalog.SearchVersionsRequest(request) @@ -445,7 +455,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -459,8 +469,10 @@ def __init__( 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, 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`. """ self._method = method self._request = private_catalog.SearchVersionsRequest(request) diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py index 5a588074064a..2d23cb8e4f69 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.privatecatalog_v1beta1.types import private_catalog from .base import DEFAULT_CLIENT_INFO, PrivateCatalogTransport +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.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": 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.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PrivateCatalogGrpcTransport(PrivateCatalogTransport): """gRPC backend transport for PrivateCatalog. @@ -200,7 +281,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -278,7 +364,7 @@ def search_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_catalogs" not in self._stubs: - self._stubs["search_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["search_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchCatalogs", request_serializer=private_catalog.SearchCatalogsRequest.serialize, response_deserializer=private_catalog.SearchCatalogsResponse.deserialize, @@ -308,7 +394,7 @@ def search_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_products" not in self._stubs: - self._stubs["search_products"] = self.grpc_channel.unary_unary( + self._stubs["search_products"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchProducts", request_serializer=private_catalog.SearchProductsRequest.serialize, response_deserializer=private_catalog.SearchProductsResponse.deserialize, @@ -338,7 +424,7 @@ def search_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_versions" not in self._stubs: - self._stubs["search_versions"] = self.grpc_channel.unary_unary( + self._stubs["search_versions"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchVersions", request_serializer=private_catalog.SearchVersionsRequest.serialize, response_deserializer=private_catalog.SearchVersionsResponse.deserialize, @@ -346,7 +432,7 @@ def search_versions( return self._stubs["search_versions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py index 3359304fff03..2c21edfcc329 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.privatecatalog_v1beta1.types import private_catalog from .base import DEFAULT_CLIENT_INFO, PrivateCatalogTransport from .grpc import PrivateCatalogGrpcTransport +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.privatecatalog.v1beta1.PrivateCatalog", + "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.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PrivateCatalogGrpcAsyncIOTransport(PrivateCatalogTransport): """gRPC AsyncIO backend transport for PrivateCatalog. @@ -247,10 +329,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -287,7 +372,7 @@ def search_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_catalogs" not in self._stubs: - self._stubs["search_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["search_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchCatalogs", request_serializer=private_catalog.SearchCatalogsRequest.serialize, response_deserializer=private_catalog.SearchCatalogsResponse.deserialize, @@ -318,7 +403,7 @@ def search_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_products" not in self._stubs: - self._stubs["search_products"] = self.grpc_channel.unary_unary( + self._stubs["search_products"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchProducts", request_serializer=private_catalog.SearchProductsRequest.serialize, response_deserializer=private_catalog.SearchProductsResponse.deserialize, @@ -349,7 +434,7 @@ def search_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_versions" not in self._stubs: - self._stubs["search_versions"] = self.grpc_channel.unary_unary( + self._stubs["search_versions"] = self._logged_channel.unary_unary( "/google.cloud.privatecatalog.v1beta1.PrivateCatalog/SearchVersions", request_serializer=private_catalog.SearchVersionsRequest.serialize, response_deserializer=private_catalog.SearchVersionsResponse.deserialize, @@ -382,7 +467,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/rest.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/rest.py index effab20c4006..98facb8d06c7 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/rest.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -93,8 +101,10 @@ def post_search_versions(self, response): def pre_search_catalogs( self, request: private_catalog.SearchCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[private_catalog.SearchCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + private_catalog.SearchCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_catalogs Override in a subclass to manipulate the request or metadata @@ -116,8 +126,10 @@ def post_search_catalogs( def pre_search_products( self, request: private_catalog.SearchProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[private_catalog.SearchProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + private_catalog.SearchProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_products Override in a subclass to manipulate the request or metadata @@ -139,8 +151,10 @@ def post_search_products( def pre_search_versions( self, request: private_catalog.SearchVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[private_catalog.SearchVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + private_catalog.SearchVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_versions Override in a subclass to manipulate the request or metadata @@ -301,7 +315,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> private_catalog.SearchCatalogsResponse: r"""Call the search catalogs method over HTTP. @@ -312,8 +326,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.private_catalog.SearchCatalogsResponse: @@ -325,6 +341,7 @@ def __call__( http_options = ( _BasePrivateCatalogRestTransport._BaseSearchCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_search_catalogs(request, metadata) transcoded_request = _BasePrivateCatalogRestTransport._BaseSearchCatalogs._get_transcoded_request( http_options, request @@ -335,6 +352,33 @@ def __call__( 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.privatecatalog_v1beta1.PrivateCatalogClient.SearchCatalogs", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivateCatalogRestTransport._SearchCatalogs._get_response( self._host, @@ -355,7 +399,31 @@ def __call__( pb_resp = private_catalog.SearchCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = private_catalog.SearchCatalogsResponse.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.privatecatalog_v1beta1.PrivateCatalogClient.search_catalogs", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchProducts( @@ -392,7 +460,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> private_catalog.SearchProductsResponse: r"""Call the search products method over HTTP. @@ -403,8 +471,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.private_catalog.SearchProductsResponse: @@ -416,6 +486,7 @@ def __call__( http_options = ( _BasePrivateCatalogRestTransport._BaseSearchProducts._get_http_options() ) + request, metadata = self._interceptor.pre_search_products(request, metadata) transcoded_request = _BasePrivateCatalogRestTransport._BaseSearchProducts._get_transcoded_request( http_options, request @@ -426,6 +497,33 @@ def __call__( 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.privatecatalog_v1beta1.PrivateCatalogClient.SearchProducts", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivateCatalogRestTransport._SearchProducts._get_response( self._host, @@ -446,7 +544,31 @@ def __call__( pb_resp = private_catalog.SearchProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = private_catalog.SearchProductsResponse.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.privatecatalog_v1beta1.PrivateCatalogClient.search_products", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchVersions( @@ -483,7 +605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> private_catalog.SearchVersionsResponse: r"""Call the search versions method over HTTP. @@ -494,8 +616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.private_catalog.SearchVersionsResponse: @@ -507,6 +631,7 @@ def __call__( http_options = ( _BasePrivateCatalogRestTransport._BaseSearchVersions._get_http_options() ) + request, metadata = self._interceptor.pre_search_versions(request, metadata) transcoded_request = _BasePrivateCatalogRestTransport._BaseSearchVersions._get_transcoded_request( http_options, request @@ -517,6 +642,33 @@ def __call__( 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.privatecatalog_v1beta1.PrivateCatalogClient.SearchVersions", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivateCatalogRestTransport._SearchVersions._get_response( self._host, @@ -537,7 +689,31 @@ def __call__( pb_resp = private_catalog.SearchVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = private_catalog.SearchVersionsResponse.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.privatecatalog_v1beta1.PrivateCatalogClient.search_versions", + extra={ + "serviceName": "google.cloud.privatecatalog.v1beta1.PrivateCatalog", + "rpcName": "SearchVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-private-catalog/samples/generated_samples/snippet_metadata_google.cloud.privatecatalog.v1beta1.json b/packages/google-cloud-private-catalog/samples/generated_samples/snippet_metadata_google.cloud.privatecatalog.v1beta1.json index 480debfe6e4a..acf623a1683e 100644 --- a/packages/google-cloud-private-catalog/samples/generated_samples/snippet_metadata_google.cloud.privatecatalog.v1beta1.json +++ b/packages/google-cloud-private-catalog/samples/generated_samples/snippet_metadata_google.cloud.privatecatalog.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-private-catalog", - "version": "0.9.13" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchCatalogsAsyncPager", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchCatalogsPager", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchProductsAsyncPager", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchProductsPager", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchVersionsAsyncPager", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privatecatalog_v1beta1.services.private_catalog.pagers.SearchVersionsPager", diff --git a/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py b/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py index 06ff194fc972..10d0faf6f767 100644 --- a/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py +++ b/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py @@ -2487,6 +2487,7 @@ def test_search_catalogs_rest_required_fields( response_value._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.search_catalogs(request) @@ -2686,6 +2687,7 @@ def test_search_products_rest_required_fields( response_value._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.search_products(request) @@ -2892,6 +2894,7 @@ def test_search_versions_rest_required_fields( response_value._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.search_versions(request) @@ -3284,6 +3287,7 @@ def test_search_catalogs_rest_bad_request( 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.search_catalogs(request) @@ -3319,6 +3323,7 @@ def test_search_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_catalogs(request) # Establish that the response is the type that we expect. @@ -3359,6 +3364,7 @@ def test_search_catalogs_rest_interceptors(null_interceptor): 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 = private_catalog.SearchCatalogsResponse.to_json( private_catalog.SearchCatalogsResponse() ) @@ -3405,6 +3411,7 @@ def test_search_products_rest_bad_request( 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.search_products(request) @@ -3440,6 +3447,7 @@ def test_search_products_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_products(request) # Establish that the response is the type that we expect. @@ -3480,6 +3488,7 @@ def test_search_products_rest_interceptors(null_interceptor): 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 = private_catalog.SearchProductsResponse.to_json( private_catalog.SearchProductsResponse() ) @@ -3526,6 +3535,7 @@ def test_search_versions_rest_bad_request( 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.search_versions(request) @@ -3561,6 +3571,7 @@ def test_search_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_versions(request) # Establish that the response is the type that we expect. @@ -3601,6 +3612,7 @@ def test_search_versions_rest_interceptors(null_interceptor): 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 = private_catalog.SearchVersionsResponse.to_json( private_catalog.SearchVersionsResponse() ) diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager/gapic_version.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager/gapic_version.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/gapic_version.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/gapic_version.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/async_client.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/async_client.py index fe11286a0ab3..f72b26c64834 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/async_client.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PrivilegedAccessManagerTransport from .transports.grpc_asyncio import PrivilegedAccessManagerGrpcAsyncIOTransport +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 PrivilegedAccessManagerAsyncClient: """This API allows customers to manage temporary, request based @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient`.", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "credentialsType": None, + }, + ) + async def check_onboarding_status( self, request: Optional[ @@ -309,7 +341,7 @@ async def check_onboarding_status( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.CheckOnboardingStatusResponse: r"""``CheckOnboardingStatus`` reports the onboarding status for a project/folder/organization. Any findings reported by this API @@ -347,8 +379,10 @@ async def sample_check_onboarding_status(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusResponse: @@ -397,7 +431,7 @@ async def list_entitlements( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEntitlementsAsyncPager: r"""Lists entitlements in a given project/folder/organization and location. @@ -443,8 +477,10 @@ async def sample_list_entitlements(): 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, 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListEntitlementsAsyncPager: @@ -520,7 +556,7 @@ async def search_entitlements( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchEntitlementsAsyncPager: r"""``SearchEntitlements`` returns entitlements on which the caller has the specified access. @@ -559,8 +595,10 @@ async def sample_search_entitlements(): 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, 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchEntitlementsAsyncPager: @@ -622,7 +660,7 @@ async def get_entitlement( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Entitlement: r"""Gets details of a single entitlement. @@ -663,8 +701,10 @@ async def sample_get_entitlement(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.Entitlement: @@ -732,7 +772,7 @@ async def create_entitlement( entitlement_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new entitlement in a given project/folder/organization and location. @@ -804,8 +844,10 @@ async def sample_create_entitlement(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -883,7 +925,7 @@ async def delete_entitlement( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single entitlement. This method can only be called when there are no in-progress @@ -931,8 +973,10 @@ async def sample_delete_entitlement(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1007,7 +1051,7 @@ async def update_entitlement( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the entitlement specified in the request. Updated fields in the entitlement need to be specified in an update mask. The @@ -1090,8 +1134,10 @@ async def sample_update_entitlement(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1169,7 +1215,7 @@ async def list_grants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGrantsAsyncPager: r"""Lists grants for a given entitlement. @@ -1214,8 +1260,10 @@ async def sample_list_grants(): 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, 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListGrantsAsyncPager: @@ -1291,7 +1339,7 @@ async def search_grants( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchGrantsAsyncPager: r"""``SearchGrants`` returns grants that are related to the calling user in the specified way. @@ -1330,8 +1378,10 @@ async def sample_search_grants(): 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, 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchGrantsAsyncPager: @@ -1391,7 +1441,7 @@ async def get_grant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Get details of a single grant. @@ -1432,8 +1482,10 @@ async def sample_get_grant(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1498,7 +1550,7 @@ async def create_grant( grant: Optional[privilegedaccessmanager.Grant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Creates a new grant in a given project/folder/organization and location. @@ -1548,8 +1600,10 @@ async def sample_create_grant(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1614,7 +1668,7 @@ async def approve_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""``ApproveGrant`` is used to approve a grant. This method can only be called on a grant when it's in the ``APPROVAL_AWAITED`` @@ -1652,8 +1706,10 @@ async def sample_approve_grant(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1700,7 +1756,7 @@ async def deny_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""``DenyGrant`` is used to deny a grant. This method can only be called on a grant when it's in the ``APPROVAL_AWAITED`` state. @@ -1738,8 +1794,10 @@ async def sample_deny_grant(): 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, 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1788,7 +1846,7 @@ async def revoke_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""``RevokeGrant`` is used to immediately revoke access for a grant. This method can be called when the grant is in a @@ -1830,8 +1888,10 @@ async def sample_revoke_grant(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1887,7 +1947,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1898,8 +1958,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1940,7 +2002,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1951,8 +2013,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1993,7 +2057,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2009,8 +2073,10 @@ async def delete_operation( 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, 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: None """ @@ -2047,7 +2113,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2058,8 +2124,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2100,7 +2168,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2111,8 +2179,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.py index dddf395d20a8..ab170cc3e144 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -645,6 +655,10 @@ def __init__( # 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( @@ -711,6 +725,29 @@ def __init__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient`.", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "credentialsType": None, + }, + ) + def check_onboarding_status( self, request: Optional[ @@ -719,7 +756,7 @@ def check_onboarding_status( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.CheckOnboardingStatusResponse: r"""``CheckOnboardingStatus`` reports the onboarding status for a project/folder/organization. Any findings reported by this API @@ -757,8 +794,10 @@ def sample_check_onboarding_status(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusResponse: @@ -805,7 +844,7 @@ def list_entitlements( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEntitlementsPager: r"""Lists entitlements in a given project/folder/organization and location. @@ -851,8 +890,10 @@ def sample_list_entitlements(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListEntitlementsPager: @@ -925,7 +966,7 @@ def search_entitlements( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchEntitlementsPager: r"""``SearchEntitlements`` returns entitlements on which the caller has the specified access. @@ -964,8 +1005,10 @@ def sample_search_entitlements(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchEntitlementsPager: @@ -1025,7 +1068,7 @@ def get_entitlement( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Entitlement: r"""Gets details of a single entitlement. @@ -1066,8 +1109,10 @@ def sample_get_entitlement(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.Entitlement: @@ -1132,7 +1177,7 @@ def create_entitlement( entitlement_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new entitlement in a given project/folder/organization and location. @@ -1204,8 +1249,10 @@ def sample_create_entitlement(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1280,7 +1327,7 @@ def delete_entitlement( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single entitlement. This method can only be called when there are no in-progress @@ -1328,8 +1375,10 @@ def sample_delete_entitlement(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1401,7 +1450,7 @@ def update_entitlement( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the entitlement specified in the request. Updated fields in the entitlement need to be specified in an update mask. The @@ -1484,8 +1533,10 @@ def sample_update_entitlement(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1560,7 +1611,7 @@ def list_grants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGrantsPager: r"""Lists grants for a given entitlement. @@ -1605,8 +1656,10 @@ def sample_list_grants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListGrantsPager: @@ -1679,7 +1732,7 @@ def search_grants( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchGrantsPager: r"""``SearchGrants`` returns grants that are related to the calling user in the specified way. @@ -1718,8 +1771,10 @@ def sample_search_grants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchGrantsPager: @@ -1777,7 +1832,7 @@ def get_grant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Get details of a single grant. @@ -1818,8 +1873,10 @@ def sample_get_grant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1881,7 +1938,7 @@ def create_grant( grant: Optional[privilegedaccessmanager.Grant] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Creates a new grant in a given project/folder/organization and location. @@ -1931,8 +1988,10 @@ def sample_create_grant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -1994,7 +2053,7 @@ def approve_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""``ApproveGrant`` is used to approve a grant. This method can only be called on a grant when it's in the ``APPROVAL_AWAITED`` @@ -2032,8 +2091,10 @@ def sample_approve_grant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -2078,7 +2139,7 @@ def deny_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""``DenyGrant`` is used to deny a grant. This method can only be called on a grant when it's in the ``APPROVAL_AWAITED`` state. @@ -2116,8 +2177,10 @@ def sample_deny_grant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.privilegedaccessmanager_v1.types.Grant: @@ -2164,7 +2227,7 @@ def revoke_grant( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""``RevokeGrant`` is used to immediately revoke access for a grant. This method can be called when the grant is in a @@ -2206,8 +2269,10 @@ def sample_revoke_grant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2274,7 +2339,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2285,8 +2350,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2327,7 +2394,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2338,8 +2405,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2380,7 +2449,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2396,8 +2465,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2434,7 +2505,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2445,8 +2516,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2487,7 +2560,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2498,8 +2571,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/pagers.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/pagers.py index 4b0d782a15bb..b96b4c1a4b65 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/pagers.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = privilegedaccessmanager.ListEntitlementsRequest(request) @@ -143,7 +145,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -157,8 +159,10 @@ def __init__( 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, 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`. """ self._method = method self._request = privilegedaccessmanager.ListEntitlementsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = privilegedaccessmanager.SearchEntitlementsRequest(request) @@ -299,7 +305,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -313,8 +319,10 @@ def __init__( 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, 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`. """ self._method = method self._request = privilegedaccessmanager.SearchEntitlementsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = privilegedaccessmanager.ListGrantsRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = privilegedaccessmanager.ListGrantsRequest(request) @@ -531,7 +543,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -545,8 +557,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = privilegedaccessmanager.SearchGrantsRequest(request) @@ -605,7 +619,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -619,8 +633,10 @@ def __init__( 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, 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`. """ self._method = method self._request = privilegedaccessmanager.SearchGrantsRequest(request) diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc.py index 3fe00b3da1c7..deb639053d46 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.privilegedaccessmanager_v1.types import privilegedaccessmanager from .base import DEFAULT_CLIENT_INFO, PrivilegedAccessManagerTransport +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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": 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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PrivilegedAccessManagerGrpcTransport(PrivilegedAccessManagerTransport): """gRPC backend transport for PrivilegedAccessManager. @@ -204,7 +285,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +354,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -297,7 +385,7 @@ def check_onboarding_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_onboarding_status" not in self._stubs: - self._stubs["check_onboarding_status"] = self.grpc_channel.unary_unary( + self._stubs["check_onboarding_status"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CheckOnboardingStatus", request_serializer=privilegedaccessmanager.CheckOnboardingStatusRequest.serialize, response_deserializer=privilegedaccessmanager.CheckOnboardingStatusResponse.deserialize, @@ -327,7 +415,7 @@ def list_entitlements( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entitlements" not in self._stubs: - self._stubs["list_entitlements"] = self.grpc_channel.unary_unary( + self._stubs["list_entitlements"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListEntitlements", request_serializer=privilegedaccessmanager.ListEntitlementsRequest.serialize, response_deserializer=privilegedaccessmanager.ListEntitlementsResponse.deserialize, @@ -357,7 +445,7 @@ def search_entitlements( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_entitlements" not in self._stubs: - self._stubs["search_entitlements"] = self.grpc_channel.unary_unary( + self._stubs["search_entitlements"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchEntitlements", request_serializer=privilegedaccessmanager.SearchEntitlementsRequest.serialize, response_deserializer=privilegedaccessmanager.SearchEntitlementsResponse.deserialize, @@ -386,7 +474,7 @@ def get_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entitlement" not in self._stubs: - self._stubs["get_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["get_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetEntitlement", request_serializer=privilegedaccessmanager.GetEntitlementRequest.serialize, response_deserializer=privilegedaccessmanager.Entitlement.deserialize, @@ -415,7 +503,7 @@ def create_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entitlement" not in self._stubs: - self._stubs["create_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["create_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateEntitlement", request_serializer=privilegedaccessmanager.CreateEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +534,7 @@ def delete_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entitlement" not in self._stubs: - self._stubs["delete_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["delete_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DeleteEntitlement", request_serializer=privilegedaccessmanager.DeleteEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -494,7 +582,7 @@ def update_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entitlement" not in self._stubs: - self._stubs["update_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["update_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/UpdateEntitlement", request_serializer=privilegedaccessmanager.UpdateEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +611,7 @@ def list_grants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_grants" not in self._stubs: - self._stubs["list_grants"] = self.grpc_channel.unary_unary( + self._stubs["list_grants"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListGrants", request_serializer=privilegedaccessmanager.ListGrantsRequest.serialize, response_deserializer=privilegedaccessmanager.ListGrantsResponse.deserialize, @@ -553,7 +641,7 @@ def search_grants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_grants" not in self._stubs: - self._stubs["search_grants"] = self.grpc_channel.unary_unary( + self._stubs["search_grants"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchGrants", request_serializer=privilegedaccessmanager.SearchGrantsRequest.serialize, response_deserializer=privilegedaccessmanager.SearchGrantsResponse.deserialize, @@ -581,7 +669,7 @@ def get_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_grant" not in self._stubs: - self._stubs["get_grant"] = self.grpc_channel.unary_unary( + self._stubs["get_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetGrant", request_serializer=privilegedaccessmanager.GetGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -610,7 +698,7 @@ def create_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_grant" not in self._stubs: - self._stubs["create_grant"] = self.grpc_channel.unary_unary( + self._stubs["create_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateGrant", request_serializer=privilegedaccessmanager.CreateGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -640,7 +728,7 @@ def approve_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_grant" not in self._stubs: - self._stubs["approve_grant"] = self.grpc_channel.unary_unary( + self._stubs["approve_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ApproveGrant", request_serializer=privilegedaccessmanager.ApproveGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -670,7 +758,7 @@ def deny_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deny_grant" not in self._stubs: - self._stubs["deny_grant"] = self.grpc_channel.unary_unary( + self._stubs["deny_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DenyGrant", request_serializer=privilegedaccessmanager.DenyGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -700,7 +788,7 @@ def revoke_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_grant" not in self._stubs: - self._stubs["revoke_grant"] = self.grpc_channel.unary_unary( + self._stubs["revoke_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/RevokeGrant", request_serializer=privilegedaccessmanager.RevokeGrantRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -708,7 +796,7 @@ def revoke_grant( return self._stubs["revoke_grant"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -720,7 +808,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -737,7 +825,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -756,7 +844,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -775,7 +863,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -792,7 +880,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc_asyncio.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc_asyncio.py index 45e3939dc27a..5ffad918023e 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.privilegedaccessmanager_v1.types import privilegedaccessmanager from .base import DEFAULT_CLIENT_INFO, PrivilegedAccessManagerTransport from .grpc import PrivilegedAccessManagerGrpcTransport +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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "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.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PrivilegedAccessManagerGrpcAsyncIOTransport(PrivilegedAccessManagerTransport): """gRPC AsyncIO backend transport for PrivilegedAccessManager. @@ -251,10 +333,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -277,7 +362,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -307,7 +392,7 @@ def check_onboarding_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_onboarding_status" not in self._stubs: - self._stubs["check_onboarding_status"] = self.grpc_channel.unary_unary( + self._stubs["check_onboarding_status"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CheckOnboardingStatus", request_serializer=privilegedaccessmanager.CheckOnboardingStatusRequest.serialize, response_deserializer=privilegedaccessmanager.CheckOnboardingStatusResponse.deserialize, @@ -337,7 +422,7 @@ def list_entitlements( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entitlements" not in self._stubs: - self._stubs["list_entitlements"] = self.grpc_channel.unary_unary( + self._stubs["list_entitlements"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListEntitlements", request_serializer=privilegedaccessmanager.ListEntitlementsRequest.serialize, response_deserializer=privilegedaccessmanager.ListEntitlementsResponse.deserialize, @@ -367,7 +452,7 @@ def search_entitlements( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_entitlements" not in self._stubs: - self._stubs["search_entitlements"] = self.grpc_channel.unary_unary( + self._stubs["search_entitlements"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchEntitlements", request_serializer=privilegedaccessmanager.SearchEntitlementsRequest.serialize, response_deserializer=privilegedaccessmanager.SearchEntitlementsResponse.deserialize, @@ -396,7 +481,7 @@ def get_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entitlement" not in self._stubs: - self._stubs["get_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["get_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetEntitlement", request_serializer=privilegedaccessmanager.GetEntitlementRequest.serialize, response_deserializer=privilegedaccessmanager.Entitlement.deserialize, @@ -426,7 +511,7 @@ def create_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entitlement" not in self._stubs: - self._stubs["create_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["create_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateEntitlement", request_serializer=privilegedaccessmanager.CreateEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -458,7 +543,7 @@ def delete_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entitlement" not in self._stubs: - self._stubs["delete_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["delete_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DeleteEntitlement", request_serializer=privilegedaccessmanager.DeleteEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +592,7 @@ def update_entitlement( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entitlement" not in self._stubs: - self._stubs["update_entitlement"] = self.grpc_channel.unary_unary( + self._stubs["update_entitlement"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/UpdateEntitlement", request_serializer=privilegedaccessmanager.UpdateEntitlementRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +621,7 @@ def list_grants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_grants" not in self._stubs: - self._stubs["list_grants"] = self.grpc_channel.unary_unary( + self._stubs["list_grants"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListGrants", request_serializer=privilegedaccessmanager.ListGrantsRequest.serialize, response_deserializer=privilegedaccessmanager.ListGrantsResponse.deserialize, @@ -566,7 +651,7 @@ def search_grants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_grants" not in self._stubs: - self._stubs["search_grants"] = self.grpc_channel.unary_unary( + self._stubs["search_grants"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchGrants", request_serializer=privilegedaccessmanager.SearchGrantsRequest.serialize, response_deserializer=privilegedaccessmanager.SearchGrantsResponse.deserialize, @@ -595,7 +680,7 @@ def get_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_grant" not in self._stubs: - self._stubs["get_grant"] = self.grpc_channel.unary_unary( + self._stubs["get_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetGrant", request_serializer=privilegedaccessmanager.GetGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -625,7 +710,7 @@ def create_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_grant" not in self._stubs: - self._stubs["create_grant"] = self.grpc_channel.unary_unary( + self._stubs["create_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateGrant", request_serializer=privilegedaccessmanager.CreateGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -656,7 +741,7 @@ def approve_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_grant" not in self._stubs: - self._stubs["approve_grant"] = self.grpc_channel.unary_unary( + self._stubs["approve_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ApproveGrant", request_serializer=privilegedaccessmanager.ApproveGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -687,7 +772,7 @@ def deny_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deny_grant" not in self._stubs: - self._stubs["deny_grant"] = self.grpc_channel.unary_unary( + self._stubs["deny_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DenyGrant", request_serializer=privilegedaccessmanager.DenyGrantRequest.serialize, response_deserializer=privilegedaccessmanager.Grant.deserialize, @@ -718,7 +803,7 @@ def revoke_grant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_grant" not in self._stubs: - self._stubs["revoke_grant"] = self.grpc_channel.unary_unary( + self._stubs["revoke_grant"] = self._logged_channel.unary_unary( "/google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/RevokeGrant", request_serializer=privilegedaccessmanager.RevokeGrantRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -831,7 +916,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -847,7 +932,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -864,7 +949,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -883,7 +968,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -902,7 +987,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -919,7 +1004,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/rest.py b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/rest.py index 24e42650091b..2b62bc33daac 100644 --- a/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/rest.py +++ b/packages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -183,8 +191,11 @@ def post_update_entitlement(self, response): def pre_approve_grant( self, request: privilegedaccessmanager.ApproveGrantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.ApproveGrantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.ApproveGrantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for approve_grant Override in a subclass to manipulate the request or metadata @@ -206,9 +217,10 @@ def post_approve_grant( def pre_check_onboarding_status( self, request: privilegedaccessmanager.CheckOnboardingStatusRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.CheckOnboardingStatusRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.CheckOnboardingStatusRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for check_onboarding_status @@ -231,9 +243,10 @@ def post_check_onboarding_status( def pre_create_entitlement( self, request: privilegedaccessmanager.CreateEntitlementRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.CreateEntitlementRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.CreateEntitlementRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_entitlement @@ -256,8 +269,11 @@ def post_create_entitlement( def pre_create_grant( self, request: privilegedaccessmanager.CreateGrantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.CreateGrantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.CreateGrantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_grant Override in a subclass to manipulate the request or metadata @@ -279,9 +295,10 @@ def post_create_grant( def pre_delete_entitlement( self, request: privilegedaccessmanager.DeleteEntitlementRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.DeleteEntitlementRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.DeleteEntitlementRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_entitlement @@ -304,8 +321,11 @@ def post_delete_entitlement( def pre_deny_grant( self, request: privilegedaccessmanager.DenyGrantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.DenyGrantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.DenyGrantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for deny_grant Override in a subclass to manipulate the request or metadata @@ -327,9 +347,10 @@ def post_deny_grant( def pre_get_entitlement( self, request: privilegedaccessmanager.GetEntitlementRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.GetEntitlementRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.GetEntitlementRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_entitlement @@ -352,8 +373,10 @@ def post_get_entitlement( def pre_get_grant( self, request: privilegedaccessmanager.GetGrantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.GetGrantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.GetGrantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_grant Override in a subclass to manipulate the request or metadata @@ -375,9 +398,10 @@ def post_get_grant( def pre_list_entitlements( self, request: privilegedaccessmanager.ListEntitlementsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.ListEntitlementsRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.ListEntitlementsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_entitlements @@ -400,8 +424,11 @@ def post_list_entitlements( def pre_list_grants( self, request: privilegedaccessmanager.ListGrantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.ListGrantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.ListGrantsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_grants Override in a subclass to manipulate the request or metadata @@ -423,8 +450,11 @@ def post_list_grants( def pre_revoke_grant( self, request: privilegedaccessmanager.RevokeGrantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.RevokeGrantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.RevokeGrantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for revoke_grant Override in a subclass to manipulate the request or metadata @@ -446,9 +476,10 @@ def post_revoke_grant( def pre_search_entitlements( self, request: privilegedaccessmanager.SearchEntitlementsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.SearchEntitlementsRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.SearchEntitlementsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_entitlements @@ -471,8 +502,11 @@ def post_search_entitlements( def pre_search_grants( self, request: privilegedaccessmanager.SearchGrantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[privilegedaccessmanager.SearchGrantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + privilegedaccessmanager.SearchGrantsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for search_grants Override in a subclass to manipulate the request or metadata @@ -494,9 +528,10 @@ def post_search_grants( def pre_update_entitlement( self, request: privilegedaccessmanager.UpdateEntitlementRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - privilegedaccessmanager.UpdateEntitlementRequest, Sequence[Tuple[str, str]] + privilegedaccessmanager.UpdateEntitlementRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_entitlement @@ -519,8 +554,10 @@ def post_update_entitlement( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -542,8 +579,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -565,8 +604,10 @@ def post_list_locations( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -586,8 +627,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -609,8 +652,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -845,7 +890,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Call the approve grant method over HTTP. @@ -855,8 +900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.Grant: @@ -869,6 +916,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseApproveGrant._get_http_options() ) + request, metadata = self._interceptor.pre_approve_grant(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseApproveGrant._get_transcoded_request( http_options, request @@ -883,6 +931,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.ApproveGrant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ApproveGrant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._ApproveGrant._get_response( self._host, @@ -904,7 +979,29 @@ def __call__( pb_resp = privilegedaccessmanager.Grant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_grant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = privilegedaccessmanager.Grant.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.approve_grant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ApproveGrant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CheckOnboardingStatus( @@ -942,7 +1039,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.CheckOnboardingStatusResponse: r"""Call the check onboarding status method over HTTP. @@ -952,8 +1049,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.CheckOnboardingStatusResponse: @@ -963,6 +1062,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseCheckOnboardingStatus._get_http_options() ) + request, metadata = self._interceptor.pre_check_onboarding_status( request, metadata ) @@ -975,6 +1075,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.CheckOnboardingStatus", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CheckOnboardingStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._CheckOnboardingStatus._get_response( self._host, @@ -995,7 +1122,33 @@ def __call__( pb_resp = privilegedaccessmanager.CheckOnboardingStatusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_onboarding_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + privilegedaccessmanager.CheckOnboardingStatusResponse.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.check_onboarding_status", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CheckOnboardingStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEntitlement( @@ -1034,7 +1187,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create entitlement method over HTTP. @@ -1044,8 +1197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1058,6 +1213,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseCreateEntitlement._get_http_options() ) + request, metadata = self._interceptor.pre_create_entitlement( request, metadata ) @@ -1074,6 +1230,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.CreateEntitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CreateEntitlement", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._CreateEntitlement._get_response( @@ -1095,7 +1278,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_entitlement(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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.create_entitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CreateEntitlement", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGrant( @@ -1134,7 +1339,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Call the create grant method over HTTP. @@ -1144,8 +1349,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.Grant: @@ -1158,6 +1365,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseCreateGrant._get_http_options() ) + request, metadata = self._interceptor.pre_create_grant(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseCreateGrant._get_transcoded_request( http_options, request @@ -1172,6 +1380,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.CreateGrant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CreateGrant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._CreateGrant._get_response( self._host, @@ -1193,7 +1428,29 @@ def __call__( pb_resp = privilegedaccessmanager.Grant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_grant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = privilegedaccessmanager.Grant.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.create_grant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "CreateGrant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEntitlement( @@ -1231,7 +1488,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete entitlement method over HTTP. @@ -1241,8 +1498,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1255,6 +1514,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseDeleteEntitlement._get_http_options() ) + request, metadata = self._interceptor.pre_delete_entitlement( request, metadata ) @@ -1267,6 +1527,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.DeleteEntitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "DeleteEntitlement", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._DeleteEntitlement._get_response( @@ -1287,7 +1574,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_entitlement(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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.delete_entitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "DeleteEntitlement", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DenyGrant( @@ -1326,7 +1635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Call the deny grant method over HTTP. @@ -1336,8 +1645,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.Grant: @@ -1350,6 +1661,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseDenyGrant._get_http_options() ) + request, metadata = self._interceptor.pre_deny_grant(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseDenyGrant._get_transcoded_request( http_options, request @@ -1364,6 +1676,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.DenyGrant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "DenyGrant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._DenyGrant._get_response( self._host, @@ -1385,7 +1724,29 @@ def __call__( pb_resp = privilegedaccessmanager.Grant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deny_grant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = privilegedaccessmanager.Grant.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.deny_grant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "DenyGrant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEntitlement( @@ -1423,7 +1784,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Entitlement: r"""Call the get entitlement method over HTTP. @@ -1433,8 +1794,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.Entitlement: @@ -1449,6 +1812,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseGetEntitlement._get_http_options() ) + request, metadata = self._interceptor.pre_get_entitlement(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseGetEntitlement._get_transcoded_request( http_options, request @@ -1459,6 +1823,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.GetEntitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetEntitlement", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._GetEntitlement._get_response( @@ -1481,7 +1872,31 @@ def __call__( pb_resp = privilegedaccessmanager.Entitlement.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_entitlement(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = privilegedaccessmanager.Entitlement.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.get_entitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetEntitlement", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGrant( @@ -1519,7 +1934,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.Grant: r"""Call the get grant method over HTTP. @@ -1529,8 +1944,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.Grant: @@ -1543,6 +1960,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseGetGrant._get_http_options() ) + request, metadata = self._interceptor.pre_get_grant(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseGetGrant._get_transcoded_request( http_options, request @@ -1553,6 +1971,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.GetGrant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetGrant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._GetGrant._get_response( self._host, @@ -1573,7 +2018,29 @@ def __call__( pb_resp = privilegedaccessmanager.Grant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_grant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = privilegedaccessmanager.Grant.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.get_grant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetGrant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEntitlements( @@ -1611,7 +2078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.ListEntitlementsResponse: r"""Call the list entitlements method over HTTP. @@ -1622,8 +2089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.ListEntitlementsResponse: @@ -1635,6 +2104,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseListEntitlements._get_http_options() ) + request, metadata = self._interceptor.pre_list_entitlements( request, metadata ) @@ -1647,6 +2117,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.ListEntitlements", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListEntitlements", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._ListEntitlements._get_response( @@ -1669,7 +2166,33 @@ def __call__( pb_resp = privilegedaccessmanager.ListEntitlementsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_entitlements(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + privilegedaccessmanager.ListEntitlementsResponse.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.list_entitlements", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListEntitlements", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGrants( @@ -1707,7 +2230,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.ListGrantsResponse: r"""Call the list grants method over HTTP. @@ -1718,8 +2241,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.ListGrantsResponse: @@ -1731,6 +2256,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseListGrants._get_http_options() ) + request, metadata = self._interceptor.pre_list_grants(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseListGrants._get_transcoded_request( http_options, request @@ -1741,6 +2267,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.ListGrants", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListGrants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._ListGrants._get_response( self._host, @@ -1761,7 +2314,31 @@ def __call__( pb_resp = privilegedaccessmanager.ListGrantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_grants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + privilegedaccessmanager.ListGrantsResponse.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.list_grants", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListGrants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RevokeGrant( @@ -1800,7 +2377,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the revoke grant method over HTTP. @@ -1810,8 +2387,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1824,6 +2403,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseRevokeGrant._get_http_options() ) + request, metadata = self._interceptor.pre_revoke_grant(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseRevokeGrant._get_transcoded_request( http_options, request @@ -1838,6 +2418,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.RevokeGrant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "RevokeGrant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._RevokeGrant._get_response( self._host, @@ -1857,7 +2464,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_revoke_grant(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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.revoke_grant", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "RevokeGrant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchEntitlements( @@ -1895,7 +2524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.SearchEntitlementsResponse: r"""Call the search entitlements method over HTTP. @@ -1905,8 +2534,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.SearchEntitlementsResponse: @@ -1916,6 +2547,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseSearchEntitlements._get_http_options() ) + request, metadata = self._interceptor.pre_search_entitlements( request, metadata ) @@ -1928,6 +2560,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.SearchEntitlements", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "SearchEntitlements", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._SearchEntitlements._get_response( @@ -1950,7 +2609,33 @@ def __call__( pb_resp = privilegedaccessmanager.SearchEntitlementsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_entitlements(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + privilegedaccessmanager.SearchEntitlementsResponse.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.search_entitlements", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "SearchEntitlements", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchGrants( @@ -1988,7 +2673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> privilegedaccessmanager.SearchGrantsResponse: r"""Call the search grants method over HTTP. @@ -1998,8 +2683,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.privilegedaccessmanager.SearchGrantsResponse: @@ -2009,6 +2696,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseSearchGrants._get_http_options() ) + request, metadata = self._interceptor.pre_search_grants(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseSearchGrants._get_transcoded_request( http_options, request @@ -2019,6 +2707,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.SearchGrants", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "SearchGrants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._SearchGrants._get_response( self._host, @@ -2039,7 +2754,31 @@ def __call__( pb_resp = privilegedaccessmanager.SearchGrantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_grants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + privilegedaccessmanager.SearchGrantsResponse.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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.search_grants", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "SearchGrants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEntitlement( @@ -2078,7 +2817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update entitlement method over HTTP. @@ -2088,8 +2827,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -2102,6 +2843,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseUpdateEntitlement._get_http_options() ) + request, metadata = self._interceptor.pre_update_entitlement( request, metadata ) @@ -2118,6 +2860,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.UpdateEntitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "UpdateEntitlement", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._UpdateEntitlement._get_response( @@ -2139,7 +2908,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_entitlement(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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.update_entitlement", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "UpdateEntitlement", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2327,7 +3118,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2337,8 +3128,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -2347,6 +3140,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2357,6 +3151,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.GetLocation", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._GetLocation._get_response( self._host, @@ -2376,6 +3197,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2417,7 +3259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2427,8 +3269,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2437,6 +3281,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2447,6 +3292,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.ListLocations", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._ListLocations._get_response( @@ -2468,6 +3340,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2509,7 +3402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2519,13 +3412,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2538,6 +3434,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._DeleteOperation._get_response( @@ -2596,7 +3519,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2606,8 +3529,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2616,6 +3541,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2626,6 +3552,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.GetOperation", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PrivilegedAccessManagerRestTransport._GetOperation._get_response( self._host, @@ -2645,6 +3598,27 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2686,7 +3660,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2696,8 +3670,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2706,6 +3682,7 @@ def __call__( http_options = ( _BasePrivilegedAccessManagerRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePrivilegedAccessManagerRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2716,6 +3693,33 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerClient.ListOperations", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PrivilegedAccessManagerRestTransport._ListOperations._get_response( @@ -2737,6 +3741,27 @@ def __call__( 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.privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-privilegedaccessmanager/samples/generated_samples/snippet_metadata_google.cloud.privilegedaccessmanager.v1.json b/packages/google-cloud-privilegedaccessmanager/samples/generated_samples/snippet_metadata_google.cloud.privilegedaccessmanager.v1.json index d0669a1a26be..ec4443c5cbc9 100644 --- a/packages/google-cloud-privilegedaccessmanager/samples/generated_samples/snippet_metadata_google.cloud.privilegedaccessmanager.v1.json +++ b/packages/google-cloud-privilegedaccessmanager/samples/generated_samples/snippet_metadata_google.cloud.privilegedaccessmanager.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-privilegedaccessmanager", - "version": "0.1.4" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusResponse", @@ -361,7 +361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -534,7 +534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -699,7 +699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -779,7 +779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -1013,7 +1013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Entitlement", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Entitlement", @@ -1174,7 +1174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.types.Grant", @@ -1335,7 +1335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListEntitlementsAsyncPager", @@ -1415,7 +1415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListEntitlementsPager", @@ -1496,7 +1496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListGrantsAsyncPager", @@ -1576,7 +1576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListGrantsPager", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1806,7 +1806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchEntitlementsAsyncPager", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchEntitlementsPager", @@ -1959,7 +1959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchGrantsAsyncPager", @@ -2035,7 +2035,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchGrantsPager", @@ -2120,7 +2120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2204,7 +2204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-privilegedaccessmanager/tests/unit/gapic/privilegedaccessmanager_v1/test_privileged_access_manager.py b/packages/google-cloud-privilegedaccessmanager/tests/unit/gapic/privilegedaccessmanager_v1/test_privileged_access_manager.py index 177fb1aafa84..b1aad649ba00 100644 --- a/packages/google-cloud-privilegedaccessmanager/tests/unit/gapic/privilegedaccessmanager_v1/test_privileged_access_manager.py +++ b/packages/google-cloud-privilegedaccessmanager/tests/unit/gapic/privilegedaccessmanager_v1/test_privileged_access_manager.py @@ -6350,6 +6350,7 @@ def test_check_onboarding_status_rest_required_fields( response_value._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.check_onboarding_status(request) @@ -6482,6 +6483,7 @@ def test_list_entitlements_rest_required_fields( response_value._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_entitlements(request) @@ -6537,6 +6539,7 @@ def test_list_entitlements_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_entitlements(**mock_args) @@ -6747,6 +6750,7 @@ def test_search_entitlements_rest_required_fields( response_value._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.search_entitlements(request) @@ -6945,6 +6949,7 @@ def test_get_entitlement_rest_required_fields( response_value._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_entitlement(request) @@ -6992,6 +6997,7 @@ def test_get_entitlement_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_entitlement(**mock_args) @@ -7143,6 +7149,7 @@ def test_create_entitlement_rest_required_fields( response_value._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_entitlement(request) @@ -7208,6 +7215,7 @@ def test_create_entitlement_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_entitlement(**mock_args) @@ -7353,6 +7361,7 @@ def test_delete_entitlement_rest_required_fields( response_value._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_entitlement(request) @@ -7406,6 +7415,7 @@ def test_delete_entitlement_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_entitlement(**mock_args) @@ -7540,6 +7550,7 @@ def test_update_entitlement_rest_required_fields( response_value._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_entitlement(request) @@ -7596,6 +7607,7 @@ def test_update_entitlement_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_entitlement(**mock_args) @@ -7737,6 +7749,7 @@ def test_list_grants_rest_required_fields( response_value._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_grants(request) @@ -7794,6 +7807,7 @@ def test_list_grants_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_grants(**mock_args) @@ -7999,6 +8013,7 @@ def test_search_grants_rest_required_fields( response_value._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.search_grants(request) @@ -8198,6 +8213,7 @@ def test_get_grant_rest_required_fields( response_value._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_grant(request) @@ -8245,6 +8261,7 @@ def test_get_grant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_grant(**mock_args) @@ -8379,6 +8396,7 @@ def test_create_grant_rest_required_fields( response_value._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_grant(request) @@ -8435,6 +8453,7 @@ def test_create_grant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_grant(**mock_args) @@ -8568,6 +8587,7 @@ def test_approve_grant_rest_required_fields( response_value._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.approve_grant(request) @@ -8688,6 +8708,7 @@ def test_deny_grant_rest_required_fields( response_value._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.deny_grant(request) @@ -8809,6 +8830,7 @@ def test_revoke_grant_rest_required_fields( response_value._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.revoke_grant(request) @@ -9682,6 +9704,7 @@ def test_check_onboarding_status_rest_bad_request( 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.check_onboarding_status(request) @@ -9719,6 +9742,7 @@ def test_check_onboarding_status_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.check_onboarding_status(request) # Establish that the response is the type that we expect. @@ -9760,6 +9784,7 @@ def test_check_onboarding_status_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.CheckOnboardingStatusResponse.to_json( privilegedaccessmanager.CheckOnboardingStatusResponse() ) @@ -9806,6 +9831,7 @@ def test_list_entitlements_rest_bad_request( 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_entitlements(request) @@ -9842,6 +9868,7 @@ def test_list_entitlements_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_entitlements(request) # Establish that the response is the type that we expect. @@ -9883,6 +9910,7 @@ def test_list_entitlements_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.ListEntitlementsResponse.to_json( privilegedaccessmanager.ListEntitlementsResponse() ) @@ -9929,6 +9957,7 @@ def test_search_entitlements_rest_bad_request( 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.search_entitlements(request) @@ -9966,6 +9995,7 @@ def test_search_entitlements_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_entitlements(request) # Establish that the response is the type that we expect. @@ -10006,6 +10036,7 @@ def test_search_entitlements_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.SearchEntitlementsResponse.to_json( privilegedaccessmanager.SearchEntitlementsResponse() ) @@ -10052,6 +10083,7 @@ def test_get_entitlement_rest_bad_request( 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_entitlement(request) @@ -10089,6 +10121,7 @@ def test_get_entitlement_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_entitlement(request) # Establish that the response is the type that we expect. @@ -10131,6 +10164,7 @@ def test_get_entitlement_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.Entitlement.to_json( privilegedaccessmanager.Entitlement() ) @@ -10177,6 +10211,7 @@ def test_create_entitlement_rest_bad_request( 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_entitlement(request) @@ -10323,6 +10358,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_entitlement(request) # Establish that the response is the type that we expect. @@ -10364,6 +10400,7 @@ def test_create_entitlement_rest_interceptors(null_interceptor): 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 @@ -10408,6 +10445,7 @@ def test_delete_entitlement_rest_bad_request( 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_entitlement(request) @@ -10438,6 +10476,7 @@ def test_delete_entitlement_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_entitlement(request) # Establish that the response is the type that we expect. @@ -10479,6 +10518,7 @@ def test_delete_entitlement_rest_interceptors(null_interceptor): 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 @@ -10527,6 +10567,7 @@ def test_update_entitlement_rest_bad_request( 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_entitlement(request) @@ -10677,6 +10718,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_entitlement(request) # Establish that the response is the type that we expect. @@ -10718,6 +10760,7 @@ def test_update_entitlement_rest_interceptors(null_interceptor): 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 @@ -10762,6 +10805,7 @@ def test_list_grants_rest_bad_request( 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_grants(request) @@ -10798,6 +10842,7 @@ def test_list_grants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_grants(request) # Establish that the response is the type that we expect. @@ -10839,6 +10884,7 @@ def test_list_grants_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.ListGrantsResponse.to_json( privilegedaccessmanager.ListGrantsResponse() ) @@ -10885,6 +10931,7 @@ def test_search_grants_rest_bad_request( 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.search_grants(request) @@ -10920,6 +10967,7 @@ def test_search_grants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_grants(request) # Establish that the response is the type that we expect. @@ -10960,6 +11008,7 @@ def test_search_grants_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.SearchGrantsResponse.to_json( privilegedaccessmanager.SearchGrantsResponse() ) @@ -11008,6 +11057,7 @@ def test_get_grant_rest_bad_request( 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_grant(request) @@ -11049,6 +11099,7 @@ def test_get_grant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_grant(request) # Establish that the response is the type that we expect. @@ -11093,6 +11144,7 @@ def test_get_grant_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.Grant.to_json( privilegedaccessmanager.Grant() ) @@ -11139,6 +11191,7 @@ def test_create_grant_rest_bad_request( 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_grant(request) @@ -11302,6 +11355,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_grant(request) # Establish that the response is the type that we expect. @@ -11346,6 +11400,7 @@ def test_create_grant_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.Grant.to_json( privilegedaccessmanager.Grant() ) @@ -11394,6 +11449,7 @@ def test_approve_grant_rest_bad_request( 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.approve_grant(request) @@ -11435,6 +11491,7 @@ def test_approve_grant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.approve_grant(request) # Establish that the response is the type that we expect. @@ -11479,6 +11536,7 @@ def test_approve_grant_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.Grant.to_json( privilegedaccessmanager.Grant() ) @@ -11527,6 +11585,7 @@ def test_deny_grant_rest_bad_request( 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.deny_grant(request) @@ -11568,6 +11627,7 @@ def test_deny_grant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.deny_grant(request) # Establish that the response is the type that we expect. @@ -11612,6 +11672,7 @@ def test_deny_grant_rest_interceptors(null_interceptor): 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 = privilegedaccessmanager.Grant.to_json( privilegedaccessmanager.Grant() ) @@ -11660,6 +11721,7 @@ def test_revoke_grant_rest_bad_request( 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.revoke_grant(request) @@ -11692,6 +11754,7 @@ def test_revoke_grant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.revoke_grant(request) # Establish that the response is the type that we expect. @@ -11733,6 +11796,7 @@ def test_revoke_grant_rest_interceptors(null_interceptor): 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 @@ -11777,6 +11841,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -11807,6 +11872,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -11835,6 +11901,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -11865,6 +11932,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -11895,6 +11963,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -11925,6 +11994,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -11955,6 +12025,7 @@ def test_get_operation_rest_bad_request( 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) @@ -11985,6 +12056,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -12015,6 +12087,7 @@ def test_list_operations_rest_bad_request( 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) @@ -12045,6 +12118,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca/gapic_version.py b/packages/google-cloud-public-ca/google/cloud/security/publicca/gapic_version.py index 0106eadcd8d9..558c8aab67c5 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca/gapic_version.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/gapic_version.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/gapic_version.py index 0106eadcd8d9..558c8aab67c5 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/gapic_version.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/async_client.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/async_client.py index 3952f79569de..fd3a698d969f 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/async_client.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ PublicCertificateAuthorityServiceGrpcAsyncIOTransport, ) +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 PublicCertificateAuthorityServiceAsyncClient: """Manages the resources required for ACME `external account @@ -279,6 +289,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.security.publicca_v1.PublicCertificateAuthorityServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.security.publicca.v1.PublicCertificateAuthorityService", + "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.security.publicca.v1.PublicCertificateAuthorityService", + "credentialsType": None, + }, + ) + async def create_external_account_key( self, request: Optional[Union[service.CreateExternalAccountKeyRequest, dict]] = None, @@ -287,7 +319,7 @@ async def create_external_account_key( external_account_key: Optional[resources.ExternalAccountKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1.ExternalAccountKey] @@ -349,8 +381,10 @@ async def sample_create_external_account_key(): 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, 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: google.cloud.security.publicca_v1.types.ExternalAccountKey: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/client.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/client.py index 5b8c64e886cc..704e6d8b1ac4 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/client.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.security.publicca_v1.types import resources, service from .transports.base import ( @@ -599,6 +609,10 @@ def __init__( # 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( @@ -671,6 +685,29 @@ def __init__( 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.security.publicca_v1.PublicCertificateAuthorityServiceClient`.", + extra={ + "serviceName": "google.cloud.security.publicca.v1.PublicCertificateAuthorityService", + "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.security.publicca.v1.PublicCertificateAuthorityService", + "credentialsType": None, + }, + ) + def create_external_account_key( self, request: Optional[Union[service.CreateExternalAccountKeyRequest, dict]] = None, @@ -679,7 +716,7 @@ def create_external_account_key( external_account_key: Optional[resources.ExternalAccountKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1.ExternalAccountKey] @@ -741,8 +778,10 @@ def sample_create_external_account_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.publicca_v1.types.ExternalAccountKey: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py index 5d2e89cf2619..474ea91c5eb8 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.security.publicca_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, PublicCertificateAuthorityServiceTransport +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.security.publicca.v1.PublicCertificateAuthorityService", + "rpcName": 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.security.publicca.v1.PublicCertificateAuthorityService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PublicCertificateAuthorityServiceGrpcTransport( PublicCertificateAuthorityServiceTransport @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,9 @@ def create_external_account_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_account_key" not in self._stubs: - self._stubs["create_external_account_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_account_key" + ] = self._logged_channel.unary_unary( "/google.cloud.security.publicca.v1.PublicCertificateAuthorityService/CreateExternalAccountKey", request_serializer=service.CreateExternalAccountKeyRequest.serialize, response_deserializer=resources.ExternalAccountKey.deserialize, @@ -269,7 +357,7 @@ def create_external_account_key( return self._stubs["create_external_account_key"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py index 6232b617e963..30211074d64a 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.security.publicca_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, PublicCertificateAuthorityServiceTransport from .grpc import PublicCertificateAuthorityServiceGrpcTransport +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.security.publicca.v1.PublicCertificateAuthorityService", + "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.security.publicca.v1.PublicCertificateAuthorityService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PublicCertificateAuthorityServiceGrpcAsyncIOTransport( PublicCertificateAuthorityServiceTransport @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,9 @@ def create_external_account_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_account_key" not in self._stubs: - self._stubs["create_external_account_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_account_key" + ] = self._logged_channel.unary_unary( "/google.cloud.security.publicca.v1.PublicCertificateAuthorityService/CreateExternalAccountKey", request_serializer=service.CreateExternalAccountKeyRequest.serialize, response_deserializer=resources.ExternalAccountKey.deserialize, @@ -293,7 +380,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/rest.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/rest.py index dd71b008b368..9630069457c7 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/rest.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,10 @@ def post_create_external_account_key(self, response): def pre_create_external_account_key( self, request: service.CreateExternalAccountKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateExternalAccountKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateExternalAccountKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_external_account_key Override in a subclass to manipulate the request or metadata @@ -228,7 +238,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Call the create external account key method over HTTP. @@ -241,8 +251,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.ExternalAccountKey: @@ -256,6 +268,7 @@ def __call__( http_options = ( _BasePublicCertificateAuthorityServiceRestTransport._BaseCreateExternalAccountKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_account_key( request, metadata ) @@ -272,6 +285,33 @@ def __call__( 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.security.publicca_v1.PublicCertificateAuthorityServiceClient.CreateExternalAccountKey", + extra={ + "serviceName": "google.cloud.security.publicca.v1.PublicCertificateAuthorityService", + "rpcName": "CreateExternalAccountKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicCertificateAuthorityServiceRestTransport._CreateExternalAccountKey._get_response( self._host, @@ -293,7 +333,29 @@ def __call__( pb_resp = resources.ExternalAccountKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_external_account_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ExternalAccountKey.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.security.publicca_v1.PublicCertificateAuthorityServiceClient.create_external_account_key", + extra={ + "serviceName": "google.cloud.security.publicca.v1.PublicCertificateAuthorityService", + "rpcName": "CreateExternalAccountKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/gapic_version.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/gapic_version.py index 0106eadcd8d9..558c8aab67c5 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/gapic_version.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/async_client.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/async_client.py index 4238b0da97aa..fc28bac84eda 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/async_client.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ PublicCertificateAuthorityServiceGrpcAsyncIOTransport, ) +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 PublicCertificateAuthorityServiceAsyncClient: """Manages the resources required for ACME `external account @@ -279,6 +289,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.security.publicca_v1beta1.PublicCertificateAuthorityServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService", + "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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "credentialsType": None, + }, + ) + async def create_external_account_key( self, request: Optional[Union[service.CreateExternalAccountKeyRequest, dict]] = None, @@ -287,7 +319,7 @@ async def create_external_account_key( external_account_key: Optional[resources.ExternalAccountKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1beta1.ExternalAccountKey] @@ -349,8 +381,10 @@ async def sample_create_external_account_key(): 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, 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: google.cloud.security.publicca_v1beta1.types.ExternalAccountKey: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/client.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/client.py index a0bfb9029f54..09bf779aa68b 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/client.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.security.publicca_v1beta1.types import resources, service from .transports.base import ( @@ -599,6 +609,10 @@ def __init__( # 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( @@ -671,6 +685,29 @@ def __init__( 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.security.publicca_v1beta1.PublicCertificateAuthorityServiceClient`.", + extra={ + "serviceName": "google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService", + "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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "credentialsType": None, + }, + ) + def create_external_account_key( self, request: Optional[Union[service.CreateExternalAccountKeyRequest, dict]] = None, @@ -679,7 +716,7 @@ def create_external_account_key( external_account_key: Optional[resources.ExternalAccountKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1beta1.ExternalAccountKey] @@ -741,8 +778,10 @@ def sample_create_external_account_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.security.publicca_v1beta1.types.ExternalAccountKey: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py index 7f3329c34327..a144465a9fa6 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.security.publicca_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, PublicCertificateAuthorityServiceTransport +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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "rpcName": 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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PublicCertificateAuthorityServiceGrpcTransport( PublicCertificateAuthorityServiceTransport @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -261,7 +347,9 @@ def create_external_account_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_account_key" not in self._stubs: - self._stubs["create_external_account_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_account_key" + ] = self._logged_channel.unary_unary( "/google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService/CreateExternalAccountKey", request_serializer=service.CreateExternalAccountKeyRequest.serialize, response_deserializer=resources.ExternalAccountKey.deserialize, @@ -269,7 +357,7 @@ def create_external_account_key( return self._stubs["create_external_account_key"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py index 5ff69f91ef04..b24fa2e549e0 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.security.publicca_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, PublicCertificateAuthorityServiceTransport from .grpc import PublicCertificateAuthorityServiceGrpcTransport +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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "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.security.publicca.v1beta1.PublicCertificateAuthorityService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PublicCertificateAuthorityServiceGrpcAsyncIOTransport( PublicCertificateAuthorityServiceTransport @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -270,7 +355,9 @@ def create_external_account_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_external_account_key" not in self._stubs: - self._stubs["create_external_account_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_external_account_key" + ] = self._logged_channel.unary_unary( "/google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService/CreateExternalAccountKey", request_serializer=service.CreateExternalAccountKeyRequest.serialize, response_deserializer=resources.ExternalAccountKey.deserialize, @@ -293,7 +380,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/rest.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/rest.py index eb19aded3f8f..74951c6c5f53 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/rest.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,10 @@ def post_create_external_account_key(self, response): def pre_create_external_account_key( self, request: service.CreateExternalAccountKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateExternalAccountKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateExternalAccountKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_external_account_key Override in a subclass to manipulate the request or metadata @@ -228,7 +238,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.ExternalAccountKey: r"""Call the create external account key method over HTTP. @@ -241,8 +251,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.ExternalAccountKey: @@ -256,6 +268,7 @@ def __call__( http_options = ( _BasePublicCertificateAuthorityServiceRestTransport._BaseCreateExternalAccountKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_account_key( request, metadata ) @@ -272,6 +285,33 @@ def __call__( 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.security.publicca_v1beta1.PublicCertificateAuthorityServiceClient.CreateExternalAccountKey", + extra={ + "serviceName": "google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService", + "rpcName": "CreateExternalAccountKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicCertificateAuthorityServiceRestTransport._CreateExternalAccountKey._get_response( self._host, @@ -293,7 +333,29 @@ def __call__( pb_resp = resources.ExternalAccountKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_external_account_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ExternalAccountKey.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.security.publicca_v1beta1.PublicCertificateAuthorityServiceClient.create_external_account_key", + extra={ + "serviceName": "google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService", + "rpcName": "CreateExternalAccountKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1.json b/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1.json index 9229f3c3f426..0e5cae8caf1b 100644 --- a/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1.json +++ b/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-security-publicca", - "version": "0.3.14" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.publicca_v1.types.ExternalAccountKey", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.publicca_v1.types.ExternalAccountKey", diff --git a/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1beta1.json b/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1beta1.json index 75d2b46127b3..5871e5024384 100644 --- a/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1beta1.json +++ b/packages/google-cloud-public-ca/samples/generated_samples/snippet_metadata_google.cloud.security.publicca.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-public-ca", - "version": "0.3.14" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.publicca_v1beta1.types.ExternalAccountKey", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.security.publicca_v1beta1.types.ExternalAccountKey", diff --git a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py index cfc08c73f6fe..51755be9ebeb 100644 --- a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py +++ b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py @@ -1626,6 +1626,7 @@ def test_create_external_account_key_rest_required_fields( response_value._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_external_account_key(request) @@ -1680,6 +1681,7 @@ def test_create_external_account_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_account_key(**mock_args) @@ -1912,6 +1914,7 @@ def test_create_external_account_key_rest_bad_request( 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_external_account_key(request) @@ -2025,6 +2028,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_account_key(request) # Establish that the response is the type that we expect. @@ -2069,6 +2073,7 @@ def test_create_external_account_key_rest_interceptors(null_interceptor): 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 = resources.ExternalAccountKey.to_json( resources.ExternalAccountKey() ) diff --git a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py index c0bfb18e40e4..a48bf32dac87 100644 --- a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py +++ b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py @@ -1626,6 +1626,7 @@ def test_create_external_account_key_rest_required_fields( response_value._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_external_account_key(request) @@ -1680,6 +1681,7 @@ def test_create_external_account_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_external_account_key(**mock_args) @@ -1912,6 +1914,7 @@ def test_create_external_account_key_rest_bad_request( 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_external_account_key(request) @@ -2025,6 +2028,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_external_account_key(request) # Establish that the response is the type that we expect. @@ -2069,6 +2073,7 @@ def test_create_external_account_key_rest_interceptors(null_interceptor): 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 = resources.ExternalAccountKey.to_json( resources.ExternalAccountKey() ) diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas/gapic_version.py b/packages/google-cloud-quotas/google/cloud/cloudquotas/gapic_version.py index 7daf9a1dd221..558c8aab67c5 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas/gapic_version.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/gapic_version.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/gapic_version.py index 7daf9a1dd221..558c8aab67c5 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/gapic_version.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/async_client.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/async_client.py index 80a6fb9730a7..16b0b081a602 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/async_client.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudQuotasTransport from .transports.grpc_asyncio import CloudQuotasGrpcAsyncIOTransport +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 CloudQuotasAsyncClient: """The Cloud Quotas API is an infrastructure service for Google @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.cloudquotas_v1.CloudQuotasAsyncClient`.", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "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.api.cloudquotas.v1.CloudQuotas", + "credentialsType": None, + }, + ) + async def list_quota_infos( self, request: Optional[Union[cloudquotas.ListQuotaInfosRequest, dict]] = None, @@ -274,7 +306,7 @@ async def list_quota_infos( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQuotaInfosAsyncPager: r"""Lists QuotaInfos of all quotas for a given project, folder or organization. @@ -326,8 +358,10 @@ async def sample_list_quota_infos(): 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, 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: google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaInfosAsyncPager: @@ -402,7 +436,7 @@ async def get_quota_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaInfo: r"""Retrieve the QuotaInfo of a quota for a project, folder or organization. @@ -448,8 +482,10 @@ async def sample_get_quota_info(): 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, 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: google.cloud.cloudquotas_v1.types.QuotaInfo: @@ -511,7 +547,7 @@ async def list_quota_preferences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQuotaPreferencesAsyncPager: r"""Lists QuotaPreferences in a given project, folder or organization. @@ -565,8 +601,10 @@ async def sample_list_quota_preferences(): 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, 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: google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaPreferencesAsyncPager: @@ -641,7 +679,7 @@ async def get_quota_preference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Gets details of a single QuotaPreference. @@ -686,8 +724,10 @@ async def sample_get_quota_preference(): 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, 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: google.cloud.cloudquotas_v1.types.QuotaPreference: @@ -754,7 +794,7 @@ async def create_quota_preference( quota_preference_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Creates a new QuotaPreference that declares the desired value for a quota. @@ -820,8 +860,10 @@ async def sample_create_quota_preference(): 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, 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: google.cloud.cloudquotas_v1.types.QuotaPreference: @@ -891,7 +933,7 @@ async def update_quota_preference( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Updates the parameters of a single QuotaPreference. It can updates the config in any states, not just the @@ -952,8 +994,10 @@ async def sample_update_quota_preference(): 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, 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: google.cloud.cloudquotas_v1.types.QuotaPreference: diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/client.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/client.py index 5dfd44f40594..90b364da2069 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/client.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -613,6 +623,10 @@ def __init__( # 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( @@ -675,6 +689,29 @@ def __init__( 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.api.cloudquotas_v1.CloudQuotasClient`.", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "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.api.cloudquotas.v1.CloudQuotas", + "credentialsType": None, + }, + ) + def list_quota_infos( self, request: Optional[Union[cloudquotas.ListQuotaInfosRequest, dict]] = None, @@ -682,7 +719,7 @@ def list_quota_infos( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQuotaInfosPager: r"""Lists QuotaInfos of all quotas for a given project, folder or organization. @@ -734,8 +771,10 @@ def sample_list_quota_infos(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaInfosPager: @@ -807,7 +846,7 @@ def get_quota_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaInfo: r"""Retrieve the QuotaInfo of a quota for a project, folder or organization. @@ -853,8 +892,10 @@ def sample_get_quota_info(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.types.QuotaInfo: @@ -913,7 +954,7 @@ def list_quota_preferences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQuotaPreferencesPager: r"""Lists QuotaPreferences in a given project, folder or organization. @@ -967,8 +1008,10 @@ def sample_list_quota_preferences(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaPreferencesPager: @@ -1040,7 +1083,7 @@ def get_quota_preference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Gets details of a single QuotaPreference. @@ -1085,8 +1128,10 @@ def sample_get_quota_preference(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.types.QuotaPreference: @@ -1150,7 +1195,7 @@ def create_quota_preference( quota_preference_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Creates a new QuotaPreference that declares the desired value for a quota. @@ -1216,8 +1261,10 @@ def sample_create_quota_preference(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.types.QuotaPreference: @@ -1284,7 +1331,7 @@ def update_quota_preference( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Updates the parameters of a single QuotaPreference. It can updates the config in any states, not just the @@ -1345,8 +1392,10 @@ def sample_update_quota_preference(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.cloudquotas_v1.types.QuotaPreference: diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/pagers.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/pagers.py index c49b27f83afb..57c1842b4f42 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/pagers.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloudquotas.ListQuotaInfosRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloudquotas.ListQuotaInfosRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloudquotas.ListQuotaPreferencesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloudquotas.ListQuotaPreferencesRequest(request) diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc.py index 599bd90756a8..2bfac2b72336 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.cloudquotas_v1.types import cloudquotas, resources from .base import DEFAULT_CLIENT_INFO, CloudQuotasTransport +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.api.cloudquotas.v1.CloudQuotas", + "rpcName": 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.api.cloudquotas.v1.CloudQuotas", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudQuotasGrpcTransport(CloudQuotasTransport): """gRPC backend transport for CloudQuotas. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +351,7 @@ def list_quota_infos( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_quota_infos" not in self._stubs: - self._stubs["list_quota_infos"] = self.grpc_channel.unary_unary( + self._stubs["list_quota_infos"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/ListQuotaInfos", request_serializer=cloudquotas.ListQuotaInfosRequest.serialize, response_deserializer=cloudquotas.ListQuotaInfosResponse.deserialize, @@ -292,7 +378,7 @@ def get_quota_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_quota_info" not in self._stubs: - self._stubs["get_quota_info"] = self.grpc_channel.unary_unary( + self._stubs["get_quota_info"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/GetQuotaInfo", request_serializer=cloudquotas.GetQuotaInfoRequest.serialize, response_deserializer=resources.QuotaInfo.deserialize, @@ -322,7 +408,7 @@ def list_quota_preferences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_quota_preferences" not in self._stubs: - self._stubs["list_quota_preferences"] = self.grpc_channel.unary_unary( + self._stubs["list_quota_preferences"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/ListQuotaPreferences", request_serializer=cloudquotas.ListQuotaPreferencesRequest.serialize, response_deserializer=cloudquotas.ListQuotaPreferencesResponse.deserialize, @@ -348,7 +434,7 @@ def get_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_quota_preference" not in self._stubs: - self._stubs["get_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["get_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/GetQuotaPreference", request_serializer=cloudquotas.GetQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -377,7 +463,7 @@ def create_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_quota_preference" not in self._stubs: - self._stubs["create_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["create_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/CreateQuotaPreference", request_serializer=cloudquotas.CreateQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -407,7 +493,7 @@ def update_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_quota_preference" not in self._stubs: - self._stubs["update_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["update_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/UpdateQuotaPreference", request_serializer=cloudquotas.UpdateQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -415,7 +501,7 @@ def update_quota_preference( return self._stubs["update_quota_preference"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc_asyncio.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc_asyncio.py index 475d3a35c05a..61dfaac40f99 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc_asyncio.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.cloudquotas_v1.types import cloudquotas, resources from .base import DEFAULT_CLIENT_INFO, CloudQuotasTransport from .grpc import CloudQuotasGrpcTransport +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.api.cloudquotas.v1.CloudQuotas", + "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.api.cloudquotas.v1.CloudQuotas", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudQuotasGrpcAsyncIOTransport(CloudQuotasTransport): """gRPC AsyncIO backend transport for CloudQuotas. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def list_quota_infos( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_quota_infos" not in self._stubs: - self._stubs["list_quota_infos"] = self.grpc_channel.unary_unary( + self._stubs["list_quota_infos"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/ListQuotaInfos", request_serializer=cloudquotas.ListQuotaInfosRequest.serialize, response_deserializer=cloudquotas.ListQuotaInfosResponse.deserialize, @@ -301,7 +386,7 @@ def get_quota_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_quota_info" not in self._stubs: - self._stubs["get_quota_info"] = self.grpc_channel.unary_unary( + self._stubs["get_quota_info"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/GetQuotaInfo", request_serializer=cloudquotas.GetQuotaInfoRequest.serialize, response_deserializer=resources.QuotaInfo.deserialize, @@ -331,7 +416,7 @@ def list_quota_preferences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_quota_preferences" not in self._stubs: - self._stubs["list_quota_preferences"] = self.grpc_channel.unary_unary( + self._stubs["list_quota_preferences"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/ListQuotaPreferences", request_serializer=cloudquotas.ListQuotaPreferencesRequest.serialize, response_deserializer=cloudquotas.ListQuotaPreferencesResponse.deserialize, @@ -359,7 +444,7 @@ def get_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_quota_preference" not in self._stubs: - self._stubs["get_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["get_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/GetQuotaPreference", request_serializer=cloudquotas.GetQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -388,7 +473,7 @@ def create_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_quota_preference" not in self._stubs: - self._stubs["create_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["create_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/CreateQuotaPreference", request_serializer=cloudquotas.CreateQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -418,7 +503,7 @@ def update_quota_preference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_quota_preference" not in self._stubs: - self._stubs["update_quota_preference"] = self.grpc_channel.unary_unary( + self._stubs["update_quota_preference"] = self._logged_channel.unary_unary( "/google.api.cloudquotas.v1.CloudQuotas/UpdateQuotaPreference", request_serializer=cloudquotas.UpdateQuotaPreferenceRequest.serialize, response_deserializer=resources.QuotaPreference.deserialize, @@ -520,7 +605,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/rest.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/rest.py index b67b5bbdf7bd..353af1a39cf1 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/rest.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1/services/cloud_quotas/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -117,8 +125,11 @@ def post_update_quota_preference(self, response): def pre_create_quota_preference( self, request: cloudquotas.CreateQuotaPreferenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.CreateQuotaPreferenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.CreateQuotaPreferenceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_quota_preference Override in a subclass to manipulate the request or metadata @@ -140,8 +151,10 @@ def post_create_quota_preference( def pre_get_quota_info( self, request: cloudquotas.GetQuotaInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.GetQuotaInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.GetQuotaInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_quota_info Override in a subclass to manipulate the request or metadata @@ -161,8 +174,10 @@ def post_get_quota_info(self, response: resources.QuotaInfo) -> resources.QuotaI def pre_get_quota_preference( self, request: cloudquotas.GetQuotaPreferenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.GetQuotaPreferenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.GetQuotaPreferenceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_quota_preference Override in a subclass to manipulate the request or metadata @@ -184,8 +199,10 @@ def post_get_quota_preference( def pre_list_quota_infos( self, request: cloudquotas.ListQuotaInfosRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.ListQuotaInfosRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.ListQuotaInfosRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_quota_infos Override in a subclass to manipulate the request or metadata @@ -207,8 +224,10 @@ def post_list_quota_infos( def pre_list_quota_preferences( self, request: cloudquotas.ListQuotaPreferencesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.ListQuotaPreferencesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.ListQuotaPreferencesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_quota_preferences Override in a subclass to manipulate the request or metadata @@ -230,8 +249,11 @@ def post_list_quota_preferences( def pre_update_quota_preference( self, request: cloudquotas.UpdateQuotaPreferenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudquotas.UpdateQuotaPreferenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudquotas.UpdateQuotaPreferenceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_quota_preference Override in a subclass to manipulate the request or metadata @@ -381,7 +403,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Call the create quota preference method over HTTP. @@ -392,8 +414,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.QuotaPreference: @@ -409,6 +433,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseCreateQuotaPreference._get_http_options() ) + request, metadata = self._interceptor.pre_create_quota_preference( request, metadata ) @@ -425,6 +450,33 @@ def __call__( 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.api.cloudquotas_v1.CloudQuotasClient.CreateQuotaPreference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "CreateQuotaPreference", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._CreateQuotaPreference._get_response( self._host, @@ -446,7 +498,29 @@ def __call__( pb_resp = resources.QuotaPreference.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_quota_preference(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.QuotaPreference.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.api.cloudquotas_v1.CloudQuotasClient.create_quota_preference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "CreateQuotaPreference", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetQuotaInfo( @@ -483,7 +557,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaInfo: r"""Call the get quota info method over HTTP. @@ -493,8 +567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.QuotaInfo: @@ -507,6 +583,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseGetQuotaInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_quota_info(request, metadata) transcoded_request = ( _BaseCloudQuotasRestTransport._BaseGetQuotaInfo._get_transcoded_request( @@ -521,6 +598,33 @@ def __call__( ) ) + 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.api.cloudquotas_v1.CloudQuotasClient.GetQuotaInfo", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "GetQuotaInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._GetQuotaInfo._get_response( self._host, @@ -541,7 +645,29 @@ def __call__( pb_resp = resources.QuotaInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_quota_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.QuotaInfo.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.api.cloudquotas_v1.CloudQuotasClient.get_quota_info", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "GetQuotaInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetQuotaPreference( @@ -578,7 +704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Call the get quota preference method over HTTP. @@ -588,8 +714,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.QuotaPreference: @@ -605,6 +733,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseGetQuotaPreference._get_http_options() ) + request, metadata = self._interceptor.pre_get_quota_preference( request, metadata ) @@ -617,6 +746,33 @@ def __call__( 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.api.cloudquotas_v1.CloudQuotasClient.GetQuotaPreference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "GetQuotaPreference", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._GetQuotaPreference._get_response( self._host, @@ -637,7 +793,29 @@ def __call__( pb_resp = resources.QuotaPreference.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_quota_preference(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.QuotaPreference.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.api.cloudquotas_v1.CloudQuotasClient.get_quota_preference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "GetQuotaPreference", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListQuotaInfos( @@ -674,7 +852,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudquotas.ListQuotaInfosResponse: r"""Call the list quota infos method over HTTP. @@ -685,8 +863,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloudquotas.ListQuotaInfosResponse: @@ -698,6 +878,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseListQuotaInfos._get_http_options() ) + request, metadata = self._interceptor.pre_list_quota_infos( request, metadata ) @@ -710,6 +891,33 @@ def __call__( 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.api.cloudquotas_v1.CloudQuotasClient.ListQuotaInfos", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "ListQuotaInfos", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._ListQuotaInfos._get_response( self._host, @@ -730,7 +938,31 @@ def __call__( pb_resp = cloudquotas.ListQuotaInfosResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_quota_infos(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudquotas.ListQuotaInfosResponse.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.api.cloudquotas_v1.CloudQuotasClient.list_quota_infos", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "ListQuotaInfos", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListQuotaPreferences( @@ -767,7 +999,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudquotas.ListQuotaPreferencesResponse: r"""Call the list quota preferences method over HTTP. @@ -778,8 +1010,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloudquotas.ListQuotaPreferencesResponse: @@ -791,6 +1025,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseListQuotaPreferences._get_http_options() ) + request, metadata = self._interceptor.pre_list_quota_preferences( request, metadata ) @@ -803,6 +1038,33 @@ def __call__( 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.api.cloudquotas_v1.CloudQuotasClient.ListQuotaPreferences", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "ListQuotaPreferences", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._ListQuotaPreferences._get_response( self._host, @@ -823,7 +1085,31 @@ def __call__( pb_resp = cloudquotas.ListQuotaPreferencesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_quota_preferences(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudquotas.ListQuotaPreferencesResponse.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.api.cloudquotas_v1.CloudQuotasClient.list_quota_preferences", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "ListQuotaPreferences", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateQuotaPreference( @@ -861,7 +1147,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.QuotaPreference: r"""Call the update quota preference method over HTTP. @@ -872,8 +1158,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resources.QuotaPreference: @@ -889,6 +1177,7 @@ def __call__( http_options = ( _BaseCloudQuotasRestTransport._BaseUpdateQuotaPreference._get_http_options() ) + request, metadata = self._interceptor.pre_update_quota_preference( request, metadata ) @@ -905,6 +1194,33 @@ def __call__( 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.api.cloudquotas_v1.CloudQuotasClient.UpdateQuotaPreference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "UpdateQuotaPreference", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudQuotasRestTransport._UpdateQuotaPreference._get_response( self._host, @@ -926,7 +1242,29 @@ def __call__( pb_resp = resources.QuotaPreference.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_quota_preference(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.QuotaPreference.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.api.cloudquotas_v1.CloudQuotasClient.update_quota_preference", + extra={ + "serviceName": "google.api.cloudquotas.v1.CloudQuotas", + "rpcName": "UpdateQuotaPreference", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-quotas/samples/generated_samples/snippet_metadata_google.api.cloudquotas.v1.json b/packages/google-cloud-quotas/samples/generated_samples/snippet_metadata_google.api.cloudquotas.v1.json index 698cfddccb39..5c9d0867f7f3 100644 --- a/packages/google-cloud-quotas/samples/generated_samples/snippet_metadata_google.api.cloudquotas.v1.json +++ b/packages/google-cloud-quotas/samples/generated_samples/snippet_metadata_google.api.cloudquotas.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-quotas", - "version": "0.1.13" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaInfo", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaInfo", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaInfosAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaInfosPager", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaPreferencesAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.services.cloud_quotas.pagers.ListQuotaPreferencesPager", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.cloudquotas_v1.types.QuotaPreference", diff --git a/packages/google-cloud-quotas/tests/unit/gapic/cloudquotas_v1/test_cloud_quotas.py b/packages/google-cloud-quotas/tests/unit/gapic/cloudquotas_v1/test_cloud_quotas.py index 789a5a86bafe..9e5844a0259d 100644 --- a/packages/google-cloud-quotas/tests/unit/gapic/cloudquotas_v1/test_cloud_quotas.py +++ b/packages/google-cloud-quotas/tests/unit/gapic/cloudquotas_v1/test_cloud_quotas.py @@ -3711,6 +3711,7 @@ def test_list_quota_infos_rest_required_fields( response_value._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_quota_infos(request) @@ -3766,6 +3767,7 @@ def test_list_quota_infos_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_infos(**mock_args) @@ -3962,6 +3964,7 @@ def test_get_quota_info_rest_required_fields( response_value._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_quota_info(request) @@ -4009,6 +4012,7 @@ def test_get_quota_info_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_info(**mock_args) @@ -4154,6 +4158,7 @@ def test_list_quota_preferences_rest_required_fields( response_value._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_quota_preferences(request) @@ -4209,6 +4214,7 @@ def test_list_quota_preferences_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_preferences(**mock_args) @@ -4407,6 +4413,7 @@ def test_get_quota_preference_rest_required_fields( response_value._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_quota_preference(request) @@ -4454,6 +4461,7 @@ def test_get_quota_preference_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_preference(**mock_args) @@ -4598,6 +4606,7 @@ def test_create_quota_preference_rest_required_fields( response_value._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_quota_preference(request) @@ -4658,6 +4667,7 @@ def test_create_quota_preference_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_preference(**mock_args) @@ -4801,6 +4811,7 @@ def test_update_quota_preference_rest_required_fields( response_value._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_quota_preference(request) @@ -4861,6 +4872,7 @@ def test_update_quota_preference_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_quota_preference(**mock_args) @@ -5375,6 +5387,7 @@ def test_list_quota_infos_rest_bad_request( 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_quota_infos(request) @@ -5410,6 +5423,7 @@ def test_list_quota_infos_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_infos(request) # Establish that the response is the type that we expect. @@ -5450,6 +5464,7 @@ def test_list_quota_infos_rest_interceptors(null_interceptor): 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 = cloudquotas.ListQuotaInfosResponse.to_json( cloudquotas.ListQuotaInfosResponse() ) @@ -5496,6 +5511,7 @@ def test_get_quota_info_rest_bad_request(request_type=cloudquotas.GetQuotaInfoRe 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_quota_info(request) @@ -5546,6 +5562,7 @@ def test_get_quota_info_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_info(request) # Establish that the response is the type that we expect. @@ -5599,6 +5616,7 @@ def test_get_quota_info_rest_interceptors(null_interceptor): 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 = resources.QuotaInfo.to_json(resources.QuotaInfo()) req.return_value.content = return_value @@ -5643,6 +5661,7 @@ def test_list_quota_preferences_rest_bad_request( 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_quota_preferences(request) @@ -5679,6 +5698,7 @@ def test_list_quota_preferences_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_preferences(request) # Establish that the response is the type that we expect. @@ -5720,6 +5740,7 @@ def test_list_quota_preferences_rest_interceptors(null_interceptor): 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 = cloudquotas.ListQuotaPreferencesResponse.to_json( cloudquotas.ListQuotaPreferencesResponse() ) @@ -5768,6 +5789,7 @@ def test_get_quota_preference_rest_bad_request( 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_quota_preference(request) @@ -5811,6 +5833,7 @@ def test_get_quota_preference_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_preference(request) # Establish that the response is the type that we expect. @@ -5857,6 +5880,7 @@ def test_get_quota_preference_rest_interceptors(null_interceptor): 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 = resources.QuotaPreference.to_json(resources.QuotaPreference()) req.return_value.content = return_value @@ -5901,6 +5925,7 @@ def test_create_quota_preference_rest_bad_request( 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_quota_preference(request) @@ -6031,6 +6056,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_preference(request) # Establish that the response is the type that we expect. @@ -6077,6 +6103,7 @@ def test_create_quota_preference_rest_interceptors(null_interceptor): 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 = resources.QuotaPreference.to_json(resources.QuotaPreference()) req.return_value.content = return_value @@ -6125,6 +6152,7 @@ def test_update_quota_preference_rest_bad_request( 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_quota_preference(request) @@ -6259,6 +6287,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_quota_preference(request) # Establish that the response is the type that we expect. @@ -6305,6 +6334,7 @@ def test_update_quota_preference_rest_interceptors(null_interceptor): 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 = resources.QuotaPreference.to_json(resources.QuotaPreference()) req.return_value.content = return_value diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment/gapic_version.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment/gapic_version.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/gapic_version.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/gapic_version.py index 4b834789ba9e..558c8aab67c5 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/gapic_version.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/async_client.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/async_client.py index acc50adbcd0a..2dabb4ba32ea 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/async_client.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RapidMigrationAssessmentTransport from .transports.grpc_asyncio import RapidMigrationAssessmentGrpcAsyncIOTransport +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 RapidMigrationAssessmentAsyncClient: """Service describing handlers for resources.""" @@ -282,6 +292,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient`.", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "credentialsType": None, + }, + ) + async def create_collector( self, request: Optional[ @@ -293,7 +325,7 @@ async def create_collector( collector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a Collector to manage the on-prem appliance which collects information about Customer assets. @@ -354,8 +386,10 @@ async def sample_create_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -434,7 +468,7 @@ async def create_annotation( annotation: Optional[api_entities.Annotation] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates an Annotation @@ -486,8 +520,10 @@ async def sample_create_annotation(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -563,7 +599,7 @@ async def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Annotation: r"""Gets details of a single Annotation. @@ -605,8 +641,10 @@ async def sample_get_annotation(): 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, 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: google.cloud.rapidmigrationassessment_v1.types.Annotation: @@ -667,7 +705,7 @@ async def list_collectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCollectorsAsyncPager: r"""Lists Collectors in a given project and location. @@ -712,8 +750,10 @@ async def sample_list_collectors(): 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, 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: google.cloud.rapidmigrationassessment_v1.services.rapid_migration_assessment.pagers.ListCollectorsAsyncPager: @@ -790,7 +830,7 @@ async def get_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Collector: r"""Gets details of a single Collector. @@ -832,8 +872,10 @@ async def sample_get_collector(): 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, 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: google.cloud.rapidmigrationassessment_v1.types.Collector: @@ -895,7 +937,7 @@ async def update_collector( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Collector. @@ -950,8 +992,10 @@ async def sample_update_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1029,7 +1073,7 @@ async def delete_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Collector - changes state of collector to "Deleting". Background jobs does final @@ -1076,8 +1120,10 @@ async def sample_delete_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1151,7 +1197,7 @@ async def resume_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Resumes the given collector. @@ -1196,8 +1242,10 @@ async def sample_resume_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1271,7 +1319,7 @@ async def register_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Registers the given collector. @@ -1316,8 +1364,10 @@ async def sample_register_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1391,7 +1441,7 @@ async def pause_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Pauses the given collector. @@ -1436,8 +1486,10 @@ async def sample_pause_collector(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1508,7 +1560,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1519,8 +1571,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1561,7 +1615,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1572,8 +1626,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1614,7 +1670,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1630,8 +1686,10 @@ async def delete_operation( 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, 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: None """ @@ -1668,7 +1726,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1683,8 +1741,10 @@ async def cancel_operation( 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, 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: None """ @@ -1721,7 +1781,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1732,8 +1792,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1774,7 +1836,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1785,8 +1847,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/client.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/client.py index 1e33374b702f..8ccacf2ddd65 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/client.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -622,6 +632,10 @@ def __init__( # 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( @@ -688,6 +702,29 @@ def __init__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient`.", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "credentialsType": None, + }, + ) + def create_collector( self, request: Optional[ @@ -699,7 +736,7 @@ def create_collector( collector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a Collector to manage the on-prem appliance which collects information about Customer assets. @@ -760,8 +797,10 @@ def sample_create_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -837,7 +876,7 @@ def create_annotation( annotation: Optional[api_entities.Annotation] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates an Annotation @@ -889,8 +928,10 @@ def sample_create_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -963,7 +1004,7 @@ def get_annotation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Annotation: r"""Gets details of a single Annotation. @@ -1005,8 +1046,10 @@ def sample_get_annotation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.rapidmigrationassessment_v1.types.Annotation: @@ -1064,7 +1107,7 @@ def list_collectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCollectorsPager: r"""Lists Collectors in a given project and location. @@ -1109,8 +1152,10 @@ def sample_list_collectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.rapidmigrationassessment_v1.services.rapid_migration_assessment.pagers.ListCollectorsPager: @@ -1184,7 +1229,7 @@ def get_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Collector: r"""Gets details of a single Collector. @@ -1226,8 +1271,10 @@ def sample_get_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.rapidmigrationassessment_v1.types.Collector: @@ -1286,7 +1333,7 @@ def update_collector( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Collector. @@ -1341,8 +1388,10 @@ def sample_update_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1417,7 +1466,7 @@ def delete_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Collector - changes state of collector to "Deleting". Background jobs does final @@ -1464,8 +1513,10 @@ def sample_delete_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1536,7 +1587,7 @@ def resume_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Resumes the given collector. @@ -1581,8 +1632,10 @@ def sample_resume_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1653,7 +1706,7 @@ def register_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Registers the given collector. @@ -1698,8 +1751,10 @@ def sample_register_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1770,7 +1825,7 @@ def pause_collector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Pauses the given collector. @@ -1815,8 +1870,10 @@ def sample_pause_collector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1897,7 +1954,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1908,8 +1965,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1950,7 +2009,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1961,8 +2020,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2003,7 +2064,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2019,8 +2080,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2057,7 +2120,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2072,8 +2135,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2110,7 +2175,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2121,8 +2186,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2163,7 +2230,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2174,8 +2241,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/pagers.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/pagers.py index bb8ba76a69fb..f286dbb0a3a1 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/pagers.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/pagers.py @@ -70,7 +70,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -84,8 +84,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = rapidmigrationassessment.ListCollectorsRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( 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, 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`. """ self._method = method self._request = rapidmigrationassessment.ListCollectorsRequest(request) diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py index 15c865e79d20..7b5fbb8eb731 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.rapidmigrationassessment_v1.types import ( api_entities, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, RapidMigrationAssessmentTransport +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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": 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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RapidMigrationAssessmentGrpcTransport(RapidMigrationAssessmentTransport): """gRPC backend transport for RapidMigrationAssessment. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def create_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collector" not in self._stubs: - self._stubs["create_collector"] = self.grpc_channel.unary_unary( + self._stubs["create_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateCollector", request_serializer=rapidmigrationassessment.CreateCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -304,7 +392,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateAnnotation", request_serializer=rapidmigrationassessment.CreateAnnotationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -332,7 +420,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetAnnotation", request_serializer=rapidmigrationassessment.GetAnnotationRequest.serialize, response_deserializer=api_entities.Annotation.deserialize, @@ -361,7 +449,7 @@ def list_collectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collectors" not in self._stubs: - self._stubs["list_collectors"] = self.grpc_channel.unary_unary( + self._stubs["list_collectors"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ListCollectors", request_serializer=rapidmigrationassessment.ListCollectorsRequest.serialize, response_deserializer=rapidmigrationassessment.ListCollectorsResponse.deserialize, @@ -389,7 +477,7 @@ def get_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collector" not in self._stubs: - self._stubs["get_collector"] = self.grpc_channel.unary_unary( + self._stubs["get_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetCollector", request_serializer=rapidmigrationassessment.GetCollectorRequest.serialize, response_deserializer=api_entities.Collector.deserialize, @@ -417,7 +505,7 @@ def update_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collector" not in self._stubs: - self._stubs["update_collector"] = self.grpc_channel.unary_unary( + self._stubs["update_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/UpdateCollector", request_serializer=rapidmigrationassessment.UpdateCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +535,7 @@ def delete_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collector" not in self._stubs: - self._stubs["delete_collector"] = self.grpc_channel.unary_unary( + self._stubs["delete_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/DeleteCollector", request_serializer=rapidmigrationassessment.DeleteCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -475,7 +563,7 @@ def resume_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_collector" not in self._stubs: - self._stubs["resume_collector"] = self.grpc_channel.unary_unary( + self._stubs["resume_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ResumeCollector", request_serializer=rapidmigrationassessment.ResumeCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -503,7 +591,7 @@ def register_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "register_collector" not in self._stubs: - self._stubs["register_collector"] = self.grpc_channel.unary_unary( + self._stubs["register_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/RegisterCollector", request_serializer=rapidmigrationassessment.RegisterCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +619,7 @@ def pause_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_collector" not in self._stubs: - self._stubs["pause_collector"] = self.grpc_channel.unary_unary( + self._stubs["pause_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/PauseCollector", request_serializer=rapidmigrationassessment.PauseCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -539,7 +627,7 @@ def pause_collector( return self._stubs["pause_collector"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -551,7 +639,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -568,7 +656,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -585,7 +673,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -604,7 +692,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -623,7 +711,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -640,7 +728,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py index b83001d64298..75be4c8df6cb 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.rapidmigrationassessment_v1.types import ( api_entities, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, RapidMigrationAssessmentTransport from .grpc import RapidMigrationAssessmentGrpcTransport +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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "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.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RapidMigrationAssessmentGrpcAsyncIOTransport(RapidMigrationAssessmentTransport): """gRPC AsyncIO backend transport for RapidMigrationAssessment. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_collector" not in self._stubs: - self._stubs["create_collector"] = self.grpc_channel.unary_unary( + self._stubs["create_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateCollector", request_serializer=rapidmigrationassessment.CreateCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +401,7 @@ def create_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_annotation" not in self._stubs: - self._stubs["create_annotation"] = self.grpc_channel.unary_unary( + self._stubs["create_annotation"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/CreateAnnotation", request_serializer=rapidmigrationassessment.CreateAnnotationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -345,7 +430,7 @@ def get_annotation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation" not in self._stubs: - self._stubs["get_annotation"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetAnnotation", request_serializer=rapidmigrationassessment.GetAnnotationRequest.serialize, response_deserializer=api_entities.Annotation.deserialize, @@ -374,7 +459,7 @@ def list_collectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_collectors" not in self._stubs: - self._stubs["list_collectors"] = self.grpc_channel.unary_unary( + self._stubs["list_collectors"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ListCollectors", request_serializer=rapidmigrationassessment.ListCollectorsRequest.serialize, response_deserializer=rapidmigrationassessment.ListCollectorsResponse.deserialize, @@ -403,7 +488,7 @@ def get_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_collector" not in self._stubs: - self._stubs["get_collector"] = self.grpc_channel.unary_unary( + self._stubs["get_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/GetCollector", request_serializer=rapidmigrationassessment.GetCollectorRequest.serialize, response_deserializer=api_entities.Collector.deserialize, @@ -432,7 +517,7 @@ def update_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_collector" not in self._stubs: - self._stubs["update_collector"] = self.grpc_channel.unary_unary( + self._stubs["update_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/UpdateCollector", request_serializer=rapidmigrationassessment.UpdateCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +548,7 @@ def delete_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_collector" not in self._stubs: - self._stubs["delete_collector"] = self.grpc_channel.unary_unary( + self._stubs["delete_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/DeleteCollector", request_serializer=rapidmigrationassessment.DeleteCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -492,7 +577,7 @@ def resume_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_collector" not in self._stubs: - self._stubs["resume_collector"] = self.grpc_channel.unary_unary( + self._stubs["resume_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/ResumeCollector", request_serializer=rapidmigrationassessment.ResumeCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -521,7 +606,7 @@ def register_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "register_collector" not in self._stubs: - self._stubs["register_collector"] = self.grpc_channel.unary_unary( + self._stubs["register_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/RegisterCollector", request_serializer=rapidmigrationassessment.RegisterCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -550,7 +635,7 @@ def pause_collector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_collector" not in self._stubs: - self._stubs["pause_collector"] = self.grpc_channel.unary_unary( + self._stubs["pause_collector"] = self._logged_channel.unary_unary( "/google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment/PauseCollector", request_serializer=rapidmigrationassessment.PauseCollectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -678,7 +763,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -694,7 +779,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -711,7 +796,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -728,7 +813,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -747,7 +832,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -766,7 +851,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -783,7 +868,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/rest.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/rest.py index 8f9c9e8cd99e..714507957c5a 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/rest.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -42,6 +42,14 @@ 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, @@ -154,9 +162,10 @@ def post_update_collector(self, response): def pre_create_annotation( self, request: rapidmigrationassessment.CreateAnnotationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.CreateAnnotationRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.CreateAnnotationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_annotation @@ -179,9 +188,10 @@ def post_create_annotation( def pre_create_collector( self, request: rapidmigrationassessment.CreateCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.CreateCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.CreateCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_collector @@ -204,9 +214,10 @@ def post_create_collector( def pre_delete_collector( self, request: rapidmigrationassessment.DeleteCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.DeleteCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.DeleteCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_collector @@ -229,9 +240,10 @@ def post_delete_collector( def pre_get_annotation( self, request: rapidmigrationassessment.GetAnnotationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.GetAnnotationRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.GetAnnotationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_annotation @@ -254,8 +266,11 @@ def post_get_annotation( def pre_get_collector( self, request: rapidmigrationassessment.GetCollectorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[rapidmigrationassessment.GetCollectorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + rapidmigrationassessment.GetCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_collector Override in a subclass to manipulate the request or metadata @@ -277,9 +292,10 @@ def post_get_collector( def pre_list_collectors( self, request: rapidmigrationassessment.ListCollectorsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.ListCollectorsRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.ListCollectorsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_collectors @@ -302,9 +318,10 @@ def post_list_collectors( def pre_pause_collector( self, request: rapidmigrationassessment.PauseCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.PauseCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.PauseCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for pause_collector @@ -327,9 +344,10 @@ def post_pause_collector( def pre_register_collector( self, request: rapidmigrationassessment.RegisterCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.RegisterCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.RegisterCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for register_collector @@ -352,9 +370,10 @@ def post_register_collector( def pre_resume_collector( self, request: rapidmigrationassessment.ResumeCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.ResumeCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.ResumeCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for resume_collector @@ -377,9 +396,10 @@ def post_resume_collector( def pre_update_collector( self, request: rapidmigrationassessment.UpdateCollectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - rapidmigrationassessment.UpdateCollectorRequest, Sequence[Tuple[str, str]] + rapidmigrationassessment.UpdateCollectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_collector @@ -402,8 +422,10 @@ def post_update_collector( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -425,8 +447,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -448,8 +472,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -469,8 +495,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -490,8 +518,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -513,8 +543,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -710,7 +742,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create annotation method over HTTP. @@ -720,8 +752,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -734,6 +768,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseCreateAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_create_annotation( request, metadata ) @@ -750,6 +785,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.CreateAnnotation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "CreateAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._CreateAnnotation._get_response( @@ -771,7 +833,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_annotation(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.create_annotation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "CreateAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCollector( @@ -810,7 +894,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create collector method over HTTP. @@ -820,8 +904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -834,6 +920,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseCreateCollector._get_http_options() ) + request, metadata = self._interceptor.pre_create_collector( request, metadata ) @@ -850,6 +937,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.CreateCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "CreateCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._CreateCollector._get_response( @@ -871,7 +985,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.create_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "CreateCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCollector( @@ -909,7 +1045,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete collector method over HTTP. @@ -919,8 +1055,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -933,6 +1071,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseDeleteCollector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_collector( request, metadata ) @@ -945,6 +1084,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.DeleteCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "DeleteCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._DeleteCollector._get_response( @@ -965,7 +1131,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.delete_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "DeleteCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotation( @@ -1003,7 +1191,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Annotation: r"""Call the get annotation method over HTTP. @@ -1014,8 +1202,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.api_entities.Annotation: @@ -1025,6 +1215,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseGetAnnotation._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseGetAnnotation._get_transcoded_request( http_options, request @@ -1035,6 +1226,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.GetAnnotation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetAnnotation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._GetAnnotation._get_response( @@ -1057,7 +1275,29 @@ def __call__( pb_resp = api_entities.Annotation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = api_entities.Annotation.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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.get_annotation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetAnnotation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCollector( @@ -1095,7 +1335,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> api_entities.Collector: r"""Call the get collector method over HTTP. @@ -1106,8 +1346,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.api_entities.Collector: @@ -1117,6 +1359,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseGetCollector._get_http_options() ) + request, metadata = self._interceptor.pre_get_collector(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseGetCollector._get_transcoded_request( http_options, request @@ -1127,6 +1370,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.GetCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._GetCollector._get_response( @@ -1149,7 +1419,29 @@ def __call__( pb_resp = api_entities.Collector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_collector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = api_entities.Collector.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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.get_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCollectors( @@ -1187,7 +1479,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rapidmigrationassessment.ListCollectorsResponse: r"""Call the list collectors method over HTTP. @@ -1198,8 +1490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.rapidmigrationassessment.ListCollectorsResponse: @@ -1211,6 +1505,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseListCollectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_collectors(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseListCollectors._get_transcoded_request( http_options, request @@ -1221,6 +1516,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.ListCollectors", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListCollectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._ListCollectors._get_response( @@ -1243,7 +1565,33 @@ def __call__( pb_resp = rapidmigrationassessment.ListCollectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_collectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + rapidmigrationassessment.ListCollectorsResponse.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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.list_collectors", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListCollectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseCollector( @@ -1282,7 +1630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the pause collector method over HTTP. @@ -1292,8 +1640,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1306,6 +1656,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BasePauseCollector._get_http_options() ) + request, metadata = self._interceptor.pre_pause_collector(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BasePauseCollector._get_transcoded_request( http_options, request @@ -1320,6 +1671,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.PauseCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "PauseCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._PauseCollector._get_response( @@ -1341,7 +1719,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.pause_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "PauseCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RegisterCollector( @@ -1380,7 +1780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the register collector method over HTTP. @@ -1390,8 +1790,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1404,6 +1806,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseRegisterCollector._get_http_options() ) + request, metadata = self._interceptor.pre_register_collector( request, metadata ) @@ -1420,6 +1823,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.RegisterCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "RegisterCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._RegisterCollector._get_response( @@ -1441,7 +1871,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_register_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.register_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "RegisterCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeCollector( @@ -1480,7 +1932,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the resume collector method over HTTP. @@ -1490,8 +1942,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1504,6 +1958,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseResumeCollector._get_http_options() ) + request, metadata = self._interceptor.pre_resume_collector( request, metadata ) @@ -1520,6 +1975,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.ResumeCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ResumeCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._ResumeCollector._get_response( @@ -1541,7 +2023,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.resume_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ResumeCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCollector( @@ -1580,7 +2084,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update collector method over HTTP. @@ -1590,8 +2094,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1604,6 +2110,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseUpdateCollector._get_http_options() ) + request, metadata = self._interceptor.pre_update_collector( request, metadata ) @@ -1620,6 +2127,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.UpdateCollector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "UpdateCollector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._UpdateCollector._get_response( @@ -1641,7 +2175,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_collector(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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.update_collector", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "UpdateCollector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1784,7 +2340,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1794,8 +2350,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1804,6 +2362,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1814,6 +2373,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.GetLocation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RapidMigrationAssessmentRestTransport._GetLocation._get_response( self._host, @@ -1833,6 +2419,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1874,7 +2481,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1884,8 +2491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1894,6 +2503,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1904,6 +2514,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.ListLocations", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._ListLocations._get_response( @@ -1925,6 +2562,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1967,7 +2625,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1977,13 +2635,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2000,6 +2661,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.CancelOperation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._CancelOperation._get_response( @@ -2059,7 +2747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2069,13 +2757,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2088,6 +2779,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._DeleteOperation._get_response( @@ -2146,7 +2864,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2156,8 +2874,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2166,6 +2886,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2176,6 +2897,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.GetOperation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._GetOperation._get_response( @@ -2197,6 +2945,27 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2238,7 +3007,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2248,8 +3017,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2258,6 +3029,7 @@ def __call__( http_options = ( _BaseRapidMigrationAssessmentRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseRapidMigrationAssessmentRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2268,6 +3040,33 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentClient.ListOperations", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RapidMigrationAssessmentRestTransport._ListOperations._get_response( @@ -2289,6 +3088,27 @@ def __call__( 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.rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-rapidmigrationassessment/samples/generated_samples/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json b/packages/google-cloud-rapidmigrationassessment/samples/generated_samples/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json index 9e610eb890fc..2c00dccb6124 100644 --- a/packages/google-cloud-rapidmigrationassessment/samples/generated_samples/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json +++ b/packages/google-cloud-rapidmigrationassessment/samples/generated_samples/snippet_metadata_google.cloud.rapidmigrationassessment.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-rapidmigrationassessment", - "version": "0.1.11" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.types.Annotation", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.types.Annotation", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.types.Collector", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.types.Collector", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.services.rapid_migration_assessment.pagers.ListCollectorsAsyncPager", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.rapidmigrationassessment_v1.services.rapid_migration_assessment.pagers.ListCollectorsPager", @@ -1037,7 +1037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1198,7 +1198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1278,7 +1278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1359,7 +1359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1439,7 +1439,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1524,7 +1524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py b/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py index 4a1e2c25d457..78aa30177f24 100644 --- a/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py +++ b/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py @@ -4874,6 +4874,7 @@ def test_create_collector_rest_required_fields( response_value._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_collector(request) @@ -4939,6 +4940,7 @@ def test_create_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collector(**mock_args) @@ -5077,6 +5079,7 @@ def test_create_annotation_rest_required_fields( response_value._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_annotation(request) @@ -5129,6 +5132,7 @@ def test_create_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -5261,6 +5265,7 @@ def test_get_annotation_rest_required_fields( response_value._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_annotation(request) @@ -5308,6 +5313,7 @@ def test_get_annotation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_annotation(**mock_args) @@ -5450,6 +5456,7 @@ def test_list_collectors_rest_required_fields( response_value._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_collectors(request) @@ -5505,6 +5512,7 @@ def test_list_collectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collectors(**mock_args) @@ -5698,6 +5706,7 @@ def test_get_collector_rest_required_fields( response_value._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_collector(request) @@ -5745,6 +5754,7 @@ def test_get_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collector(**mock_args) @@ -5881,6 +5891,7 @@ def test_update_collector_rest_required_fields( response_value._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_collector(request) @@ -5942,6 +5953,7 @@ def test_update_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collector(**mock_args) @@ -6079,6 +6091,7 @@ def test_delete_collector_rest_required_fields( response_value._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_collector(request) @@ -6124,6 +6137,7 @@ def test_delete_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_collector(**mock_args) @@ -6258,6 +6272,7 @@ def test_resume_collector_rest_required_fields( response_value._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.resume_collector(request) @@ -6303,6 +6318,7 @@ def test_resume_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.resume_collector(**mock_args) @@ -6440,6 +6456,7 @@ def test_register_collector_rest_required_fields( response_value._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.register_collector(request) @@ -6485,6 +6502,7 @@ def test_register_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.register_collector(**mock_args) @@ -6618,6 +6636,7 @@ def test_pause_collector_rest_required_fields( response_value._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.pause_collector(request) @@ -6663,6 +6682,7 @@ def test_pause_collector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.pause_collector(**mock_args) @@ -7325,6 +7345,7 @@ def test_create_collector_rest_bad_request( 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_collector(request) @@ -7441,6 +7462,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_collector(request) # Establish that the response is the type that we expect. @@ -7482,6 +7504,7 @@ def test_create_collector_rest_interceptors(null_interceptor): 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 @@ -7526,6 +7549,7 @@ def test_create_annotation_rest_bad_request( 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_annotation(request) @@ -7632,6 +7656,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -7673,6 +7698,7 @@ def test_create_annotation_rest_interceptors(null_interceptor): 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 @@ -7717,6 +7743,7 @@ def test_get_annotation_rest_bad_request( 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_annotation(request) @@ -7753,6 +7780,7 @@ def test_get_annotation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_annotation(request) # Establish that the response is the type that we expect. @@ -7794,6 +7822,7 @@ def test_get_annotation_rest_interceptors(null_interceptor): 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 = api_entities.Annotation.to_json(api_entities.Annotation()) req.return_value.content = return_value @@ -7838,6 +7867,7 @@ def test_list_collectors_rest_bad_request( 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_collectors(request) @@ -7874,6 +7904,7 @@ def test_list_collectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collectors(request) # Establish that the response is the type that we expect. @@ -7915,6 +7946,7 @@ def test_list_collectors_rest_interceptors(null_interceptor): 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 = rapidmigrationassessment.ListCollectorsResponse.to_json( rapidmigrationassessment.ListCollectorsResponse() ) @@ -7961,6 +7993,7 @@ def test_get_collector_rest_bad_request( 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_collector(request) @@ -8005,6 +8038,7 @@ def test_get_collector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collector(request) # Establish that the response is the type that we expect. @@ -8054,6 +8088,7 @@ def test_get_collector_rest_interceptors(null_interceptor): 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 = api_entities.Collector.to_json(api_entities.Collector()) req.return_value.content = return_value @@ -8100,6 +8135,7 @@ def test_update_collector_rest_bad_request( 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_collector(request) @@ -8218,6 +8254,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_collector(request) # Establish that the response is the type that we expect. @@ -8259,6 +8296,7 @@ def test_update_collector_rest_interceptors(null_interceptor): 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 @@ -8303,6 +8341,7 @@ def test_delete_collector_rest_bad_request( 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_collector(request) @@ -8333,6 +8372,7 @@ def test_delete_collector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_collector(request) # Establish that the response is the type that we expect. @@ -8374,6 +8414,7 @@ def test_delete_collector_rest_interceptors(null_interceptor): 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 @@ -8418,6 +8459,7 @@ def test_resume_collector_rest_bad_request( 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.resume_collector(request) @@ -8448,6 +8490,7 @@ def test_resume_collector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.resume_collector(request) # Establish that the response is the type that we expect. @@ -8489,6 +8532,7 @@ def test_resume_collector_rest_interceptors(null_interceptor): 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 @@ -8533,6 +8577,7 @@ def test_register_collector_rest_bad_request( 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.register_collector(request) @@ -8563,6 +8608,7 @@ def test_register_collector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.register_collector(request) # Establish that the response is the type that we expect. @@ -8604,6 +8650,7 @@ def test_register_collector_rest_interceptors(null_interceptor): 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 @@ -8648,6 +8695,7 @@ def test_pause_collector_rest_bad_request( 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.pause_collector(request) @@ -8678,6 +8726,7 @@ def test_pause_collector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.pause_collector(request) # Establish that the response is the type that we expect. @@ -8719,6 +8768,7 @@ def test_pause_collector_rest_interceptors(null_interceptor): 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 @@ -8763,6 +8813,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -8793,6 +8844,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -8821,6 +8873,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -8851,6 +8904,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -8881,6 +8935,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -8911,6 +8966,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -8941,6 +8997,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -8971,6 +9028,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -9001,6 +9059,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9031,6 +9090,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -9061,6 +9121,7 @@ def test_list_operations_rest_bad_request( 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) @@ -9091,6 +9152,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py index c93583c25687..484effa463cd 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RecaptchaEnterpriseServiceTransport from .transports.grpc_asyncio import RecaptchaEnterpriseServiceGrpcAsyncIOTransport +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 RecaptchaEnterpriseServiceAsyncClient: """Service to determine the likelihood an event is legitimate.""" @@ -297,6 +307,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "credentialsType": None, + }, + ) + async def create_assessment( self, request: Optional[ @@ -307,7 +339,7 @@ async def create_assessment( assessment: Optional[recaptchaenterprise.Assessment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Assessment: r"""Creates an Assessment of the likelihood an event is legitimate. @@ -358,8 +390,10 @@ async def sample_create_assessment(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Assessment: @@ -427,7 +461,7 @@ async def annotate_assessment( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.AnnotateAssessmentResponse: r"""Annotates a previously created Assessment to provide additional information on whether the event turned out @@ -483,8 +517,10 @@ async def sample_annotate_assessment(): 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, 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: google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentResponse: @@ -548,7 +584,7 @@ async def create_key( key: Optional[recaptchaenterprise.Key] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Creates a new reCAPTCHA Enterprise key. @@ -603,8 +639,10 @@ async def sample_create_key(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -668,7 +706,7 @@ async def list_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListKeysAsyncPager: r"""Returns the list of all keys that belong to a project. @@ -713,8 +751,10 @@ async def sample_list_keys(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListKeysAsyncPager: @@ -791,7 +831,7 @@ async def retrieve_legacy_secret_key( key: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.RetrieveLegacySecretKeyResponse: r"""Returns the secret key related to the specified public key. You must use the legacy secret key only in a @@ -838,8 +878,10 @@ async def sample_retrieve_legacy_secret_key(): 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, 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: google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse: @@ -901,7 +943,7 @@ async def get_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Returns the specified key. @@ -944,8 +986,10 @@ async def sample_get_key(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1006,7 +1050,7 @@ async def update_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Updates the specified key. @@ -1060,8 +1104,10 @@ async def sample_update_key(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1125,7 +1171,7 @@ async def delete_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified key. @@ -1165,8 +1211,10 @@ async def sample_delete_key(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1217,7 +1265,7 @@ async def migrate_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from @@ -1259,8 +1307,10 @@ async def sample_migrate_key(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1309,7 +1359,7 @@ async def add_ip_override( ip_override_data: Optional[recaptchaenterprise.IpOverrideData] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.AddIpOverrideResponse: r"""Adds an IP override to a key. The following restrictions hold: @@ -1369,8 +1419,10 @@ async def sample_add_ip_override(): 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, 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: google.cloud.recaptchaenterprise_v1.types.AddIpOverrideResponse: @@ -1434,7 +1486,7 @@ async def remove_ip_override( ip_override_data: Optional[recaptchaenterprise.IpOverrideData] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.RemoveIpOverrideResponse: r"""Removes an IP override from a key. The following restrictions hold: @@ -1497,8 +1549,10 @@ async def sample_remove_ip_override(): 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, 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: google.cloud.recaptchaenterprise_v1.types.RemoveIpOverrideResponse: @@ -1561,7 +1615,7 @@ async def list_ip_overrides( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIpOverridesAsyncPager: r"""Lists all IP overrides for a key. @@ -1605,8 +1659,10 @@ async def sample_list_ip_overrides(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListIpOverridesAsyncPager: @@ -1681,7 +1737,7 @@ async def get_metrics( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Metrics: r"""Get some aggregated metrics for a Key. This data can be used to build dashboards. @@ -1725,8 +1781,10 @@ async def sample_get_metrics(): 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, 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: google.cloud.recaptchaenterprise_v1.types.Metrics: @@ -1788,7 +1846,7 @@ async def create_firewall_policy( firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed. A @@ -1841,8 +1899,10 @@ async def sample_create_firewall_policy(): 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, 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -1908,7 +1968,7 @@ async def list_firewall_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirewallPoliciesAsyncPager: r"""Returns the list of all firewall policies that belong to a project. @@ -1954,8 +2014,10 @@ async def sample_list_firewall_policies(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesAsyncPager: @@ -2032,7 +2094,7 @@ async def get_firewall_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Returns the specified firewall policy. @@ -2077,8 +2139,10 @@ async def sample_get_firewall_policy(): 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, 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -2143,7 +2207,7 @@ async def update_firewall_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Updates the specified firewall policy. @@ -2193,8 +2257,10 @@ async def sample_update_firewall_policy(): 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, 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -2262,7 +2328,7 @@ async def delete_firewall_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified firewall policy. @@ -2304,8 +2370,10 @@ async def sample_delete_firewall_policy(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2360,7 +2428,7 @@ async def reorder_firewall_policies( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.ReorderFirewallPoliciesResponse: r"""Reorders all firewall policies. @@ -2413,8 +2481,10 @@ async def sample_reorder_firewall_policies(): 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, 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: google.cloud.recaptchaenterprise_v1.types.ReorderFirewallPoliciesResponse: @@ -2479,7 +2549,7 @@ async def list_related_account_groups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRelatedAccountGroupsAsyncPager: r"""List groups of related accounts. @@ -2525,8 +2595,10 @@ async def sample_list_related_account_groups(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupsAsyncPager: @@ -2602,7 +2674,7 @@ async def list_related_account_group_memberships( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRelatedAccountGroupMembershipsAsyncPager: r"""Get memberships in a group of related accounts. @@ -2648,8 +2720,10 @@ async def sample_list_related_account_group_memberships(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupMembershipsAsyncPager: @@ -2731,7 +2805,7 @@ async def search_related_account_group_memberships( hashed_account_id: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchRelatedAccountGroupMembershipsAsyncPager: r"""Search group memberships related to a given account. @@ -2789,8 +2863,10 @@ async def sample_search_related_account_group_memberships(): 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, 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.SearchRelatedAccountGroupMembershipsAsyncPager: diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py index 8bc83a54de8e..7dac0be6025a 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -682,6 +692,10 @@ def __init__( # 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( @@ -748,6 +762,29 @@ def __init__( 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.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient`.", + extra={ + "serviceName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "credentialsType": None, + }, + ) + def create_assessment( self, request: Optional[ @@ -758,7 +795,7 @@ def create_assessment( assessment: Optional[recaptchaenterprise.Assessment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Assessment: r"""Creates an Assessment of the likelihood an event is legitimate. @@ -809,8 +846,10 @@ def sample_create_assessment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Assessment: @@ -875,7 +914,7 @@ def annotate_assessment( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.AnnotateAssessmentResponse: r"""Annotates a previously created Assessment to provide additional information on whether the event turned out @@ -931,8 +970,10 @@ def sample_annotate_assessment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentResponse: @@ -993,7 +1034,7 @@ def create_key( key: Optional[recaptchaenterprise.Key] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Creates a new reCAPTCHA Enterprise key. @@ -1048,8 +1089,10 @@ def sample_create_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1110,7 +1153,7 @@ def list_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListKeysPager: r"""Returns the list of all keys that belong to a project. @@ -1155,8 +1198,10 @@ def sample_list_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListKeysPager: @@ -1230,7 +1275,7 @@ def retrieve_legacy_secret_key( key: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.RetrieveLegacySecretKeyResponse: r"""Returns the secret key related to the specified public key. You must use the legacy secret key only in a @@ -1277,8 +1322,10 @@ def sample_retrieve_legacy_secret_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse: @@ -1339,7 +1386,7 @@ def get_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Returns the specified key. @@ -1382,8 +1429,10 @@ def sample_get_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1443,7 +1492,7 @@ def update_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Updates the specified key. @@ -1497,8 +1546,10 @@ def sample_update_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1559,7 +1610,7 @@ def delete_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified key. @@ -1599,8 +1650,10 @@ def sample_delete_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1648,7 +1701,7 @@ def migrate_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Key: r"""Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from @@ -1690,8 +1743,10 @@ def sample_migrate_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Key: @@ -1738,7 +1793,7 @@ def add_ip_override( ip_override_data: Optional[recaptchaenterprise.IpOverrideData] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.AddIpOverrideResponse: r"""Adds an IP override to a key. The following restrictions hold: @@ -1798,8 +1853,10 @@ def sample_add_ip_override(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.AddIpOverrideResponse: @@ -1860,7 +1917,7 @@ def remove_ip_override( ip_override_data: Optional[recaptchaenterprise.IpOverrideData] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.RemoveIpOverrideResponse: r"""Removes an IP override from a key. The following restrictions hold: @@ -1923,8 +1980,10 @@ def sample_remove_ip_override(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.RemoveIpOverrideResponse: @@ -1984,7 +2043,7 @@ def list_ip_overrides( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListIpOverridesPager: r"""Lists all IP overrides for a key. @@ -2028,8 +2087,10 @@ def sample_list_ip_overrides(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListIpOverridesPager: @@ -2101,7 +2162,7 @@ def get_metrics( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.Metrics: r"""Get some aggregated metrics for a Key. This data can be used to build dashboards. @@ -2145,8 +2206,10 @@ def sample_get_metrics(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.Metrics: @@ -2205,7 +2268,7 @@ def create_firewall_policy( firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed. A @@ -2258,8 +2321,10 @@ def sample_create_firewall_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -2322,7 +2387,7 @@ def list_firewall_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirewallPoliciesPager: r"""Returns the list of all firewall policies that belong to a project. @@ -2368,8 +2433,10 @@ def sample_list_firewall_policies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesPager: @@ -2443,7 +2510,7 @@ def get_firewall_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Returns the specified firewall policy. @@ -2488,8 +2555,10 @@ def sample_get_firewall_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -2551,7 +2620,7 @@ def update_firewall_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.FirewallPolicy: r"""Updates the specified firewall policy. @@ -2601,8 +2670,10 @@ def sample_update_firewall_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.FirewallPolicy: @@ -2667,7 +2738,7 @@ def delete_firewall_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified firewall policy. @@ -2709,8 +2780,10 @@ def sample_delete_firewall_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2762,7 +2835,7 @@ def reorder_firewall_policies( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recaptchaenterprise.ReorderFirewallPoliciesResponse: r"""Reorders all firewall policies. @@ -2815,8 +2888,10 @@ def sample_reorder_firewall_policies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.types.ReorderFirewallPoliciesResponse: @@ -2880,7 +2955,7 @@ def list_related_account_groups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRelatedAccountGroupsPager: r"""List groups of related accounts. @@ -2926,8 +3001,10 @@ def sample_list_related_account_groups(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupsPager: @@ -3002,7 +3079,7 @@ def list_related_account_group_memberships( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRelatedAccountGroupMembershipsPager: r"""Get memberships in a group of related accounts. @@ -3048,8 +3125,10 @@ def sample_list_related_account_group_memberships(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupMembershipsPager: @@ -3130,7 +3209,7 @@ def search_related_account_group_memberships( hashed_account_id: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchRelatedAccountGroupMembershipsPager: r"""Search group memberships related to a given account. @@ -3188,8 +3267,10 @@ def sample_search_related_account_group_memberships(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.SearchRelatedAccountGroupMembershipsPager: diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py index f50c54e13244..b104fff8c458 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.ListKeysRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.ListKeysRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.ListIpOverridesRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.ListIpOverridesRequest(request) @@ -371,7 +379,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -385,8 +393,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.ListFirewallPoliciesRequest(request) @@ -447,7 +457,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -461,8 +471,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.ListFirewallPoliciesRequest(request) @@ -527,7 +539,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -541,8 +553,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.ListRelatedAccountGroupsRequest(request) @@ -603,7 +617,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -617,8 +631,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.ListRelatedAccountGroupsRequest(request) @@ -685,7 +701,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -699,8 +715,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.ListRelatedAccountGroupMembershipsRequest( @@ -766,7 +784,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -780,8 +798,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.ListRelatedAccountGroupMembershipsRequest( @@ -852,7 +872,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -866,8 +886,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recaptchaenterprise.SearchRelatedAccountGroupMembershipsRequest( @@ -933,7 +955,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -947,8 +969,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recaptchaenterprise.SearchRelatedAccountGroupMembershipsRequest( diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py index 687afe06080c..89ac2b80f323 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.recaptchaenterprise_v1.types import recaptchaenterprise from .base import DEFAULT_CLIENT_INFO, RecaptchaEnterpriseServiceTransport +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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "rpcName": 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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecaptchaEnterpriseServiceGrpcTransport(RecaptchaEnterpriseServiceTransport): """gRPC backend transport for RecaptchaEnterpriseService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def create_assessment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_assessment" not in self._stubs: - self._stubs["create_assessment"] = self.grpc_channel.unary_unary( + self._stubs["create_assessment"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateAssessment", request_serializer=recaptchaenterprise.CreateAssessmentRequest.serialize, response_deserializer=recaptchaenterprise.Assessment.deserialize, @@ -288,7 +374,7 @@ def annotate_assessment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_assessment" not in self._stubs: - self._stubs["annotate_assessment"] = self.grpc_channel.unary_unary( + self._stubs["annotate_assessment"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/AnnotateAssessment", request_serializer=recaptchaenterprise.AnnotateAssessmentRequest.serialize, response_deserializer=recaptchaenterprise.AnnotateAssessmentResponse.deserialize, @@ -314,7 +400,7 @@ def create_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key" not in self._stubs: - self._stubs["create_key"] = self.grpc_channel.unary_unary( + self._stubs["create_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateKey", request_serializer=recaptchaenterprise.CreateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -343,7 +429,7 @@ def list_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_keys" not in self._stubs: - self._stubs["list_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_keys"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListKeys", request_serializer=recaptchaenterprise.ListKeysRequest.serialize, response_deserializer=recaptchaenterprise.ListKeysResponse.deserialize, @@ -374,7 +460,9 @@ def retrieve_legacy_secret_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "retrieve_legacy_secret_key" not in self._stubs: - self._stubs["retrieve_legacy_secret_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "retrieve_legacy_secret_key" + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RetrieveLegacySecretKey", request_serializer=recaptchaenterprise.RetrieveLegacySecretKeyRequest.serialize, response_deserializer=recaptchaenterprise.RetrieveLegacySecretKeyResponse.deserialize, @@ -400,7 +488,7 @@ def get_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key" not in self._stubs: - self._stubs["get_key"] = self.grpc_channel.unary_unary( + self._stubs["get_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetKey", request_serializer=recaptchaenterprise.GetKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -426,7 +514,7 @@ def update_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key" not in self._stubs: - self._stubs["update_key"] = self.grpc_channel.unary_unary( + self._stubs["update_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateKey", request_serializer=recaptchaenterprise.UpdateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -452,7 +540,7 @@ def delete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key" not in self._stubs: - self._stubs["delete_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteKey", request_serializer=recaptchaenterprise.DeleteKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -484,7 +572,7 @@ def migrate_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "migrate_key" not in self._stubs: - self._stubs["migrate_key"] = self.grpc_channel.unary_unary( + self._stubs["migrate_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/MigrateKey", request_serializer=recaptchaenterprise.MigrateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -517,7 +605,7 @@ def add_ip_override( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_ip_override" not in self._stubs: - self._stubs["add_ip_override"] = self.grpc_channel.unary_unary( + self._stubs["add_ip_override"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/AddIpOverride", request_serializer=recaptchaenterprise.AddIpOverrideRequest.serialize, response_deserializer=recaptchaenterprise.AddIpOverrideResponse.deserialize, @@ -553,7 +641,7 @@ def remove_ip_override( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_ip_override" not in self._stubs: - self._stubs["remove_ip_override"] = self.grpc_channel.unary_unary( + self._stubs["remove_ip_override"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RemoveIpOverride", request_serializer=recaptchaenterprise.RemoveIpOverrideRequest.serialize, response_deserializer=recaptchaenterprise.RemoveIpOverrideResponse.deserialize, @@ -582,7 +670,7 @@ def list_ip_overrides( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ip_overrides" not in self._stubs: - self._stubs["list_ip_overrides"] = self.grpc_channel.unary_unary( + self._stubs["list_ip_overrides"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListIpOverrides", request_serializer=recaptchaenterprise.ListIpOverridesRequest.serialize, response_deserializer=recaptchaenterprise.ListIpOverridesResponse.deserialize, @@ -609,7 +697,7 @@ def get_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_metrics" not in self._stubs: - self._stubs["get_metrics"] = self.grpc_channel.unary_unary( + self._stubs["get_metrics"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetMetrics", request_serializer=recaptchaenterprise.GetMetricsRequest.serialize, response_deserializer=recaptchaenterprise.Metrics.deserialize, @@ -640,7 +728,7 @@ def create_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firewall_policy" not in self._stubs: - self._stubs["create_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy", request_serializer=recaptchaenterprise.CreateFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -670,7 +758,7 @@ def list_firewall_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firewall_policies" not in self._stubs: - self._stubs["list_firewall_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_firewall_policies"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies", request_serializer=recaptchaenterprise.ListFirewallPoliciesRequest.serialize, response_deserializer=recaptchaenterprise.ListFirewallPoliciesResponse.deserialize, @@ -699,7 +787,7 @@ def get_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_firewall_policy" not in self._stubs: - self._stubs["get_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy", request_serializer=recaptchaenterprise.GetFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -728,7 +816,7 @@ def update_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_firewall_policy" not in self._stubs: - self._stubs["update_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy", request_serializer=recaptchaenterprise.UpdateFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -754,7 +842,7 @@ def delete_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firewall_policy" not in self._stubs: - self._stubs["delete_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy", request_serializer=recaptchaenterprise.DeleteFirewallPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -783,7 +871,7 @@ def reorder_firewall_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reorder_firewall_policies" not in self._stubs: - self._stubs["reorder_firewall_policies"] = self.grpc_channel.unary_unary( + self._stubs["reorder_firewall_policies"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ReorderFirewallPolicies", request_serializer=recaptchaenterprise.ReorderFirewallPoliciesRequest.serialize, response_deserializer=recaptchaenterprise.ReorderFirewallPoliciesResponse.deserialize, @@ -812,7 +900,9 @@ def list_related_account_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_related_account_groups" not in self._stubs: - self._stubs["list_related_account_groups"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_related_account_groups" + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListRelatedAccountGroups", request_serializer=recaptchaenterprise.ListRelatedAccountGroupsRequest.serialize, response_deserializer=recaptchaenterprise.ListRelatedAccountGroupsResponse.deserialize, @@ -844,7 +934,7 @@ def list_related_account_group_memberships( if "list_related_account_group_memberships" not in self._stubs: self._stubs[ "list_related_account_group_memberships" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListRelatedAccountGroupMemberships", request_serializer=recaptchaenterprise.ListRelatedAccountGroupMembershipsRequest.serialize, response_deserializer=recaptchaenterprise.ListRelatedAccountGroupMembershipsResponse.deserialize, @@ -876,7 +966,7 @@ def search_related_account_group_memberships( if "search_related_account_group_memberships" not in self._stubs: self._stubs[ "search_related_account_group_memberships" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/SearchRelatedAccountGroupMemberships", request_serializer=recaptchaenterprise.SearchRelatedAccountGroupMembershipsRequest.serialize, response_deserializer=recaptchaenterprise.SearchRelatedAccountGroupMembershipsResponse.deserialize, @@ -884,7 +974,7 @@ def search_related_account_group_memberships( return self._stubs["search_related_account_group_memberships"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py index d1ca99fffd9b..237641de903c 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recaptchaenterprise_v1.types import recaptchaenterprise from .base import DEFAULT_CLIENT_INFO, RecaptchaEnterpriseServiceTransport from .grpc import RecaptchaEnterpriseServiceGrpcTransport +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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "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.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecaptchaEnterpriseServiceGrpcAsyncIOTransport( RecaptchaEnterpriseServiceTransport @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def create_assessment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_assessment" not in self._stubs: - self._stubs["create_assessment"] = self.grpc_channel.unary_unary( + self._stubs["create_assessment"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateAssessment", request_serializer=recaptchaenterprise.CreateAssessmentRequest.serialize, response_deserializer=recaptchaenterprise.Assessment.deserialize, @@ -299,7 +384,7 @@ def annotate_assessment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "annotate_assessment" not in self._stubs: - self._stubs["annotate_assessment"] = self.grpc_channel.unary_unary( + self._stubs["annotate_assessment"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/AnnotateAssessment", request_serializer=recaptchaenterprise.AnnotateAssessmentRequest.serialize, response_deserializer=recaptchaenterprise.AnnotateAssessmentResponse.deserialize, @@ -327,7 +412,7 @@ def create_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key" not in self._stubs: - self._stubs["create_key"] = self.grpc_channel.unary_unary( + self._stubs["create_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateKey", request_serializer=recaptchaenterprise.CreateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -357,7 +442,7 @@ def list_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_keys" not in self._stubs: - self._stubs["list_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_keys"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListKeys", request_serializer=recaptchaenterprise.ListKeysRequest.serialize, response_deserializer=recaptchaenterprise.ListKeysResponse.deserialize, @@ -388,7 +473,9 @@ def retrieve_legacy_secret_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "retrieve_legacy_secret_key" not in self._stubs: - self._stubs["retrieve_legacy_secret_key"] = self.grpc_channel.unary_unary( + self._stubs[ + "retrieve_legacy_secret_key" + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RetrieveLegacySecretKey", request_serializer=recaptchaenterprise.RetrieveLegacySecretKeyRequest.serialize, response_deserializer=recaptchaenterprise.RetrieveLegacySecretKeyResponse.deserialize, @@ -416,7 +503,7 @@ def get_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key" not in self._stubs: - self._stubs["get_key"] = self.grpc_channel.unary_unary( + self._stubs["get_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetKey", request_serializer=recaptchaenterprise.GetKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -444,7 +531,7 @@ def update_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key" not in self._stubs: - self._stubs["update_key"] = self.grpc_channel.unary_unary( + self._stubs["update_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateKey", request_serializer=recaptchaenterprise.UpdateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -470,7 +557,7 @@ def delete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key" not in self._stubs: - self._stubs["delete_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteKey", request_serializer=recaptchaenterprise.DeleteKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -504,7 +591,7 @@ def migrate_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "migrate_key" not in self._stubs: - self._stubs["migrate_key"] = self.grpc_channel.unary_unary( + self._stubs["migrate_key"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/MigrateKey", request_serializer=recaptchaenterprise.MigrateKeyRequest.serialize, response_deserializer=recaptchaenterprise.Key.deserialize, @@ -537,7 +624,7 @@ def add_ip_override( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "add_ip_override" not in self._stubs: - self._stubs["add_ip_override"] = self.grpc_channel.unary_unary( + self._stubs["add_ip_override"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/AddIpOverride", request_serializer=recaptchaenterprise.AddIpOverrideRequest.serialize, response_deserializer=recaptchaenterprise.AddIpOverrideResponse.deserialize, @@ -573,7 +660,7 @@ def remove_ip_override( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "remove_ip_override" not in self._stubs: - self._stubs["remove_ip_override"] = self.grpc_channel.unary_unary( + self._stubs["remove_ip_override"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RemoveIpOverride", request_serializer=recaptchaenterprise.RemoveIpOverrideRequest.serialize, response_deserializer=recaptchaenterprise.RemoveIpOverrideResponse.deserialize, @@ -602,7 +689,7 @@ def list_ip_overrides( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ip_overrides" not in self._stubs: - self._stubs["list_ip_overrides"] = self.grpc_channel.unary_unary( + self._stubs["list_ip_overrides"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListIpOverrides", request_serializer=recaptchaenterprise.ListIpOverridesRequest.serialize, response_deserializer=recaptchaenterprise.ListIpOverridesResponse.deserialize, @@ -631,7 +718,7 @@ def get_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_metrics" not in self._stubs: - self._stubs["get_metrics"] = self.grpc_channel.unary_unary( + self._stubs["get_metrics"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetMetrics", request_serializer=recaptchaenterprise.GetMetricsRequest.serialize, response_deserializer=recaptchaenterprise.Metrics.deserialize, @@ -662,7 +749,7 @@ def create_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firewall_policy" not in self._stubs: - self._stubs["create_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy", request_serializer=recaptchaenterprise.CreateFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -692,7 +779,7 @@ def list_firewall_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firewall_policies" not in self._stubs: - self._stubs["list_firewall_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_firewall_policies"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies", request_serializer=recaptchaenterprise.ListFirewallPoliciesRequest.serialize, response_deserializer=recaptchaenterprise.ListFirewallPoliciesResponse.deserialize, @@ -721,7 +808,7 @@ def get_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_firewall_policy" not in self._stubs: - self._stubs["get_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy", request_serializer=recaptchaenterprise.GetFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -750,7 +837,7 @@ def update_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_firewall_policy" not in self._stubs: - self._stubs["update_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy", request_serializer=recaptchaenterprise.UpdateFirewallPolicyRequest.serialize, response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, @@ -778,7 +865,7 @@ def delete_firewall_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firewall_policy" not in self._stubs: - self._stubs["delete_firewall_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_firewall_policy"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy", request_serializer=recaptchaenterprise.DeleteFirewallPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -807,7 +894,7 @@ def reorder_firewall_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reorder_firewall_policies" not in self._stubs: - self._stubs["reorder_firewall_policies"] = self.grpc_channel.unary_unary( + self._stubs["reorder_firewall_policies"] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ReorderFirewallPolicies", request_serializer=recaptchaenterprise.ReorderFirewallPoliciesRequest.serialize, response_deserializer=recaptchaenterprise.ReorderFirewallPoliciesResponse.deserialize, @@ -836,7 +923,9 @@ def list_related_account_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_related_account_groups" not in self._stubs: - self._stubs["list_related_account_groups"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_related_account_groups" + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListRelatedAccountGroups", request_serializer=recaptchaenterprise.ListRelatedAccountGroupsRequest.serialize, response_deserializer=recaptchaenterprise.ListRelatedAccountGroupsResponse.deserialize, @@ -868,7 +957,7 @@ def list_related_account_group_memberships( if "list_related_account_group_memberships" not in self._stubs: self._stubs[ "list_related_account_group_memberships" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListRelatedAccountGroupMemberships", request_serializer=recaptchaenterprise.ListRelatedAccountGroupMembershipsRequest.serialize, response_deserializer=recaptchaenterprise.ListRelatedAccountGroupMembershipsResponse.deserialize, @@ -900,7 +989,7 @@ def search_related_account_group_memberships( if "search_related_account_group_memberships" not in self._stubs: self._stubs[ "search_related_account_group_memberships" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/SearchRelatedAccountGroupMemberships", request_serializer=recaptchaenterprise.SearchRelatedAccountGroupMembershipsRequest.serialize, response_deserializer=recaptchaenterprise.SearchRelatedAccountGroupMembershipsResponse.deserialize, @@ -1028,7 +1117,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json index 0d14f8e6deb6..78c7a5f19cbb 100644 --- a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.AddIpOverrideResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.AddIpOverrideResponse", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentResponse", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentResponse", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Assessment", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Assessment", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -727,7 +727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_firewall_policy" @@ -969,7 +969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_firewall_policy" @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_key" @@ -1124,7 +1124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_key" @@ -1202,7 +1202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -1282,7 +1282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -1363,7 +1363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -1443,7 +1443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -1524,7 +1524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", @@ -1604,7 +1604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", @@ -1685,7 +1685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesAsyncPager", @@ -1765,7 +1765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesPager", @@ -1846,7 +1846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListIpOverridesAsyncPager", @@ -1926,7 +1926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListIpOverridesPager", @@ -2007,7 +2007,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListKeysAsyncPager", @@ -2087,7 +2087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListKeysPager", @@ -2168,7 +2168,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupMembershipsAsyncPager", @@ -2248,7 +2248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupMembershipsPager", @@ -2329,7 +2329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupsAsyncPager", @@ -2409,7 +2409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListRelatedAccountGroupsPager", @@ -2486,7 +2486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -2562,7 +2562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -2647,7 +2647,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.RemoveIpOverrideResponse", @@ -2731,7 +2731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.RemoveIpOverrideResponse", @@ -2816,7 +2816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.ReorderFirewallPoliciesResponse", @@ -2900,7 +2900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.ReorderFirewallPoliciesResponse", @@ -2981,7 +2981,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse", @@ -3061,7 +3061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.SearchRelatedAccountGroupMembershipsAsyncPager", @@ -3230,7 +3230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.SearchRelatedAccountGroupMembershipsPager", @@ -3315,7 +3315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -3399,7 +3399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", @@ -3484,7 +3484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", @@ -3568,7 +3568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine/gapic_version.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine/gapic_version.py index e9c1f8ae6685..558c8aab67c5 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine/gapic_version.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/gapic_version.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/gapic_version.py index e9c1f8ae6685..558c8aab67c5 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/gapic_version.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py index f6b05b6cebb8..fe2f58ad1287 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .transports.grpc_asyncio import CatalogServiceGrpcAsyncIOTransport +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 CatalogServiceAsyncClient: """Service for ingesting catalog information of the customer's @@ -269,6 +279,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "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.recommendationengine.v1beta1.CatalogService", + "credentialsType": None, + }, + ) + async def create_catalog_item( self, request: Optional[Union[catalog_service.CreateCatalogItemRequest, dict]] = None, @@ -277,7 +309,7 @@ async def create_catalog_item( catalog_item: Optional[catalog.CatalogItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Creates a catalog item. @@ -332,8 +364,10 @@ async def sample_create_catalog_item(): 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, 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -396,7 +430,7 @@ async def get_catalog_item( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Gets a specific catalog item. @@ -440,8 +474,10 @@ async def sample_get_catalog_item(): 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, 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -503,7 +539,7 @@ async def list_catalog_items( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogItemsAsyncPager: r"""Gets a list of catalog items. @@ -555,8 +591,10 @@ async def sample_list_catalog_items(): 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, 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: google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsAsyncPager: @@ -635,7 +673,7 @@ async def update_catalog_item( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Updates a catalog item. Partial updating is supported. Non-existing items will be created. @@ -701,8 +739,10 @@ async def sample_update_catalog_item(): 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, 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -767,7 +807,7 @@ async def delete_catalog_item( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a catalog item. @@ -808,8 +848,10 @@ async def sample_delete_catalog_item(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -864,7 +906,7 @@ async def import_catalog_items( errors_config: Optional[import_.ImportErrorsConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of multiple catalog items. Request processing may be synchronous. No partial updating @@ -944,8 +986,10 @@ async def sample_import_catalog_items(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py index 6421ed94b14c..07a6ee428d57 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import field_mask_pb2 # type: ignore @@ -613,6 +623,10 @@ def __init__( # 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( @@ -678,6 +692,29 @@ def __init__( 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.recommendationengine_v1beta1.CatalogServiceClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "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.recommendationengine.v1beta1.CatalogService", + "credentialsType": None, + }, + ) + def create_catalog_item( self, request: Optional[Union[catalog_service.CreateCatalogItemRequest, dict]] = None, @@ -686,7 +723,7 @@ def create_catalog_item( catalog_item: Optional[catalog.CatalogItem] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Creates a catalog item. @@ -741,8 +778,10 @@ def sample_create_catalog_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -802,7 +841,7 @@ def get_catalog_item( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Gets a specific catalog item. @@ -846,8 +885,10 @@ def sample_get_catalog_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -906,7 +947,7 @@ def list_catalog_items( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogItemsPager: r"""Gets a list of catalog items. @@ -958,8 +999,10 @@ def sample_list_catalog_items(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsPager: @@ -1035,7 +1078,7 @@ def update_catalog_item( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Updates a catalog item. Partial updating is supported. Non-existing items will be created. @@ -1101,8 +1144,10 @@ def sample_update_catalog_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.types.CatalogItem: @@ -1164,7 +1209,7 @@ def delete_catalog_item( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a catalog item. @@ -1205,8 +1250,10 @@ def sample_delete_catalog_item(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1258,7 +1305,7 @@ def import_catalog_items( errors_config: Optional[import_.ImportErrorsConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of multiple catalog items. Request processing may be synchronous. No partial updating @@ -1338,8 +1385,10 @@ def sample_import_catalog_items(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/pagers.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/pagers.py index a3be7e9af1eb..f90864597491 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/pagers.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = catalog_service.ListCatalogItemsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = catalog_service.ListCatalogItemsRequest(request) diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py index d4f5db092aad..ce65d5605d34 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import ( catalog, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport +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.recommendationengine.v1beta1.CatalogService", + "rpcName": 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.recommendationengine.v1beta1.CatalogService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcTransport(CatalogServiceTransport): """gRPC backend transport for CatalogService. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def create_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog_item" not in self._stubs: - self._stubs["create_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/CreateCatalogItem", request_serializer=catalog_service.CreateCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -301,7 +389,7 @@ def get_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog_item" not in self._stubs: - self._stubs["get_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/GetCatalogItem", request_serializer=catalog_service.GetCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -330,7 +418,7 @@ def list_catalog_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalog_items" not in self._stubs: - self._stubs["list_catalog_items"] = self.grpc_channel.unary_unary( + self._stubs["list_catalog_items"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/ListCatalogItems", request_serializer=catalog_service.ListCatalogItemsRequest.serialize, response_deserializer=catalog_service.ListCatalogItemsResponse.deserialize, @@ -357,7 +445,7 @@ def update_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog_item" not in self._stubs: - self._stubs["update_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/UpdateCatalogItem", request_serializer=catalog_service.UpdateCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -383,7 +471,7 @@ def delete_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog_item" not in self._stubs: - self._stubs["delete_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/DeleteCatalogItem", request_serializer=catalog_service.DeleteCatalogItemRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +503,7 @@ def import_catalog_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_catalog_items" not in self._stubs: - self._stubs["import_catalog_items"] = self.grpc_channel.unary_unary( + self._stubs["import_catalog_items"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/ImportCatalogItems", request_serializer=import_.ImportCatalogItemsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +511,7 @@ def import_catalog_items( return self._stubs["import_catalog_items"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py index 851088c51b64..0bc9444ebe83 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import ( catalog, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, CatalogServiceTransport from .grpc import CatalogServiceGrpcTransport +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.recommendationengine.v1beta1.CatalogService", + "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.recommendationengine.v1beta1.CatalogService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CatalogServiceGrpcAsyncIOTransport(CatalogServiceTransport): """gRPC AsyncIO backend transport for CatalogService. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog_item" not in self._stubs: - self._stubs["create_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/CreateCatalogItem", request_serializer=catalog_service.CreateCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -315,7 +400,7 @@ def get_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog_item" not in self._stubs: - self._stubs["get_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/GetCatalogItem", request_serializer=catalog_service.GetCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -344,7 +429,7 @@ def list_catalog_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalog_items" not in self._stubs: - self._stubs["list_catalog_items"] = self.grpc_channel.unary_unary( + self._stubs["list_catalog_items"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/ListCatalogItems", request_serializer=catalog_service.ListCatalogItemsRequest.serialize, response_deserializer=catalog_service.ListCatalogItemsResponse.deserialize, @@ -373,7 +458,7 @@ def update_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_catalog_item" not in self._stubs: - self._stubs["update_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["update_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/UpdateCatalogItem", request_serializer=catalog_service.UpdateCatalogItemRequest.serialize, response_deserializer=catalog.CatalogItem.deserialize, @@ -401,7 +486,7 @@ def delete_catalog_item( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog_item" not in self._stubs: - self._stubs["delete_catalog_item"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog_item"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/DeleteCatalogItem", request_serializer=catalog_service.DeleteCatalogItemRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -435,7 +520,7 @@ def import_catalog_items( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_catalog_items" not in self._stubs: - self._stubs["import_catalog_items"] = self.grpc_channel.unary_unary( + self._stubs["import_catalog_items"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.CatalogService/ImportCatalogItems", request_serializer=import_.ImportCatalogItemsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +628,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/rest.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/rest.py index 4378227f9804..9acbdce0a671 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/rest.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -43,6 +43,14 @@ 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, @@ -119,8 +127,11 @@ def post_update_catalog_item(self, response): def pre_create_catalog_item( self, request: catalog_service.CreateCatalogItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.CreateCatalogItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.CreateCatalogItemRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_catalog_item Override in a subclass to manipulate the request or metadata @@ -142,8 +153,11 @@ def post_create_catalog_item( def pre_delete_catalog_item( self, request: catalog_service.DeleteCatalogItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.DeleteCatalogItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.DeleteCatalogItemRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_catalog_item Override in a subclass to manipulate the request or metadata @@ -154,8 +168,10 @@ def pre_delete_catalog_item( def pre_get_catalog_item( self, request: catalog_service.GetCatalogItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.GetCatalogItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.GetCatalogItemRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_catalog_item Override in a subclass to manipulate the request or metadata @@ -177,8 +193,10 @@ def post_get_catalog_item( def pre_import_catalog_items( self, request: import_.ImportCatalogItemsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_.ImportCatalogItemsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_.ImportCatalogItemsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_catalog_items Override in a subclass to manipulate the request or metadata @@ -200,8 +218,10 @@ def post_import_catalog_items( def pre_list_catalog_items( self, request: catalog_service.ListCatalogItemsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.ListCatalogItemsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.ListCatalogItemsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_catalog_items Override in a subclass to manipulate the request or metadata @@ -223,8 +243,11 @@ def post_list_catalog_items( def pre_update_catalog_item( self, request: catalog_service.UpdateCatalogItemRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[catalog_service.UpdateCatalogItemRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + catalog_service.UpdateCatalogItemRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_catalog_item Override in a subclass to manipulate the request or metadata @@ -415,7 +438,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Call the create catalog item method over HTTP. @@ -426,8 +449,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CatalogItem: @@ -439,6 +464,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseCreateCatalogItem._get_http_options() ) + request, metadata = self._interceptor.pre_create_catalog_item( request, metadata ) @@ -455,6 +481,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.CreateCatalogItem", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "CreateCatalogItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._CreateCatalogItem._get_response( self._host, @@ -476,7 +529,29 @@ def __call__( pb_resp = catalog.CatalogItem.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_catalog_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CatalogItem.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.recommendationengine_v1beta1.CatalogServiceClient.create_catalog_item", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "CreateCatalogItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCatalogItem( @@ -513,7 +588,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete catalog item method over HTTP. @@ -524,13 +599,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCatalogServiceRestTransport._BaseDeleteCatalogItem._get_http_options() ) + request, metadata = self._interceptor.pre_delete_catalog_item( request, metadata ) @@ -543,6 +621,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.DeleteCatalogItem", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "DeleteCatalogItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._DeleteCatalogItem._get_response( self._host, @@ -592,7 +697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Call the get catalog item method over HTTP. @@ -603,8 +708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CatalogItem: @@ -616,6 +723,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseGetCatalogItem._get_http_options() ) + request, metadata = self._interceptor.pre_get_catalog_item( request, metadata ) @@ -628,6 +736,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.GetCatalogItem", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "GetCatalogItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._GetCatalogItem._get_response( self._host, @@ -648,7 +783,29 @@ def __call__( pb_resp = catalog.CatalogItem.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_catalog_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CatalogItem.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.recommendationengine_v1beta1.CatalogServiceClient.get_catalog_item", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "GetCatalogItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportCatalogItems( @@ -686,7 +843,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import catalog items method over HTTP. @@ -696,8 +853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -710,6 +869,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseImportCatalogItems._get_http_options() ) + request, metadata = self._interceptor.pre_import_catalog_items( request, metadata ) @@ -726,6 +886,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.ImportCatalogItems", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "ImportCatalogItems", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ImportCatalogItems._get_response( self._host, @@ -745,7 +932,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_catalog_items(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.recommendationengine_v1beta1.CatalogServiceClient.import_catalog_items", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "ImportCatalogItems", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogItems( @@ -782,7 +991,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog_service.ListCatalogItemsResponse: r"""Call the list catalog items method over HTTP. @@ -793,8 +1002,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog_service.ListCatalogItemsResponse: @@ -806,6 +1017,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseListCatalogItems._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalog_items( request, metadata ) @@ -818,6 +1030,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.ListCatalogItems", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "ListCatalogItems", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._ListCatalogItems._get_response( self._host, @@ -838,7 +1077,31 @@ def __call__( pb_resp = catalog_service.ListCatalogItemsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalog_items(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog_service.ListCatalogItemsResponse.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.recommendationengine_v1beta1.CatalogServiceClient.list_catalog_items", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "ListCatalogItems", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCatalogItem( @@ -876,7 +1139,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> catalog.CatalogItem: r"""Call the update catalog item method over HTTP. @@ -887,8 +1150,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.catalog.CatalogItem: @@ -900,6 +1165,7 @@ def __call__( http_options = ( _BaseCatalogServiceRestTransport._BaseUpdateCatalogItem._get_http_options() ) + request, metadata = self._interceptor.pre_update_catalog_item( request, metadata ) @@ -916,6 +1182,33 @@ def __call__( 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.recommendationengine_v1beta1.CatalogServiceClient.UpdateCatalogItem", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "UpdateCatalogItem", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CatalogServiceRestTransport._UpdateCatalogItem._get_response( self._host, @@ -937,7 +1230,29 @@ def __call__( pb_resp = catalog.CatalogItem.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_catalog_item(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = catalog.CatalogItem.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.recommendationengine_v1beta1.CatalogServiceClient.update_catalog_item", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.CatalogService", + "rpcName": "UpdateCatalogItem", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py index b8da065eece4..b5e1f694483c 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionApiKeyRegistryTransport from .transports.grpc_asyncio import PredictionApiKeyRegistryGrpcAsyncIOTransport +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 PredictionApiKeyRegistryAsyncClient: """Service for registering API keys for use with the ``predict`` @@ -282,6 +292,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "credentialsType": None, + }, + ) + async def create_prediction_api_key_registration( self, request: Optional[ @@ -297,7 +329,7 @@ async def create_prediction_api_key_registration( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_apikey_registry_service.PredictionApiKeyRegistration: r"""Register an API key for use with predict method. @@ -348,8 +380,10 @@ async def sample_create_prediction_api_key_registration(): 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, 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: google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration: @@ -420,7 +454,7 @@ async def list_prediction_api_key_registrations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPredictionApiKeyRegistrationsAsyncPager: r"""List the registered apiKeys for use with predict method. @@ -466,8 +500,10 @@ async def sample_list_prediction_api_key_registrations(): 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, 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: google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsAsyncPager: @@ -552,7 +588,7 @@ async def delete_prediction_api_key_registration( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Unregister an apiKey from using for predict method. @@ -594,8 +630,10 @@ async def sample_delete_prediction_api_key_registration(): 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, 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py index 0042b9bbdfba..036d80331e7d 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry import ( pagers, ) @@ -624,6 +634,10 @@ def __init__( # 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( @@ -690,6 +704,29 @@ def __init__( 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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "credentialsType": None, + }, + ) + def create_prediction_api_key_registration( self, request: Optional[ @@ -705,7 +742,7 @@ def create_prediction_api_key_registration( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_apikey_registry_service.PredictionApiKeyRegistration: r"""Register an API key for use with predict method. @@ -756,8 +793,10 @@ def sample_create_prediction_api_key_registration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration: @@ -829,7 +868,7 @@ def list_prediction_api_key_registrations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPredictionApiKeyRegistrationsPager: r"""List the registered apiKeys for use with predict method. @@ -875,8 +914,10 @@ def sample_list_prediction_api_key_registrations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsPager: @@ -960,7 +1001,7 @@ def delete_prediction_api_key_registration( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Unregister an apiKey from using for predict method. @@ -1002,8 +1043,10 @@ def sample_delete_prediction_api_key_registration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py index 5d99b48c5633..b58bd3229c09 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py @@ -72,7 +72,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -86,8 +86,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = ( @@ -161,7 +163,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -175,8 +177,10 @@ def __init__( 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, 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`. """ self._method = method self._request = ( diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py index a122ae8c72e0..e29895a2a2c1 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import ( prediction_apikey_registry_service, @@ -29,6 +35,81 @@ from .base import DEFAULT_CLIENT_INFO, PredictionApiKeyRegistryTransport +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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": 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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionApiKeyRegistryGrpcTransport(PredictionApiKeyRegistryTransport): """gRPC backend transport for PredictionApiKeyRegistry. @@ -187,7 +268,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +353,7 @@ def create_prediction_api_key_registration( if "create_prediction_api_key_registration" not in self._stubs: self._stubs[ "create_prediction_api_key_registration" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/CreatePredictionApiKeyRegistration", request_serializer=prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest.serialize, response_deserializer=prediction_apikey_registry_service.PredictionApiKeyRegistration.deserialize, @@ -300,7 +386,7 @@ def list_prediction_api_key_registrations( if "list_prediction_api_key_registrations" not in self._stubs: self._stubs[ "list_prediction_api_key_registrations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/ListPredictionApiKeyRegistrations", request_serializer=prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest.serialize, response_deserializer=prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse.deserialize, @@ -332,7 +418,7 @@ def delete_prediction_api_key_registration( if "delete_prediction_api_key_registration" not in self._stubs: self._stubs[ "delete_prediction_api_key_registration" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/DeletePredictionApiKeyRegistration", request_serializer=prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -340,7 +426,7 @@ def delete_prediction_api_key_registration( return self._stubs["delete_prediction_api_key_registration"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py index d1c124c847f3..fc87754ef147 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import ( prediction_apikey_registry_service, @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, PredictionApiKeyRegistryTransport from .grpc import PredictionApiKeyRegistryGrpcTransport +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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "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.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionApiKeyRegistryGrpcAsyncIOTransport(PredictionApiKeyRegistryTransport): """gRPC AsyncIO backend transport for PredictionApiKeyRegistry. @@ -234,10 +316,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -275,7 +360,7 @@ def create_prediction_api_key_registration( if "create_prediction_api_key_registration" not in self._stubs: self._stubs[ "create_prediction_api_key_registration" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/CreatePredictionApiKeyRegistration", request_serializer=prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest.serialize, response_deserializer=prediction_apikey_registry_service.PredictionApiKeyRegistration.deserialize, @@ -310,7 +395,7 @@ def list_prediction_api_key_registrations( if "list_prediction_api_key_registrations" not in self._stubs: self._stubs[ "list_prediction_api_key_registrations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/ListPredictionApiKeyRegistrations", request_serializer=prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest.serialize, response_deserializer=prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse.deserialize, @@ -342,7 +427,7 @@ def delete_prediction_api_key_registration( if "delete_prediction_api_key_registration" not in self._stubs: self._stubs[ "delete_prediction_api_key_registration" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry/DeletePredictionApiKeyRegistration", request_serializer=prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -405,7 +490,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/rest.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/rest.py index bc9c34970b52..2258b1f82b3a 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/rest.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -92,10 +100,10 @@ def post_list_prediction_api_key_registrations(self, response): def pre_create_prediction_api_key_registration( self, request: prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_prediction_api_key_registration @@ -118,10 +126,10 @@ def post_create_prediction_api_key_registration( def pre_delete_prediction_api_key_registration( self, request: prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_prediction_api_key_registration @@ -133,10 +141,10 @@ def pre_delete_prediction_api_key_registration( def pre_list_prediction_api_key_registrations( self, request: prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_prediction_api_key_registrations @@ -287,7 +295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_apikey_registry_service.PredictionApiKeyRegistration: r"""Call the create prediction api key registration method over HTTP. @@ -299,8 +307,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_apikey_registry_service.PredictionApiKeyRegistration: @@ -310,6 +320,7 @@ def __call__( http_options = ( _BasePredictionApiKeyRegistryRestTransport._BaseCreatePredictionApiKeyRegistration._get_http_options() ) + ( request, metadata, @@ -329,6 +340,33 @@ def __call__( 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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.CreatePredictionApiKeyRegistration", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": "CreatePredictionApiKeyRegistration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionApiKeyRegistryRestTransport._CreatePredictionApiKeyRegistration._get_response( self._host, @@ -352,7 +390,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_prediction_api_key_registration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_apikey_registry_service.PredictionApiKeyRegistration.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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.create_prediction_api_key_registration", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": "CreatePredictionApiKeyRegistration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePredictionApiKeyRegistration( @@ -392,7 +454,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete prediction api key registration method over HTTP. @@ -404,13 +466,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BasePredictionApiKeyRegistryRestTransport._BaseDeletePredictionApiKeyRegistration._get_http_options() ) + ( request, metadata, @@ -426,6 +491,33 @@ def __call__( 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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.DeletePredictionApiKeyRegistration", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": "DeletePredictionApiKeyRegistration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionApiKeyRegistryRestTransport._DeletePredictionApiKeyRegistration._get_response( self._host, @@ -478,7 +570,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ( prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse ): @@ -492,8 +584,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse: @@ -505,6 +599,7 @@ def __call__( http_options = ( _BasePredictionApiKeyRegistryRestTransport._BaseListPredictionApiKeyRegistrations._get_http_options() ) + ( request, metadata, @@ -520,6 +615,33 @@ def __call__( 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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrations", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": "ListPredictionApiKeyRegistrations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionApiKeyRegistryRestTransport._ListPredictionApiKeyRegistrations._get_response( self._host, @@ -544,7 +666,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_prediction_api_key_registrations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse.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.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.list_prediction_api_key_registrations", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", + "rpcName": "ListPredictionApiKeyRegistrations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py index 3c0ea1a7de50..5324a0f324df 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """Service for making recommendation prediction.""" @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommendationengine_v1beta1.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionService", + "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.recommendationengine.v1beta1.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -267,7 +299,7 @@ async def predict( user_event: Optional[gcr_user_event.UserEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.PredictAsyncPager: r"""Makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the @@ -367,8 +399,10 @@ async def sample_predict(): 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, 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: google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictAsyncPager: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py index 09195e8b3adf..3156b065fbe6 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.recommendationengine_v1beta1.services.prediction_service import pagers from google.cloud.recommendationengine_v1beta1.types import user_event as gcr_user_event from google.cloud.recommendationengine_v1beta1.types import prediction_service @@ -587,6 +597,10 @@ def __init__( # 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( @@ -653,6 +667,29 @@ def __init__( 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.recommendationengine_v1beta1.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionService", + "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.recommendationengine.v1beta1.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -661,7 +698,7 @@ def predict( user_event: Optional[gcr_user_event.UserEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.PredictPager: r"""Makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the @@ -761,8 +798,10 @@ def sample_predict(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictPager: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py index 02faf4a3e2ba..cc69a48ec5f8 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = prediction_service.PredictRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = prediction_service.PredictRequest(request) diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py index 47c3244ef842..2b03a7d2353d 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.recommendationengine_v1beta1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.recommendationengine.v1beta1.PredictionService", + "rpcName": 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.recommendationengine.v1beta1.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -179,7 +260,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +345,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -267,7 +353,7 @@ def predict( return self._stubs["predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py index cf292e2009f3..0a766dff6572 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.recommendationengine.v1beta1.PredictionService", + "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.recommendationengine.v1beta1.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -226,10 +308,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -268,7 +353,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -301,7 +386,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/rest.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/rest.py index c558589bb0e1..bd23c1b1b54c 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -77,8 +85,10 @@ def post_predict(self, response): def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -219,7 +229,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -229,8 +239,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.prediction_service.PredictResponse: @@ -240,6 +252,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -258,6 +271,33 @@ def __call__( ) ) + 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.recommendationengine_v1beta1.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -279,7 +319,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.recommendationengine_v1beta1.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py index c618593aaac8..bdd58ca28207 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .transports.grpc_asyncio import UserEventServiceGrpcAsyncIOTransport +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 UserEventServiceAsyncClient: """Service for ingesting end user actions on the customer @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "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.recommendationengine.v1beta1.UserEventService", + "credentialsType": None, + }, + ) + async def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, @@ -275,7 +307,7 @@ async def write_user_event( user_event: Optional[gcr_user_event.UserEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_user_event.UserEvent: r"""Writes a single user event. @@ -329,8 +361,10 @@ async def sample_write_user_event(): 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, 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: google.cloud.recommendationengine_v1beta1.types.UserEvent: @@ -400,7 +434,7 @@ async def collect_user_event( ets: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -481,8 +515,10 @@ async def sample_collect_user_event(): 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, 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: google.api.httpbody_pb2.HttpBody: @@ -594,7 +630,7 @@ async def list_user_events( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUserEventsAsyncPager: r"""Gets a list of user events within a time range, with potential filtering. @@ -681,8 +717,10 @@ async def sample_list_user_events(): 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, 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: google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsAsyncPager: @@ -763,7 +801,7 @@ async def purge_user_events( force: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -851,8 +889,10 @@ async def sample_purge_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -931,7 +971,7 @@ async def import_user_events( errors_config: Optional[import_.ImportErrorsConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. @@ -1012,8 +1052,10 @@ async def sample_import_user_events(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py index 9c1bc8193293..3b8ec2844e8d 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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 import httpbody_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -593,6 +603,10 @@ def __init__( # 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( @@ -659,6 +673,29 @@ def __init__( 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.recommendationengine_v1beta1.UserEventServiceClient`.", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "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.recommendationengine.v1beta1.UserEventService", + "credentialsType": None, + }, + ) + def write_user_event( self, request: Optional[Union[user_event_service.WriteUserEventRequest, dict]] = None, @@ -667,7 +704,7 @@ def write_user_event( user_event: Optional[gcr_user_event.UserEvent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_user_event.UserEvent: r"""Writes a single user event. @@ -721,8 +758,10 @@ def sample_write_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.types.UserEvent: @@ -789,7 +828,7 @@ def collect_user_event( ets: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Writes a single user event from the browser. This uses a GET request to due to browser restriction of @@ -870,8 +909,10 @@ def sample_collect_user_event(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api.httpbody_pb2.HttpBody: @@ -980,7 +1021,7 @@ def list_user_events( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUserEventsPager: r"""Gets a list of user events within a time range, with potential filtering. @@ -1067,8 +1108,10 @@ def sample_list_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsPager: @@ -1146,7 +1189,7 @@ def purge_user_events( force: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes permanently all user events specified by the filter provided. Depending on the number of events @@ -1234,8 +1277,10 @@ def sample_purge_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1311,7 +1356,7 @@ def import_user_events( errors_config: Optional[import_.ImportErrorsConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. @@ -1392,8 +1437,10 @@ def sample_import_user_events(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/pagers.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/pagers.py index ece5e17a1a5f..0f29ea52e5f9 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/pagers.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/pagers.py @@ -70,7 +70,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -84,8 +84,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = user_event_service.ListUserEventsRequest(request) @@ -144,7 +146,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -158,8 +160,10 @@ def __init__( 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, 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`. """ self._method = method self._request = user_event_service.ListUserEventsRequest(request) diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py index bfe5cfd85a3c..d7255532ef36 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import user_event as gcr_user_event from google.cloud.recommendationengine_v1beta1.types import import_ @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport +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.recommendationengine.v1beta1.UserEventService", + "rpcName": 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.recommendationengine.v1beta1.UserEventService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcTransport(UserEventServiceTransport): """gRPC backend transport for UserEventService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=gcr_user_event.UserEvent.deserialize, @@ -305,7 +393,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -335,7 +423,7 @@ def list_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_events" not in self._stubs: - self._stubs["list_user_events"] = self.grpc_channel.unary_unary( + self._stubs["list_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/ListUserEvents", request_serializer=user_event_service.ListUserEventsRequest.serialize, response_deserializer=user_event_service.ListUserEventsResponse.deserialize, @@ -367,7 +455,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/PurgeUserEvents", request_serializer=user_event_service.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -400,7 +488,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/ImportUserEvents", request_serializer=import_.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def import_user_events( return self._stubs["import_user_events"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py index c0277db65ecd..83b3d2a9b004 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommendationengine_v1beta1.types import user_event as gcr_user_event from google.cloud.recommendationengine_v1beta1.types import import_ @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, UserEventServiceTransport from .grpc import UserEventServiceGrpcTransport +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.recommendationengine.v1beta1.UserEventService", + "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.recommendationengine.v1beta1.UserEventService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class UserEventServiceGrpcAsyncIOTransport(UserEventServiceTransport): """gRPC AsyncIO backend transport for UserEventService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def write_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "write_user_event" not in self._stubs: - self._stubs["write_user_event"] = self.grpc_channel.unary_unary( + self._stubs["write_user_event"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/WriteUserEvent", request_serializer=user_event_service.WriteUserEventRequest.serialize, response_deserializer=gcr_user_event.UserEvent.deserialize, @@ -319,7 +404,7 @@ def collect_user_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "collect_user_event" not in self._stubs: - self._stubs["collect_user_event"] = self.grpc_channel.unary_unary( + self._stubs["collect_user_event"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/CollectUserEvent", request_serializer=user_event_service.CollectUserEventRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -349,7 +434,7 @@ def list_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_events" not in self._stubs: - self._stubs["list_user_events"] = self.grpc_channel.unary_unary( + self._stubs["list_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/ListUserEvents", request_serializer=user_event_service.ListUserEventsRequest.serialize, response_deserializer=user_event_service.ListUserEventsResponse.deserialize, @@ -381,7 +466,7 @@ def purge_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_user_events" not in self._stubs: - self._stubs["purge_user_events"] = self.grpc_channel.unary_unary( + self._stubs["purge_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/PurgeUserEvents", request_serializer=user_event_service.PurgeUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +501,7 @@ def import_user_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_user_events" not in self._stubs: - self._stubs["import_user_events"] = self.grpc_channel.unary_unary( + self._stubs["import_user_events"] = self._logged_channel.unary_unary( "/google.cloud.recommendationengine.v1beta1.UserEventService/ImportUserEvents", request_serializer=import_.ImportUserEventsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -509,7 +594,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/rest.py b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/rest.py index e060f959e61b..2808d40aa592 100644 --- a/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/rest.py +++ b/packages/google-cloud-recommendations-ai/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ 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, @@ -113,8 +121,11 @@ def post_write_user_event(self, response): def pre_collect_user_event( self, request: user_event_service.CollectUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.CollectUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.CollectUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for collect_user_event Override in a subclass to manipulate the request or metadata @@ -136,8 +147,10 @@ def post_collect_user_event( def pre_import_user_events( self, request: import_.ImportUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[import_.ImportUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + import_.ImportUserEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_user_events Override in a subclass to manipulate the request or metadata @@ -159,8 +172,11 @@ def post_import_user_events( def pre_list_user_events( self, request: user_event_service.ListUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.ListUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.ListUserEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_user_events Override in a subclass to manipulate the request or metadata @@ -182,8 +198,11 @@ def post_list_user_events( def pre_purge_user_events( self, request: user_event_service.PurgeUserEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.PurgeUserEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.PurgeUserEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for purge_user_events Override in a subclass to manipulate the request or metadata @@ -205,8 +224,11 @@ def post_purge_user_events( def pre_write_user_event( self, request: user_event_service.WriteUserEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[user_event_service.WriteUserEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + user_event_service.WriteUserEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for write_user_event Override in a subclass to manipulate the request or metadata @@ -397,7 +419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the collect user event method over HTTP. @@ -408,8 +430,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.httpbody_pb2.HttpBody: @@ -468,6 +492,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseCollectUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_collect_user_event( request, metadata ) @@ -480,6 +505,33 @@ def __call__( 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.recommendationengine_v1beta1.UserEventServiceClient.CollectUserEvent", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "CollectUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._CollectUserEvent._get_response( self._host, @@ -500,7 +552,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_collect_user_event(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.recommendationengine_v1beta1.UserEventServiceClient.collect_user_event", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "CollectUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportUserEvents( @@ -539,7 +613,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import user events method over HTTP. @@ -550,8 +624,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -564,6 +640,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseImportUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_import_user_events( request, metadata ) @@ -580,6 +657,33 @@ def __call__( 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.recommendationengine_v1beta1.UserEventServiceClient.ImportUserEvents", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "ImportUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ImportUserEvents._get_response( self._host, @@ -599,7 +703,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_user_events(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.recommendationengine_v1beta1.UserEventServiceClient.import_user_events", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "ImportUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUserEvents( @@ -636,7 +762,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_event_service.ListUserEventsResponse: r"""Call the list user events method over HTTP. @@ -647,8 +773,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.user_event_service.ListUserEventsResponse: @@ -660,6 +788,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseListUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_user_events( request, metadata ) @@ -672,6 +801,33 @@ def __call__( 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.recommendationengine_v1beta1.UserEventServiceClient.ListUserEvents", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "ListUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._ListUserEvents._get_response( self._host, @@ -692,7 +848,31 @@ def __call__( pb_resp = user_event_service.ListUserEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_user_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + user_event_service.ListUserEventsResponse.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.recommendationengine_v1beta1.UserEventServiceClient.list_user_events", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "ListUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeUserEvents( @@ -731,7 +911,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the purge user events method over HTTP. @@ -742,8 +922,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -756,6 +938,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BasePurgeUserEvents._get_http_options() ) + request, metadata = self._interceptor.pre_purge_user_events( request, metadata ) @@ -772,6 +955,33 @@ def __call__( 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.recommendationengine_v1beta1.UserEventServiceClient.PurgeUserEvents", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "PurgeUserEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._PurgeUserEvents._get_response( self._host, @@ -791,7 +1001,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_user_events(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.recommendationengine_v1beta1.UserEventServiceClient.purge_user_events", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "PurgeUserEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _WriteUserEvent( @@ -829,7 +1061,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_user_event.UserEvent: r"""Call the write user event method over HTTP. @@ -840,8 +1072,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_user_event.UserEvent: @@ -855,6 +1089,7 @@ def __call__( http_options = ( _BaseUserEventServiceRestTransport._BaseWriteUserEvent._get_http_options() ) + request, metadata = self._interceptor.pre_write_user_event( request, metadata ) @@ -871,6 +1106,33 @@ def __call__( 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.recommendationengine_v1beta1.UserEventServiceClient.WriteUserEvent", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "WriteUserEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserEventServiceRestTransport._WriteUserEvent._get_response( self._host, @@ -892,7 +1154,29 @@ def __call__( pb_resp = gcr_user_event.UserEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_write_user_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_user_event.UserEvent.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.recommendationengine_v1beta1.UserEventServiceClient.write_user_event", + extra={ + "serviceName": "google.cloud.recommendationengine.v1beta1.UserEventService", + "rpcName": "WriteUserEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommendations-ai/samples/generated_samples/snippet_metadata_google.cloud.recommendationengine.v1beta1.json b/packages/google-cloud-recommendations-ai/samples/generated_samples/snippet_metadata_google.cloud.recommendationengine.v1beta1.json index 966c861303ab..d22dc88c7d5b 100644 --- a/packages/google-cloud-recommendations-ai/samples/generated_samples/snippet_metadata_google.cloud.recommendationengine.v1beta1.json +++ b/packages/google-cloud-recommendations-ai/samples/generated_samples/snippet_metadata_google.cloud.recommendationengine.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-recommendations-ai", - "version": "0.10.14" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_catalog_item" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_catalog_item" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -544,7 +544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -636,7 +636,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -721,7 +721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsAsyncPager", @@ -805,7 +805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsPager", @@ -894,7 +894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -982,7 +982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", @@ -1067,7 +1067,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration", @@ -1151,7 +1151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration", @@ -1232,7 +1232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_prediction_api_key_registration" @@ -1309,7 +1309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_prediction_api_key_registration" @@ -1387,7 +1387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsAsyncPager", @@ -1467,7 +1467,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsPager", @@ -1552,7 +1552,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictAsyncPager", @@ -1636,7 +1636,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictPager", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -1821,7 +1821,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2006,7 +2006,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2091,7 +2091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsAsyncPager", @@ -2175,7 +2175,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsPager", @@ -2264,7 +2264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2352,7 +2352,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2437,7 +2437,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.UserEvent", @@ -2521,7 +2521,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommendationengine_v1beta1.types.UserEvent", diff --git a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py index d072b6a8c97a..40a8e8d24f93 100644 --- a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py +++ b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py @@ -3561,6 +3561,7 @@ def test_create_catalog_item_rest_required_fields( response_value._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_catalog_item(request) @@ -3617,6 +3618,7 @@ def test_create_catalog_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog_item(**mock_args) @@ -3751,6 +3753,7 @@ def test_get_catalog_item_rest_required_fields( response_value._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_catalog_item(request) @@ -3798,6 +3801,7 @@ def test_get_catalog_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog_item(**mock_args) @@ -3941,6 +3945,7 @@ def test_list_catalog_items_rest_required_fields( response_value._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_catalog_items(request) @@ -3998,6 +4003,7 @@ def test_list_catalog_items_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog_items(**mock_args) @@ -4202,6 +4208,7 @@ def test_update_catalog_item_rest_required_fields( response_value._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_catalog_item(request) @@ -4259,6 +4266,7 @@ def test_update_catalog_item_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_catalog_item(**mock_args) @@ -4393,6 +4401,7 @@ def test_delete_catalog_item_rest_required_fields( response_value._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_catalog_item(request) @@ -4438,6 +4447,7 @@ def test_delete_catalog_item_rest_flattened(): 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"} client.delete_catalog_item(**mock_args) @@ -4575,6 +4585,7 @@ def test_import_catalog_items_rest_required_fields( response_value._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.import_catalog_items(request) @@ -4635,6 +4646,7 @@ def test_import_catalog_items_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_catalog_items(**mock_args) @@ -5136,6 +5148,7 @@ def test_create_catalog_item_rest_bad_request( 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_catalog_item(request) @@ -5265,6 +5278,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog_item(request) # Establish that the response is the type that we expect. @@ -5310,6 +5324,7 @@ def test_create_catalog_item_rest_interceptors(null_interceptor): 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 = catalog.CatalogItem.to_json(catalog.CatalogItem()) req.return_value.content = return_value @@ -5356,6 +5371,7 @@ def test_get_catalog_item_rest_bad_request( 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_catalog_item(request) @@ -5398,6 +5414,7 @@ def test_get_catalog_item_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog_item(request) # Establish that the response is the type that we expect. @@ -5443,6 +5460,7 @@ def test_get_catalog_item_rest_interceptors(null_interceptor): 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 = catalog.CatalogItem.to_json(catalog.CatalogItem()) req.return_value.content = return_value @@ -5487,6 +5505,7 @@ def test_list_catalog_items_rest_bad_request( 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_catalog_items(request) @@ -5522,6 +5541,7 @@ def test_list_catalog_items_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog_items(request) # Establish that the response is the type that we expect. @@ -5562,6 +5582,7 @@ def test_list_catalog_items_rest_interceptors(null_interceptor): 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 = catalog_service.ListCatalogItemsResponse.to_json( catalog_service.ListCatalogItemsResponse() ) @@ -5610,6 +5631,7 @@ def test_update_catalog_item_rest_bad_request( 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_catalog_item(request) @@ -5741,6 +5763,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_catalog_item(request) # Establish that the response is the type that we expect. @@ -5786,6 +5809,7 @@ def test_update_catalog_item_rest_interceptors(null_interceptor): 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 = catalog.CatalogItem.to_json(catalog.CatalogItem()) req.return_value.content = return_value @@ -5832,6 +5856,7 @@ def test_delete_catalog_item_rest_bad_request( 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_catalog_item(request) @@ -5864,6 +5889,7 @@ def test_delete_catalog_item_rest_call_success(request_type): 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_catalog_item(request) # Establish that the response is the type that we expect. @@ -5900,6 +5926,7 @@ def test_delete_catalog_item_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = catalog_service.DeleteCatalogItemRequest() metadata = [ @@ -5940,6 +5967,7 @@ def test_import_catalog_items_rest_bad_request( 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.import_catalog_items(request) @@ -5970,6 +5998,7 @@ def test_import_catalog_items_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_catalog_items(request) # Establish that the response is the type that we expect. @@ -6011,6 +6040,7 @@ def test_import_catalog_items_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py index ee3edf7e85fb..e417cbeb6e91 100644 --- a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py +++ b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py @@ -2557,6 +2557,7 @@ def test_create_prediction_api_key_registration_rest_required_fields( response_value._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_prediction_api_key_registration(request) @@ -2621,6 +2622,7 @@ def test_create_prediction_api_key_registration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_prediction_api_key_registration(**mock_args) @@ -2777,6 +2779,7 @@ def test_list_prediction_api_key_registrations_rest_required_fields( response_value._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_prediction_api_key_registrations(request) @@ -2838,6 +2841,7 @@ def test_list_prediction_api_key_registrations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_prediction_api_key_registrations(**mock_args) @@ -3052,6 +3056,7 @@ def test_delete_prediction_api_key_registration_rest_required_fields( response_value._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_prediction_api_key_registration(request) @@ -3099,6 +3104,7 @@ def test_delete_prediction_api_key_registration_rest_flattened(): 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"} client.delete_prediction_api_key_registration(**mock_args) @@ -3448,6 +3454,7 @@ def test_create_prediction_api_key_registration_rest_bad_request( 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_prediction_api_key_registration(request) @@ -3489,6 +3496,7 @@ def test_create_prediction_api_key_registration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_prediction_api_key_registration(request) # Establish that the response is the type that we expect. @@ -3533,6 +3541,7 @@ def test_create_prediction_api_key_registration_rest_interceptors(null_intercept 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 = ( prediction_apikey_registry_service.PredictionApiKeyRegistration.to_json( prediction_apikey_registry_service.PredictionApiKeyRegistration() @@ -3587,6 +3596,7 @@ def test_list_prediction_api_key_registrations_rest_bad_request( 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_prediction_api_key_registrations(request) @@ -3626,6 +3636,7 @@ def test_list_prediction_api_key_registrations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_prediction_api_key_registrations(request) # Establish that the response is the type that we expect. @@ -3668,6 +3679,7 @@ def test_list_prediction_api_key_registrations_rest_interceptors(null_intercepto 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 = prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse.to_json( prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse() ) @@ -3720,6 +3732,7 @@ def test_delete_prediction_api_key_registration_rest_bad_request( 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_prediction_api_key_registration(request) @@ -3752,6 +3765,7 @@ def test_delete_prediction_api_key_registration_rest_call_success(request_type): 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_prediction_api_key_registration(request) # Establish that the response is the type that we expect. @@ -3789,6 +3803,7 @@ def test_delete_prediction_api_key_registration_rest_interceptors(null_intercept req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest() diff --git a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py index 32a0a73d3788..55224e7f9975 100644 --- a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py +++ b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py @@ -1753,6 +1753,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq response_value._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.predict(request) @@ -1809,6 +1810,7 @@ def test_predict_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.predict(**mock_args) @@ -2106,6 +2108,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -2146,6 +2149,7 @@ def test_predict_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.predict(request) # Establish that the response is the type that we expect. @@ -2189,6 +2193,7 @@ def test_predict_rest_interceptors(null_interceptor): 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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) diff --git a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py index 89c8229f81dd..c89712ecff86 100644 --- a/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py +++ b/packages/google-cloud-recommendations-ai/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py @@ -3232,6 +3232,7 @@ def test_write_user_event_rest_required_fields( response_value._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.write_user_event(request) @@ -3288,6 +3289,7 @@ def test_write_user_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.write_user_event(**mock_args) @@ -3437,6 +3439,7 @@ def test_collect_user_event_rest_required_fields( response_value._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.collect_user_event(request) @@ -3505,6 +3508,7 @@ def test_collect_user_event_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.collect_user_event(**mock_args) @@ -3649,6 +3653,7 @@ def test_list_user_events_rest_required_fields( response_value._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_user_events(request) @@ -3706,6 +3711,7 @@ def test_list_user_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_user_events(**mock_args) @@ -3911,6 +3917,7 @@ def test_purge_user_events_rest_required_fields( response_value._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.purge_user_events(request) @@ -3966,6 +3973,7 @@ def test_purge_user_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.purge_user_events(**mock_args) @@ -4105,6 +4113,7 @@ def test_import_user_events_rest_required_fields( response_value._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.import_user_events(request) @@ -4165,6 +4174,7 @@ def test_import_user_events_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_user_events(**mock_args) @@ -4601,6 +4611,7 @@ def test_write_user_event_rest_bad_request( 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.write_user_event(request) @@ -4753,6 +4764,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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.write_user_event(request) # Establish that the response is the type that we expect. @@ -4794,6 +4806,7 @@ def test_write_user_event_rest_interceptors(null_interceptor): 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 = gcr_user_event.UserEvent.to_json(gcr_user_event.UserEvent()) req.return_value.content = return_value @@ -4840,6 +4853,7 @@ def test_collect_user_event_rest_bad_request( 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.collect_user_event(request) @@ -4875,6 +4889,7 @@ def test_collect_user_event_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.collect_user_event(request) # Establish that the response is the type that we expect. @@ -4916,6 +4931,7 @@ def test_collect_user_event_rest_interceptors(null_interceptor): 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(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -4962,6 +4978,7 @@ def test_list_user_events_rest_bad_request( 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_user_events(request) @@ -4999,6 +5016,7 @@ def test_list_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_user_events(request) # Establish that the response is the type that we expect. @@ -5039,6 +5057,7 @@ def test_list_user_events_rest_interceptors(null_interceptor): 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 = user_event_service.ListUserEventsResponse.to_json( user_event_service.ListUserEventsResponse() ) @@ -5087,6 +5106,7 @@ def test_purge_user_events_rest_bad_request( 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.purge_user_events(request) @@ -5119,6 +5139,7 @@ def test_purge_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.purge_user_events(request) # Establish that the response is the type that we expect. @@ -5160,6 +5181,7 @@ def test_purge_user_events_rest_interceptors(null_interceptor): 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 @@ -5206,6 +5228,7 @@ def test_import_user_events_rest_bad_request( 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.import_user_events(request) @@ -5238,6 +5261,7 @@ def test_import_user_events_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_user_events(request) # Establish that the response is the type that we expect. @@ -5279,6 +5303,7 @@ def test_import_user_events_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-recommender/google/cloud/recommender/gapic_version.py b/packages/google-cloud-recommender/google/cloud/recommender/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender/gapic_version.py +++ b/packages/google-cloud-recommender/google/cloud/recommender/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/gapic_version.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/gapic_version.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/async_client.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/async_client.py index fde02c55493e..a402c8ffebcb 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/async_client.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RecommenderTransport from .transports.grpc_asyncio import RecommenderGrpcAsyncIOTransport +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 RecommenderAsyncClient: """Provides insights and recommendations for cloud customers for @@ -286,6 +296,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommender_v1.RecommenderAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "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.recommender.v1.Recommender", + "credentialsType": None, + }, + ) + async def list_insights( self, request: Optional[Union[recommender_service.ListInsightsRequest, dict]] = None, @@ -293,7 +325,7 @@ async def list_insights( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightsAsyncPager: r"""Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight @@ -354,8 +386,10 @@ async def sample_list_insights(): 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, 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: google.cloud.recommender_v1.services.recommender.pagers.ListInsightsAsyncPager: @@ -429,7 +463,7 @@ async def get_insight( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type. @@ -471,8 +505,10 @@ async def sample_get_insight(): 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, 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: google.cloud.recommender_v1.types.Insight: @@ -539,7 +575,7 @@ async def mark_insight_accepted( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some @@ -602,8 +638,10 @@ async def sample_mark_insight_accepted(): 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, 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: google.cloud.recommender_v1.types.Insight: @@ -674,7 +712,7 @@ async def list_recommendations( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendationsAsyncPager: r"""Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified @@ -767,8 +805,10 @@ async def sample_list_recommendations(): 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, 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: google.cloud.recommender_v1.services.recommender.pagers.ListRecommendationsAsyncPager: @@ -846,7 +886,7 @@ async def get_recommendation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender. @@ -888,8 +928,10 @@ async def sample_get_recommendation(): 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, 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: google.cloud.recommender_v1.types.Recommendation: @@ -953,7 +995,7 @@ async def mark_recommendation_dismissed( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE @@ -997,8 +1039,10 @@ async def sample_mark_recommendation_dismissed(): 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, 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: google.cloud.recommender_v1.types.Recommendation: @@ -1053,7 +1097,7 @@ async def mark_recommendation_claimed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting @@ -1122,8 +1166,10 @@ async def sample_mark_recommendation_claimed(): 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, 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: google.cloud.recommender_v1.types.Recommendation: @@ -1197,7 +1243,7 @@ async def mark_recommendation_succeeded( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied @@ -1266,8 +1312,10 @@ async def sample_mark_recommendation_succeeded(): 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, 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: google.cloud.recommender_v1.types.Recommendation: @@ -1341,7 +1389,7 @@ async def mark_recommendation_failed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied @@ -1410,8 +1458,10 @@ async def sample_mark_recommendation_failed(): 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, 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: google.cloud.recommender_v1.types.Recommendation: @@ -1481,7 +1531,7 @@ async def get_recommender_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Gets the requested Recommender Config. There is only one instance of the config for each Recommender. @@ -1534,8 +1584,10 @@ async def sample_get_recommender_config(): 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, 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: google.cloud.recommender_v1.types.RecommenderConfig: @@ -1597,7 +1649,7 @@ async def update_recommender_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Updates a Recommender Config. This will create a new revision of the config. @@ -1645,8 +1697,10 @@ async def sample_update_recommender_config(): 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, 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: google.cloud.recommender_v1.types.RecommenderConfig: @@ -1711,7 +1765,7 @@ async def get_insight_type_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType. @@ -1764,8 +1818,10 @@ async def sample_get_insight_type_config(): 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, 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: google.cloud.recommender_v1.types.InsightTypeConfig: @@ -1827,7 +1883,7 @@ async def update_insight_type_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Updates an InsightTypeConfig change. This will create a new revision of the config. @@ -1875,8 +1931,10 @@ async def sample_update_insight_type_config(): 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, 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: google.cloud.recommender_v1.types.InsightTypeConfig: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/client.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/client.py index 71b561dc213c..1a4a9226790d 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/client.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -712,6 +722,10 @@ def __init__( # 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( @@ -774,6 +788,29 @@ def __init__( 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.recommender_v1.RecommenderClient`.", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "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.recommender.v1.Recommender", + "credentialsType": None, + }, + ) + def list_insights( self, request: Optional[Union[recommender_service.ListInsightsRequest, dict]] = None, @@ -781,7 +818,7 @@ def list_insights( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightsPager: r"""Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight @@ -842,8 +879,10 @@ def sample_list_insights(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.recommender_v1.services.recommender.pagers.ListInsightsPager: @@ -914,7 +953,7 @@ def get_insight( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type. @@ -956,8 +995,10 @@ def sample_get_insight(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Insight: @@ -1021,7 +1062,7 @@ def mark_insight_accepted( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some @@ -1084,8 +1125,10 @@ def sample_mark_insight_accepted(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Insight: @@ -1152,7 +1195,7 @@ def list_recommendations( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendationsPager: r"""Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified @@ -1245,8 +1288,10 @@ def sample_list_recommendations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.services.recommender.pagers.ListRecommendationsPager: @@ -1321,7 +1366,7 @@ def get_recommendation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender. @@ -1363,8 +1408,10 @@ def sample_get_recommendation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Recommendation: @@ -1425,7 +1472,7 @@ def mark_recommendation_dismissed( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE @@ -1469,8 +1516,10 @@ def sample_mark_recommendation_dismissed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Recommendation: @@ -1525,7 +1574,7 @@ def mark_recommendation_claimed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting @@ -1594,8 +1643,10 @@ def sample_mark_recommendation_claimed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Recommendation: @@ -1667,7 +1718,7 @@ def mark_recommendation_succeeded( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied @@ -1736,8 +1787,10 @@ def sample_mark_recommendation_succeeded(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Recommendation: @@ -1809,7 +1862,7 @@ def mark_recommendation_failed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied @@ -1878,8 +1931,10 @@ def sample_mark_recommendation_failed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.Recommendation: @@ -1947,7 +2002,7 @@ def get_recommender_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Gets the requested Recommender Config. There is only one instance of the config for each Recommender. @@ -2000,8 +2055,10 @@ def sample_get_recommender_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.RecommenderConfig: @@ -2060,7 +2117,7 @@ def update_recommender_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Updates a Recommender Config. This will create a new revision of the config. @@ -2108,8 +2165,10 @@ def sample_update_recommender_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.RecommenderConfig: @@ -2173,7 +2232,7 @@ def get_insight_type_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType. @@ -2226,8 +2285,10 @@ def sample_get_insight_type_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.InsightTypeConfig: @@ -2286,7 +2347,7 @@ def update_insight_type_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Updates an InsightTypeConfig change. This will create a new revision of the config. @@ -2334,8 +2395,10 @@ def sample_update_insight_type_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1.types.InsightTypeConfig: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/pagers.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/pagers.py index f0fc915235d2..19361bd8e868 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/pagers.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListInsightsRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListInsightsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListRecommendationsRequest(request) @@ -299,7 +305,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -313,8 +319,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListRecommendationsRequest(request) diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc.py index eb2bd4abcb16..0368879c10c9 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,7 +23,10 @@ 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.recommender_v1.types import ( insight_type_config as gcr_insight_type_config, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, RecommenderTransport +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.recommender.v1.Recommender", + "rpcName": 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.recommender.v1.Recommender", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecommenderGrpcTransport(RecommenderTransport): """gRPC backend transport for Recommender. @@ -193,7 +274,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +358,7 @@ def list_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insights" not in self._stubs: - self._stubs["list_insights"] = self.grpc_channel.unary_unary( + self._stubs["list_insights"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/ListInsights", request_serializer=recommender_service.ListInsightsRequest.serialize, response_deserializer=recommender_service.ListInsightsResponse.deserialize, @@ -299,7 +385,7 @@ def get_insight( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight" not in self._stubs: - self._stubs["get_insight"] = self.grpc_channel.unary_unary( + self._stubs["get_insight"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetInsight", request_serializer=recommender_service.GetInsightRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -332,7 +418,7 @@ def mark_insight_accepted( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_insight_accepted" not in self._stubs: - self._stubs["mark_insight_accepted"] = self.grpc_channel.unary_unary( + self._stubs["mark_insight_accepted"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkInsightAccepted", request_serializer=recommender_service.MarkInsightAcceptedRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -363,7 +449,7 @@ def list_recommendations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommendations" not in self._stubs: - self._stubs["list_recommendations"] = self.grpc_channel.unary_unary( + self._stubs["list_recommendations"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/ListRecommendations", request_serializer=recommender_service.ListRecommendationsRequest.serialize, response_deserializer=recommender_service.ListRecommendationsResponse.deserialize, @@ -392,7 +478,7 @@ def get_recommendation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommendation" not in self._stubs: - self._stubs["get_recommendation"] = self.grpc_channel.unary_unary( + self._stubs["get_recommendation"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetRecommendation", request_serializer=recommender_service.GetRecommendationRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -431,7 +517,7 @@ def mark_recommendation_dismissed( if "mark_recommendation_dismissed" not in self._stubs: self._stubs[ "mark_recommendation_dismissed" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationDismissed", request_serializer=recommender_service.MarkRecommendationDismissedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -470,7 +556,9 @@ def mark_recommendation_claimed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_claimed" not in self._stubs: - self._stubs["mark_recommendation_claimed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_claimed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationClaimed", request_serializer=recommender_service.MarkRecommendationClaimedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -511,7 +599,7 @@ def mark_recommendation_succeeded( if "mark_recommendation_succeeded" not in self._stubs: self._stubs[ "mark_recommendation_succeeded" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationSucceeded", request_serializer=recommender_service.MarkRecommendationSucceededRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -550,7 +638,9 @@ def mark_recommendation_failed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_failed" not in self._stubs: - self._stubs["mark_recommendation_failed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_failed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationFailed", request_serializer=recommender_service.MarkRecommendationFailedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -580,7 +670,7 @@ def get_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommender_config" not in self._stubs: - self._stubs["get_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["get_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetRecommenderConfig", request_serializer=recommender_service.GetRecommenderConfigRequest.serialize, response_deserializer=recommender_config.RecommenderConfig.deserialize, @@ -610,7 +700,7 @@ def update_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recommender_config" not in self._stubs: - self._stubs["update_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["update_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/UpdateRecommenderConfig", request_serializer=recommender_service.UpdateRecommenderConfigRequest.serialize, response_deserializer=gcr_recommender_config.RecommenderConfig.deserialize, @@ -640,7 +730,7 @@ def get_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight_type_config" not in self._stubs: - self._stubs["get_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs["get_insight_type_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetInsightTypeConfig", request_serializer=recommender_service.GetInsightTypeConfigRequest.serialize, response_deserializer=insight_type_config.InsightTypeConfig.deserialize, @@ -670,7 +760,9 @@ def update_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_insight_type_config" not in self._stubs: - self._stubs["update_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_insight_type_config" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/UpdateInsightTypeConfig", request_serializer=recommender_service.UpdateInsightTypeConfigRequest.serialize, response_deserializer=gcr_insight_type_config.InsightTypeConfig.deserialize, @@ -678,7 +770,7 @@ def update_insight_type_config( return self._stubs["update_insight_type_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc_asyncio.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc_asyncio.py index 413fbd3463c0..d8d212ba0f15 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,8 +25,11 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommender_v1.types import ( insight_type_config as gcr_insight_type_config, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, RecommenderTransport from .grpc import RecommenderGrpcTransport +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.recommender.v1.Recommender", + "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.recommender.v1.Recommender", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecommenderGrpcAsyncIOTransport(RecommenderTransport): """gRPC AsyncIO backend transport for Recommender. @@ -240,10 +322,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -280,7 +365,7 @@ def list_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insights" not in self._stubs: - self._stubs["list_insights"] = self.grpc_channel.unary_unary( + self._stubs["list_insights"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/ListInsights", request_serializer=recommender_service.ListInsightsRequest.serialize, response_deserializer=recommender_service.ListInsightsResponse.deserialize, @@ -307,7 +392,7 @@ def get_insight( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight" not in self._stubs: - self._stubs["get_insight"] = self.grpc_channel.unary_unary( + self._stubs["get_insight"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetInsight", request_serializer=recommender_service.GetInsightRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -342,7 +427,7 @@ def mark_insight_accepted( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_insight_accepted" not in self._stubs: - self._stubs["mark_insight_accepted"] = self.grpc_channel.unary_unary( + self._stubs["mark_insight_accepted"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkInsightAccepted", request_serializer=recommender_service.MarkInsightAcceptedRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -373,7 +458,7 @@ def list_recommendations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommendations" not in self._stubs: - self._stubs["list_recommendations"] = self.grpc_channel.unary_unary( + self._stubs["list_recommendations"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/ListRecommendations", request_serializer=recommender_service.ListRecommendationsRequest.serialize, response_deserializer=recommender_service.ListRecommendationsResponse.deserialize, @@ -403,7 +488,7 @@ def get_recommendation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommendation" not in self._stubs: - self._stubs["get_recommendation"] = self.grpc_channel.unary_unary( + self._stubs["get_recommendation"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetRecommendation", request_serializer=recommender_service.GetRecommendationRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -442,7 +527,7 @@ def mark_recommendation_dismissed( if "mark_recommendation_dismissed" not in self._stubs: self._stubs[ "mark_recommendation_dismissed" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationDismissed", request_serializer=recommender_service.MarkRecommendationDismissedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -481,7 +566,9 @@ def mark_recommendation_claimed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_claimed" not in self._stubs: - self._stubs["mark_recommendation_claimed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_claimed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationClaimed", request_serializer=recommender_service.MarkRecommendationClaimedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -522,7 +609,7 @@ def mark_recommendation_succeeded( if "mark_recommendation_succeeded" not in self._stubs: self._stubs[ "mark_recommendation_succeeded" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationSucceeded", request_serializer=recommender_service.MarkRecommendationSucceededRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -561,7 +648,9 @@ def mark_recommendation_failed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_failed" not in self._stubs: - self._stubs["mark_recommendation_failed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_failed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/MarkRecommendationFailed", request_serializer=recommender_service.MarkRecommendationFailedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -591,7 +680,7 @@ def get_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommender_config" not in self._stubs: - self._stubs["get_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["get_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetRecommenderConfig", request_serializer=recommender_service.GetRecommenderConfigRequest.serialize, response_deserializer=recommender_config.RecommenderConfig.deserialize, @@ -621,7 +710,7 @@ def update_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recommender_config" not in self._stubs: - self._stubs["update_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["update_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/UpdateRecommenderConfig", request_serializer=recommender_service.UpdateRecommenderConfigRequest.serialize, response_deserializer=gcr_recommender_config.RecommenderConfig.deserialize, @@ -651,7 +740,7 @@ def get_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight_type_config" not in self._stubs: - self._stubs["get_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs["get_insight_type_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/GetInsightTypeConfig", request_serializer=recommender_service.GetInsightTypeConfigRequest.serialize, response_deserializer=insight_type_config.InsightTypeConfig.deserialize, @@ -681,7 +770,9 @@ def update_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_insight_type_config" not in self._stubs: - self._stubs["update_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_insight_type_config" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1.Recommender/UpdateInsightTypeConfig", request_serializer=recommender_service.UpdateInsightTypeConfigRequest.serialize, response_deserializer=gcr_insight_type_config.InsightTypeConfig.deserialize, @@ -804,7 +895,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/rest.py b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/rest.py index d72350cbb6eb..25b3a7928786 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/rest.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1/services/recommender/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -47,6 +47,14 @@ 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, @@ -183,8 +191,10 @@ def post_update_recommender_config(self, response): def pre_get_insight( self, request: recommender_service.GetInsightRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.GetInsightRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.GetInsightRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_insight Override in a subclass to manipulate the request or metadata @@ -204,9 +214,10 @@ def post_get_insight(self, response: insight.Insight) -> insight.Insight: def pre_get_insight_type_config( self, request: recommender_service.GetInsightTypeConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.GetInsightTypeConfigRequest, Sequence[Tuple[str, str]] + recommender_service.GetInsightTypeConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_insight_type_config @@ -229,8 +240,11 @@ def post_get_insight_type_config( def pre_get_recommendation( self, request: recommender_service.GetRecommendationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.GetRecommendationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.GetRecommendationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_recommendation Override in a subclass to manipulate the request or metadata @@ -252,9 +266,10 @@ def post_get_recommendation( def pre_get_recommender_config( self, request: recommender_service.GetRecommenderConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.GetRecommenderConfigRequest, Sequence[Tuple[str, str]] + recommender_service.GetRecommenderConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_recommender_config @@ -277,8 +292,10 @@ def post_get_recommender_config( def pre_list_insights( self, request: recommender_service.ListInsightsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.ListInsightsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.ListInsightsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_insights Override in a subclass to manipulate the request or metadata @@ -300,9 +317,10 @@ def post_list_insights( def pre_list_recommendations( self, request: recommender_service.ListRecommendationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.ListRecommendationsRequest, Sequence[Tuple[str, str]] + recommender_service.ListRecommendationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_recommendations @@ -325,9 +343,10 @@ def post_list_recommendations( def pre_mark_insight_accepted( self, request: recommender_service.MarkInsightAcceptedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkInsightAcceptedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkInsightAcceptedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_insight_accepted @@ -348,9 +367,10 @@ def post_mark_insight_accepted(self, response: insight.Insight) -> insight.Insig def pre_mark_recommendation_claimed( self, request: recommender_service.MarkRecommendationClaimedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkRecommendationClaimedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkRecommendationClaimedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_claimed @@ -373,10 +393,10 @@ def post_mark_recommendation_claimed( def pre_mark_recommendation_dismissed( self, request: recommender_service.MarkRecommendationDismissedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ recommender_service.MarkRecommendationDismissedRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_dismissed @@ -399,9 +419,10 @@ def post_mark_recommendation_dismissed( def pre_mark_recommendation_failed( self, request: recommender_service.MarkRecommendationFailedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkRecommendationFailedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkRecommendationFailedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_failed @@ -424,10 +445,10 @@ def post_mark_recommendation_failed( def pre_mark_recommendation_succeeded( self, request: recommender_service.MarkRecommendationSucceededRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ recommender_service.MarkRecommendationSucceededRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_succeeded @@ -450,9 +471,10 @@ def post_mark_recommendation_succeeded( def pre_update_insight_type_config( self, request: recommender_service.UpdateInsightTypeConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.UpdateInsightTypeConfigRequest, Sequence[Tuple[str, str]] + recommender_service.UpdateInsightTypeConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_insight_type_config @@ -475,9 +497,10 @@ def post_update_insight_type_config( def pre_update_recommender_config( self, request: recommender_service.UpdateRecommenderConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.UpdateRecommenderConfigRequest, Sequence[Tuple[str, str]] + recommender_service.UpdateRecommenderConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_recommender_config @@ -622,7 +645,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Call the get insight method over HTTP. @@ -632,8 +655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight.Insight: @@ -647,6 +672,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetInsight._get_http_options() ) + request, metadata = self._interceptor.pre_get_insight(request, metadata) transcoded_request = ( _BaseRecommenderRestTransport._BaseGetInsight._get_transcoded_request( @@ -661,6 +687,33 @@ def __call__( ) ) + 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.recommender_v1.RecommenderClient.GetInsight", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetInsight", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetInsight._get_response( self._host, @@ -681,7 +734,29 @@ def __call__( pb_resp = insight.Insight.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_insight(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight.Insight.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.recommender_v1.RecommenderClient.get_insight", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetInsight", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInsightTypeConfig( @@ -718,7 +793,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Call the get insight type config method over HTTP. @@ -728,8 +803,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight_type_config.InsightTypeConfig: @@ -739,6 +816,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetInsightTypeConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_insight_type_config( request, metadata ) @@ -751,6 +829,33 @@ def __call__( 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.recommender_v1.RecommenderClient.GetInsightTypeConfig", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetInsightTypeConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetInsightTypeConfig._get_response( self._host, @@ -771,7 +876,31 @@ def __call__( pb_resp = insight_type_config.InsightTypeConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_insight_type_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight_type_config.InsightTypeConfig.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.recommender_v1.RecommenderClient.get_insight_type_config", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetInsightTypeConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecommendation( @@ -808,7 +937,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the get recommendation method over HTTP. @@ -818,8 +947,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -833,6 +964,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetRecommendation._get_http_options() ) + request, metadata = self._interceptor.pre_get_recommendation( request, metadata ) @@ -845,6 +977,33 @@ def __call__( 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.recommender_v1.RecommenderClient.GetRecommendation", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetRecommendation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetRecommendation._get_response( self._host, @@ -865,7 +1024,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recommendation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1.RecommenderClient.get_recommendation", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetRecommendation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecommenderConfig( @@ -902,7 +1083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Call the get recommender config method over HTTP. @@ -912,8 +1093,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_config.RecommenderConfig: @@ -923,6 +1106,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetRecommenderConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_recommender_config( request, metadata ) @@ -935,6 +1119,33 @@ def __call__( 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.recommender_v1.RecommenderClient.GetRecommenderConfig", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetRecommenderConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetRecommenderConfig._get_response( self._host, @@ -955,7 +1166,31 @@ def __call__( pb_resp = recommender_config.RecommenderConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recommender_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommender_config.RecommenderConfig.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.recommender_v1.RecommenderClient.get_recommender_config", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "GetRecommenderConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInsights( @@ -992,7 +1227,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListInsightsResponse: r"""Call the list insights method over HTTP. @@ -1002,8 +1237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListInsightsResponse: @@ -1013,6 +1250,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListInsights._get_http_options() ) + request, metadata = self._interceptor.pre_list_insights(request, metadata) transcoded_request = ( _BaseRecommenderRestTransport._BaseListInsights._get_transcoded_request( @@ -1027,6 +1265,33 @@ def __call__( ) ) + 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.recommender_v1.RecommenderClient.ListInsights", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "ListInsights", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListInsights._get_response( self._host, @@ -1047,7 +1312,31 @@ def __call__( pb_resp = recommender_service.ListInsightsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_insights(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommender_service.ListInsightsResponse.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.recommender_v1.RecommenderClient.list_insights", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "ListInsights", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecommendations( @@ -1084,7 +1373,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListRecommendationsResponse: r"""Call the list recommendations method over HTTP. @@ -1094,8 +1383,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListRecommendationsResponse: @@ -1105,6 +1396,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListRecommendations._get_http_options() ) + request, metadata = self._interceptor.pre_list_recommendations( request, metadata ) @@ -1117,6 +1409,33 @@ def __call__( 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.recommender_v1.RecommenderClient.ListRecommendations", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "ListRecommendations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListRecommendations._get_response( self._host, @@ -1137,7 +1456,33 @@ def __call__( pb_resp = recommender_service.ListRecommendationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recommendations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + recommender_service.ListRecommendationsResponse.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.recommender_v1.RecommenderClient.list_recommendations", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "ListRecommendations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkInsightAccepted( @@ -1175,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Call the mark insight accepted method over HTTP. @@ -1185,8 +1530,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight.Insight: @@ -1200,6 +1547,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkInsightAccepted._get_http_options() ) + request, metadata = self._interceptor.pre_mark_insight_accepted( request, metadata ) @@ -1216,6 +1564,33 @@ def __call__( 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.recommender_v1.RecommenderClient.MarkInsightAccepted", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkInsightAccepted", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._MarkInsightAccepted._get_response( self._host, @@ -1237,7 +1612,29 @@ def __call__( pb_resp = insight.Insight.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_insight_accepted(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight.Insight.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.recommender_v1.RecommenderClient.mark_insight_accepted", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkInsightAccepted", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationClaimed( @@ -1276,7 +1673,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation claimed method over HTTP. @@ -1287,8 +1684,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1302,6 +1701,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationClaimed._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_claimed( request, metadata ) @@ -1318,6 +1718,33 @@ def __call__( 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.recommender_v1.RecommenderClient.MarkRecommendationClaimed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationClaimed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RecommenderRestTransport._MarkRecommendationClaimed._get_response( @@ -1341,7 +1768,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_claimed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1.RecommenderClient.mark_recommendation_claimed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationClaimed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationDismissed( @@ -1380,7 +1829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation dismissed method over HTTP. @@ -1391,8 +1840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1406,6 +1857,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationDismissed._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_dismissed( request, metadata ) @@ -1422,6 +1874,33 @@ def __call__( 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.recommender_v1.RecommenderClient.MarkRecommendationDismissed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationDismissed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RecommenderRestTransport._MarkRecommendationDismissed._get_response( @@ -1445,7 +1924,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_dismissed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1.RecommenderClient.mark_recommendation_dismissed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationDismissed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationFailed( @@ -1483,7 +1984,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation failed method over HTTP. @@ -1494,8 +1995,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1509,6 +2012,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationFailed._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_failed( request, metadata ) @@ -1525,6 +2029,33 @@ def __call__( 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.recommender_v1.RecommenderClient.MarkRecommendationFailed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationFailed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._MarkRecommendationFailed._get_response( self._host, @@ -1546,7 +2077,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_failed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1.RecommenderClient.mark_recommendation_failed", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationFailed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationSucceeded( @@ -1585,7 +2138,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation succeeded method over HTTP. @@ -1596,8 +2149,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1611,6 +2166,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationSucceeded._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_succeeded( request, metadata ) @@ -1627,6 +2183,33 @@ def __call__( 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.recommender_v1.RecommenderClient.MarkRecommendationSucceeded", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationSucceeded", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RecommenderRestTransport._MarkRecommendationSucceeded._get_response( @@ -1650,7 +2233,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_succeeded(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1.RecommenderClient.mark_recommendation_succeeded", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "MarkRecommendationSucceeded", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInsightTypeConfig( @@ -1688,7 +2293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Call the update insight type config method over HTTP. @@ -1699,8 +2304,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_insight_type_config.InsightTypeConfig: @@ -1710,6 +2317,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseUpdateInsightTypeConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_insight_type_config( request, metadata ) @@ -1726,6 +2334,33 @@ def __call__( 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.recommender_v1.RecommenderClient.UpdateInsightTypeConfig", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "UpdateInsightTypeConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._UpdateInsightTypeConfig._get_response( self._host, @@ -1747,7 +2382,31 @@ def __call__( pb_resp = gcr_insight_type_config.InsightTypeConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_insight_type_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcr_insight_type_config.InsightTypeConfig.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.recommender_v1.RecommenderClient.update_insight_type_config", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "UpdateInsightTypeConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRecommenderConfig( @@ -1785,7 +2444,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Call the update recommender config method over HTTP. @@ -1795,8 +2454,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_recommender_config.RecommenderConfig: @@ -1806,6 +2467,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseUpdateRecommenderConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_recommender_config( request, metadata ) @@ -1822,6 +2484,33 @@ def __call__( 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.recommender_v1.RecommenderClient.UpdateRecommenderConfig", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "UpdateRecommenderConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._UpdateRecommenderConfig._get_response( self._host, @@ -1843,7 +2532,31 @@ def __call__( pb_resp = gcr_recommender_config.RecommenderConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_recommender_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_recommender_config.RecommenderConfig.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.recommender_v1.RecommenderClient.update_recommender_config", + extra={ + "serviceName": "google.cloud.recommender.v1.Recommender", + "rpcName": "UpdateRecommenderConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/gapic_version.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/gapic_version.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/async_client.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/async_client.py index f7546402b04b..52c20f7d05b4 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/async_client.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RecommenderTransport from .transports.grpc_asyncio import RecommenderGrpcAsyncIOTransport +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 RecommenderAsyncClient: """Provides insights and recommendations for cloud customers for @@ -286,6 +296,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.recommender_v1beta1.RecommenderAsyncClient`.", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "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.recommender.v1beta1.Recommender", + "credentialsType": None, + }, + ) + async def list_insights( self, request: Optional[Union[recommender_service.ListInsightsRequest, dict]] = None, @@ -293,7 +325,7 @@ async def list_insights( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightsAsyncPager: r"""Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight @@ -354,8 +386,10 @@ async def sample_list_insights(): 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, 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightsAsyncPager: @@ -429,7 +463,7 @@ async def get_insight( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type. @@ -471,8 +505,10 @@ async def sample_get_insight(): 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, 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: google.cloud.recommender_v1beta1.types.Insight: @@ -539,7 +575,7 @@ async def mark_insight_accepted( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some @@ -602,8 +638,10 @@ async def sample_mark_insight_accepted(): 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, 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: google.cloud.recommender_v1beta1.types.Insight: @@ -674,7 +712,7 @@ async def list_recommendations( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendationsAsyncPager: r"""Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified @@ -761,8 +799,10 @@ async def sample_list_recommendations(): 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, 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendationsAsyncPager: @@ -840,7 +880,7 @@ async def get_recommendation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender. @@ -882,8 +922,10 @@ async def sample_get_recommendation(): 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, 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -950,7 +992,7 @@ async def mark_recommendation_claimed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting @@ -1019,8 +1061,10 @@ async def sample_mark_recommendation_claimed(): 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, 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1094,7 +1138,7 @@ async def mark_recommendation_succeeded( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied @@ -1163,8 +1207,10 @@ async def sample_mark_recommendation_succeeded(): 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, 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1238,7 +1284,7 @@ async def mark_recommendation_failed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied @@ -1307,8 +1353,10 @@ async def sample_mark_recommendation_failed(): 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, 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1378,7 +1426,7 @@ async def get_recommender_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Gets the requested Recommender Config. There is only one instance of the config for each Recommender. @@ -1429,8 +1477,10 @@ async def sample_get_recommender_config(): 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, 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: google.cloud.recommender_v1beta1.types.RecommenderConfig: @@ -1492,7 +1542,7 @@ async def update_recommender_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Updates a Recommender Config. This will create a new revision of the config. @@ -1540,8 +1590,10 @@ async def sample_update_recommender_config(): 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, 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: google.cloud.recommender_v1beta1.types.RecommenderConfig: @@ -1606,7 +1658,7 @@ async def get_insight_type_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType. @@ -1657,8 +1709,10 @@ async def sample_get_insight_type_config(): 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, 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: google.cloud.recommender_v1beta1.types.InsightTypeConfig: @@ -1720,7 +1774,7 @@ async def update_insight_type_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Updates an InsightTypeConfig change. This will create a new revision of the config. @@ -1768,8 +1822,10 @@ async def sample_update_insight_type_config(): 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, 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: google.cloud.recommender_v1beta1.types.InsightTypeConfig: @@ -1833,7 +1889,7 @@ async def list_recommenders( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendersAsyncPager: r"""Lists all available Recommenders. No IAM permissions are required. @@ -1870,8 +1926,10 @@ async def sample_list_recommenders(): 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, 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendersAsyncPager: @@ -1926,7 +1984,7 @@ async def list_insight_types( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightTypesAsyncPager: r"""Lists available InsightTypes. No IAM permissions are required. @@ -1963,8 +2021,10 @@ async def sample_list_insight_types(): 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, 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightTypesAsyncPager: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/client.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/client.py index 983ea9c9bb2b..611392db7047 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/client.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -712,6 +722,10 @@ def __init__( # 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( @@ -774,6 +788,29 @@ def __init__( 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.recommender_v1beta1.RecommenderClient`.", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "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.recommender.v1beta1.Recommender", + "credentialsType": None, + }, + ) + def list_insights( self, request: Optional[Union[recommender_service.ListInsightsRequest, dict]] = None, @@ -781,7 +818,7 @@ def list_insights( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightsPager: r"""Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight @@ -842,8 +879,10 @@ def sample_list_insights(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.recommender_v1beta1.services.recommender.pagers.ListInsightsPager: @@ -914,7 +953,7 @@ def get_insight( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type. @@ -956,8 +995,10 @@ def sample_get_insight(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Insight: @@ -1021,7 +1062,7 @@ def mark_insight_accepted( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some @@ -1084,8 +1125,10 @@ def sample_mark_insight_accepted(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Insight: @@ -1152,7 +1195,7 @@ def list_recommendations( filter: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendationsPager: r"""Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified @@ -1239,8 +1282,10 @@ def sample_list_recommendations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendationsPager: @@ -1315,7 +1360,7 @@ def get_recommendation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender. @@ -1357,8 +1402,10 @@ def sample_get_recommendation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1422,7 +1469,7 @@ def mark_recommendation_claimed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting @@ -1491,8 +1538,10 @@ def sample_mark_recommendation_claimed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1564,7 +1613,7 @@ def mark_recommendation_succeeded( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied @@ -1633,8 +1682,10 @@ def sample_mark_recommendation_succeeded(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1706,7 +1757,7 @@ def mark_recommendation_failed( etag: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied @@ -1775,8 +1826,10 @@ def sample_mark_recommendation_failed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.Recommendation: @@ -1844,7 +1897,7 @@ def get_recommender_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Gets the requested Recommender Config. There is only one instance of the config for each Recommender. @@ -1895,8 +1948,10 @@ def sample_get_recommender_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.RecommenderConfig: @@ -1955,7 +2010,7 @@ def update_recommender_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Updates a Recommender Config. This will create a new revision of the config. @@ -2003,8 +2058,10 @@ def sample_update_recommender_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.RecommenderConfig: @@ -2068,7 +2125,7 @@ def get_insight_type_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType. @@ -2119,8 +2176,10 @@ def sample_get_insight_type_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.InsightTypeConfig: @@ -2179,7 +2238,7 @@ def update_insight_type_config( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Updates an InsightTypeConfig change. This will create a new revision of the config. @@ -2227,8 +2286,10 @@ def sample_update_insight_type_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.types.InsightTypeConfig: @@ -2291,7 +2352,7 @@ def list_recommenders( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecommendersPager: r"""Lists all available Recommenders. No IAM permissions are required. @@ -2328,8 +2389,10 @@ def sample_list_recommenders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendersPager: @@ -2382,7 +2445,7 @@ def list_insight_types( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInsightTypesPager: r"""Lists available InsightTypes. No IAM permissions are required. @@ -2419,8 +2482,10 @@ def sample_list_insight_types(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightTypesPager: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/pagers.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/pagers.py index 92bfd5756b95..951eb50ab9b2 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/pagers.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListInsightsRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListInsightsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListRecommendationsRequest(request) @@ -299,7 +305,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -313,8 +319,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListRecommendationsRequest(request) @@ -379,7 +387,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -393,8 +401,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListRecommendersRequest(request) @@ -453,7 +463,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -467,8 +477,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListRecommendersRequest(request) @@ -533,7 +545,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -547,8 +559,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = recommender_service.ListInsightTypesRequest(request) @@ -607,7 +621,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -621,8 +635,10 @@ def __init__( 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, 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`. """ self._method = method self._request = recommender_service.ListInsightTypesRequest(request) diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc.py index 2fa1f60fe5ff..7b0058c552bf 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,7 +23,10 @@ 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.recommender_v1beta1.types import ( insight_type_config as gcr_insight_type_config, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, RecommenderTransport +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.recommender.v1beta1.Recommender", + "rpcName": 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.recommender.v1beta1.Recommender", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecommenderGrpcTransport(RecommenderTransport): """gRPC backend transport for Recommender. @@ -193,7 +274,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +358,7 @@ def list_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insights" not in self._stubs: - self._stubs["list_insights"] = self.grpc_channel.unary_unary( + self._stubs["list_insights"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListInsights", request_serializer=recommender_service.ListInsightsRequest.serialize, response_deserializer=recommender_service.ListInsightsResponse.deserialize, @@ -299,7 +385,7 @@ def get_insight( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight" not in self._stubs: - self._stubs["get_insight"] = self.grpc_channel.unary_unary( + self._stubs["get_insight"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetInsight", request_serializer=recommender_service.GetInsightRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -332,7 +418,7 @@ def mark_insight_accepted( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_insight_accepted" not in self._stubs: - self._stubs["mark_insight_accepted"] = self.grpc_channel.unary_unary( + self._stubs["mark_insight_accepted"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkInsightAccepted", request_serializer=recommender_service.MarkInsightAcceptedRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -363,7 +449,7 @@ def list_recommendations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommendations" not in self._stubs: - self._stubs["list_recommendations"] = self.grpc_channel.unary_unary( + self._stubs["list_recommendations"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListRecommendations", request_serializer=recommender_service.ListRecommendationsRequest.serialize, response_deserializer=recommender_service.ListRecommendationsResponse.deserialize, @@ -392,7 +478,7 @@ def get_recommendation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommendation" not in self._stubs: - self._stubs["get_recommendation"] = self.grpc_channel.unary_unary( + self._stubs["get_recommendation"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetRecommendation", request_serializer=recommender_service.GetRecommendationRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -431,7 +517,9 @@ def mark_recommendation_claimed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_claimed" not in self._stubs: - self._stubs["mark_recommendation_claimed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_claimed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationClaimed", request_serializer=recommender_service.MarkRecommendationClaimedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -472,7 +560,7 @@ def mark_recommendation_succeeded( if "mark_recommendation_succeeded" not in self._stubs: self._stubs[ "mark_recommendation_succeeded" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationSucceeded", request_serializer=recommender_service.MarkRecommendationSucceededRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -511,7 +599,9 @@ def mark_recommendation_failed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_failed" not in self._stubs: - self._stubs["mark_recommendation_failed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_failed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationFailed", request_serializer=recommender_service.MarkRecommendationFailedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -541,7 +631,7 @@ def get_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommender_config" not in self._stubs: - self._stubs["get_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["get_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetRecommenderConfig", request_serializer=recommender_service.GetRecommenderConfigRequest.serialize, response_deserializer=recommender_config.RecommenderConfig.deserialize, @@ -571,7 +661,7 @@ def update_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recommender_config" not in self._stubs: - self._stubs["update_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["update_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/UpdateRecommenderConfig", request_serializer=recommender_service.UpdateRecommenderConfigRequest.serialize, response_deserializer=gcr_recommender_config.RecommenderConfig.deserialize, @@ -601,7 +691,7 @@ def get_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight_type_config" not in self._stubs: - self._stubs["get_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs["get_insight_type_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetInsightTypeConfig", request_serializer=recommender_service.GetInsightTypeConfigRequest.serialize, response_deserializer=insight_type_config.InsightTypeConfig.deserialize, @@ -631,7 +721,9 @@ def update_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_insight_type_config" not in self._stubs: - self._stubs["update_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_insight_type_config" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/UpdateInsightTypeConfig", request_serializer=recommender_service.UpdateInsightTypeConfigRequest.serialize, response_deserializer=gcr_insight_type_config.InsightTypeConfig.deserialize, @@ -661,7 +753,7 @@ def list_recommenders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommenders" not in self._stubs: - self._stubs["list_recommenders"] = self.grpc_channel.unary_unary( + self._stubs["list_recommenders"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListRecommenders", request_serializer=recommender_service.ListRecommendersRequest.serialize, response_deserializer=recommender_service.ListRecommendersResponse.deserialize, @@ -691,7 +783,7 @@ def list_insight_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insight_types" not in self._stubs: - self._stubs["list_insight_types"] = self.grpc_channel.unary_unary( + self._stubs["list_insight_types"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListInsightTypes", request_serializer=recommender_service.ListInsightTypesRequest.serialize, response_deserializer=recommender_service.ListInsightTypesResponse.deserialize, @@ -699,7 +791,7 @@ def list_insight_types( return self._stubs["list_insight_types"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc_asyncio.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc_asyncio.py index c3d1f32f3027..cdbd77549166 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc_asyncio.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,8 +25,11 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.recommender_v1beta1.types import ( insight_type_config as gcr_insight_type_config, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, RecommenderTransport from .grpc import RecommenderGrpcTransport +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.recommender.v1beta1.Recommender", + "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.recommender.v1beta1.Recommender", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RecommenderGrpcAsyncIOTransport(RecommenderTransport): """gRPC AsyncIO backend transport for Recommender. @@ -240,10 +322,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -280,7 +365,7 @@ def list_insights( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insights" not in self._stubs: - self._stubs["list_insights"] = self.grpc_channel.unary_unary( + self._stubs["list_insights"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListInsights", request_serializer=recommender_service.ListInsightsRequest.serialize, response_deserializer=recommender_service.ListInsightsResponse.deserialize, @@ -307,7 +392,7 @@ def get_insight( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight" not in self._stubs: - self._stubs["get_insight"] = self.grpc_channel.unary_unary( + self._stubs["get_insight"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetInsight", request_serializer=recommender_service.GetInsightRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -342,7 +427,7 @@ def mark_insight_accepted( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_insight_accepted" not in self._stubs: - self._stubs["mark_insight_accepted"] = self.grpc_channel.unary_unary( + self._stubs["mark_insight_accepted"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkInsightAccepted", request_serializer=recommender_service.MarkInsightAcceptedRequest.serialize, response_deserializer=insight.Insight.deserialize, @@ -373,7 +458,7 @@ def list_recommendations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommendations" not in self._stubs: - self._stubs["list_recommendations"] = self.grpc_channel.unary_unary( + self._stubs["list_recommendations"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListRecommendations", request_serializer=recommender_service.ListRecommendationsRequest.serialize, response_deserializer=recommender_service.ListRecommendationsResponse.deserialize, @@ -403,7 +488,7 @@ def get_recommendation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommendation" not in self._stubs: - self._stubs["get_recommendation"] = self.grpc_channel.unary_unary( + self._stubs["get_recommendation"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetRecommendation", request_serializer=recommender_service.GetRecommendationRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -442,7 +527,9 @@ def mark_recommendation_claimed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_claimed" not in self._stubs: - self._stubs["mark_recommendation_claimed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_claimed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationClaimed", request_serializer=recommender_service.MarkRecommendationClaimedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -483,7 +570,7 @@ def mark_recommendation_succeeded( if "mark_recommendation_succeeded" not in self._stubs: self._stubs[ "mark_recommendation_succeeded" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationSucceeded", request_serializer=recommender_service.MarkRecommendationSucceededRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -522,7 +609,9 @@ def mark_recommendation_failed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "mark_recommendation_failed" not in self._stubs: - self._stubs["mark_recommendation_failed"] = self.grpc_channel.unary_unary( + self._stubs[ + "mark_recommendation_failed" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationFailed", request_serializer=recommender_service.MarkRecommendationFailedRequest.serialize, response_deserializer=recommendation.Recommendation.deserialize, @@ -552,7 +641,7 @@ def get_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recommender_config" not in self._stubs: - self._stubs["get_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["get_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetRecommenderConfig", request_serializer=recommender_service.GetRecommenderConfigRequest.serialize, response_deserializer=recommender_config.RecommenderConfig.deserialize, @@ -582,7 +671,7 @@ def update_recommender_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_recommender_config" not in self._stubs: - self._stubs["update_recommender_config"] = self.grpc_channel.unary_unary( + self._stubs["update_recommender_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/UpdateRecommenderConfig", request_serializer=recommender_service.UpdateRecommenderConfigRequest.serialize, response_deserializer=gcr_recommender_config.RecommenderConfig.deserialize, @@ -612,7 +701,7 @@ def get_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_insight_type_config" not in self._stubs: - self._stubs["get_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs["get_insight_type_config"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/GetInsightTypeConfig", request_serializer=recommender_service.GetInsightTypeConfigRequest.serialize, response_deserializer=insight_type_config.InsightTypeConfig.deserialize, @@ -642,7 +731,9 @@ def update_insight_type_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_insight_type_config" not in self._stubs: - self._stubs["update_insight_type_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_insight_type_config" + ] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/UpdateInsightTypeConfig", request_serializer=recommender_service.UpdateInsightTypeConfigRequest.serialize, response_deserializer=gcr_insight_type_config.InsightTypeConfig.deserialize, @@ -672,7 +763,7 @@ def list_recommenders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recommenders" not in self._stubs: - self._stubs["list_recommenders"] = self.grpc_channel.unary_unary( + self._stubs["list_recommenders"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListRecommenders", request_serializer=recommender_service.ListRecommendersRequest.serialize, response_deserializer=recommender_service.ListRecommendersResponse.deserialize, @@ -702,7 +793,7 @@ def list_insight_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_insight_types" not in self._stubs: - self._stubs["list_insight_types"] = self.grpc_channel.unary_unary( + self._stubs["list_insight_types"] = self._logged_channel.unary_unary( "/google.cloud.recommender.v1beta1.Recommender/ListInsightTypes", request_serializer=recommender_service.ListInsightTypesRequest.serialize, response_deserializer=recommender_service.ListInsightTypesResponse.deserialize, @@ -830,7 +921,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/rest.py b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/rest.py index 67ca1b6a737f..8d6380149d10 100644 --- a/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/rest.py +++ b/packages/google-cloud-recommender/google/cloud/recommender_v1beta1/services/recommender/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -47,6 +47,14 @@ 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, @@ -191,8 +199,10 @@ def post_update_recommender_config(self, response): def pre_get_insight( self, request: recommender_service.GetInsightRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.GetInsightRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.GetInsightRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_insight Override in a subclass to manipulate the request or metadata @@ -212,9 +222,10 @@ def post_get_insight(self, response: insight.Insight) -> insight.Insight: def pre_get_insight_type_config( self, request: recommender_service.GetInsightTypeConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.GetInsightTypeConfigRequest, Sequence[Tuple[str, str]] + recommender_service.GetInsightTypeConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_insight_type_config @@ -237,8 +248,11 @@ def post_get_insight_type_config( def pre_get_recommendation( self, request: recommender_service.GetRecommendationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.GetRecommendationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.GetRecommendationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_recommendation Override in a subclass to manipulate the request or metadata @@ -260,9 +274,10 @@ def post_get_recommendation( def pre_get_recommender_config( self, request: recommender_service.GetRecommenderConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.GetRecommenderConfigRequest, Sequence[Tuple[str, str]] + recommender_service.GetRecommenderConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_recommender_config @@ -285,8 +300,10 @@ def post_get_recommender_config( def pre_list_insights( self, request: recommender_service.ListInsightsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.ListInsightsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.ListInsightsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_insights Override in a subclass to manipulate the request or metadata @@ -308,8 +325,11 @@ def post_list_insights( def pre_list_insight_types( self, request: recommender_service.ListInsightTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.ListInsightTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.ListInsightTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_insight_types Override in a subclass to manipulate the request or metadata @@ -331,9 +351,10 @@ def post_list_insight_types( def pre_list_recommendations( self, request: recommender_service.ListRecommendationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.ListRecommendationsRequest, Sequence[Tuple[str, str]] + recommender_service.ListRecommendationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_recommendations @@ -356,8 +377,11 @@ def post_list_recommendations( def pre_list_recommenders( self, request: recommender_service.ListRecommendersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[recommender_service.ListRecommendersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + recommender_service.ListRecommendersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_recommenders Override in a subclass to manipulate the request or metadata @@ -379,9 +403,10 @@ def post_list_recommenders( def pre_mark_insight_accepted( self, request: recommender_service.MarkInsightAcceptedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkInsightAcceptedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkInsightAcceptedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_insight_accepted @@ -402,9 +427,10 @@ def post_mark_insight_accepted(self, response: insight.Insight) -> insight.Insig def pre_mark_recommendation_claimed( self, request: recommender_service.MarkRecommendationClaimedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkRecommendationClaimedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkRecommendationClaimedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_claimed @@ -427,9 +453,10 @@ def post_mark_recommendation_claimed( def pre_mark_recommendation_failed( self, request: recommender_service.MarkRecommendationFailedRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.MarkRecommendationFailedRequest, Sequence[Tuple[str, str]] + recommender_service.MarkRecommendationFailedRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_failed @@ -452,10 +479,10 @@ def post_mark_recommendation_failed( def pre_mark_recommendation_succeeded( self, request: recommender_service.MarkRecommendationSucceededRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ recommender_service.MarkRecommendationSucceededRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for mark_recommendation_succeeded @@ -478,9 +505,10 @@ def post_mark_recommendation_succeeded( def pre_update_insight_type_config( self, request: recommender_service.UpdateInsightTypeConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.UpdateInsightTypeConfigRequest, Sequence[Tuple[str, str]] + recommender_service.UpdateInsightTypeConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_insight_type_config @@ -503,9 +531,10 @@ def post_update_insight_type_config( def pre_update_recommender_config( self, request: recommender_service.UpdateRecommenderConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - recommender_service.UpdateRecommenderConfigRequest, Sequence[Tuple[str, str]] + recommender_service.UpdateRecommenderConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_recommender_config @@ -650,7 +679,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Call the get insight method over HTTP. @@ -660,8 +689,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight.Insight: @@ -675,6 +706,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetInsight._get_http_options() ) + request, metadata = self._interceptor.pre_get_insight(request, metadata) transcoded_request = ( _BaseRecommenderRestTransport._BaseGetInsight._get_transcoded_request( @@ -689,6 +721,33 @@ def __call__( ) ) + 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.recommender_v1beta1.RecommenderClient.GetInsight", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetInsight", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetInsight._get_response( self._host, @@ -709,7 +768,29 @@ def __call__( pb_resp = insight.Insight.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_insight(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight.Insight.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.recommender_v1beta1.RecommenderClient.get_insight", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetInsight", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInsightTypeConfig( @@ -746,7 +827,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight_type_config.InsightTypeConfig: r"""Call the get insight type config method over HTTP. @@ -756,8 +837,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight_type_config.InsightTypeConfig: @@ -767,6 +850,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetInsightTypeConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_insight_type_config( request, metadata ) @@ -779,6 +863,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.GetInsightTypeConfig", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetInsightTypeConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetInsightTypeConfig._get_response( self._host, @@ -799,7 +910,31 @@ def __call__( pb_resp = insight_type_config.InsightTypeConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_insight_type_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight_type_config.InsightTypeConfig.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.recommender_v1beta1.RecommenderClient.get_insight_type_config", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetInsightTypeConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecommendation( @@ -836,7 +971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the get recommendation method over HTTP. @@ -846,8 +981,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -861,6 +998,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetRecommendation._get_http_options() ) + request, metadata = self._interceptor.pre_get_recommendation( request, metadata ) @@ -873,6 +1011,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.GetRecommendation", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetRecommendation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetRecommendation._get_response( self._host, @@ -893,7 +1058,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recommendation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1beta1.RecommenderClient.get_recommendation", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetRecommendation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecommenderConfig( @@ -930,7 +1117,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_config.RecommenderConfig: r"""Call the get recommender config method over HTTP. @@ -940,8 +1127,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_config.RecommenderConfig: @@ -951,6 +1140,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseGetRecommenderConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_recommender_config( request, metadata ) @@ -963,6 +1153,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.GetRecommenderConfig", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetRecommenderConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._GetRecommenderConfig._get_response( self._host, @@ -983,7 +1200,31 @@ def __call__( pb_resp = recommender_config.RecommenderConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recommender_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommender_config.RecommenderConfig.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.recommender_v1beta1.RecommenderClient.get_recommender_config", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "GetRecommenderConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInsights( @@ -1020,7 +1261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListInsightsResponse: r"""Call the list insights method over HTTP. @@ -1030,8 +1271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListInsightsResponse: @@ -1041,6 +1284,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListInsights._get_http_options() ) + request, metadata = self._interceptor.pre_list_insights(request, metadata) transcoded_request = ( _BaseRecommenderRestTransport._BaseListInsights._get_transcoded_request( @@ -1055,6 +1299,33 @@ def __call__( ) ) + 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.recommender_v1beta1.RecommenderClient.ListInsights", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListInsights", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListInsights._get_response( self._host, @@ -1075,7 +1346,31 @@ def __call__( pb_resp = recommender_service.ListInsightsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_insights(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommender_service.ListInsightsResponse.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.recommender_v1beta1.RecommenderClient.list_insights", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListInsights", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInsightTypes( @@ -1112,7 +1407,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListInsightTypesResponse: r"""Call the list insight types method over HTTP. @@ -1122,8 +1417,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListInsightTypesResponse: @@ -1133,6 +1430,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListInsightTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_insight_types( request, metadata ) @@ -1145,6 +1443,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.ListInsightTypes", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListInsightTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListInsightTypes._get_response( self._host, @@ -1165,7 +1490,31 @@ def __call__( pb_resp = recommender_service.ListInsightTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_insight_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + recommender_service.ListInsightTypesResponse.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.recommender_v1beta1.RecommenderClient.list_insight_types", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListInsightTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecommendations( @@ -1202,7 +1551,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListRecommendationsResponse: r"""Call the list recommendations method over HTTP. @@ -1212,8 +1561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListRecommendationsResponse: @@ -1223,6 +1574,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListRecommendations._get_http_options() ) + request, metadata = self._interceptor.pre_list_recommendations( request, metadata ) @@ -1235,6 +1587,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.ListRecommendations", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListRecommendations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListRecommendations._get_response( self._host, @@ -1255,7 +1634,33 @@ def __call__( pb_resp = recommender_service.ListRecommendationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recommendations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + recommender_service.ListRecommendationsResponse.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.recommender_v1beta1.RecommenderClient.list_recommendations", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListRecommendations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecommenders( @@ -1292,7 +1697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommender_service.ListRecommendersResponse: r"""Call the list recommenders method over HTTP. @@ -1302,8 +1707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommender_service.ListRecommendersResponse: @@ -1313,6 +1720,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseListRecommenders._get_http_options() ) + request, metadata = self._interceptor.pre_list_recommenders( request, metadata ) @@ -1325,6 +1733,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.ListRecommenders", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListRecommenders", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._ListRecommenders._get_response( self._host, @@ -1345,7 +1780,31 @@ def __call__( pb_resp = recommender_service.ListRecommendersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recommenders(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + recommender_service.ListRecommendersResponse.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.recommender_v1beta1.RecommenderClient.list_recommenders", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "ListRecommenders", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkInsightAccepted( @@ -1383,7 +1842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> insight.Insight: r"""Call the mark insight accepted method over HTTP. @@ -1393,8 +1852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.insight.Insight: @@ -1408,6 +1869,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkInsightAccepted._get_http_options() ) + request, metadata = self._interceptor.pre_mark_insight_accepted( request, metadata ) @@ -1424,6 +1886,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.MarkInsightAccepted", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkInsightAccepted", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._MarkInsightAccepted._get_response( self._host, @@ -1445,7 +1934,29 @@ def __call__( pb_resp = insight.Insight.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_insight_accepted(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = insight.Insight.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.recommender_v1beta1.RecommenderClient.mark_insight_accepted", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkInsightAccepted", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationClaimed( @@ -1484,7 +1995,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation claimed method over HTTP. @@ -1495,8 +2006,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1510,6 +2023,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationClaimed._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_claimed( request, metadata ) @@ -1526,6 +2040,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.MarkRecommendationClaimed", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationClaimed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RecommenderRestTransport._MarkRecommendationClaimed._get_response( @@ -1549,7 +2090,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_claimed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1beta1.RecommenderClient.mark_recommendation_claimed", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationClaimed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationFailed( @@ -1587,7 +2150,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation failed method over HTTP. @@ -1598,8 +2161,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1613,6 +2178,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationFailed._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_failed( request, metadata ) @@ -1629,6 +2195,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.MarkRecommendationFailed", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationFailed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._MarkRecommendationFailed._get_response( self._host, @@ -1650,7 +2243,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_failed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1beta1.RecommenderClient.mark_recommendation_failed", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationFailed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MarkRecommendationSucceeded( @@ -1689,7 +2304,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> recommendation.Recommendation: r"""Call the mark recommendation succeeded method over HTTP. @@ -1700,8 +2315,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.recommendation.Recommendation: @@ -1715,6 +2332,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseMarkRecommendationSucceeded._get_http_options() ) + request, metadata = self._interceptor.pre_mark_recommendation_succeeded( request, metadata ) @@ -1731,6 +2349,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.MarkRecommendationSucceeded", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationSucceeded", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RecommenderRestTransport._MarkRecommendationSucceeded._get_response( @@ -1754,7 +2399,29 @@ def __call__( pb_resp = recommendation.Recommendation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_mark_recommendation_succeeded(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = recommendation.Recommendation.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.recommender_v1beta1.RecommenderClient.mark_recommendation_succeeded", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "MarkRecommendationSucceeded", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInsightTypeConfig( @@ -1792,7 +2459,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_insight_type_config.InsightTypeConfig: r"""Call the update insight type config method over HTTP. @@ -1803,8 +2470,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_insight_type_config.InsightTypeConfig: @@ -1814,6 +2483,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseUpdateInsightTypeConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_insight_type_config( request, metadata ) @@ -1830,6 +2500,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.UpdateInsightTypeConfig", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "UpdateInsightTypeConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._UpdateInsightTypeConfig._get_response( self._host, @@ -1851,7 +2548,31 @@ def __call__( pb_resp = gcr_insight_type_config.InsightTypeConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_insight_type_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcr_insight_type_config.InsightTypeConfig.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.recommender_v1beta1.RecommenderClient.update_insight_type_config", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "UpdateInsightTypeConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRecommenderConfig( @@ -1889,7 +2610,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcr_recommender_config.RecommenderConfig: r"""Call the update recommender config method over HTTP. @@ -1899,8 +2620,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.gcr_recommender_config.RecommenderConfig: @@ -1910,6 +2633,7 @@ def __call__( http_options = ( _BaseRecommenderRestTransport._BaseUpdateRecommenderConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_recommender_config( request, metadata ) @@ -1926,6 +2650,33 @@ def __call__( 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.recommender_v1beta1.RecommenderClient.UpdateRecommenderConfig", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "UpdateRecommenderConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RecommenderRestTransport._UpdateRecommenderConfig._get_response( self._host, @@ -1947,7 +2698,31 @@ def __call__( pb_resp = gcr_recommender_config.RecommenderConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_recommender_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcr_recommender_config.RecommenderConfig.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.recommender_v1beta1.RecommenderClient.update_recommender_config", + extra={ + "serviceName": "google.cloud.recommender.v1beta1.Recommender", + "rpcName": "UpdateRecommenderConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1.json b/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1.json index b2b87bc1bf10..3ccf1bb20a47 100644 --- a/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1.json +++ b/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-recommender", - "version": "2.16.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.InsightTypeConfig", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.InsightTypeConfig", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Insight", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Insight", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.RecommenderConfig", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.RecommenderConfig", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.services.recommender.pagers.ListInsightsAsyncPager", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.services.recommender.pagers.ListInsightsPager", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.services.recommender.pagers.ListRecommendationsAsyncPager", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.services.recommender.pagers.ListRecommendationsPager", @@ -1029,7 +1029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Insight", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Insight", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1371,7 +1371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1713,7 +1713,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1801,7 +1801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.Recommendation", @@ -1886,7 +1886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.InsightTypeConfig", @@ -1970,7 +1970,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.InsightTypeConfig", @@ -2055,7 +2055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.RecommenderConfig", @@ -2139,7 +2139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1.types.RecommenderConfig", diff --git a/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1beta1.json b/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1beta1.json index 46ac91fbdd72..01d4bcaa2c08 100644 --- a/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1beta1.json +++ b/packages/google-cloud-recommender/samples/generated_samples/snippet_metadata_google.cloud.recommender.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-recommender", - "version": "2.16.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.InsightTypeConfig", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.InsightTypeConfig", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Insight", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Insight", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.RecommenderConfig", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.RecommenderConfig", @@ -687,7 +687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightTypesAsyncPager", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightTypesPager", @@ -844,7 +844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightsAsyncPager", @@ -924,7 +924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListInsightsPager", @@ -1009,7 +1009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendationsAsyncPager", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendationsPager", @@ -1170,7 +1170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendersAsyncPager", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.services.recommender.pagers.ListRecommendersPager", @@ -1335,7 +1335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Insight", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Insight", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -1600,7 +1600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -1954,7 +1954,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.Recommendation", @@ -2039,7 +2039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.InsightTypeConfig", @@ -2123,7 +2123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.InsightTypeConfig", @@ -2208,7 +2208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.RecommenderConfig", @@ -2292,7 +2292,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.recommender_v1beta1.types.RecommenderConfig", diff --git a/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1/test_recommender.py b/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1/test_recommender.py index 8555512be416..982c9ede4b09 100644 --- a/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1/test_recommender.py +++ b/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1/test_recommender.py @@ -6199,6 +6199,7 @@ def test_list_insights_rest_required_fields( response_value._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_insights(request) @@ -6255,6 +6256,7 @@ def test_list_insights_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insights(**mock_args) @@ -6451,6 +6453,7 @@ def test_get_insight_rest_required_fields( response_value._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_insight(request) @@ -6498,6 +6501,7 @@ def test_get_insight_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight(**mock_args) @@ -6639,6 +6643,7 @@ def test_mark_insight_accepted_rest_required_fields( response_value._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.mark_insight_accepted(request) @@ -6696,6 +6701,7 @@ def test_mark_insight_accepted_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_insight_accepted(**mock_args) @@ -6843,6 +6849,7 @@ def test_list_recommendations_rest_required_fields( response_value._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_recommendations(request) @@ -6900,6 +6907,7 @@ def test_list_recommendations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommendations(**mock_args) @@ -7101,6 +7109,7 @@ def test_get_recommendation_rest_required_fields( response_value._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_recommendation(request) @@ -7148,6 +7157,7 @@ def test_get_recommendation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommendation(**mock_args) @@ -7285,6 +7295,7 @@ def test_mark_recommendation_dismissed_rest_required_fields( response_value._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.mark_recommendation_dismissed(request) @@ -7416,6 +7427,7 @@ def test_mark_recommendation_claimed_rest_required_fields( response_value._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.mark_recommendation_claimed(request) @@ -7473,6 +7485,7 @@ def test_mark_recommendation_claimed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_claimed(**mock_args) @@ -7616,6 +7629,7 @@ def test_mark_recommendation_succeeded_rest_required_fields( response_value._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.mark_recommendation_succeeded(request) @@ -7675,6 +7689,7 @@ def test_mark_recommendation_succeeded_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_succeeded(**mock_args) @@ -7818,6 +7833,7 @@ def test_mark_recommendation_failed_rest_required_fields( response_value._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.mark_recommendation_failed(request) @@ -7875,6 +7891,7 @@ def test_mark_recommendation_failed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_failed(**mock_args) @@ -8013,6 +8030,7 @@ def test_get_recommender_config_rest_required_fields( response_value._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_recommender_config(request) @@ -8060,6 +8078,7 @@ def test_get_recommender_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommender_config(**mock_args) @@ -8199,6 +8218,7 @@ def test_update_recommender_config_rest_required_fields( response_value._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_recommender_config(request) @@ -8259,6 +8279,7 @@ def test_update_recommender_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommender_config(**mock_args) @@ -8398,6 +8419,7 @@ def test_get_insight_type_config_rest_required_fields( response_value._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_insight_type_config(request) @@ -8445,6 +8467,7 @@ def test_get_insight_type_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight_type_config(**mock_args) @@ -8584,6 +8607,7 @@ def test_update_insight_type_config_rest_required_fields( response_value._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_insight_type_config(request) @@ -8644,6 +8668,7 @@ def test_update_insight_type_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight_type_config(**mock_args) @@ -9541,6 +9566,7 @@ def test_list_insights_rest_bad_request( 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_insights(request) @@ -9576,6 +9602,7 @@ def test_list_insights_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insights(request) # Establish that the response is the type that we expect. @@ -9616,6 +9643,7 @@ def test_list_insights_rest_interceptors(null_interceptor): 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 = recommender_service.ListInsightsResponse.to_json( recommender_service.ListInsightsResponse() ) @@ -9664,6 +9692,7 @@ def test_get_insight_rest_bad_request( 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_insight(request) @@ -9707,6 +9736,7 @@ def test_get_insight_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight(request) # Establish that the response is the type that we expect. @@ -9753,6 +9783,7 @@ def test_get_insight_rest_interceptors(null_interceptor): 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 = insight.Insight.to_json(insight.Insight()) req.return_value.content = return_value @@ -9799,6 +9830,7 @@ def test_mark_insight_accepted_rest_bad_request( 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.mark_insight_accepted(request) @@ -9842,6 +9874,7 @@ def test_mark_insight_accepted_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_insight_accepted(request) # Establish that the response is the type that we expect. @@ -9888,6 +9921,7 @@ def test_mark_insight_accepted_rest_interceptors(null_interceptor): 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 = insight.Insight.to_json(insight.Insight()) req.return_value.content = return_value @@ -9932,6 +9966,7 @@ def test_list_recommendations_rest_bad_request( 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_recommendations(request) @@ -9967,6 +10002,7 @@ def test_list_recommendations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommendations(request) # Establish that the response is the type that we expect. @@ -10007,6 +10043,7 @@ def test_list_recommendations_rest_interceptors(null_interceptor): 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 = recommender_service.ListRecommendationsResponse.to_json( recommender_service.ListRecommendationsResponse() ) @@ -10055,6 +10092,7 @@ def test_get_recommendation_rest_bad_request( 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_recommendation(request) @@ -10097,6 +10135,7 @@ def test_get_recommendation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommendation(request) # Establish that the response is the type that we expect. @@ -10142,6 +10181,7 @@ def test_get_recommendation_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10190,6 +10230,7 @@ def test_mark_recommendation_dismissed_rest_bad_request( 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.mark_recommendation_dismissed(request) @@ -10232,6 +10273,7 @@ def test_mark_recommendation_dismissed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_dismissed(request) # Establish that the response is the type that we expect. @@ -10277,6 +10319,7 @@ def test_mark_recommendation_dismissed_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10325,6 +10368,7 @@ def test_mark_recommendation_claimed_rest_bad_request( 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.mark_recommendation_claimed(request) @@ -10367,6 +10411,7 @@ def test_mark_recommendation_claimed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_claimed(request) # Establish that the response is the type that we expect. @@ -10412,6 +10457,7 @@ def test_mark_recommendation_claimed_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10460,6 +10506,7 @@ def test_mark_recommendation_succeeded_rest_bad_request( 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.mark_recommendation_succeeded(request) @@ -10502,6 +10549,7 @@ def test_mark_recommendation_succeeded_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_succeeded(request) # Establish that the response is the type that we expect. @@ -10547,6 +10595,7 @@ def test_mark_recommendation_succeeded_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10595,6 +10644,7 @@ def test_mark_recommendation_failed_rest_bad_request( 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.mark_recommendation_failed(request) @@ -10637,6 +10687,7 @@ def test_mark_recommendation_failed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_failed(request) # Establish that the response is the type that we expect. @@ -10682,6 +10733,7 @@ def test_mark_recommendation_failed_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10730,6 +10782,7 @@ def test_get_recommender_config_rest_bad_request( 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_recommender_config(request) @@ -10770,6 +10823,7 @@ def test_get_recommender_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommender_config(request) # Establish that the response is the type that we expect. @@ -10813,6 +10867,7 @@ def test_get_recommender_config_rest_interceptors(null_interceptor): 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 = recommender_config.RecommenderConfig.to_json( recommender_config.RecommenderConfig() ) @@ -10863,6 +10918,7 @@ def test_update_recommender_config_rest_bad_request( 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_recommender_config(request) @@ -10983,6 +11039,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommender_config(request) # Establish that the response is the type that we expect. @@ -11026,6 +11083,7 @@ def test_update_recommender_config_rest_interceptors(null_interceptor): 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 = gcr_recommender_config.RecommenderConfig.to_json( gcr_recommender_config.RecommenderConfig() ) @@ -11074,6 +11132,7 @@ def test_get_insight_type_config_rest_bad_request( 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_insight_type_config(request) @@ -11114,6 +11173,7 @@ def test_get_insight_type_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight_type_config(request) # Establish that the response is the type that we expect. @@ -11157,6 +11217,7 @@ def test_get_insight_type_config_rest_interceptors(null_interceptor): 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 = insight_type_config.InsightTypeConfig.to_json( insight_type_config.InsightTypeConfig() ) @@ -11207,6 +11268,7 @@ def test_update_insight_type_config_rest_bad_request( 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_insight_type_config(request) @@ -11327,6 +11389,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight_type_config(request) # Establish that the response is the type that we expect. @@ -11370,6 +11433,7 @@ def test_update_insight_type_config_rest_interceptors(null_interceptor): 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 = gcr_insight_type_config.InsightTypeConfig.to_json( gcr_insight_type_config.InsightTypeConfig() ) diff --git a/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1beta1/test_recommender.py b/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1beta1/test_recommender.py index 99e4cc88d75b..afac04746868 100644 --- a/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1beta1/test_recommender.py +++ b/packages/google-cloud-recommender/tests/unit/gapic/recommender_v1beta1/test_recommender.py @@ -6698,6 +6698,7 @@ def test_list_insights_rest_required_fields( response_value._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_insights(request) @@ -6754,6 +6755,7 @@ def test_list_insights_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insights(**mock_args) @@ -6950,6 +6952,7 @@ def test_get_insight_rest_required_fields( response_value._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_insight(request) @@ -6997,6 +7000,7 @@ def test_get_insight_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight(**mock_args) @@ -7138,6 +7142,7 @@ def test_mark_insight_accepted_rest_required_fields( response_value._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.mark_insight_accepted(request) @@ -7195,6 +7200,7 @@ def test_mark_insight_accepted_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_insight_accepted(**mock_args) @@ -7342,6 +7348,7 @@ def test_list_recommendations_rest_required_fields( response_value._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_recommendations(request) @@ -7399,6 +7406,7 @@ def test_list_recommendations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommendations(**mock_args) @@ -7600,6 +7608,7 @@ def test_get_recommendation_rest_required_fields( response_value._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_recommendation(request) @@ -7647,6 +7656,7 @@ def test_get_recommendation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommendation(**mock_args) @@ -7788,6 +7798,7 @@ def test_mark_recommendation_claimed_rest_required_fields( response_value._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.mark_recommendation_claimed(request) @@ -7845,6 +7856,7 @@ def test_mark_recommendation_claimed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_claimed(**mock_args) @@ -7988,6 +8000,7 @@ def test_mark_recommendation_succeeded_rest_required_fields( response_value._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.mark_recommendation_succeeded(request) @@ -8047,6 +8060,7 @@ def test_mark_recommendation_succeeded_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_succeeded(**mock_args) @@ -8190,6 +8204,7 @@ def test_mark_recommendation_failed_rest_required_fields( response_value._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.mark_recommendation_failed(request) @@ -8247,6 +8262,7 @@ def test_mark_recommendation_failed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.mark_recommendation_failed(**mock_args) @@ -8385,6 +8401,7 @@ def test_get_recommender_config_rest_required_fields( response_value._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_recommender_config(request) @@ -8432,6 +8449,7 @@ def test_get_recommender_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommender_config(**mock_args) @@ -8571,6 +8589,7 @@ def test_update_recommender_config_rest_required_fields( response_value._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_recommender_config(request) @@ -8631,6 +8650,7 @@ def test_update_recommender_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_recommender_config(**mock_args) @@ -8770,6 +8790,7 @@ def test_get_insight_type_config_rest_required_fields( response_value._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_insight_type_config(request) @@ -8817,6 +8838,7 @@ def test_get_insight_type_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight_type_config(**mock_args) @@ -8956,6 +8978,7 @@ def test_update_insight_type_config_rest_required_fields( response_value._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_insight_type_config(request) @@ -9016,6 +9039,7 @@ def test_update_insight_type_config_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_insight_type_config(**mock_args) @@ -10164,6 +10188,7 @@ def test_list_insights_rest_bad_request( 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_insights(request) @@ -10199,6 +10224,7 @@ def test_list_insights_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insights(request) # Establish that the response is the type that we expect. @@ -10239,6 +10265,7 @@ def test_list_insights_rest_interceptors(null_interceptor): 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 = recommender_service.ListInsightsResponse.to_json( recommender_service.ListInsightsResponse() ) @@ -10287,6 +10314,7 @@ def test_get_insight_rest_bad_request( 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_insight(request) @@ -10330,6 +10358,7 @@ def test_get_insight_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight(request) # Establish that the response is the type that we expect. @@ -10376,6 +10405,7 @@ def test_get_insight_rest_interceptors(null_interceptor): 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 = insight.Insight.to_json(insight.Insight()) req.return_value.content = return_value @@ -10422,6 +10452,7 @@ def test_mark_insight_accepted_rest_bad_request( 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.mark_insight_accepted(request) @@ -10465,6 +10496,7 @@ def test_mark_insight_accepted_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_insight_accepted(request) # Establish that the response is the type that we expect. @@ -10511,6 +10543,7 @@ def test_mark_insight_accepted_rest_interceptors(null_interceptor): 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 = insight.Insight.to_json(insight.Insight()) req.return_value.content = return_value @@ -10555,6 +10588,7 @@ def test_list_recommendations_rest_bad_request( 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_recommendations(request) @@ -10590,6 +10624,7 @@ def test_list_recommendations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommendations(request) # Establish that the response is the type that we expect. @@ -10630,6 +10665,7 @@ def test_list_recommendations_rest_interceptors(null_interceptor): 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 = recommender_service.ListRecommendationsResponse.to_json( recommender_service.ListRecommendationsResponse() ) @@ -10678,6 +10714,7 @@ def test_get_recommendation_rest_bad_request( 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_recommendation(request) @@ -10720,6 +10757,7 @@ def test_get_recommendation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommendation(request) # Establish that the response is the type that we expect. @@ -10765,6 +10803,7 @@ def test_get_recommendation_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10813,6 +10852,7 @@ def test_mark_recommendation_claimed_rest_bad_request( 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.mark_recommendation_claimed(request) @@ -10855,6 +10895,7 @@ def test_mark_recommendation_claimed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_claimed(request) # Establish that the response is the type that we expect. @@ -10900,6 +10941,7 @@ def test_mark_recommendation_claimed_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -10948,6 +10990,7 @@ def test_mark_recommendation_succeeded_rest_bad_request( 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.mark_recommendation_succeeded(request) @@ -10990,6 +11033,7 @@ def test_mark_recommendation_succeeded_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_succeeded(request) # Establish that the response is the type that we expect. @@ -11035,6 +11079,7 @@ def test_mark_recommendation_succeeded_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -11083,6 +11128,7 @@ def test_mark_recommendation_failed_rest_bad_request( 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.mark_recommendation_failed(request) @@ -11125,6 +11171,7 @@ def test_mark_recommendation_failed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.mark_recommendation_failed(request) # Establish that the response is the type that we expect. @@ -11170,6 +11217,7 @@ def test_mark_recommendation_failed_rest_interceptors(null_interceptor): 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 = recommendation.Recommendation.to_json( recommendation.Recommendation() ) @@ -11218,6 +11266,7 @@ def test_get_recommender_config_rest_bad_request( 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_recommender_config(request) @@ -11258,6 +11307,7 @@ def test_get_recommender_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommender_config(request) # Establish that the response is the type that we expect. @@ -11301,6 +11351,7 @@ def test_get_recommender_config_rest_interceptors(null_interceptor): 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 = recommender_config.RecommenderConfig.to_json( recommender_config.RecommenderConfig() ) @@ -11351,6 +11402,7 @@ def test_update_recommender_config_rest_bad_request( 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_recommender_config(request) @@ -11471,6 +11523,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommender_config(request) # Establish that the response is the type that we expect. @@ -11514,6 +11567,7 @@ def test_update_recommender_config_rest_interceptors(null_interceptor): 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 = gcr_recommender_config.RecommenderConfig.to_json( gcr_recommender_config.RecommenderConfig() ) @@ -11562,6 +11616,7 @@ def test_get_insight_type_config_rest_bad_request( 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_insight_type_config(request) @@ -11602,6 +11657,7 @@ def test_get_insight_type_config_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight_type_config(request) # Establish that the response is the type that we expect. @@ -11645,6 +11701,7 @@ def test_get_insight_type_config_rest_interceptors(null_interceptor): 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 = insight_type_config.InsightTypeConfig.to_json( insight_type_config.InsightTypeConfig() ) @@ -11695,6 +11752,7 @@ def test_update_insight_type_config_rest_bad_request( 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_insight_type_config(request) @@ -11815,6 +11873,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight_type_config(request) # Establish that the response is the type that we expect. @@ -11858,6 +11917,7 @@ def test_update_insight_type_config_rest_interceptors(null_interceptor): 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 = gcr_insight_type_config.InsightTypeConfig.to_json( gcr_insight_type_config.InsightTypeConfig() ) @@ -11904,6 +11964,7 @@ def test_list_recommenders_rest_bad_request( 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_recommenders(request) @@ -11939,6 +12000,7 @@ def test_list_recommenders_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_recommenders(request) # Establish that the response is the type that we expect. @@ -11979,6 +12041,7 @@ def test_list_recommenders_rest_interceptors(null_interceptor): 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 = recommender_service.ListRecommendersResponse.to_json( recommender_service.ListRecommendersResponse() ) @@ -12025,6 +12088,7 @@ def test_list_insight_types_rest_bad_request( 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_insight_types(request) @@ -12060,6 +12124,7 @@ def test_list_insight_types_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_insight_types(request) # Establish that the response is the type that we expect. @@ -12100,6 +12165,7 @@ def test_list_insight_types_rest_interceptors(null_interceptor): 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 = recommender_service.ListInsightTypesResponse.to_json( recommender_service.ListInsightTypesResponse() ) diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster/gapic_version.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster/gapic_version.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/gapic_version.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/gapic_version.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/async_client.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/async_client.py index 51d889d7c98d..fb648e78d281 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/async_client.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport from .transports.grpc_asyncio import CloudRedisClusterGrpcAsyncIOTransport +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 CloudRedisClusterAsyncClient: """Configures and manages Cloud Memorystore for Redis clusters @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.redis.cluster_v1.CloudRedisClusterAsyncClient`.", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "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.redis.cluster.v1.CloudRedisCluster", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[cloud_redis_cluster.ListClustersRequest, dict]] = None, @@ -308,7 +340,7 @@ async def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersAsyncPager: r"""Lists all Redis clusters owned by a project in either the specified location (region) or all locations. @@ -363,8 +395,10 @@ async def sample_list_clusters(): 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, 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: google.cloud.redis_cluster_v1.services.cloud_redis_cluster.pagers.ListClustersAsyncPager: @@ -438,7 +472,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Gets the details of a specific Redis cluster. @@ -482,8 +516,10 @@ async def sample_get_cluster(): 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, 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: google.cloud.redis_cluster_v1.types.Cluster: @@ -543,7 +579,7 @@ async def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the metadata and configuration of a specific Redis cluster. @@ -611,8 +647,10 @@ async def sample_update_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -688,7 +726,7 @@ async def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a specific Redis cluster. Cluster stops serving and data is deleted. @@ -737,8 +775,10 @@ async def sample_delete_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -819,7 +859,7 @@ async def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and @@ -904,8 +944,10 @@ async def sample_create_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -983,7 +1025,7 @@ async def get_cluster_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Gets the details of certificate authority information for Redis cluster. @@ -1030,8 +1072,10 @@ async def sample_get_cluster_certificate_authority(): 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, 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: google.cloud.redis_cluster_v1.types.CertificateAuthority: @@ -1091,7 +1135,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1102,8 +1146,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1144,7 +1190,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1155,8 +1201,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1197,7 +1245,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1213,8 +1261,10 @@ async def delete_operation( 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, 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: None """ @@ -1251,7 +1301,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1266,8 +1316,10 @@ async def cancel_operation( 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, 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: None """ @@ -1304,7 +1356,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1315,8 +1367,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1357,7 +1411,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1368,8 +1422,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/client.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/client.py index 69db7419de72..21cf424a0ca4 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/client.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -641,6 +651,10 @@ def __init__( # 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( @@ -707,6 +721,29 @@ def __init__( 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.redis.cluster_v1.CloudRedisClusterClient`.", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "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.redis.cluster.v1.CloudRedisCluster", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[cloud_redis_cluster.ListClustersRequest, dict]] = None, @@ -714,7 +751,7 @@ def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersPager: r"""Lists all Redis clusters owned by a project in either the specified location (region) or all locations. @@ -769,8 +806,10 @@ def sample_list_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1.services.cloud_redis_cluster.pagers.ListClustersPager: @@ -841,7 +880,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Gets the details of a specific Redis cluster. @@ -885,8 +924,10 @@ def sample_get_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1.types.Cluster: @@ -943,7 +984,7 @@ def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the metadata and configuration of a specific Redis cluster. @@ -1011,8 +1052,10 @@ def sample_update_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1085,7 +1128,7 @@ def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a specific Redis cluster. Cluster stops serving and data is deleted. @@ -1134,8 +1177,10 @@ def sample_delete_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1213,7 +1258,7 @@ def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and @@ -1298,8 +1343,10 @@ def sample_create_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1374,7 +1421,7 @@ def get_cluster_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Gets the details of certificate authority information for Redis cluster. @@ -1421,8 +1468,10 @@ def sample_get_cluster_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1.types.CertificateAuthority: @@ -1494,7 +1543,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1505,8 +1554,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1547,7 +1598,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1558,8 +1609,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1600,7 +1653,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1616,8 +1669,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1654,7 +1709,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1669,8 +1724,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1707,7 +1764,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1718,8 +1775,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1760,7 +1819,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1771,8 +1830,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/pagers.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/pagers.py index c6caa11b280c..8f166d332f73 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/pagers.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_redis_cluster.ListClustersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_redis_cluster.ListClustersRequest(request) diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc.py index 8be76b51d33d..10af31c026d4 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.redis_cluster_v1.types import cloud_redis_cluster from .base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport +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.redis.cluster.v1.CloudRedisCluster", + "rpcName": 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.redis.cluster.v1.CloudRedisCluster", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisClusterGrpcTransport(CloudRedisClusterTransport): """gRPC backend transport for CloudRedisCluster. @@ -209,7 +290,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +359,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -309,7 +397,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/ListClusters", request_serializer=cloud_redis_cluster.ListClustersRequest.serialize, response_deserializer=cloud_redis_cluster.ListClustersResponse.deserialize, @@ -335,7 +423,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/GetCluster", request_serializer=cloud_redis_cluster.GetClusterRequest.serialize, response_deserializer=cloud_redis_cluster.Cluster.deserialize, @@ -366,7 +454,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/UpdateCluster", request_serializer=cloud_redis_cluster.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +481,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/DeleteCluster", request_serializer=cloud_redis_cluster.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +516,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/CreateCluster", request_serializer=cloud_redis_cluster.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +549,7 @@ def get_cluster_certificate_authority( if "get_cluster_certificate_authority" not in self._stubs: self._stubs[ "get_cluster_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/GetClusterCertificateAuthority", request_serializer=cloud_redis_cluster.GetClusterCertificateAuthorityRequest.serialize, response_deserializer=cloud_redis_cluster.CertificateAuthority.deserialize, @@ -469,7 +557,7 @@ def get_cluster_certificate_authority( return self._stubs["get_cluster_certificate_authority"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -481,7 +569,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -498,7 +586,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -515,7 +603,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -534,7 +622,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -553,7 +641,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -570,7 +658,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc_asyncio.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc_asyncio.py index 774b8036f7b5..f8a1b30295e5 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc_asyncio.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.redis_cluster_v1.types import cloud_redis_cluster from .base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport from .grpc import CloudRedisClusterGrpcTransport +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.redis.cluster.v1.CloudRedisCluster", + "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.redis.cluster.v1.CloudRedisCluster", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisClusterGrpcAsyncIOTransport(CloudRedisClusterTransport): """gRPC AsyncIO backend transport for CloudRedisCluster. @@ -256,10 +338,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -282,7 +367,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -319,7 +404,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/ListClusters", request_serializer=cloud_redis_cluster.ListClustersRequest.serialize, response_deserializer=cloud_redis_cluster.ListClustersResponse.deserialize, @@ -347,7 +432,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/GetCluster", request_serializer=cloud_redis_cluster.GetClusterRequest.serialize, response_deserializer=cloud_redis_cluster.Cluster.deserialize, @@ -380,7 +465,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/UpdateCluster", request_serializer=cloud_redis_cluster.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -409,7 +494,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/DeleteCluster", request_serializer=cloud_redis_cluster.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/CreateCluster", request_serializer=cloud_redis_cluster.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def get_cluster_certificate_authority( if "get_cluster_certificate_authority" not in self._stubs: self._stubs[ "get_cluster_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1.CloudRedisCluster/GetClusterCertificateAuthority", request_serializer=cloud_redis_cluster.GetClusterCertificateAuthorityRequest.serialize, response_deserializer=cloud_redis_cluster.CertificateAuthority.deserialize, @@ -557,7 +642,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -573,7 +658,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -590,7 +675,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -607,7 +692,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -626,7 +711,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -645,7 +730,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -662,7 +747,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/rest.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/rest.py index 1c0659689366..8b2a43ddb877 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/rest.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1/services/cloud_redis_cluster/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -119,8 +127,11 @@ def post_update_cluster(self, response): def pre_create_cluster( self, request: cloud_redis_cluster.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.CreateClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -142,8 +153,11 @@ def post_create_cluster( def pre_delete_cluster( self, request: cloud_redis_cluster.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.DeleteClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -165,8 +179,10 @@ def post_delete_cluster( def pre_get_cluster( self, request: cloud_redis_cluster.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -188,10 +204,10 @@ def post_get_cluster( def pre_get_cluster_certificate_authority( self, request: cloud_redis_cluster.GetClusterCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ cloud_redis_cluster.GetClusterCertificateAuthorityRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_cluster_certificate_authority @@ -214,8 +230,10 @@ def post_get_cluster_certificate_authority( def pre_list_clusters( self, request: cloud_redis_cluster.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -237,8 +255,11 @@ def post_list_clusters( def pre_update_cluster( self, request: cloud_redis_cluster.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.UpdateClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -260,8 +281,10 @@ def post_update_cluster( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -283,8 +306,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -306,8 +331,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -327,8 +354,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -348,8 +377,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -371,8 +402,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -594,7 +627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -604,8 +637,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -618,6 +653,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -632,6 +668,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.CreateCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._CreateCluster._get_response( self._host, @@ -651,7 +714,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.redis.cluster_v1.CloudRedisClusterClient.create_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -689,7 +774,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -699,8 +784,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -713,6 +800,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -723,6 +811,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._DeleteCluster._get_response( self._host, @@ -741,7 +856,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.redis.cluster_v1.CloudRedisClusterClient.delete_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -778,7 +915,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Call the get cluster method over HTTP. @@ -788,8 +925,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.Cluster: @@ -799,6 +938,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -809,6 +949,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.GetCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetCluster._get_response( self._host, @@ -829,7 +996,29 @@ def __call__( pb_resp = cloud_redis_cluster.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.Cluster.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.redis.cluster_v1.CloudRedisClusterClient.get_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClusterCertificateAuthority( @@ -867,7 +1056,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Call the get cluster certificate authority method over HTTP. @@ -879,8 +1068,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.CertificateAuthority: @@ -890,6 +1081,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetClusterCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster_certificate_authority( request, metadata ) @@ -902,6 +1094,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.GetClusterCertificateAuthority", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetClusterCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetClusterCertificateAuthority._get_response( self._host, @@ -922,7 +1141,31 @@ def __call__( pb_resp = cloud_redis_cluster.CertificateAuthority.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster_certificate_authority(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.CertificateAuthority.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.redis.cluster_v1.CloudRedisClusterClient.get_cluster_certificate_authority", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetClusterCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -959,7 +1202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -969,8 +1212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.ListClustersResponse: @@ -980,6 +1225,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -990,6 +1236,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.ListClusters", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListClusters._get_response( self._host, @@ -1010,7 +1283,31 @@ def __call__( pb_resp = cloud_redis_cluster.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.ListClustersResponse.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.redis.cluster_v1.CloudRedisClusterClient.list_clusters", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -1049,7 +1346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -1059,8 +1356,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1073,6 +1372,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -1087,6 +1387,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._UpdateCluster._get_response( self._host, @@ -1106,7 +1433,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.redis.cluster_v1.CloudRedisClusterClient.update_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1201,7 +1550,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1211,8 +1560,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1221,6 +1572,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1231,6 +1583,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetLocation._get_response( self._host, @@ -1250,6 +1629,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.redis.cluster_v1.CloudRedisClusterAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1291,7 +1691,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1301,8 +1701,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1311,6 +1713,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1321,6 +1724,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListLocations._get_response( self._host, @@ -1340,6 +1770,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.redis.cluster_v1.CloudRedisClusterAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1381,7 +1832,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1391,13 +1842,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisClusterRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1410,6 +1864,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.CancelOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._CancelOperation._get_response( self._host, @@ -1466,7 +1947,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1476,13 +1957,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisClusterRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1495,6 +1979,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._DeleteOperation._get_response( self._host, @@ -1550,7 +2061,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1560,8 +2071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1570,6 +2083,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1580,6 +2094,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetOperation._get_response( self._host, @@ -1599,6 +2140,27 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1640,7 +2202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1650,8 +2212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1660,6 +2224,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1670,6 +2235,33 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListOperations._get_response( self._host, @@ -1689,6 +2281,27 @@ def __call__( 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.redis.cluster_v1.CloudRedisClusterAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1.CloudRedisCluster", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/gapic_version.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/gapic_version.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/async_client.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/async_client.py index 7a209fb1d5f3..24e0cd182052 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/async_client.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport from .transports.grpc_asyncio import CloudRedisClusterGrpcAsyncIOTransport +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 CloudRedisClusterAsyncClient: """Configures and manages Cloud Memorystore for Redis clusters @@ -301,6 +311,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.redis.cluster_v1beta1.CloudRedisClusterAsyncClient`.", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "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.redis.cluster.v1beta1.CloudRedisCluster", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[cloud_redis_cluster.ListClustersRequest, dict]] = None, @@ -308,7 +340,7 @@ async def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersAsyncPager: r"""Lists all Redis clusters owned by a project in either the specified location (region) or all locations. @@ -363,8 +395,10 @@ async def sample_list_clusters(): 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, 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: google.cloud.redis_cluster_v1beta1.services.cloud_redis_cluster.pagers.ListClustersAsyncPager: @@ -438,7 +472,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Gets the details of a specific Redis cluster. @@ -482,8 +516,10 @@ async def sample_get_cluster(): 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, 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: google.cloud.redis_cluster_v1beta1.types.Cluster: @@ -543,7 +579,7 @@ async def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the metadata and configuration of a specific Redis cluster. @@ -611,8 +647,10 @@ async def sample_update_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -688,7 +726,7 @@ async def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a specific Redis cluster. Cluster stops serving and data is deleted. @@ -737,8 +775,10 @@ async def sample_delete_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -819,7 +859,7 @@ async def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and @@ -904,8 +944,10 @@ async def sample_create_cluster(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -983,7 +1025,7 @@ async def get_cluster_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Gets the details of certificate authority information for Redis cluster. @@ -1030,8 +1072,10 @@ async def sample_get_cluster_certificate_authority(): 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, 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: google.cloud.redis_cluster_v1beta1.types.CertificateAuthority: @@ -1091,7 +1135,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1102,8 +1146,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1144,7 +1190,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1155,8 +1201,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1197,7 +1245,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1213,8 +1261,10 @@ async def delete_operation( 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, 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: None """ @@ -1251,7 +1301,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1266,8 +1316,10 @@ async def cancel_operation( 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, 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: None """ @@ -1304,7 +1356,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1315,8 +1367,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -1357,7 +1411,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1368,8 +1422,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/client.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/client.py index 6d523c048087..d06e8d2d505a 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/client.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -641,6 +651,10 @@ def __init__( # 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( @@ -707,6 +721,29 @@ def __init__( 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.redis.cluster_v1beta1.CloudRedisClusterClient`.", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "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.redis.cluster.v1beta1.CloudRedisCluster", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[cloud_redis_cluster.ListClustersRequest, dict]] = None, @@ -714,7 +751,7 @@ def list_clusters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListClustersPager: r"""Lists all Redis clusters owned by a project in either the specified location (region) or all locations. @@ -769,8 +806,10 @@ def sample_list_clusters(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1beta1.services.cloud_redis_cluster.pagers.ListClustersPager: @@ -841,7 +880,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Gets the details of a specific Redis cluster. @@ -885,8 +924,10 @@ def sample_get_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1beta1.types.Cluster: @@ -943,7 +984,7 @@ def update_cluster( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the metadata and configuration of a specific Redis cluster. @@ -1011,8 +1052,10 @@ def sample_update_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1085,7 +1128,7 @@ def delete_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a specific Redis cluster. Cluster stops serving and data is deleted. @@ -1134,8 +1177,10 @@ def sample_delete_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1213,7 +1258,7 @@ def create_cluster( cluster_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and @@ -1298,8 +1343,10 @@ def sample_create_cluster(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1374,7 +1421,7 @@ def get_cluster_certificate_authority( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Gets the details of certificate authority information for Redis cluster. @@ -1421,8 +1468,10 @@ def sample_get_cluster_certificate_authority(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_cluster_v1beta1.types.CertificateAuthority: @@ -1494,7 +1543,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1505,8 +1554,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1547,7 +1598,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1558,8 +1609,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1600,7 +1653,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1616,8 +1669,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1654,7 +1709,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1669,8 +1724,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -1707,7 +1764,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -1718,8 +1775,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -1760,7 +1819,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -1771,8 +1830,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/pagers.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/pagers.py index 552f00641a4c..1e80ee4a2e4f 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/pagers.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_redis_cluster.ListClustersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_redis_cluster.ListClustersRequest(request) diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc.py index 0a4571230163..b53d2adf0e70 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.redis_cluster_v1beta1.types import cloud_redis_cluster from .base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport +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.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": 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.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisClusterGrpcTransport(CloudRedisClusterTransport): """gRPC backend transport for CloudRedisCluster. @@ -209,7 +290,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -273,7 +359,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -309,7 +397,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/ListClusters", request_serializer=cloud_redis_cluster.ListClustersRequest.serialize, response_deserializer=cloud_redis_cluster.ListClustersResponse.deserialize, @@ -335,7 +423,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/GetCluster", request_serializer=cloud_redis_cluster.GetClusterRequest.serialize, response_deserializer=cloud_redis_cluster.Cluster.deserialize, @@ -366,7 +454,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/UpdateCluster", request_serializer=cloud_redis_cluster.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +481,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/DeleteCluster", request_serializer=cloud_redis_cluster.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +516,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/CreateCluster", request_serializer=cloud_redis_cluster.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +549,7 @@ def get_cluster_certificate_authority( if "get_cluster_certificate_authority" not in self._stubs: self._stubs[ "get_cluster_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/GetClusterCertificateAuthority", request_serializer=cloud_redis_cluster.GetClusterCertificateAuthorityRequest.serialize, response_deserializer=cloud_redis_cluster.CertificateAuthority.deserialize, @@ -469,7 +557,7 @@ def get_cluster_certificate_authority( return self._stubs["get_cluster_certificate_authority"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -481,7 +569,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -498,7 +586,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -515,7 +603,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -534,7 +622,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -553,7 +641,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -570,7 +658,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc_asyncio.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc_asyncio.py index b1fc12751d6e..18809713fd2d 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc_asyncio.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.redis_cluster_v1beta1.types import cloud_redis_cluster from .base import DEFAULT_CLIENT_INFO, CloudRedisClusterTransport from .grpc import CloudRedisClusterGrpcTransport +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.redis.cluster.v1beta1.CloudRedisCluster", + "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.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisClusterGrpcAsyncIOTransport(CloudRedisClusterTransport): """gRPC AsyncIO backend transport for CloudRedisCluster. @@ -256,10 +338,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -282,7 +367,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -319,7 +404,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/ListClusters", request_serializer=cloud_redis_cluster.ListClustersRequest.serialize, response_deserializer=cloud_redis_cluster.ListClustersResponse.deserialize, @@ -347,7 +432,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/GetCluster", request_serializer=cloud_redis_cluster.GetClusterRequest.serialize, response_deserializer=cloud_redis_cluster.Cluster.deserialize, @@ -380,7 +465,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/UpdateCluster", request_serializer=cloud_redis_cluster.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -409,7 +494,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/DeleteCluster", request_serializer=cloud_redis_cluster.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/CreateCluster", request_serializer=cloud_redis_cluster.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def get_cluster_certificate_authority( if "get_cluster_certificate_authority" not in self._stubs: self._stubs[ "get_cluster_certificate_authority" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.redis.cluster.v1beta1.CloudRedisCluster/GetClusterCertificateAuthority", request_serializer=cloud_redis_cluster.GetClusterCertificateAuthorityRequest.serialize, response_deserializer=cloud_redis_cluster.CertificateAuthority.deserialize, @@ -557,7 +642,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -573,7 +658,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -590,7 +675,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -607,7 +692,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -626,7 +711,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -645,7 +730,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -662,7 +747,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/rest.py b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/rest.py index a86975b08c8f..2578278227c1 100644 --- a/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/rest.py +++ b/packages/google-cloud-redis-cluster/google/cloud/redis_cluster_v1beta1/services/cloud_redis_cluster/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -119,8 +127,11 @@ def post_update_cluster(self, response): def pre_create_cluster( self, request: cloud_redis_cluster.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.CreateClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -142,8 +153,11 @@ def post_create_cluster( def pre_delete_cluster( self, request: cloud_redis_cluster.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.DeleteClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -165,8 +179,10 @@ def post_delete_cluster( def pre_get_cluster( self, request: cloud_redis_cluster.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -188,10 +204,10 @@ def post_get_cluster( def pre_get_cluster_certificate_authority( self, request: cloud_redis_cluster.GetClusterCertificateAuthorityRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ cloud_redis_cluster.GetClusterCertificateAuthorityRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_cluster_certificate_authority @@ -214,8 +230,10 @@ def post_get_cluster_certificate_authority( def pre_list_clusters( self, request: cloud_redis_cluster.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -237,8 +255,11 @@ def post_list_clusters( def pre_update_cluster( self, request: cloud_redis_cluster.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis_cluster.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis_cluster.UpdateClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -260,8 +281,10 @@ def post_update_cluster( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -283,8 +306,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -306,8 +331,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -327,8 +354,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -348,8 +377,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -371,8 +402,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -594,7 +627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -604,8 +637,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -618,6 +653,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -632,6 +668,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.CreateCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._CreateCluster._get_response( self._host, @@ -651,7 +714,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.redis.cluster_v1beta1.CloudRedisClusterClient.create_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -689,7 +774,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -699,8 +784,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -713,6 +800,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -723,6 +811,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._DeleteCluster._get_response( self._host, @@ -741,7 +856,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.redis.cluster_v1beta1.CloudRedisClusterClient.delete_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -778,7 +915,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.Cluster: r"""Call the get cluster method over HTTP. @@ -788,8 +925,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.Cluster: @@ -799,6 +938,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetCluster._get_transcoded_request( http_options, request @@ -809,6 +949,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.GetCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetCluster._get_response( self._host, @@ -829,7 +996,29 @@ def __call__( pb_resp = cloud_redis_cluster.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.Cluster.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.redis.cluster_v1beta1.CloudRedisClusterClient.get_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClusterCertificateAuthority( @@ -867,7 +1056,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.CertificateAuthority: r"""Call the get cluster certificate authority method over HTTP. @@ -879,8 +1068,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.CertificateAuthority: @@ -890,6 +1081,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetClusterCertificateAuthority._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster_certificate_authority( request, metadata ) @@ -902,6 +1094,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.GetClusterCertificateAuthority", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetClusterCertificateAuthority", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetClusterCertificateAuthority._get_response( self._host, @@ -922,7 +1141,31 @@ def __call__( pb_resp = cloud_redis_cluster.CertificateAuthority.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster_certificate_authority(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.CertificateAuthority.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.redis.cluster_v1beta1.CloudRedisClusterClient.get_cluster_certificate_authority", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetClusterCertificateAuthority", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -959,7 +1202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis_cluster.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -969,8 +1212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis_cluster.ListClustersResponse: @@ -980,6 +1225,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -990,6 +1236,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.ListClusters", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListClusters._get_response( self._host, @@ -1010,7 +1283,31 @@ def __call__( pb_resp = cloud_redis_cluster.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis_cluster.ListClustersResponse.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.redis.cluster_v1beta1.CloudRedisClusterClient.list_clusters", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -1049,7 +1346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -1059,8 +1356,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1073,6 +1372,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -1087,6 +1387,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._UpdateCluster._get_response( self._host, @@ -1106,7 +1433,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.redis.cluster_v1beta1.CloudRedisClusterClient.update_cluster", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1201,7 +1550,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1211,8 +1560,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1221,6 +1572,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1231,6 +1583,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetLocation._get_response( self._host, @@ -1250,6 +1629,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.redis.cluster_v1beta1.CloudRedisClusterAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1291,7 +1691,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1301,8 +1701,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1311,6 +1713,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1321,6 +1724,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListLocations._get_response( self._host, @@ -1340,6 +1770,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.redis.cluster_v1beta1.CloudRedisClusterAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1381,7 +1832,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1391,13 +1842,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisClusterRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1410,6 +1864,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.CancelOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._CancelOperation._get_response( self._host, @@ -1466,7 +1947,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1476,13 +1957,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisClusterRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1495,6 +1979,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._DeleteOperation._get_response( self._host, @@ -1550,7 +2061,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1560,8 +2071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1570,6 +2083,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1580,6 +2094,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._GetOperation._get_response( self._host, @@ -1599,6 +2140,27 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1640,7 +2202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1650,8 +2212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1660,6 +2224,7 @@ def __call__( http_options = ( _BaseCloudRedisClusterRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCloudRedisClusterRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1670,6 +2235,33 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisClusterRestTransport._ListOperations._get_response( self._host, @@ -1689,6 +2281,27 @@ def __call__( 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.redis.cluster_v1beta1.CloudRedisClusterAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.cluster.v1beta1.CloudRedisCluster", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1.json b/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1.json index 4b2d29fd84d8..e63fbaacc385 100644 --- a/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1.json +++ b/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-redis-cluster", - "version": "0.1.10" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.types.CertificateAuthority", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.types.CertificateAuthority", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.types.Cluster", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.types.Cluster", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.services.cloud_redis_cluster.pagers.ListClustersAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1.services.cloud_redis_cluster.pagers.ListClustersPager", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1beta1.json b/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1beta1.json index 4760e34e310f..65c1106a88db 100644 --- a/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1beta1.json +++ b/packages/google-cloud-redis-cluster/samples/generated_samples/snippet_metadata_google.cloud.redis.cluster.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-redis-cluster", - "version": "0.1.10" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.types.CertificateAuthority", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.types.CertificateAuthority", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.types.Cluster", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.types.Cluster", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.services.cloud_redis_cluster.pagers.ListClustersAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_cluster_v1beta1.services.cloud_redis_cluster.pagers.ListClustersPager", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1/test_cloud_redis_cluster.py b/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1/test_cloud_redis_cluster.py index 5fdb46860d8c..4da6af6a0ea7 100644 --- a/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1/test_cloud_redis_cluster.py +++ b/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1/test_cloud_redis_cluster.py @@ -3484,6 +3484,7 @@ def test_list_clusters_rest_required_fields( response_value._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_clusters(request) @@ -3537,6 +3538,7 @@ def test_list_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clusters(**mock_args) @@ -3730,6 +3732,7 @@ def test_get_cluster_rest_required_fields( response_value._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_cluster(request) @@ -3775,6 +3778,7 @@ def test_get_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -3909,6 +3913,7 @@ def test_update_cluster_rest_required_fields( response_value._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_cluster(request) @@ -3968,6 +3973,7 @@ def test_update_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4103,6 +4109,7 @@ def test_delete_cluster_rest_required_fields( response_value._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_cluster(request) @@ -4146,6 +4153,7 @@ def test_delete_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4292,6 +4300,7 @@ def test_create_cluster_rest_required_fields( response_value._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_cluster(request) @@ -4357,6 +4366,7 @@ def test_create_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4494,6 +4504,7 @@ def test_get_cluster_certificate_authority_rest_required_fields( response_value._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_cluster_certificate_authority(request) @@ -4543,6 +4554,7 @@ def test_get_cluster_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster_certificate_authority(**mock_args) @@ -5019,6 +5031,7 @@ def test_list_clusters_rest_bad_request( 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_clusters(request) @@ -5055,6 +5068,7 @@ def test_list_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clusters(request) # Establish that the response is the type that we expect. @@ -5096,6 +5110,7 @@ def test_list_clusters_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.ListClustersResponse.to_json( cloud_redis_cluster.ListClustersResponse() ) @@ -5142,6 +5157,7 @@ def test_get_cluster_rest_bad_request( 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_cluster(request) @@ -5187,6 +5203,7 @@ def test_get_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5243,6 +5260,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.Cluster.to_json( cloud_redis_cluster.Cluster() ) @@ -5291,6 +5309,7 @@ def test_update_cluster_rest_bad_request( 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_cluster(request) @@ -5427,6 +5446,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5468,6 +5488,7 @@ def test_update_cluster_rest_interceptors(null_interceptor): 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 @@ -5512,6 +5533,7 @@ def test_delete_cluster_rest_bad_request( 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_cluster(request) @@ -5542,6 +5564,7 @@ def test_delete_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5583,6 +5606,7 @@ def test_delete_cluster_rest_interceptors(null_interceptor): 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 @@ -5627,6 +5651,7 @@ def test_create_cluster_rest_bad_request( 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_cluster(request) @@ -5761,6 +5786,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5802,6 +5828,7 @@ def test_create_cluster_rest_interceptors(null_interceptor): 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 @@ -5848,6 +5875,7 @@ def test_get_cluster_certificate_authority_rest_bad_request( 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_cluster_certificate_authority(request) @@ -5885,6 +5913,7 @@ def test_get_cluster_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster_certificate_authority(request) # Establish that the response is the type that we expect. @@ -5927,6 +5956,7 @@ def test_get_cluster_certificate_authority_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.CertificateAuthority.to_json( cloud_redis_cluster.CertificateAuthority() ) @@ -5973,6 +6003,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -6003,6 +6034,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -6031,6 +6063,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -6061,6 +6094,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -6091,6 +6125,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -6121,6 +6156,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -6151,6 +6187,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -6181,6 +6218,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -6211,6 +6249,7 @@ def test_get_operation_rest_bad_request( 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) @@ -6241,6 +6280,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -6271,6 +6311,7 @@ def test_list_operations_rest_bad_request( 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) @@ -6301,6 +6342,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1beta1/test_cloud_redis_cluster.py b/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1beta1/test_cloud_redis_cluster.py index d520191b1aec..9b5986dc0140 100644 --- a/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1beta1/test_cloud_redis_cluster.py +++ b/packages/google-cloud-redis-cluster/tests/unit/gapic/redis_cluster_v1beta1/test_cloud_redis_cluster.py @@ -3484,6 +3484,7 @@ def test_list_clusters_rest_required_fields( response_value._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_clusters(request) @@ -3537,6 +3538,7 @@ def test_list_clusters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_clusters(**mock_args) @@ -3731,6 +3733,7 @@ def test_get_cluster_rest_required_fields( response_value._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_cluster(request) @@ -3776,6 +3779,7 @@ def test_get_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -3911,6 +3915,7 @@ def test_update_cluster_rest_required_fields( response_value._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_cluster(request) @@ -3970,6 +3975,7 @@ def test_update_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4105,6 +4111,7 @@ def test_delete_cluster_rest_required_fields( response_value._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_cluster(request) @@ -4148,6 +4155,7 @@ def test_delete_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4295,6 +4303,7 @@ def test_create_cluster_rest_required_fields( response_value._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_cluster(request) @@ -4360,6 +4369,7 @@ def test_create_cluster_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster(**mock_args) @@ -4498,6 +4508,7 @@ def test_get_cluster_certificate_authority_rest_required_fields( response_value._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_cluster_certificate_authority(request) @@ -4547,6 +4558,7 @@ def test_get_cluster_certificate_authority_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_cluster_certificate_authority(**mock_args) @@ -5023,6 +5035,7 @@ def test_list_clusters_rest_bad_request( 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_clusters(request) @@ -5059,6 +5072,7 @@ def test_list_clusters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_clusters(request) # Establish that the response is the type that we expect. @@ -5100,6 +5114,7 @@ def test_list_clusters_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.ListClustersResponse.to_json( cloud_redis_cluster.ListClustersResponse() ) @@ -5146,6 +5161,7 @@ def test_get_cluster_rest_bad_request( 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_cluster(request) @@ -5191,6 +5207,7 @@ def test_get_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5247,6 +5264,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.Cluster.to_json( cloud_redis_cluster.Cluster() ) @@ -5295,6 +5313,7 @@ def test_update_cluster_rest_bad_request( 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_cluster(request) @@ -5431,6 +5450,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5472,6 +5492,7 @@ def test_update_cluster_rest_interceptors(null_interceptor): 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 @@ -5516,6 +5537,7 @@ def test_delete_cluster_rest_bad_request( 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_cluster(request) @@ -5546,6 +5568,7 @@ def test_delete_cluster_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5587,6 +5610,7 @@ def test_delete_cluster_rest_interceptors(null_interceptor): 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 @@ -5631,6 +5655,7 @@ def test_create_cluster_rest_bad_request( 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_cluster(request) @@ -5765,6 +5790,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster(request) # Establish that the response is the type that we expect. @@ -5806,6 +5832,7 @@ def test_create_cluster_rest_interceptors(null_interceptor): 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 @@ -5852,6 +5879,7 @@ def test_get_cluster_certificate_authority_rest_bad_request( 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_cluster_certificate_authority(request) @@ -5889,6 +5917,7 @@ def test_get_cluster_certificate_authority_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_cluster_certificate_authority(request) # Establish that the response is the type that we expect. @@ -5931,6 +5960,7 @@ def test_get_cluster_certificate_authority_rest_interceptors(null_interceptor): 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 = cloud_redis_cluster.CertificateAuthority.to_json( cloud_redis_cluster.CertificateAuthority() ) @@ -5977,6 +6007,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -6007,6 +6038,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -6035,6 +6067,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -6065,6 +6098,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -6095,6 +6129,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -6125,6 +6160,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -6155,6 +6191,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -6185,6 +6222,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -6215,6 +6253,7 @@ def test_get_operation_rest_bad_request( 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) @@ -6245,6 +6284,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -6275,6 +6315,7 @@ def test_list_operations_rest_bad_request( 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) @@ -6305,6 +6346,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-redis/google/cloud/redis/gapic_version.py b/packages/google-cloud-redis/google/cloud/redis/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-redis/google/cloud/redis/gapic_version.py +++ b/packages/google-cloud-redis/google/cloud/redis/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/gapic_version.py b/packages/google-cloud-redis/google/cloud/redis_v1/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/gapic_version.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/async_client.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/async_client.py index 2d8f440212ec..de10d33f58e0 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/async_client.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudRedisTransport from .transports.grpc_asyncio import CloudRedisGrpcAsyncIOTransport +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 CloudRedisAsyncClient: """Configures and manages Cloud Memorystore for Redis instances @@ -277,6 +287,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.redis_v1.CloudRedisAsyncClient`.", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "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.redis.v1.CloudRedis", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, @@ -284,7 +316,7 @@ async def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists all Redis instances owned by a project in either the specified location (region) or all locations. @@ -340,8 +372,10 @@ async def sample_list_instances(): 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, 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: google.cloud.redis_v1.services.cloud_redis.pagers.ListInstancesAsyncPager: @@ -416,7 +450,7 @@ async def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Gets the details of a specific Redis instance. @@ -461,8 +495,10 @@ async def sample_get_instance(): 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, 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: google.cloud.redis_v1.types.Instance: @@ -521,7 +557,7 @@ async def get_instance_auth_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. @@ -569,8 +605,10 @@ async def sample_get_instance_auth_string(): 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, 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: google.cloud.redis_v1.types.InstanceAuthString: @@ -631,7 +669,7 @@ async def create_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Redis instance based on the specified tier and memory size. @@ -720,8 +758,10 @@ async def sample_create_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -798,7 +838,7 @@ async def update_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the metadata and configuration of a specific Redis instance. @@ -871,8 +911,10 @@ async def sample_update_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -949,7 +991,7 @@ async def upgrade_instance( redis_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Upgrades Redis instance to the newer Redis version specified in the request. @@ -1007,8 +1049,10 @@ async def sample_upgrade_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1083,7 +1127,7 @@ async def import_instance( input_config: Optional[cloud_redis.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. @@ -1151,8 +1195,10 @@ async def sample_import_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1227,7 +1273,7 @@ async def export_instance( output_config: Optional[cloud_redis.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Export Redis instance data into a Redis RDB format file in Cloud Storage. @@ -1292,8 +1338,10 @@ async def sample_export_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1370,7 +1418,7 @@ async def failover_instance( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud @@ -1429,8 +1477,10 @@ async def sample_failover_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1504,7 +1554,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a specific Redis instance. Instance stops serving and data is deleted. @@ -1554,8 +1604,10 @@ async def sample_delete_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1638,7 +1690,7 @@ async def reschedule_maintenance( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Reschedule maintenance for a given instance in a given project and location. @@ -1704,8 +1756,10 @@ async def sample_reschedule_maintenance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1780,7 +1834,7 @@ async def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1791,8 +1845,10 @@ async def list_operations( 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, 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1833,7 +1889,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1844,8 +1900,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1886,7 +1944,7 @@ async def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1902,8 +1960,10 @@ async def delete_operation( 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, 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: None """ @@ -1940,7 +2000,7 @@ async def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1955,8 +2015,10 @@ async def cancel_operation( 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, 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: None """ @@ -1993,7 +2055,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2004,8 +2066,10 @@ async def get_location( 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, 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: ~.location_pb2.Location: Location object. @@ -2046,7 +2110,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2057,8 +2121,10 @@ async def list_locations( 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, 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/client.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/client.py index a7183e652897..728d00e4a1e5 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/client.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.location import locations_pb2 # type: ignore @@ -605,6 +615,10 @@ def __init__( # 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( @@ -667,6 +681,29 @@ def __init__( 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.redis_v1.CloudRedisClient`.", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "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.redis.v1.CloudRedis", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, @@ -674,7 +711,7 @@ def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesPager: r"""Lists all Redis instances owned by a project in either the specified location (region) or all locations. @@ -730,8 +767,10 @@ def sample_list_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1.services.cloud_redis.pagers.ListInstancesPager: @@ -803,7 +842,7 @@ def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Gets the details of a specific Redis instance. @@ -848,8 +887,10 @@ def sample_get_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1.types.Instance: @@ -905,7 +946,7 @@ def get_instance_auth_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. @@ -953,8 +994,10 @@ def sample_get_instance_auth_string(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1.types.InstanceAuthString: @@ -1012,7 +1055,7 @@ def create_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Redis instance based on the specified tier and memory size. @@ -1101,8 +1144,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1176,7 +1221,7 @@ def update_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the metadata and configuration of a specific Redis instance. @@ -1249,8 +1294,10 @@ def sample_update_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1324,7 +1371,7 @@ def upgrade_instance( redis_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Upgrades Redis instance to the newer Redis version specified in the request. @@ -1382,8 +1429,10 @@ def sample_upgrade_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1455,7 +1504,7 @@ def import_instance( input_config: Optional[cloud_redis.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. @@ -1523,8 +1572,10 @@ def sample_import_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1596,7 +1647,7 @@ def export_instance( output_config: Optional[cloud_redis.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Export Redis instance data into a Redis RDB format file in Cloud Storage. @@ -1661,8 +1712,10 @@ def sample_export_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1736,7 +1789,7 @@ def failover_instance( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud @@ -1795,8 +1848,10 @@ def sample_failover_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1867,7 +1922,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a specific Redis instance. Instance stops serving and data is deleted. @@ -1917,8 +1972,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1998,7 +2055,7 @@ def reschedule_maintenance( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Reschedule maintenance for a given instance in a given project and location. @@ -2064,8 +2121,10 @@ def sample_reschedule_maintenance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -2150,7 +2209,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2161,8 +2220,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2203,7 +2264,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2214,8 +2275,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2256,7 +2319,7 @@ def delete_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a long-running operation. @@ -2272,8 +2335,10 @@ def delete_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2310,7 +2375,7 @@ def cancel_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -2325,8 +2390,10 @@ def cancel_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: None """ @@ -2363,7 +2430,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2374,8 +2441,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.Location: Location object. @@ -2416,7 +2485,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2427,8 +2496,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/pagers.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/pagers.py index 4291ea1f45e9..7942c1e56ca1 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/pagers.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_redis.ListInstancesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_redis.ListInstancesRequest(request) diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py index 5048e4f4242e..3385355475af 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.redis_v1.types import cloud_redis from .base import DEFAULT_CLIENT_INFO, CloudRedisTransport +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.redis.v1.CloudRedis", + "rpcName": 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.redis.v1.CloudRedis", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisGrpcTransport(CloudRedisTransport): """gRPC backend transport for CloudRedis. @@ -202,7 +283,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -266,7 +352,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -301,7 +389,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ListInstances", request_serializer=cloud_redis.ListInstancesRequest.serialize, response_deserializer=cloud_redis.ListInstancesResponse.deserialize, @@ -327,7 +415,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/GetInstance", request_serializer=cloud_redis.GetInstanceRequest.serialize, response_deserializer=cloud_redis.Instance.deserialize, @@ -358,7 +446,7 @@ def get_instance_auth_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance_auth_string" not in self._stubs: - self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + self._stubs["get_instance_auth_string"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/GetInstanceAuthString", request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, response_deserializer=cloud_redis.InstanceAuthString.deserialize, @@ -397,7 +485,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/CreateInstance", request_serializer=cloud_redis.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +516,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/UpdateInstance", request_serializer=cloud_redis.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -455,7 +543,7 @@ def upgrade_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_instance" not in self._stubs: - self._stubs["upgrade_instance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/UpgradeInstance", request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -489,7 +577,7 @@ def import_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_instance" not in self._stubs: - self._stubs["import_instance"] = self.grpc_channel.unary_unary( + self._stubs["import_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ImportInstance", request_serializer=cloud_redis.ImportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def export_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_instance" not in self._stubs: - self._stubs["export_instance"] = self.grpc_channel.unary_unary( + self._stubs["export_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ExportInstance", request_serializer=cloud_redis.ExportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -548,7 +636,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/FailoverInstance", request_serializer=cloud_redis.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -575,7 +663,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/DeleteInstance", request_serializer=cloud_redis.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +690,7 @@ def reschedule_maintenance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reschedule_maintenance" not in self._stubs: - self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + self._stubs["reschedule_maintenance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/RescheduleMaintenance", request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +698,7 @@ def reschedule_maintenance( return self._stubs["reschedule_maintenance"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -622,7 +710,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -639,7 +727,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -656,7 +744,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -675,7 +763,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -694,7 +782,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -711,7 +799,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py index 80737763497f..26b3f12f8425 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.redis_v1.types import cloud_redis from .base import DEFAULT_CLIENT_INFO, CloudRedisTransport from .grpc import CloudRedisGrpcTransport +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.redis.v1.CloudRedis", + "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.redis.v1.CloudRedis", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisGrpcAsyncIOTransport(CloudRedisTransport): """gRPC AsyncIO backend transport for CloudRedis. @@ -249,10 +331,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -275,7 +360,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -311,7 +396,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ListInstances", request_serializer=cloud_redis.ListInstancesRequest.serialize, response_deserializer=cloud_redis.ListInstancesResponse.deserialize, @@ -337,7 +422,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/GetInstance", request_serializer=cloud_redis.GetInstanceRequest.serialize, response_deserializer=cloud_redis.Instance.deserialize, @@ -369,7 +454,7 @@ def get_instance_auth_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance_auth_string" not in self._stubs: - self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + self._stubs["get_instance_auth_string"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/GetInstanceAuthString", request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, response_deserializer=cloud_redis.InstanceAuthString.deserialize, @@ -410,7 +495,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/CreateInstance", request_serializer=cloud_redis.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -443,7 +528,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/UpdateInstance", request_serializer=cloud_redis.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +557,7 @@ def upgrade_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_instance" not in self._stubs: - self._stubs["upgrade_instance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/UpgradeInstance", request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -508,7 +593,7 @@ def import_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_instance" not in self._stubs: - self._stubs["import_instance"] = self.grpc_channel.unary_unary( + self._stubs["import_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ImportInstance", request_serializer=cloud_redis.ImportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +626,7 @@ def export_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_instance" not in self._stubs: - self._stubs["export_instance"] = self.grpc_channel.unary_unary( + self._stubs["export_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/ExportInstance", request_serializer=cloud_redis.ExportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -571,7 +656,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/FailoverInstance", request_serializer=cloud_redis.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +685,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/DeleteInstance", request_serializer=cloud_redis.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -629,7 +714,7 @@ def reschedule_maintenance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reschedule_maintenance" not in self._stubs: - self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + self._stubs["reschedule_maintenance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1.CloudRedis/RescheduleMaintenance", request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -732,7 +817,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -748,7 +833,7 @@ def delete_operation( # 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.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -765,7 +850,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -782,7 +867,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, @@ -801,7 +886,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + 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, @@ -820,7 +905,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -837,7 +922,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py index 004b3a441adc..69c204dddbf3 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -39,6 +39,14 @@ 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, @@ -159,8 +167,10 @@ def post_upgrade_instance(self, response): def pre_create_instance( self, request: cloud_redis.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -182,8 +192,10 @@ def post_create_instance( def pre_delete_instance( self, request: cloud_redis.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -205,8 +217,10 @@ def post_delete_instance( def pre_export_instance( self, request: cloud_redis.ExportInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_instance Override in a subclass to manipulate the request or metadata @@ -228,8 +242,10 @@ def post_export_instance( def pre_failover_instance( self, request: cloud_redis.FailoverInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -251,8 +267,8 @@ def post_failover_instance( def pre_get_instance( self, request: cloud_redis.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -272,8 +288,11 @@ def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Insta def pre_get_instance_auth_string( self, request: cloud_redis.GetInstanceAuthStringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.GetInstanceAuthStringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the request or metadata @@ -295,8 +314,10 @@ def post_get_instance_auth_string( def pre_import_instance( self, request: cloud_redis.ImportInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_instance Override in a subclass to manipulate the request or metadata @@ -318,8 +339,10 @@ def post_import_instance( def pre_list_instances( self, request: cloud_redis.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -341,8 +364,11 @@ def post_list_instances( def pre_reschedule_maintenance( self, request: cloud_redis.RescheduleMaintenanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.RescheduleMaintenanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for reschedule_maintenance Override in a subclass to manipulate the request or metadata @@ -364,8 +390,10 @@ def post_reschedule_maintenance( def pre_update_instance( self, request: cloud_redis.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -387,8 +415,10 @@ def post_update_instance( def pre_upgrade_instance( self, request: cloud_redis.UpgradeInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for upgrade_instance Override in a subclass to manipulate the request or metadata @@ -410,8 +440,10 @@ def post_upgrade_instance( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -433,8 +465,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -456,8 +490,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -477,8 +513,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -498,8 +536,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -521,8 +561,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + 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 @@ -736,7 +778,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -747,8 +789,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -761,6 +805,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -779,6 +824,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.CreateInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._CreateInstance._get_response( self._host, @@ -798,7 +870,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(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.redis_v1.CloudRedisClient.create_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -835,7 +929,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -846,8 +940,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -860,6 +956,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -872,6 +969,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._DeleteInstance._get_response( self._host, @@ -890,7 +1014,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(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.redis_v1.CloudRedisClient.delete_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportInstance( @@ -928,7 +1074,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export instance method over HTTP. @@ -939,8 +1085,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -953,6 +1101,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseExportInstance._get_http_options() ) + request, metadata = self._interceptor.pre_export_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseExportInstance._get_transcoded_request( http_options, request @@ -971,6 +1120,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.ExportInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ExportInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ExportInstance._get_response( self._host, @@ -990,7 +1166,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_instance(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.redis_v1.CloudRedisClient.export_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ExportInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FailoverInstance( @@ -1028,7 +1226,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the failover instance method over HTTP. @@ -1039,8 +1237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1053,6 +1253,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseFailoverInstance._get_http_options() ) + request, metadata = self._interceptor.pre_failover_instance( request, metadata ) @@ -1069,6 +1270,33 @@ def __call__( 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.redis_v1.CloudRedisClient.FailoverInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "FailoverInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._FailoverInstance._get_response( self._host, @@ -1088,7 +1316,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_instance(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.redis_v1.CloudRedisClient.failover_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "FailoverInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -1125,7 +1375,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Call the get instance method over HTTP. @@ -1136,8 +1386,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.Instance: @@ -1147,6 +1399,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseGetInstance._get_transcoded_request( @@ -1161,6 +1414,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.GetInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetInstance._get_response( self._host, @@ -1181,7 +1461,29 @@ def __call__( pb_resp = cloud_redis.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.Instance.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.redis_v1.CloudRedisClient.get_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstanceAuthString( @@ -1218,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Call the get instance auth string method over HTTP. @@ -1229,8 +1531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.InstanceAuthString: @@ -1240,6 +1544,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetInstanceAuthString._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance_auth_string( request, metadata ) @@ -1252,6 +1557,33 @@ def __call__( 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.redis_v1.CloudRedisClient.GetInstanceAuthString", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetInstanceAuthString", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetInstanceAuthString._get_response( self._host, @@ -1272,7 +1604,29 @@ def __call__( pb_resp = cloud_redis.InstanceAuthString.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance_auth_string(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.InstanceAuthString.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.redis_v1.CloudRedisClient.get_instance_auth_string", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetInstanceAuthString", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportInstance( @@ -1310,7 +1664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import instance method over HTTP. @@ -1321,8 +1675,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1335,6 +1691,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseImportInstance._get_http_options() ) + request, metadata = self._interceptor.pre_import_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseImportInstance._get_transcoded_request( http_options, request @@ -1353,6 +1710,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.ImportInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ImportInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ImportInstance._get_response( self._host, @@ -1372,7 +1756,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_instance(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.redis_v1.CloudRedisClient.import_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ImportInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -1409,7 +1815,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -1420,8 +1826,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.ListInstancesResponse: @@ -1433,6 +1841,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseListInstances._get_transcoded_request( @@ -1447,6 +1856,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.ListInstances", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ListInstances._get_response( self._host, @@ -1467,7 +1903,31 @@ def __call__( pb_resp = cloud_redis.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.ListInstancesResponse.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.redis_v1.CloudRedisClient.list_instances", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RescheduleMaintenance( @@ -1505,7 +1965,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the reschedule maintenance method over HTTP. @@ -1516,8 +1976,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1530,6 +1992,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseRescheduleMaintenance._get_http_options() ) + request, metadata = self._interceptor.pre_reschedule_maintenance( request, metadata ) @@ -1546,6 +2009,33 @@ def __call__( 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.redis_v1.CloudRedisClient.RescheduleMaintenance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "RescheduleMaintenance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._RescheduleMaintenance._get_response( self._host, @@ -1565,7 +2055,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reschedule_maintenance(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.redis_v1.CloudRedisClient.reschedule_maintenance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "RescheduleMaintenance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -1603,7 +2115,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -1614,8 +2126,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1628,6 +2142,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -1646,6 +2161,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._UpdateInstance._get_response( self._host, @@ -1665,7 +2207,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(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.redis_v1.CloudRedisClient.update_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeInstance( @@ -1703,7 +2267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the upgrade instance method over HTTP. @@ -1714,8 +2278,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1728,6 +2294,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseUpgradeInstance._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_instance( request, metadata ) @@ -1744,6 +2311,33 @@ def __call__( 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.redis_v1.CloudRedisClient.UpgradeInstance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "UpgradeInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._UpgradeInstance._get_response( self._host, @@ -1763,7 +2357,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upgrade_instance(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.redis_v1.CloudRedisClient.upgrade_instance", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "UpgradeInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1896,7 +2512,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1906,8 +2522,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.Location: Response from GetLocation method. @@ -1916,6 +2534,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseGetLocation._get_transcoded_request( @@ -1930,6 +2549,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetLocation._get_response( self._host, @@ -1949,6 +2595,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(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.redis_v1.CloudRedisAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1989,7 +2656,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1999,8 +2666,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2009,6 +2678,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseListLocations._get_transcoded_request( @@ -2023,6 +2693,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ListLocations._get_response( self._host, @@ -2042,6 +2739,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(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.redis_v1.CloudRedisAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2082,7 +2800,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2092,13 +2810,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2111,6 +2832,33 @@ def __call__( 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.redis_v1.CloudRedisClient.CancelOperation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._CancelOperation._get_response( self._host, @@ -2166,7 +2914,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2176,13 +2924,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ http_options = ( _BaseCloudRedisRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2195,6 +2946,33 @@ def __call__( 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.redis_v1.CloudRedisClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._DeleteOperation._get_response( self._host, @@ -2250,7 +3028,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2260,8 +3038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -2270,6 +3050,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseGetOperation._get_transcoded_request( @@ -2284,6 +3065,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetOperation._get_response( self._host, @@ -2303,6 +3111,27 @@ def __call__( 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.redis_v1.CloudRedisAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2343,7 +3172,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2353,8 +3182,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2363,6 +3194,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2375,6 +3207,33 @@ def __call__( ) ) + 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.redis_v1.CloudRedisClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ListOperations._get_response( self._host, @@ -2394,6 +3253,27 @@ def __call__( 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.redis_v1.CloudRedisAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.redis.v1.CloudRedis", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/gapic_version.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/gapic_version.py index 1230672bab9e..558c8aab67c5 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/gapic_version.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py index e53aa8945e14..8f5c9258f84b 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudRedisTransport from .transports.grpc_asyncio import CloudRedisGrpcAsyncIOTransport +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 CloudRedisAsyncClient: """Configures and manages Cloud Memorystore for Redis instances @@ -276,6 +286,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.redis_v1beta1.CloudRedisAsyncClient`.", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "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.redis.v1beta1.CloudRedis", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, @@ -283,7 +315,7 @@ async def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists all Redis instances owned by a project in either the specified location (region) or all locations. @@ -339,8 +371,10 @@ async def sample_list_instances(): 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, 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: google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesAsyncPager: @@ -415,7 +449,7 @@ async def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Gets the details of a specific Redis instance. @@ -460,8 +494,10 @@ async def sample_get_instance(): 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, 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: google.cloud.redis_v1beta1.types.Instance: @@ -520,7 +556,7 @@ async def get_instance_auth_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. @@ -568,8 +604,10 @@ async def sample_get_instance_auth_string(): 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, 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: google.cloud.redis_v1beta1.types.InstanceAuthString: @@ -630,7 +668,7 @@ async def create_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Redis instance based on the specified tier and memory size. @@ -719,8 +757,10 @@ async def sample_create_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -797,7 +837,7 @@ async def update_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the metadata and configuration of a specific Redis instance. @@ -870,8 +910,10 @@ async def sample_update_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -948,7 +990,7 @@ async def upgrade_instance( redis_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Upgrades Redis instance to the newer Redis version specified in the request. @@ -1006,8 +1048,10 @@ async def sample_upgrade_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1082,7 +1126,7 @@ async def import_instance( input_config: Optional[cloud_redis.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. @@ -1150,8 +1194,10 @@ async def sample_import_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1226,7 +1272,7 @@ async def export_instance( output_config: Optional[cloud_redis.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Export Redis instance data into a Redis RDB format file in Cloud Storage. @@ -1291,8 +1337,10 @@ async def sample_export_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1369,7 +1417,7 @@ async def failover_instance( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud @@ -1428,8 +1476,10 @@ async def sample_failover_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1503,7 +1553,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a specific Redis instance. Instance stops serving and data is deleted. @@ -1553,8 +1603,10 @@ async def sample_delete_instance(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1637,7 +1689,7 @@ async def reschedule_maintenance( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Reschedule maintenance for a given instance in a given project and location. @@ -1703,8 +1755,10 @@ async def sample_reschedule_maintenance(): 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, 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: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/client.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/client.py index 3c406edbf0ef..ed5ba91a16f3 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/client.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.protobuf import any_pb2 # type: ignore @@ -604,6 +614,10 @@ def __init__( # 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( @@ -666,6 +680,29 @@ def __init__( 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.redis_v1beta1.CloudRedisClient`.", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "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.redis.v1beta1.CloudRedis", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, @@ -673,7 +710,7 @@ def list_instances( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListInstancesPager: r"""Lists all Redis instances owned by a project in either the specified location (region) or all locations. @@ -729,8 +766,10 @@ def sample_list_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesPager: @@ -802,7 +841,7 @@ def get_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Gets the details of a specific Redis instance. @@ -847,8 +886,10 @@ def sample_get_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1beta1.types.Instance: @@ -904,7 +945,7 @@ def get_instance_auth_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. @@ -952,8 +993,10 @@ def sample_get_instance_auth_string(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.redis_v1beta1.types.InstanceAuthString: @@ -1011,7 +1054,7 @@ def create_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Redis instance based on the specified tier and memory size. @@ -1100,8 +1143,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1175,7 +1220,7 @@ def update_instance( instance: Optional[cloud_redis.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the metadata and configuration of a specific Redis instance. @@ -1248,8 +1293,10 @@ def sample_update_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1323,7 +1370,7 @@ def upgrade_instance( redis_version: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Upgrades Redis instance to the newer Redis version specified in the request. @@ -1381,8 +1428,10 @@ def sample_upgrade_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1454,7 +1503,7 @@ def import_instance( input_config: Optional[cloud_redis.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. @@ -1522,8 +1571,10 @@ def sample_import_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1595,7 +1646,7 @@ def export_instance( output_config: Optional[cloud_redis.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Export Redis instance data into a Redis RDB format file in Cloud Storage. @@ -1660,8 +1711,10 @@ def sample_export_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1735,7 +1788,7 @@ def failover_instance( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud @@ -1794,8 +1847,10 @@ def sample_failover_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1866,7 +1921,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a specific Redis instance. Instance stops serving and data is deleted. @@ -1916,8 +1971,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1997,7 +2054,7 @@ def reschedule_maintenance( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Reschedule maintenance for a given instance in a given project and location. @@ -2063,8 +2120,10 @@ def sample_reschedule_maintenance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/pagers.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/pagers.py index d9e97a5f152c..e3d17ae9b5cc 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/pagers.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = cloud_redis.ListInstancesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = cloud_redis.ListInstancesRequest(request) diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py index 4b7d62bee262..c93d2e332049 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.redis_v1beta1.types import cloud_redis from .base import DEFAULT_CLIENT_INFO, CloudRedisTransport +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.redis.v1beta1.CloudRedis", + "rpcName": 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.redis.v1beta1.CloudRedis", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisGrpcTransport(CloudRedisTransport): """gRPC backend transport for CloudRedis. @@ -201,7 +282,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -265,7 +351,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -300,7 +388,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ListInstances", request_serializer=cloud_redis.ListInstancesRequest.serialize, response_deserializer=cloud_redis.ListInstancesResponse.deserialize, @@ -326,7 +414,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/GetInstance", request_serializer=cloud_redis.GetInstanceRequest.serialize, response_deserializer=cloud_redis.Instance.deserialize, @@ -357,7 +445,7 @@ def get_instance_auth_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance_auth_string" not in self._stubs: - self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + self._stubs["get_instance_auth_string"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/GetInstanceAuthString", request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, response_deserializer=cloud_redis.InstanceAuthString.deserialize, @@ -396,7 +484,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/CreateInstance", request_serializer=cloud_redis.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +515,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/UpdateInstance", request_serializer=cloud_redis.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -454,7 +542,7 @@ def upgrade_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_instance" not in self._stubs: - self._stubs["upgrade_instance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/UpgradeInstance", request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -488,7 +576,7 @@ def import_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_instance" not in self._stubs: - self._stubs["import_instance"] = self.grpc_channel.unary_unary( + self._stubs["import_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ImportInstance", request_serializer=cloud_redis.ImportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +607,7 @@ def export_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_instance" not in self._stubs: - self._stubs["export_instance"] = self.grpc_channel.unary_unary( + self._stubs["export_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ExportInstance", request_serializer=cloud_redis.ExportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -547,7 +635,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/FailoverInstance", request_serializer=cloud_redis.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +662,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/DeleteInstance", request_serializer=cloud_redis.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -601,7 +689,7 @@ def reschedule_maintenance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reschedule_maintenance" not in self._stubs: - self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + self._stubs["reschedule_maintenance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/RescheduleMaintenance", request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -609,7 +697,7 @@ def reschedule_maintenance( return self._stubs["reschedule_maintenance"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py index 03281c8cb333..b8a63f40be58 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.redis_v1beta1.types import cloud_redis from .base import DEFAULT_CLIENT_INFO, CloudRedisTransport from .grpc import CloudRedisGrpcTransport +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.redis.v1beta1.CloudRedis", + "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.redis.v1beta1.CloudRedis", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudRedisGrpcAsyncIOTransport(CloudRedisTransport): """gRPC AsyncIO backend transport for CloudRedis. @@ -248,10 +330,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -274,7 +359,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -310,7 +395,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ListInstances", request_serializer=cloud_redis.ListInstancesRequest.serialize, response_deserializer=cloud_redis.ListInstancesResponse.deserialize, @@ -336,7 +421,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/GetInstance", request_serializer=cloud_redis.GetInstanceRequest.serialize, response_deserializer=cloud_redis.Instance.deserialize, @@ -368,7 +453,7 @@ def get_instance_auth_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance_auth_string" not in self._stubs: - self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + self._stubs["get_instance_auth_string"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/GetInstanceAuthString", request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, response_deserializer=cloud_redis.InstanceAuthString.deserialize, @@ -409,7 +494,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/CreateInstance", request_serializer=cloud_redis.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -442,7 +527,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/UpdateInstance", request_serializer=cloud_redis.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -471,7 +556,7 @@ def upgrade_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_instance" not in self._stubs: - self._stubs["upgrade_instance"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/UpgradeInstance", request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +592,7 @@ def import_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_instance" not in self._stubs: - self._stubs["import_instance"] = self.grpc_channel.unary_unary( + self._stubs["import_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ImportInstance", request_serializer=cloud_redis.ImportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -540,7 +625,7 @@ def export_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_instance" not in self._stubs: - self._stubs["export_instance"] = self.grpc_channel.unary_unary( + self._stubs["export_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/ExportInstance", request_serializer=cloud_redis.ExportInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -570,7 +655,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/FailoverInstance", request_serializer=cloud_redis.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -599,7 +684,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/DeleteInstance", request_serializer=cloud_redis.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -628,7 +713,7 @@ def reschedule_maintenance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reschedule_maintenance" not in self._stubs: - self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + self._stubs["reschedule_maintenance"] = self._logged_channel.unary_unary( "/google.cloud.redis.v1beta1.CloudRedis/RescheduleMaintenance", request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +786,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/rest.py b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/rest.py index c149776eb342..c3d6149ea416 100644 --- a/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/rest.py +++ b/packages/google-cloud-redis/google/cloud/redis_v1beta1/services/cloud_redis/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -158,8 +166,10 @@ def post_upgrade_instance(self, response): def pre_create_instance( self, request: cloud_redis.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -181,8 +191,10 @@ def post_create_instance( def pre_delete_instance( self, request: cloud_redis.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -204,8 +216,10 @@ def post_delete_instance( def pre_export_instance( self, request: cloud_redis.ExportInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_instance Override in a subclass to manipulate the request or metadata @@ -227,8 +241,10 @@ def post_export_instance( def pre_failover_instance( self, request: cloud_redis.FailoverInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -250,8 +266,8 @@ def post_failover_instance( def pre_get_instance( self, request: cloud_redis.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -271,8 +287,11 @@ def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Insta def pre_get_instance_auth_string( self, request: cloud_redis.GetInstanceAuthStringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.GetInstanceAuthStringRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the request or metadata @@ -294,8 +313,10 @@ def post_get_instance_auth_string( def pre_import_instance( self, request: cloud_redis.ImportInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_instance Override in a subclass to manipulate the request or metadata @@ -317,8 +338,10 @@ def post_import_instance( def pre_list_instances( self, request: cloud_redis.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -340,8 +363,11 @@ def post_list_instances( def pre_reschedule_maintenance( self, request: cloud_redis.RescheduleMaintenanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.RescheduleMaintenanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for reschedule_maintenance Override in a subclass to manipulate the request or metadata @@ -363,8 +389,10 @@ def post_reschedule_maintenance( def pre_update_instance( self, request: cloud_redis.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -386,8 +414,10 @@ def post_update_instance( def pre_upgrade_instance( self, request: cloud_redis.UpgradeInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for upgrade_instance Override in a subclass to manipulate the request or metadata @@ -601,7 +631,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -612,8 +642,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -626,6 +658,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -644,6 +677,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.CreateInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._CreateInstance._get_response( self._host, @@ -663,7 +723,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(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.redis_v1beta1.CloudRedisClient.create_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -700,7 +782,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -711,8 +793,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -725,6 +809,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -737,6 +822,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._DeleteInstance._get_response( self._host, @@ -755,7 +867,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(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.redis_v1beta1.CloudRedisClient.delete_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportInstance( @@ -793,7 +927,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export instance method over HTTP. @@ -804,8 +938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -818,6 +954,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseExportInstance._get_http_options() ) + request, metadata = self._interceptor.pre_export_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseExportInstance._get_transcoded_request( http_options, request @@ -836,6 +973,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.ExportInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ExportInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ExportInstance._get_response( self._host, @@ -855,7 +1019,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_instance(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.redis_v1beta1.CloudRedisClient.export_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ExportInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FailoverInstance( @@ -893,7 +1079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the failover instance method over HTTP. @@ -904,8 +1090,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -918,6 +1106,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseFailoverInstance._get_http_options() ) + request, metadata = self._interceptor.pre_failover_instance( request, metadata ) @@ -934,6 +1123,33 @@ def __call__( 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.redis_v1beta1.CloudRedisClient.FailoverInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "FailoverInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._FailoverInstance._get_response( self._host, @@ -953,7 +1169,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_instance(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.redis_v1beta1.CloudRedisClient.failover_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "FailoverInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -990,7 +1228,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.Instance: r"""Call the get instance method over HTTP. @@ -1001,8 +1239,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.Instance: @@ -1012,6 +1252,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseGetInstance._get_transcoded_request( @@ -1026,6 +1267,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.GetInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetInstance._get_response( self._host, @@ -1046,7 +1314,29 @@ def __call__( pb_resp = cloud_redis.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.Instance.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.redis_v1beta1.CloudRedisClient.get_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstanceAuthString( @@ -1083,7 +1373,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.InstanceAuthString: r"""Call the get instance auth string method over HTTP. @@ -1094,8 +1384,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.InstanceAuthString: @@ -1105,6 +1397,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseGetInstanceAuthString._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance_auth_string( request, metadata ) @@ -1117,6 +1410,33 @@ def __call__( 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.redis_v1beta1.CloudRedisClient.GetInstanceAuthString", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "GetInstanceAuthString", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._GetInstanceAuthString._get_response( self._host, @@ -1137,7 +1457,29 @@ def __call__( pb_resp = cloud_redis.InstanceAuthString.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance_auth_string(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.InstanceAuthString.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.redis_v1beta1.CloudRedisClient.get_instance_auth_string", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "GetInstanceAuthString", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportInstance( @@ -1175,7 +1517,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the import instance method over HTTP. @@ -1186,8 +1528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1200,6 +1544,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseImportInstance._get_http_options() ) + request, metadata = self._interceptor.pre_import_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseImportInstance._get_transcoded_request( http_options, request @@ -1218,6 +1563,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.ImportInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ImportInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ImportInstance._get_response( self._host, @@ -1237,7 +1609,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_instance(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.redis_v1beta1.CloudRedisClient.import_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ImportInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -1274,7 +1668,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_redis.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -1285,8 +1679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.cloud_redis.ListInstancesResponse: @@ -1298,6 +1694,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = ( _BaseCloudRedisRestTransport._BaseListInstances._get_transcoded_request( @@ -1312,6 +1709,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.ListInstances", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._ListInstances._get_response( self._host, @@ -1332,7 +1756,31 @@ def __call__( pb_resp = cloud_redis.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_redis.ListInstancesResponse.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.redis_v1beta1.CloudRedisClient.list_instances", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RescheduleMaintenance( @@ -1370,7 +1818,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the reschedule maintenance method over HTTP. @@ -1381,8 +1829,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1395,6 +1845,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseRescheduleMaintenance._get_http_options() ) + request, metadata = self._interceptor.pre_reschedule_maintenance( request, metadata ) @@ -1411,6 +1862,33 @@ def __call__( 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.redis_v1beta1.CloudRedisClient.RescheduleMaintenance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "RescheduleMaintenance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._RescheduleMaintenance._get_response( self._host, @@ -1430,7 +1908,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reschedule_maintenance(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.redis_v1beta1.CloudRedisClient.reschedule_maintenance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "RescheduleMaintenance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -1468,7 +1968,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -1479,8 +1979,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1493,6 +1995,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseCloudRedisRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -1511,6 +2014,33 @@ def __call__( ) ) + 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.redis_v1beta1.CloudRedisClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._UpdateInstance._get_response( self._host, @@ -1530,7 +2060,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(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.redis_v1beta1.CloudRedisClient.update_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeInstance( @@ -1568,7 +2120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the upgrade instance method over HTTP. @@ -1579,8 +2131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1593,6 +2147,7 @@ def __call__( http_options = ( _BaseCloudRedisRestTransport._BaseUpgradeInstance._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_instance( request, metadata ) @@ -1609,6 +2164,33 @@ def __call__( 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.redis_v1beta1.CloudRedisClient.UpgradeInstance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "UpgradeInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudRedisRestTransport._UpgradeInstance._get_response( self._host, @@ -1628,7 +2210,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upgrade_instance(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.redis_v1beta1.CloudRedisClient.upgrade_instance", + extra={ + "serviceName": "google.cloud.redis.v1beta1.CloudRedis", + "rpcName": "UpgradeInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json b/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json index b39a9ed32274..78f872bc4aef 100644 --- a/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json +++ b/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-redis", - "version": "2.16.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.types.InstanceAuthString", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.types.InstanceAuthString", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.types.Instance", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.types.Instance", @@ -1049,7 +1049,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.services.cloud_redis.pagers.ListInstancesAsyncPager", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1.services.cloud_redis.pagers.ListInstancesPager", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1471,7 +1471,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1640,7 +1640,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1725,7 +1725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1809,7 +1809,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1beta1.json b/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1beta1.json index cbdefa7eddae..e1412dd446e5 100644 --- a/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1beta1.json +++ b/packages/google-cloud-redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-redis", - "version": "2.16.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.types.InstanceAuthString", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.types.InstanceAuthString", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.types.Instance", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.types.Instance", @@ -1049,7 +1049,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1214,7 +1214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesAsyncPager", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesPager", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1471,7 +1471,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1640,7 +1640,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1725,7 +1725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1809,7 +1809,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-redis/tests/unit/gapic/redis_v1/test_cloud_redis.py b/packages/google-cloud-redis/tests/unit/gapic/redis_v1/test_cloud_redis.py index eaed0859bc68..a18ae66530de 100644 --- a/packages/google-cloud-redis/tests/unit/gapic/redis_v1/test_cloud_redis.py +++ b/packages/google-cloud-redis/tests/unit/gapic/redis_v1/test_cloud_redis.py @@ -5234,6 +5234,7 @@ def test_list_instances_rest_required_fields( response_value._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_instances(request) @@ -5287,6 +5288,7 @@ def test_list_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instances(**mock_args) @@ -5476,6 +5478,7 @@ def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceR response_value._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_instance(request) @@ -5523,6 +5526,7 @@ def test_get_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -5658,6 +5662,7 @@ def test_get_instance_auth_string_rest_required_fields( response_value._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_instance_auth_string(request) @@ -5705,6 +5710,7 @@ def test_get_instance_auth_string_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance_auth_string(**mock_args) @@ -5847,6 +5853,7 @@ def test_create_instance_rest_required_fields( response_value._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_instance(request) @@ -5907,6 +5914,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -6038,6 +6046,7 @@ def test_update_instance_rest_required_fields( response_value._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_instance(request) @@ -6092,6 +6101,7 @@ def test_update_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -6232,6 +6242,7 @@ def test_upgrade_instance_rest_required_fields( response_value._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.upgrade_instance(request) @@ -6286,6 +6297,7 @@ def test_upgrade_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.upgrade_instance(**mock_args) @@ -6420,6 +6432,7 @@ def test_import_instance_rest_required_fields( response_value._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.import_instance(request) @@ -6476,6 +6489,7 @@ def test_import_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_instance(**mock_args) @@ -6612,6 +6626,7 @@ def test_export_instance_rest_required_fields( response_value._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.export_instance(request) @@ -6668,6 +6683,7 @@ def test_export_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.export_instance(**mock_args) @@ -6806,6 +6822,7 @@ def test_failover_instance_rest_required_fields( response_value._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.failover_instance(request) @@ -6852,6 +6869,7 @@ def test_failover_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.failover_instance(**mock_args) @@ -6985,6 +7003,7 @@ def test_delete_instance_rest_required_fields( response_value._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_instance(request) @@ -7030,6 +7049,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -7167,6 +7187,7 @@ def test_reschedule_maintenance_rest_required_fields( response_value._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.reschedule_maintenance(request) @@ -7222,6 +7243,7 @@ def test_reschedule_maintenance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reschedule_maintenance(**mock_args) @@ -7952,6 +7974,7 @@ def test_list_instances_rest_bad_request(request_type=cloud_redis.ListInstancesR 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_instances(request) @@ -7988,6 +8011,7 @@ def test_list_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instances(request) # Establish that the response is the type that we expect. @@ -8029,6 +8053,7 @@ def test_list_instances_rest_interceptors(null_interceptor): 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 = cloud_redis.ListInstancesResponse.to_json( cloud_redis.ListInstancesResponse() ) @@ -8073,6 +8098,7 @@ def test_get_instance_rest_bad_request(request_type=cloud_redis.GetInstanceReque 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_instance(request) @@ -8136,6 +8162,7 @@ def test_get_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8210,6 +8237,7 @@ def test_get_instance_rest_interceptors(null_interceptor): 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 = cloud_redis.Instance.to_json(cloud_redis.Instance()) req.return_value.content = return_value @@ -8254,6 +8282,7 @@ def test_get_instance_auth_string_rest_bad_request( 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_instance_auth_string(request) @@ -8289,6 +8318,7 @@ def test_get_instance_auth_string_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance_auth_string(request) # Establish that the response is the type that we expect. @@ -8329,6 +8359,7 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): 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 = cloud_redis.InstanceAuthString.to_json( cloud_redis.InstanceAuthString() ) @@ -8375,6 +8406,7 @@ def test_create_instance_rest_bad_request( 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_instance(request) @@ -8546,6 +8578,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8587,6 +8620,7 @@ def test_create_instance_rest_interceptors(null_interceptor): 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 @@ -8633,6 +8667,7 @@ def test_update_instance_rest_bad_request( 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_instance(request) @@ -8806,6 +8841,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8847,6 +8883,7 @@ def test_update_instance_rest_interceptors(null_interceptor): 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 @@ -8891,6 +8928,7 @@ def test_upgrade_instance_rest_bad_request( 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.upgrade_instance(request) @@ -8921,6 +8959,7 @@ def test_upgrade_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.upgrade_instance(request) # Establish that the response is the type that we expect. @@ -8962,6 +9001,7 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): 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 @@ -9006,6 +9046,7 @@ def test_import_instance_rest_bad_request( 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.import_instance(request) @@ -9036,6 +9077,7 @@ def test_import_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_instance(request) # Establish that the response is the type that we expect. @@ -9077,6 +9119,7 @@ def test_import_instance_rest_interceptors(null_interceptor): 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 @@ -9121,6 +9164,7 @@ def test_export_instance_rest_bad_request( 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.export_instance(request) @@ -9151,6 +9195,7 @@ def test_export_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_instance(request) # Establish that the response is the type that we expect. @@ -9192,6 +9237,7 @@ def test_export_instance_rest_interceptors(null_interceptor): 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 @@ -9236,6 +9282,7 @@ def test_failover_instance_rest_bad_request( 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.failover_instance(request) @@ -9266,6 +9313,7 @@ def test_failover_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.failover_instance(request) # Establish that the response is the type that we expect. @@ -9307,6 +9355,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): 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 @@ -9351,6 +9400,7 @@ def test_delete_instance_rest_bad_request( 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_instance(request) @@ -9381,6 +9431,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -9422,6 +9473,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): 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 @@ -9466,6 +9518,7 @@ def test_reschedule_maintenance_rest_bad_request( 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.reschedule_maintenance(request) @@ -9496,6 +9549,7 @@ def test_reschedule_maintenance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reschedule_maintenance(request) # Establish that the response is the type that we expect. @@ -9537,6 +9591,7 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): 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 @@ -9581,6 +9636,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq 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_location(request) @@ -9611,6 +9667,7 @@ def test_get_location_rest(request_type): response_value.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_location(request) @@ -9639,6 +9696,7 @@ def test_list_locations_rest_bad_request( 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_locations(request) @@ -9669,6 +9727,7 @@ def test_list_locations_rest(request_type): response_value.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_locations(request) @@ -9699,6 +9758,7 @@ def test_cancel_operation_rest_bad_request( 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) @@ -9729,6 +9789,7 @@ def test_cancel_operation_rest(request_type): response_value.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) @@ -9759,6 +9820,7 @@ def test_delete_operation_rest_bad_request( 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) @@ -9789,6 +9851,7 @@ def test_delete_operation_rest(request_type): response_value.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) @@ -9819,6 +9882,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9849,6 +9913,7 @@ def test_get_operation_rest(request_type): response_value.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) @@ -9879,6 +9944,7 @@ def test_list_operations_rest_bad_request( 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) @@ -9909,6 +9975,7 @@ def test_list_operations_rest(request_type): response_value.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) diff --git a/packages/google-cloud-redis/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py b/packages/google-cloud-redis/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py index 003d0ea284a0..c40f00572e24 100644 --- a/packages/google-cloud-redis/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py +++ b/packages/google-cloud-redis/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py @@ -5206,6 +5206,7 @@ def test_list_instances_rest_required_fields( response_value._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_instances(request) @@ -5259,6 +5260,7 @@ def test_list_instances_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instances(**mock_args) @@ -5449,6 +5451,7 @@ def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceR response_value._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_instance(request) @@ -5496,6 +5499,7 @@ def test_get_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -5632,6 +5636,7 @@ def test_get_instance_auth_string_rest_required_fields( response_value._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_instance_auth_string(request) @@ -5679,6 +5684,7 @@ def test_get_instance_auth_string_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance_auth_string(**mock_args) @@ -5821,6 +5827,7 @@ def test_create_instance_rest_required_fields( response_value._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_instance(request) @@ -5881,6 +5888,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -6013,6 +6021,7 @@ def test_update_instance_rest_required_fields( response_value._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_instance(request) @@ -6067,6 +6076,7 @@ def test_update_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -6207,6 +6217,7 @@ def test_upgrade_instance_rest_required_fields( response_value._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.upgrade_instance(request) @@ -6261,6 +6272,7 @@ def test_upgrade_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.upgrade_instance(**mock_args) @@ -6395,6 +6407,7 @@ def test_import_instance_rest_required_fields( response_value._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.import_instance(request) @@ -6451,6 +6464,7 @@ def test_import_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.import_instance(**mock_args) @@ -6587,6 +6601,7 @@ def test_export_instance_rest_required_fields( response_value._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.export_instance(request) @@ -6643,6 +6658,7 @@ def test_export_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.export_instance(**mock_args) @@ -6781,6 +6797,7 @@ def test_failover_instance_rest_required_fields( response_value._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.failover_instance(request) @@ -6827,6 +6844,7 @@ def test_failover_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.failover_instance(**mock_args) @@ -6960,6 +6978,7 @@ def test_delete_instance_rest_required_fields( response_value._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_instance(request) @@ -7005,6 +7024,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_instance(**mock_args) @@ -7143,6 +7163,7 @@ def test_reschedule_maintenance_rest_required_fields( response_value._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.reschedule_maintenance(request) @@ -7198,6 +7219,7 @@ def test_reschedule_maintenance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.reschedule_maintenance(**mock_args) @@ -7922,6 +7944,7 @@ def test_list_instances_rest_bad_request(request_type=cloud_redis.ListInstancesR 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_instances(request) @@ -7958,6 +7981,7 @@ def test_list_instances_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instances(request) # Establish that the response is the type that we expect. @@ -7999,6 +8023,7 @@ def test_list_instances_rest_interceptors(null_interceptor): 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 = cloud_redis.ListInstancesResponse.to_json( cloud_redis.ListInstancesResponse() ) @@ -8043,6 +8068,7 @@ def test_get_instance_rest_bad_request(request_type=cloud_redis.GetInstanceReque 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_instance(request) @@ -8100,6 +8126,7 @@ def test_get_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8166,6 +8193,7 @@ def test_get_instance_rest_interceptors(null_interceptor): 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 = cloud_redis.Instance.to_json(cloud_redis.Instance()) req.return_value.content = return_value @@ -8210,6 +8238,7 @@ def test_get_instance_auth_string_rest_bad_request( 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_instance_auth_string(request) @@ -8245,6 +8274,7 @@ def test_get_instance_auth_string_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance_auth_string(request) # Establish that the response is the type that we expect. @@ -8285,6 +8315,7 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): 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 = cloud_redis.InstanceAuthString.to_json( cloud_redis.InstanceAuthString() ) @@ -8331,6 +8362,7 @@ def test_create_instance_rest_bad_request( 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_instance(request) @@ -8495,6 +8527,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8536,6 +8569,7 @@ def test_create_instance_rest_interceptors(null_interceptor): 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 @@ -8582,6 +8616,7 @@ def test_update_instance_rest_bad_request( 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_instance(request) @@ -8748,6 +8783,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -8789,6 +8825,7 @@ def test_update_instance_rest_interceptors(null_interceptor): 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 @@ -8833,6 +8870,7 @@ def test_upgrade_instance_rest_bad_request( 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.upgrade_instance(request) @@ -8863,6 +8901,7 @@ def test_upgrade_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.upgrade_instance(request) # Establish that the response is the type that we expect. @@ -8904,6 +8943,7 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): 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 @@ -8948,6 +8988,7 @@ def test_import_instance_rest_bad_request( 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.import_instance(request) @@ -8978,6 +9019,7 @@ def test_import_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.import_instance(request) # Establish that the response is the type that we expect. @@ -9019,6 +9061,7 @@ def test_import_instance_rest_interceptors(null_interceptor): 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 @@ -9063,6 +9106,7 @@ def test_export_instance_rest_bad_request( 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.export_instance(request) @@ -9093,6 +9137,7 @@ def test_export_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.export_instance(request) # Establish that the response is the type that we expect. @@ -9134,6 +9179,7 @@ def test_export_instance_rest_interceptors(null_interceptor): 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 @@ -9178,6 +9224,7 @@ def test_failover_instance_rest_bad_request( 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.failover_instance(request) @@ -9208,6 +9255,7 @@ def test_failover_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.failover_instance(request) # Establish that the response is the type that we expect. @@ -9249,6 +9297,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): 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 @@ -9293,6 +9342,7 @@ def test_delete_instance_rest_bad_request( 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_instance(request) @@ -9323,6 +9373,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_instance(request) # Establish that the response is the type that we expect. @@ -9364,6 +9415,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): 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 @@ -9408,6 +9460,7 @@ def test_reschedule_maintenance_rest_bad_request( 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.reschedule_maintenance(request) @@ -9438,6 +9491,7 @@ def test_reschedule_maintenance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.reschedule_maintenance(request) # Establish that the response is the type that we expect. @@ -9479,6 +9533,7 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): 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 diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager/gapic_version.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager/gapic_version.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/gapic_version.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/gapic_version.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.13.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/async_client.py index b27e74377692..49d8554c6bf0 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, FoldersTransport from .transports.grpc_asyncio import FoldersGrpcAsyncIOTransport +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 FoldersAsyncClient: """Manages Cloud Platform folder resources. @@ -258,6 +268,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.FoldersAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "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.resourcemanager.v3.Folders", + "credentialsType": None, + }, + ) + async def get_folder( self, request: Optional[Union[folders.GetFolderRequest, dict]] = None, @@ -265,7 +297,7 @@ async def get_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> folders.Folder: r"""Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format @@ -312,8 +344,10 @@ async def sample_get_folder(): 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, 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: google.cloud.resourcemanager_v3.types.Folder: @@ -375,7 +409,7 @@ async def list_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFoldersAsyncPager: r"""Lists the folders that are direct descendants of supplied parent resource. ``list()`` provides a strongly consistent view of the @@ -434,8 +468,10 @@ async def sample_list_folders(): 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, 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: google.cloud.resourcemanager_v3.services.folders.pagers.ListFoldersAsyncPager: @@ -504,7 +540,7 @@ async def search_folders( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchFoldersAsyncPager: r"""Search for folders that match specific filter criteria. ``search()`` provides an eventually consistent view of the @@ -587,8 +623,10 @@ async def sample_search_folders(): 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, 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: google.cloud.resourcemanager_v3.services.folders.pagers.SearchFoldersAsyncPager: @@ -657,7 +695,7 @@ async def create_folder( folder: Optional[folders.Folder] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a folder in the resource hierarchy. Returns an ``Operation`` which can be used to track the progress of the @@ -737,8 +775,10 @@ async def sample_create_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -804,7 +844,7 @@ async def update_folder( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a folder, changing its ``display_name``. Changes to the folder ``display_name`` will be rejected if they violate either @@ -885,8 +925,10 @@ async def sample_update_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -962,7 +1004,7 @@ async def move_folder( destination_parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Moves a folder under a new resource parent. Returns an ``Operation`` which can be used to track the progress of the @@ -1036,8 +1078,10 @@ async def sample_move_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1110,7 +1154,7 @@ async def delete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] @@ -1168,8 +1212,10 @@ async def sample_delete_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1240,7 +1286,7 @@ async def undelete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the @@ -1299,8 +1345,10 @@ async def sample_undelete_folder(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1371,7 +1419,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The @@ -1422,8 +1470,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1509,7 +1559,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a folder, replacing any existing policy. The ``resource`` field should be the folder's @@ -1559,8 +1609,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1647,7 +1699,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified folder. The ``resource`` field should be the folder's resource name, for @@ -1707,8 +1759,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1765,7 +1819,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1776,8 +1830,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/client.py index b742c52dc8b8..38bccb239b15 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -581,6 +591,10 @@ def __init__( # 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( @@ -643,6 +657,29 @@ def __init__( 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.resourcemanager_v3.FoldersClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "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.resourcemanager.v3.Folders", + "credentialsType": None, + }, + ) + def get_folder( self, request: Optional[Union[folders.GetFolderRequest, dict]] = None, @@ -650,7 +687,7 @@ def get_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> folders.Folder: r"""Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format @@ -697,8 +734,10 @@ def sample_get_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.Folder: @@ -757,7 +796,7 @@ def list_folders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFoldersPager: r"""Lists the folders that are direct descendants of supplied parent resource. ``list()`` provides a strongly consistent view of the @@ -816,8 +855,10 @@ def sample_list_folders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.folders.pagers.ListFoldersPager: @@ -883,7 +924,7 @@ def search_folders( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchFoldersPager: r"""Search for folders that match specific filter criteria. ``search()`` provides an eventually consistent view of the @@ -966,8 +1007,10 @@ def sample_search_folders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.folders.pagers.SearchFoldersPager: @@ -1033,7 +1076,7 @@ def create_folder( folder: Optional[folders.Folder] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a folder in the resource hierarchy. Returns an ``Operation`` which can be used to track the progress of the @@ -1113,8 +1156,10 @@ def sample_create_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1177,7 +1222,7 @@ def update_folder( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a folder, changing its ``display_name``. Changes to the folder ``display_name`` will be rejected if they violate either @@ -1258,8 +1303,10 @@ def sample_update_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1332,7 +1379,7 @@ def move_folder( destination_parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Moves a folder under a new resource parent. Returns an ``Operation`` which can be used to track the progress of the @@ -1406,8 +1453,10 @@ def sample_move_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1477,7 +1526,7 @@ def delete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] @@ -1535,8 +1584,10 @@ def sample_delete_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1604,7 +1655,7 @@ def undelete_folder( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the @@ -1663,8 +1714,10 @@ def sample_undelete_folder(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1732,7 +1785,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The @@ -1783,8 +1836,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1871,7 +1926,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a folder, replacing any existing policy. The ``resource`` field should be the folder's @@ -1921,8 +1976,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2010,7 +2067,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified folder. The ``resource`` field should be the folder's resource name, for @@ -2070,8 +2127,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2142,7 +2201,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2153,8 +2212,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/pagers.py index 112332233e55..f19010b37c0f 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = folders.ListFoldersRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = folders.ListFoldersRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = folders.SearchFoldersRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = folders.SearchFoldersRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc.py index 00645f337ac0..a09d63b4dc41 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import folders from .base import DEFAULT_CLIENT_INFO, FoldersTransport +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.resourcemanager.v3.Folders", + "rpcName": 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.resourcemanager.v3.Folders", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FoldersGrpcTransport(FoldersTransport): """gRPC backend transport for Folders. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def get_folder(self) -> Callable[[folders.GetFolderRequest], folders.Folder]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_folder" not in self._stubs: - self._stubs["get_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/GetFolder", request_serializer=folders.GetFolderRequest.serialize, response_deserializer=folders.Folder.deserialize, @@ -308,7 +396,7 @@ def list_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_folders" not in self._stubs: - self._stubs["list_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_folders"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/ListFolders", request_serializer=folders.ListFoldersRequest.serialize, response_deserializer=folders.ListFoldersResponse.deserialize, @@ -340,7 +428,7 @@ def search_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_folders" not in self._stubs: - self._stubs["search_folders"] = self.grpc_channel.unary_unary( + self._stubs["search_folders"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/SearchFolders", request_serializer=folders.SearchFoldersRequest.serialize, response_deserializer=folders.SearchFoldersResponse.deserialize, @@ -394,7 +482,7 @@ def create_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_folder" not in self._stubs: - self._stubs["create_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/CreateFolder", request_serializer=folders.CreateFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -437,7 +525,7 @@ def update_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_folder" not in self._stubs: - self._stubs["update_folder"] = self.grpc_channel.unary_unary( + self._stubs["update_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/UpdateFolder", request_serializer=folders.UpdateFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -480,7 +568,7 @@ def move_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_folder" not in self._stubs: - self._stubs["move_folder"] = self.grpc_channel.unary_unary( + self._stubs["move_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/MoveFolder", request_serializer=folders.MoveFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +605,7 @@ def delete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_folder" not in self._stubs: - self._stubs["delete_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/DeleteFolder", request_serializer=folders.DeleteFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -555,7 +643,7 @@ def undelete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_folder" not in self._stubs: - self._stubs["undelete_folder"] = self.grpc_channel.unary_unary( + self._stubs["undelete_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/UndeleteFolder", request_serializer=folders.UndeleteFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -586,7 +674,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -616,7 +704,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -649,7 +737,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -657,7 +745,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -669,7 +757,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc_asyncio.py index 54d509dcd97a..70bf82f87271 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import folders from .base import DEFAULT_CLIENT_INFO, FoldersTransport from .grpc import FoldersGrpcTransport +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.resourcemanager.v3.Folders", + "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.resourcemanager.v3.Folders", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FoldersGrpcAsyncIOTransport(FoldersTransport): """gRPC AsyncIO backend transport for Folders. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def get_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_folder" not in self._stubs: - self._stubs["get_folder"] = self.grpc_channel.unary_unary( + self._stubs["get_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/GetFolder", request_serializer=folders.GetFolderRequest.serialize, response_deserializer=folders.Folder.deserialize, @@ -320,7 +405,7 @@ def list_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_folders" not in self._stubs: - self._stubs["list_folders"] = self.grpc_channel.unary_unary( + self._stubs["list_folders"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/ListFolders", request_serializer=folders.ListFoldersRequest.serialize, response_deserializer=folders.ListFoldersResponse.deserialize, @@ -354,7 +439,7 @@ def search_folders( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_folders" not in self._stubs: - self._stubs["search_folders"] = self.grpc_channel.unary_unary( + self._stubs["search_folders"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/SearchFolders", request_serializer=folders.SearchFoldersRequest.serialize, response_deserializer=folders.SearchFoldersResponse.deserialize, @@ -408,7 +493,7 @@ def create_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_folder" not in self._stubs: - self._stubs["create_folder"] = self.grpc_channel.unary_unary( + self._stubs["create_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/CreateFolder", request_serializer=folders.CreateFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -451,7 +536,7 @@ def update_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_folder" not in self._stubs: - self._stubs["update_folder"] = self.grpc_channel.unary_unary( + self._stubs["update_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/UpdateFolder", request_serializer=folders.UpdateFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -494,7 +579,7 @@ def move_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_folder" not in self._stubs: - self._stubs["move_folder"] = self.grpc_channel.unary_unary( + self._stubs["move_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/MoveFolder", request_serializer=folders.MoveFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +616,7 @@ def delete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_folder" not in self._stubs: - self._stubs["delete_folder"] = self.grpc_channel.unary_unary( + self._stubs["delete_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/DeleteFolder", request_serializer=folders.DeleteFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -569,7 +654,7 @@ def undelete_folder( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_folder" not in self._stubs: - self._stubs["undelete_folder"] = self.grpc_channel.unary_unary( + self._stubs["undelete_folder"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/UndeleteFolder", request_serializer=folders.UndeleteFolderRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -600,7 +685,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -630,7 +715,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -663,7 +748,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Folders/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -768,7 +853,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -784,7 +869,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/rest.py index bbf5ab0b9483..ea8b18e665ed 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/folders/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -158,8 +166,10 @@ def post_update_folder(self, response): """ def pre_create_folder( - self, request: folders.CreateFolderRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.CreateFolderRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.CreateFolderRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.CreateFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_folder Override in a subclass to manipulate the request or metadata @@ -179,8 +189,10 @@ def post_create_folder( return response def pre_delete_folder( - self, request: folders.DeleteFolderRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.DeleteFolderRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.DeleteFolderRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.DeleteFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_folder Override in a subclass to manipulate the request or metadata @@ -200,8 +212,10 @@ def post_delete_folder( return response def pre_get_folder( - self, request: folders.GetFolderRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.GetFolderRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.GetFolderRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.GetFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_folder Override in a subclass to manipulate the request or metadata @@ -221,8 +235,10 @@ def post_get_folder(self, response: folders.Folder) -> folders.Folder: def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -240,8 +256,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_list_folders( - self, request: folders.ListFoldersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.ListFoldersRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.ListFoldersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.ListFoldersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_folders Override in a subclass to manipulate the request or metadata @@ -261,8 +279,10 @@ def post_list_folders( return response def pre_move_folder( - self, request: folders.MoveFolderRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.MoveFolderRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.MoveFolderRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.MoveFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for move_folder Override in a subclass to manipulate the request or metadata @@ -282,8 +302,10 @@ def post_move_folder( return response def pre_search_folders( - self, request: folders.SearchFoldersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.SearchFoldersRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.SearchFoldersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.SearchFoldersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_folders Override in a subclass to manipulate the request or metadata @@ -305,8 +327,10 @@ def post_search_folders( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -326,8 +350,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -349,8 +376,8 @@ def post_test_iam_permissions( def pre_undelete_folder( self, request: folders.UndeleteFolderRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[folders.UndeleteFolderRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.UndeleteFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undelete_folder Override in a subclass to manipulate the request or metadata @@ -370,8 +397,10 @@ def post_undelete_folder( return response def pre_update_folder( - self, request: folders.UpdateFolderRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[folders.UpdateFolderRequest, Sequence[Tuple[str, str]]]: + self, + request: folders.UpdateFolderRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[folders.UpdateFolderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_folder Override in a subclass to manipulate the request or metadata @@ -393,8 +422,10 @@ def post_update_folder( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -571,7 +602,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create folder method over HTTP. @@ -581,8 +612,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -595,6 +628,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseCreateFolder._get_http_options() ) + request, metadata = self._interceptor.pre_create_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseCreateFolder._get_transcoded_request( @@ -613,6 +647,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.CreateFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "CreateFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._CreateFolder._get_response( self._host, @@ -632,7 +693,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_folder(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.resourcemanager_v3.FoldersClient.create_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "CreateFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteFolder(_BaseFoldersRestTransport._BaseDeleteFolder, FoldersRestStub): @@ -667,7 +750,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete folder method over HTTP. @@ -677,8 +760,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -691,6 +776,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseDeleteFolder._get_http_options() ) + request, metadata = self._interceptor.pre_delete_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseDeleteFolder._get_transcoded_request( @@ -705,6 +791,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.DeleteFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "DeleteFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._DeleteFolder._get_response( self._host, @@ -723,7 +836,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_folder(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.resourcemanager_v3.FoldersClient.delete_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "DeleteFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetFolder(_BaseFoldersRestTransport._BaseGetFolder, FoldersRestStub): @@ -758,7 +893,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> folders.Folder: r"""Call the get folder method over HTTP. @@ -768,8 +903,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.folders.Folder: @@ -780,6 +917,7 @@ def __call__( """ http_options = _BaseFoldersRestTransport._BaseGetFolder._get_http_options() + request, metadata = self._interceptor.pre_get_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseGetFolder._get_transcoded_request( @@ -794,6 +932,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.GetFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._GetFolder._get_response( self._host, @@ -814,7 +979,29 @@ def __call__( pb_resp = folders.Folder.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_folder(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = folders.Folder.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.resourcemanager_v3.FoldersClient.get_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseFoldersRestTransport._BaseGetIamPolicy, FoldersRestStub): @@ -850,7 +1037,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -860,8 +1047,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -946,6 +1135,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -964,6 +1154,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._GetIamPolicy._get_response( self._host, @@ -985,7 +1202,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.resourcemanager_v3.FoldersClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFolders(_BaseFoldersRestTransport._BaseListFolders, FoldersRestStub): @@ -1020,7 +1259,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> folders.ListFoldersResponse: r"""Call the list folders method over HTTP. @@ -1030,8 +1269,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.folders.ListFoldersResponse: @@ -1041,6 +1282,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseListFolders._get_http_options() ) + request, metadata = self._interceptor.pre_list_folders(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseListFolders._get_transcoded_request( @@ -1055,6 +1297,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.ListFolders", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "ListFolders", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._ListFolders._get_response( self._host, @@ -1075,7 +1344,29 @@ def __call__( pb_resp = folders.ListFoldersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_folders(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = folders.ListFoldersResponse.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.resourcemanager_v3.FoldersClient.list_folders", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "ListFolders", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveFolder(_BaseFoldersRestTransport._BaseMoveFolder, FoldersRestStub): @@ -1111,7 +1402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the move folder method over HTTP. @@ -1121,8 +1412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1133,6 +1426,7 @@ def __call__( """ http_options = _BaseFoldersRestTransport._BaseMoveFolder._get_http_options() + request, metadata = self._interceptor.pre_move_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseMoveFolder._get_transcoded_request( @@ -1151,6 +1445,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.MoveFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "MoveFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._MoveFolder._get_response( self._host, @@ -1170,7 +1491,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_folder(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.resourcemanager_v3.FoldersClient.move_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "MoveFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchFolders(_BaseFoldersRestTransport._BaseSearchFolders, FoldersRestStub): @@ -1205,7 +1548,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> folders.SearchFoldersResponse: r"""Call the search folders method over HTTP. @@ -1216,8 +1559,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.folders.SearchFoldersResponse: @@ -1229,6 +1574,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseSearchFolders._get_http_options() ) + request, metadata = self._interceptor.pre_search_folders(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseSearchFolders._get_transcoded_request( @@ -1243,6 +1589,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.SearchFolders", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "SearchFolders", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._SearchFolders._get_response( self._host, @@ -1263,7 +1636,29 @@ def __call__( pb_resp = folders.SearchFoldersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_folders(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = folders.SearchFoldersResponse.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.resourcemanager_v3.FoldersClient.search_folders", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "SearchFolders", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseFoldersRestTransport._BaseSetIamPolicy, FoldersRestStub): @@ -1299,7 +1694,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1309,8 +1704,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1395,6 +1792,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1413,6 +1811,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._SetIamPolicy._get_response( self._host, @@ -1434,7 +1859,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.resourcemanager_v3.FoldersClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1472,7 +1919,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1482,8 +1929,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1493,6 +1942,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1509,6 +1959,33 @@ def __call__( 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.resourcemanager_v3.FoldersClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._TestIamPermissions._get_response( self._host, @@ -1530,7 +2007,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.resourcemanager_v3.FoldersClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteFolder( @@ -1568,7 +2067,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete folder method over HTTP. @@ -1578,8 +2077,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1592,6 +2093,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseUndeleteFolder._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseUndeleteFolder._get_transcoded_request( @@ -1610,6 +2112,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.UndeleteFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "UndeleteFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._UndeleteFolder._get_response( self._host, @@ -1629,7 +2158,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_folder(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.resourcemanager_v3.FoldersClient.undelete_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "UndeleteFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFolder(_BaseFoldersRestTransport._BaseUpdateFolder, FoldersRestStub): @@ -1665,7 +2216,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update folder method over HTTP. @@ -1682,8 +2233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1696,6 +2249,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseUpdateFolder._get_http_options() ) + request, metadata = self._interceptor.pre_update_folder(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseUpdateFolder._get_transcoded_request( @@ -1714,6 +2268,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.UpdateFolder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "UpdateFolder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._UpdateFolder._get_response( self._host, @@ -1733,7 +2314,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_folder(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.resourcemanager_v3.FoldersClient.update_folder", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "UpdateFolder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1861,7 +2464,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1871,8 +2474,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1881,6 +2486,7 @@ def __call__( http_options = ( _BaseFoldersRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseFoldersRestTransport._BaseGetOperation._get_transcoded_request( @@ -1895,6 +2501,33 @@ def __call__( ) ) + 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.resourcemanager_v3.FoldersClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FoldersRestTransport._GetOperation._get_response( self._host, @@ -1914,6 +2547,27 @@ def __call__( 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.resourcemanager_v3.FoldersAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Folders", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/async_client.py index f64be9dc0123..32441868bc37 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, OrganizationsTransport from .transports.grpc_asyncio import OrganizationsGrpcAsyncIOTransport +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 OrganizationsAsyncClient: """Allows users to manage their organization resources.""" @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.OrganizationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "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.resourcemanager.v3.Organizations", + "credentialsType": None, + }, + ) + async def get_organization( self, request: Optional[Union[organizations.GetOrganizationRequest, dict]] = None, @@ -266,7 +298,7 @@ async def get_organization( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organizations.Organization: r"""Fetches an organization resource identified by the specified resource name. @@ -314,8 +346,10 @@ async def sample_get_organization(): 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, 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: google.cloud.resourcemanager_v3.types.Organization: @@ -378,7 +412,7 @@ async def search_organizations( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchOrganizationsAsyncPager: r"""Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations @@ -448,8 +482,10 @@ async def sample_search_organizations(): 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, 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: google.cloud.resourcemanager_v3.services.organizations.pagers.SearchOrganizationsAsyncPager: @@ -518,7 +554,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The @@ -571,8 +607,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -658,7 +696,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on an organization resource. Replaces any existing policy. The ``resource`` field should be @@ -711,8 +749,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -799,7 +839,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified organization. The ``resource`` field should be the @@ -859,8 +899,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -917,7 +959,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -928,8 +970,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/client.py index 8db4d927e4be..eec927ece34a 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -574,6 +584,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.resourcemanager_v3.OrganizationsClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "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.resourcemanager.v3.Organizations", + "credentialsType": None, + }, + ) + def get_organization( self, request: Optional[Union[organizations.GetOrganizationRequest, dict]] = None, @@ -646,7 +683,7 @@ def get_organization( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organizations.Organization: r"""Fetches an organization resource identified by the specified resource name. @@ -694,8 +731,10 @@ def sample_get_organization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.Organization: @@ -755,7 +794,7 @@ def search_organizations( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchOrganizationsPager: r"""Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations @@ -825,8 +864,10 @@ def sample_search_organizations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.organizations.pagers.SearchOrganizationsPager: @@ -892,7 +933,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The @@ -945,8 +986,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1033,7 +1076,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on an organization resource. Replaces any existing policy. The ``resource`` field should be @@ -1086,8 +1129,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1175,7 +1220,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns the permissions that a caller has on the specified organization. The ``resource`` field should be the @@ -1235,8 +1280,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1307,7 +1354,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1318,8 +1365,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/pagers.py index 53419bd1ca3f..430b3e48b173 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = organizations.SearchOrganizationsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = organizations.SearchOrganizationsRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc.py index e57984f172e4..463d86620777 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import organizations from .base import DEFAULT_CLIENT_INFO, OrganizationsTransport +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.resourcemanager.v3.Organizations", + "rpcName": 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.resourcemanager.v3.Organizations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OrganizationsGrpcTransport(OrganizationsTransport): """gRPC backend transport for Organizations. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -257,7 +343,7 @@ def get_organization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization" not in self._stubs: - self._stubs["get_organization"] = self.grpc_channel.unary_unary( + self._stubs["get_organization"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/GetOrganization", request_serializer=organizations.GetOrganizationRequest.serialize, response_deserializer=organizations.Organization.deserialize, @@ -293,7 +379,7 @@ def search_organizations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_organizations" not in self._stubs: - self._stubs["search_organizations"] = self.grpc_channel.unary_unary( + self._stubs["search_organizations"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/SearchOrganizations", request_serializer=organizations.SearchOrganizationsRequest.serialize, response_deserializer=organizations.SearchOrganizationsResponse.deserialize, @@ -326,7 +412,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -359,7 +445,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -392,7 +478,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -400,7 +486,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -412,7 +498,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc_asyncio.py index 23a93093f608..04acd8560eef 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import organizations from .base import DEFAULT_CLIENT_INFO, OrganizationsTransport from .grpc import OrganizationsGrpcTransport +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.resourcemanager.v3.Organizations", + "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.resourcemanager.v3.Organizations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class OrganizationsGrpcAsyncIOTransport(OrganizationsTransport): """gRPC AsyncIO backend transport for Organizations. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -267,7 +352,7 @@ def get_organization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization" not in self._stubs: - self._stubs["get_organization"] = self.grpc_channel.unary_unary( + self._stubs["get_organization"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/GetOrganization", request_serializer=organizations.GetOrganizationRequest.serialize, response_deserializer=organizations.Organization.deserialize, @@ -303,7 +388,7 @@ def search_organizations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_organizations" not in self._stubs: - self._stubs["search_organizations"] = self.grpc_channel.unary_unary( + self._stubs["search_organizations"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/SearchOrganizations", request_serializer=organizations.SearchOrganizationsRequest.serialize, response_deserializer=organizations.SearchOrganizationsResponse.deserialize, @@ -336,7 +421,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -369,7 +454,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -402,7 +487,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Organizations/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -468,7 +553,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -484,7 +569,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/rest.py index bd0543b86776..338156e473b6 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/organizations/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -112,8 +120,10 @@ def post_test_iam_permissions(self, response): def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_organization( self, request: organizations.GetOrganizationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[organizations.GetOrganizationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + organizations.GetOrganizationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_organization Override in a subclass to manipulate the request or metadata @@ -156,8 +168,11 @@ def post_get_organization( def pre_search_organizations( self, request: organizations.SearchOrganizationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[organizations.SearchOrganizationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + organizations.SearchOrganizationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for search_organizations Override in a subclass to manipulate the request or metadata @@ -179,8 +194,10 @@ def post_search_organizations( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -200,8 +217,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -223,8 +243,10 @@ def post_test_iam_permissions( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -365,7 +387,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -375,8 +397,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -461,6 +485,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseOrganizationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -475,6 +500,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._GetIamPolicy._get_response( self._host, @@ -496,7 +548,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.resourcemanager_v3.OrganizationsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetOrganization( @@ -533,7 +607,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organizations.Organization: r"""Call the get organization method over HTTP. @@ -545,8 +619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.organizations.Organization: @@ -560,6 +636,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseGetOrganization._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization( request, metadata ) @@ -572,6 +649,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.GetOrganization", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetOrganization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._GetOrganization._get_response( self._host, @@ -592,7 +696,29 @@ def __call__( pb_resp = organizations.Organization.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = organizations.Organization.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.resourcemanager_v3.OrganizationsClient.get_organization", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetOrganization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchOrganizations( @@ -629,7 +755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> organizations.SearchOrganizationsResponse: r"""Call the search organizations method over HTTP. @@ -639,8 +765,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.organizations.SearchOrganizationsResponse: @@ -652,6 +780,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseSearchOrganizations._get_http_options() ) + request, metadata = self._interceptor.pre_search_organizations( request, metadata ) @@ -664,6 +793,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.SearchOrganizations", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "SearchOrganizations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._SearchOrganizations._get_response( self._host, @@ -684,7 +840,31 @@ def __call__( pb_resp = organizations.SearchOrganizationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_organizations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + organizations.SearchOrganizationsResponse.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.resourcemanager_v3.OrganizationsClient.search_organizations", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "SearchOrganizations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -722,7 +902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -732,8 +912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -818,6 +1000,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseOrganizationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -832,6 +1015,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._SetIamPolicy._get_response( self._host, @@ -853,7 +1063,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.resourcemanager_v3.OrganizationsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -891,7 +1123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -901,8 +1133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -912,6 +1146,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -928,6 +1163,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._TestIamPermissions._get_response( self._host, @@ -949,7 +1211,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.resourcemanager_v3.OrganizationsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1036,7 +1320,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1046,8 +1330,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1056,6 +1342,7 @@ def __call__( http_options = ( _BaseOrganizationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseOrganizationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1066,6 +1353,33 @@ def __call__( 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.resourcemanager_v3.OrganizationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrganizationsRestTransport._GetOperation._get_response( self._host, @@ -1085,6 +1399,27 @@ def __call__( 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.resourcemanager_v3.OrganizationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Organizations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/async_client.py index 258d67302211..fb7fc0cbdcb9 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProjectsTransport from .transports.grpc_asyncio import ProjectsGrpcAsyncIOTransport +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 ProjectsAsyncClient: """Manages Google Cloud Projects.""" @@ -254,6 +264,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.ProjectsAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "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.resourcemanager.v3.Projects", + "credentialsType": None, + }, + ) + async def get_project( self, request: Optional[Union[projects.GetProjectRequest, dict]] = None, @@ -261,7 +293,7 @@ async def get_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> projects.Project: r"""Retrieves the project identified by the specified ``name`` (for example, ``projects/415104041262``). @@ -310,8 +342,10 @@ async def sample_get_project(): 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, 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: google.cloud.resourcemanager_v3.types.Project: @@ -374,7 +408,7 @@ async def list_projects( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProjectsAsyncPager: r"""Lists projects that are direct children of the specified folder or organization resource. ``list()`` provides a strongly @@ -431,8 +465,10 @@ async def sample_list_projects(): 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, 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: google.cloud.resourcemanager_v3.services.projects.pagers.ListProjectsAsyncPager: @@ -509,7 +545,7 @@ async def search_projects( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchProjectsAsyncPager: r"""Search for projects that the caller has both ``resourcemanager.projects.get`` permission on, and also satisfy @@ -607,8 +643,10 @@ async def sample_search_projects(): 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, 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: google.cloud.resourcemanager_v3.services.projects.pagers.SearchProjectsAsyncPager: @@ -682,7 +720,7 @@ async def create_project( project: Optional[projects.Project] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Request that a new project be created. The result is an ``Operation`` which can be used to track the creation process. @@ -743,8 +781,10 @@ async def sample_create_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -811,7 +851,7 @@ async def update_project( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the ``display_name`` and labels of the project identified by the specified ``name`` (for example, @@ -877,8 +917,10 @@ async def sample_update_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -955,7 +997,7 @@ async def move_project( destination_parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Move a project to another place in your resource hierarchy, under a new resource parent. @@ -1027,8 +1069,10 @@ async def sample_move_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1102,7 +1146,7 @@ async def delete_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Marks the project identified by the specified ``name`` (for example, ``projects/415104041262``) for deletion. @@ -1184,8 +1228,10 @@ async def sample_delete_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1257,7 +1303,7 @@ async def undelete_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restores the project identified by the specified ``name`` (for example, ``projects/415104041262``). You can only use this @@ -1315,8 +1361,10 @@ async def sample_undelete_project(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -1388,7 +1436,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Returns the IAM access control policy for the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. @@ -1437,8 +1485,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1524,7 +1574,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy for the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. projects/123. @@ -1617,8 +1667,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1705,7 +1757,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. @@ -1763,8 +1815,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1821,7 +1875,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1832,8 +1886,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/client.py index d8fb12662a45..9f50334b832e 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -577,6 +587,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.resourcemanager_v3.ProjectsClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "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.resourcemanager.v3.Projects", + "credentialsType": None, + }, + ) + def get_project( self, request: Optional[Union[projects.GetProjectRequest, dict]] = None, @@ -646,7 +683,7 @@ def get_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> projects.Project: r"""Retrieves the project identified by the specified ``name`` (for example, ``projects/415104041262``). @@ -695,8 +732,10 @@ def sample_get_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.Project: @@ -756,7 +795,7 @@ def list_projects( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProjectsPager: r"""Lists projects that are direct children of the specified folder or organization resource. ``list()`` provides a strongly @@ -813,8 +852,10 @@ def sample_list_projects(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.projects.pagers.ListProjectsPager: @@ -888,7 +929,7 @@ def search_projects( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchProjectsPager: r"""Search for projects that the caller has both ``resourcemanager.projects.get`` permission on, and also satisfy @@ -986,8 +1027,10 @@ def sample_search_projects(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.projects.pagers.SearchProjectsPager: @@ -1058,7 +1101,7 @@ def create_project( project: Optional[projects.Project] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Request that a new project be created. The result is an ``Operation`` which can be used to track the creation process. @@ -1119,8 +1162,10 @@ def sample_create_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1184,7 +1229,7 @@ def update_project( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the ``display_name`` and labels of the project identified by the specified ``name`` (for example, @@ -1250,8 +1295,10 @@ def sample_update_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1325,7 +1372,7 @@ def move_project( destination_parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Move a project to another place in your resource hierarchy, under a new resource parent. @@ -1397,8 +1444,10 @@ def sample_move_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1469,7 +1518,7 @@ def delete_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Marks the project identified by the specified ``name`` (for example, ``projects/415104041262``) for deletion. @@ -1551,8 +1600,10 @@ def sample_delete_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1621,7 +1672,7 @@ def undelete_project( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restores the project identified by the specified ``name`` (for example, ``projects/415104041262``). You can only use this @@ -1679,8 +1730,10 @@ def sample_undelete_project(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1749,7 +1802,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Returns the IAM access control policy for the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. @@ -1798,8 +1851,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1886,7 +1941,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the IAM access control policy for the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. projects/123. @@ -1979,8 +2034,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -2068,7 +2125,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified project, in the format ``projects/{ProjectIdOrNumber}`` e.g. @@ -2126,8 +2183,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2198,7 +2257,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2209,8 +2268,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/pagers.py index fadb8e12e632..4bfbef1ce570 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = projects.ListProjectsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = projects.ListProjectsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = projects.SearchProjectsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = projects.SearchProjectsRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc.py index e467ddb9c888..7607da1cb262 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import projects from .base import DEFAULT_CLIENT_INFO, ProjectsTransport +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.resourcemanager.v3.Projects", + "rpcName": 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.resourcemanager.v3.Projects", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectsGrpcTransport(ProjectsTransport): """gRPC backend transport for Projects. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def get_project(self) -> Callable[[projects.GetProjectRequest], projects.Project # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project" not in self._stubs: - self._stubs["get_project"] = self.grpc_channel.unary_unary( + self._stubs["get_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/GetProject", request_serializer=projects.GetProjectRequest.serialize, response_deserializer=projects.Project.deserialize, @@ -305,7 +393,7 @@ def list_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_projects" not in self._stubs: - self._stubs["list_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_projects"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/ListProjects", request_serializer=projects.ListProjectsRequest.serialize, response_deserializer=projects.ListProjectsResponse.deserialize, @@ -343,7 +431,7 @@ def search_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_projects" not in self._stubs: - self._stubs["search_projects"] = self.grpc_channel.unary_unary( + self._stubs["search_projects"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/SearchProjects", request_serializer=projects.SearchProjectsRequest.serialize, response_deserializer=projects.SearchProjectsResponse.deserialize, @@ -374,7 +462,7 @@ def create_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_project" not in self._stubs: - self._stubs["create_project"] = self.grpc_channel.unary_unary( + self._stubs["create_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/CreateProject", request_serializer=projects.CreateProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,7 +494,7 @@ def update_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project" not in self._stubs: - self._stubs["update_project"] = self.grpc_channel.unary_unary( + self._stubs["update_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/UpdateProject", request_serializer=projects.UpdateProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +535,7 @@ def move_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_project" not in self._stubs: - self._stubs["move_project"] = self.grpc_channel.unary_unary( + self._stubs["move_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/MoveProject", request_serializer=projects.MoveProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +595,7 @@ def delete_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_project" not in self._stubs: - self._stubs["delete_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/DeleteProject", request_serializer=projects.DeleteProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -540,7 +628,7 @@ def undelete_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_project" not in self._stubs: - self._stubs["undelete_project"] = self.grpc_channel.unary_unary( + self._stubs["undelete_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/UndeleteProject", request_serializer=projects.UndeleteProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -569,7 +657,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -642,7 +730,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -673,7 +761,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -681,7 +769,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -693,7 +781,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc_asyncio.py index db3bfa44e52c..190bbf2e465f 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import projects from .base import DEFAULT_CLIENT_INFO, ProjectsTransport from .grpc import ProjectsGrpcTransport +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.resourcemanager.v3.Projects", + "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.resourcemanager.v3.Projects", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProjectsGrpcAsyncIOTransport(ProjectsTransport): """gRPC AsyncIO backend transport for Projects. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project" not in self._stubs: - self._stubs["get_project"] = self.grpc_channel.unary_unary( + self._stubs["get_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/GetProject", request_serializer=projects.GetProjectRequest.serialize, response_deserializer=projects.Project.deserialize, @@ -319,7 +404,7 @@ def list_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_projects" not in self._stubs: - self._stubs["list_projects"] = self.grpc_channel.unary_unary( + self._stubs["list_projects"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/ListProjects", request_serializer=projects.ListProjectsRequest.serialize, response_deserializer=projects.ListProjectsResponse.deserialize, @@ -359,7 +444,7 @@ def search_projects( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_projects" not in self._stubs: - self._stubs["search_projects"] = self.grpc_channel.unary_unary( + self._stubs["search_projects"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/SearchProjects", request_serializer=projects.SearchProjectsRequest.serialize, response_deserializer=projects.SearchProjectsResponse.deserialize, @@ -390,7 +475,7 @@ def create_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_project" not in self._stubs: - self._stubs["create_project"] = self.grpc_channel.unary_unary( + self._stubs["create_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/CreateProject", request_serializer=projects.CreateProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,7 @@ def update_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project" not in self._stubs: - self._stubs["update_project"] = self.grpc_channel.unary_unary( + self._stubs["update_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/UpdateProject", request_serializer=projects.UpdateProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +548,7 @@ def move_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_project" not in self._stubs: - self._stubs["move_project"] = self.grpc_channel.unary_unary( + self._stubs["move_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/MoveProject", request_serializer=projects.MoveProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +608,7 @@ def delete_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_project" not in self._stubs: - self._stubs["delete_project"] = self.grpc_channel.unary_unary( + self._stubs["delete_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/DeleteProject", request_serializer=projects.DeleteProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -558,7 +643,7 @@ def undelete_project( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_project" not in self._stubs: - self._stubs["undelete_project"] = self.grpc_channel.unary_unary( + self._stubs["undelete_project"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/UndeleteProject", request_serializer=projects.UndeleteProjectRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -587,7 +672,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -660,7 +745,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -691,7 +776,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.Projects/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -796,7 +881,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -812,7 +897,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/rest.py index 25a24534849d..55312200c880 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/projects/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -160,8 +168,8 @@ def post_update_project(self, response): def pre_create_project( self, request: projects.CreateProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[projects.CreateProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.CreateProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_project Override in a subclass to manipulate the request or metadata @@ -183,8 +191,8 @@ def post_create_project( def pre_delete_project( self, request: projects.DeleteProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[projects.DeleteProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.DeleteProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_project Override in a subclass to manipulate the request or metadata @@ -206,8 +214,10 @@ def post_delete_project( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -225,8 +235,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_project( - self, request: projects.GetProjectRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[projects.GetProjectRequest, Sequence[Tuple[str, str]]]: + self, + request: projects.GetProjectRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.GetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_project Override in a subclass to manipulate the request or metadata @@ -244,8 +256,10 @@ def post_get_project(self, response: projects.Project) -> projects.Project: return response def pre_list_projects( - self, request: projects.ListProjectsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[projects.ListProjectsRequest, Sequence[Tuple[str, str]]]: + self, + request: projects.ListProjectsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.ListProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_projects Override in a subclass to manipulate the request or metadata @@ -265,8 +279,10 @@ def post_list_projects( return response def pre_move_project( - self, request: projects.MoveProjectRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[projects.MoveProjectRequest, Sequence[Tuple[str, str]]]: + self, + request: projects.MoveProjectRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.MoveProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for move_project Override in a subclass to manipulate the request or metadata @@ -288,8 +304,8 @@ def post_move_project( def pre_search_projects( self, request: projects.SearchProjectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[projects.SearchProjectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.SearchProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_projects Override in a subclass to manipulate the request or metadata @@ -311,8 +327,10 @@ def post_search_projects( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -332,8 +350,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -355,8 +376,10 @@ def post_test_iam_permissions( def pre_undelete_project( self, request: projects.UndeleteProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[projects.UndeleteProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + projects.UndeleteProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undelete_project Override in a subclass to manipulate the request or metadata @@ -378,8 +401,8 @@ def post_undelete_project( def pre_update_project( self, request: projects.UpdateProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[projects.UpdateProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[projects.UpdateProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_project Override in a subclass to manipulate the request or metadata @@ -401,8 +424,10 @@ def post_update_project( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -578,7 +603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create project method over HTTP. @@ -590,8 +615,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -604,6 +631,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseCreateProject._get_http_options() ) + request, metadata = self._interceptor.pre_create_project(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseCreateProject._get_transcoded_request( @@ -622,6 +650,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.CreateProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "CreateProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._CreateProject._get_response( self._host, @@ -641,7 +696,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_project(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.resourcemanager_v3.ProjectsClient.create_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "CreateProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteProject( @@ -678,7 +755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete project method over HTTP. @@ -689,8 +766,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -703,6 +782,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseDeleteProject._get_http_options() ) + request, metadata = self._interceptor.pre_delete_project(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseDeleteProject._get_transcoded_request( @@ -717,6 +797,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.DeleteProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "DeleteProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._DeleteProject._get_response( self._host, @@ -735,7 +842,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_project(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.resourcemanager_v3.ProjectsClient.delete_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "DeleteProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseProjectsRestTransport._BaseGetIamPolicy, ProjectsRestStub): @@ -771,7 +900,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -781,8 +910,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -867,6 +998,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -885,6 +1017,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._GetIamPolicy._get_response( self._host, @@ -906,7 +1065,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.resourcemanager_v3.ProjectsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProject(_BaseProjectsRestTransport._BaseGetProject, ProjectsRestStub): @@ -941,7 +1122,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> projects.Project: r"""Call the get project method over HTTP. @@ -953,8 +1134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.projects.Project: @@ -968,6 +1151,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseGetProject._get_http_options() ) + request, metadata = self._interceptor.pre_get_project(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseGetProject._get_transcoded_request( @@ -982,6 +1166,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.GetProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._GetProject._get_response( self._host, @@ -1002,7 +1213,29 @@ def __call__( pb_resp = projects.Project.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_project(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = projects.Project.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.resourcemanager_v3.ProjectsClient.get_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProjects(_BaseProjectsRestTransport._BaseListProjects, ProjectsRestStub): @@ -1037,7 +1270,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> projects.ListProjectsResponse: r"""Call the list projects method over HTTP. @@ -1049,8 +1282,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.projects.ListProjectsResponse: @@ -1071,6 +1306,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseListProjects._get_http_options() ) + request, metadata = self._interceptor.pre_list_projects(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseListProjects._get_transcoded_request( @@ -1085,6 +1321,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.ListProjects", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "ListProjects", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._ListProjects._get_response( self._host, @@ -1105,7 +1368,29 @@ def __call__( pb_resp = projects.ListProjectsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_projects(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = projects.ListProjectsResponse.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.resourcemanager_v3.ProjectsClient.list_projects", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "ListProjects", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveProject(_BaseProjectsRestTransport._BaseMoveProject, ProjectsRestStub): @@ -1141,7 +1426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the move project method over HTTP. @@ -1153,8 +1438,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1167,6 +1454,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseMoveProject._get_http_options() ) + request, metadata = self._interceptor.pre_move_project(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseMoveProject._get_transcoded_request( @@ -1185,6 +1473,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.MoveProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "MoveProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._MoveProject._get_response( self._host, @@ -1204,7 +1519,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_project(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.resourcemanager_v3.ProjectsClient.move_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "MoveProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchProjects( @@ -1241,7 +1578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> projects.SearchProjectsResponse: r"""Call the search projects method over HTTP. @@ -1253,8 +1590,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.projects.SearchProjectsResponse: @@ -1271,6 +1610,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSearchProjects._get_http_options() ) + request, metadata = self._interceptor.pre_search_projects(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseSearchProjects._get_transcoded_request( @@ -1285,6 +1625,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.SearchProjects", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "SearchProjects", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SearchProjects._get_response( self._host, @@ -1305,7 +1672,29 @@ def __call__( pb_resp = projects.SearchProjectsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_projects(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = projects.SearchProjectsResponse.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.resourcemanager_v3.ProjectsClient.search_projects", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "SearchProjects", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseProjectsRestTransport._BaseSetIamPolicy, ProjectsRestStub): @@ -1341,7 +1730,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1351,8 +1740,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1437,6 +1828,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1455,6 +1847,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SetIamPolicy._get_response( self._host, @@ -1476,7 +1895,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.resourcemanager_v3.ProjectsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1514,7 +1955,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1524,8 +1965,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1535,6 +1978,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1551,6 +1995,33 @@ def __call__( 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.resourcemanager_v3.ProjectsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._TestIamPermissions._get_response( self._host, @@ -1572,7 +2043,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.resourcemanager_v3.ProjectsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteProject( @@ -1610,7 +2103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete project method over HTTP. @@ -1622,8 +2115,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1636,6 +2131,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseUndeleteProject._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_project( request, metadata ) @@ -1658,6 +2154,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.UndeleteProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "UndeleteProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._UndeleteProject._get_response( self._host, @@ -1677,7 +2200,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_project(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.resourcemanager_v3.ProjectsClient.undelete_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "UndeleteProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProject( @@ -1715,7 +2260,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update project method over HTTP. @@ -1732,8 +2277,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1746,6 +2293,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseUpdateProject._get_http_options() ) + request, metadata = self._interceptor.pre_update_project(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseUpdateProject._get_transcoded_request( @@ -1764,6 +2312,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.UpdateProject", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "UpdateProject", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._UpdateProject._get_response( self._host, @@ -1783,7 +2358,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_project(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.resourcemanager_v3.ProjectsClient.update_project", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "UpdateProject", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1911,7 +2508,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1921,8 +2518,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1931,6 +2530,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1945,6 +2545,33 @@ def __call__( ) ) + 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.resourcemanager_v3.ProjectsClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._GetOperation._get_response( self._host, @@ -1964,6 +2591,27 @@ def __call__( 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.resourcemanager_v3.ProjectsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.Projects", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/async_client.py index 129b38e5c2a4..e86e6d5dd972 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TagBindingsTransport from .transports.grpc_asyncio import TagBindingsGrpcAsyncIOTransport +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 TagBindingsAsyncClient: """Allow users to create and manage TagBindings between @@ -262,6 +272,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.TagBindingsAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "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.resourcemanager.v3.TagBindings", + "credentialsType": None, + }, + ) + async def list_tag_bindings( self, request: Optional[Union[tag_bindings.ListTagBindingsRequest, dict]] = None, @@ -269,7 +301,7 @@ async def list_tag_bindings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagBindingsAsyncPager: r"""Lists the TagBindings for the given Google Cloud resource, as specified with ``parent``. @@ -321,8 +353,10 @@ async def sample_list_tag_bindings(): 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, 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: google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListTagBindingsAsyncPager: @@ -391,7 +425,7 @@ async def create_tag_binding( tag_binding: Optional[tag_bindings.TagBinding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a TagBinding between a TagValue and a Google Cloud resource. @@ -439,8 +473,10 @@ async def sample_create_tag_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -507,7 +543,7 @@ async def delete_tag_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a TagBinding. @@ -556,8 +592,10 @@ async def sample_delete_tag_binding(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -636,7 +674,7 @@ async def list_effective_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveTagsAsyncPager: r"""Return a list of effective tags for the given Google Cloud resource, as specified in ``parent``. @@ -684,8 +722,10 @@ async def sample_list_effective_tags(): 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, 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: google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListEffectiveTagsAsyncPager: @@ -753,7 +793,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -764,8 +804,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/client.py index c59d4dbd9939..72886ad92428 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -607,6 +617,10 @@ def __init__( # 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( @@ -669,6 +683,29 @@ def __init__( 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.resourcemanager_v3.TagBindingsClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "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.resourcemanager.v3.TagBindings", + "credentialsType": None, + }, + ) + def list_tag_bindings( self, request: Optional[Union[tag_bindings.ListTagBindingsRequest, dict]] = None, @@ -676,7 +713,7 @@ def list_tag_bindings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagBindingsPager: r"""Lists the TagBindings for the given Google Cloud resource, as specified with ``parent``. @@ -728,8 +765,10 @@ def sample_list_tag_bindings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListTagBindingsPager: @@ -795,7 +834,7 @@ def create_tag_binding( tag_binding: Optional[tag_bindings.TagBinding] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a TagBinding between a TagValue and a Google Cloud resource. @@ -843,8 +882,10 @@ def sample_create_tag_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -908,7 +949,7 @@ def delete_tag_binding( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a TagBinding. @@ -957,8 +998,10 @@ def sample_delete_tag_binding(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1034,7 +1077,7 @@ def list_effective_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEffectiveTagsPager: r"""Return a list of effective tags for the given Google Cloud resource, as specified in ``parent``. @@ -1082,8 +1125,10 @@ def sample_list_effective_tags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListEffectiveTagsPager: @@ -1161,7 +1206,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1172,8 +1217,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/pagers.py index e2e3cb451a8f..8334736ae46f 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tag_bindings.ListTagBindingsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tag_bindings.ListTagBindingsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tag_bindings.ListEffectiveTagsRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tag_bindings.ListEffectiveTagsRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc.py index e1f716ab3cb7..ed8c5ced0413 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_bindings from .base import DEFAULT_CLIENT_INFO, TagBindingsTransport +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.resourcemanager.v3.TagBindings", + "rpcName": 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.resourcemanager.v3.TagBindings", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagBindingsGrpcTransport(TagBindingsTransport): """gRPC backend transport for TagBindings. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def list_tag_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_bindings" not in self._stubs: - self._stubs["list_tag_bindings"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_bindings"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/ListTagBindings", request_serializer=tag_bindings.ListTagBindingsRequest.serialize, response_deserializer=tag_bindings.ListTagBindingsResponse.deserialize, @@ -305,7 +393,7 @@ def create_tag_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_binding" not in self._stubs: - self._stubs["create_tag_binding"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_binding"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/CreateTagBinding", request_serializer=tag_bindings.CreateTagBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -331,7 +419,7 @@ def delete_tag_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_binding" not in self._stubs: - self._stubs["delete_tag_binding"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_binding"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/DeleteTagBinding", request_serializer=tag_bindings.DeleteTagBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -360,7 +448,7 @@ def list_effective_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_effective_tags" not in self._stubs: - self._stubs["list_effective_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_effective_tags"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/ListEffectiveTags", request_serializer=tag_bindings.ListEffectiveTagsRequest.serialize, response_deserializer=tag_bindings.ListEffectiveTagsResponse.deserialize, @@ -368,7 +456,7 @@ def list_effective_tags( return self._stubs["list_effective_tags"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -380,7 +468,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc_asyncio.py index 1736e074e55c..7d1ac6aa0c0d 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_bindings from .base import DEFAULT_CLIENT_INFO, TagBindingsTransport from .grpc import TagBindingsGrpcTransport +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.resourcemanager.v3.TagBindings", + "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.resourcemanager.v3.TagBindings", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagBindingsGrpcAsyncIOTransport(TagBindingsTransport): """gRPC AsyncIO backend transport for TagBindings. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,7 @@ def list_tag_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_bindings" not in self._stubs: - self._stubs["list_tag_bindings"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_bindings"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/ListTagBindings", request_serializer=tag_bindings.ListTagBindingsRequest.serialize, response_deserializer=tag_bindings.ListTagBindingsResponse.deserialize, @@ -318,7 +403,7 @@ def create_tag_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_binding" not in self._stubs: - self._stubs["create_tag_binding"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_binding"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/CreateTagBinding", request_serializer=tag_bindings.CreateTagBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -346,7 +431,7 @@ def delete_tag_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_binding" not in self._stubs: - self._stubs["delete_tag_binding"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_binding"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/DeleteTagBinding", request_serializer=tag_bindings.DeleteTagBindingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +461,7 @@ def list_effective_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_effective_tags" not in self._stubs: - self._stubs["list_effective_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_effective_tags"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagBindings/ListEffectiveTags", request_serializer=tag_bindings.ListEffectiveTagsRequest.serialize, response_deserializer=tag_bindings.ListEffectiveTagsResponse.deserialize, @@ -428,7 +513,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -444,7 +529,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/rest.py index 67d83171cc9f..da6ad505f359 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_bindings/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -102,8 +110,10 @@ def post_list_tag_bindings(self, response): def pre_create_tag_binding( self, request: tag_bindings.CreateTagBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_bindings.CreateTagBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_bindings.CreateTagBindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tag_binding Override in a subclass to manipulate the request or metadata @@ -125,8 +135,10 @@ def post_create_tag_binding( def pre_delete_tag_binding( self, request: tag_bindings.DeleteTagBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_bindings.DeleteTagBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_bindings.DeleteTagBindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tag_binding Override in a subclass to manipulate the request or metadata @@ -148,8 +160,10 @@ def post_delete_tag_binding( def pre_list_effective_tags( self, request: tag_bindings.ListEffectiveTagsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_bindings.ListEffectiveTagsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_bindings.ListEffectiveTagsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_effective_tags Override in a subclass to manipulate the request or metadata @@ -171,8 +185,10 @@ def post_list_effective_tags( def pre_list_tag_bindings( self, request: tag_bindings.ListTagBindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_bindings.ListTagBindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_bindings.ListTagBindingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tag_bindings Override in a subclass to manipulate the request or metadata @@ -194,8 +210,10 @@ def post_list_tag_bindings( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -373,7 +391,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create tag binding method over HTTP. @@ -384,8 +402,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -398,6 +418,7 @@ def __call__( http_options = ( _BaseTagBindingsRestTransport._BaseCreateTagBinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag_binding( request, metadata ) @@ -414,6 +435,33 @@ def __call__( 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.resourcemanager_v3.TagBindingsClient.CreateTagBinding", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "CreateTagBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagBindingsRestTransport._CreateTagBinding._get_response( self._host, @@ -433,7 +481,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag_binding(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.resourcemanager_v3.TagBindingsClient.create_tag_binding", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "CreateTagBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTagBinding( @@ -470,7 +540,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete tag binding method over HTTP. @@ -481,8 +551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -495,6 +567,7 @@ def __call__( http_options = ( _BaseTagBindingsRestTransport._BaseDeleteTagBinding._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag_binding( request, metadata ) @@ -507,6 +580,33 @@ def __call__( 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.resourcemanager_v3.TagBindingsClient.DeleteTagBinding", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "DeleteTagBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagBindingsRestTransport._DeleteTagBinding._get_response( self._host, @@ -525,7 +625,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_tag_binding(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.resourcemanager_v3.TagBindingsClient.delete_tag_binding", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "DeleteTagBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEffectiveTags( @@ -562,7 +684,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_bindings.ListEffectiveTagsResponse: r"""Call the list effective tags method over HTTP. @@ -573,8 +695,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_bindings.ListEffectiveTagsResponse: @@ -584,6 +708,7 @@ def __call__( http_options = ( _BaseTagBindingsRestTransport._BaseListEffectiveTags._get_http_options() ) + request, metadata = self._interceptor.pre_list_effective_tags( request, metadata ) @@ -596,6 +721,33 @@ def __call__( 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.resourcemanager_v3.TagBindingsClient.ListEffectiveTags", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "ListEffectiveTags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagBindingsRestTransport._ListEffectiveTags._get_response( self._host, @@ -616,7 +768,31 @@ def __call__( pb_resp = tag_bindings.ListEffectiveTagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_tags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_bindings.ListEffectiveTagsResponse.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.resourcemanager_v3.TagBindingsClient.list_effective_tags", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "ListEffectiveTags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTagBindings( @@ -653,7 +829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_bindings.ListTagBindingsResponse: r"""Call the list tag bindings method over HTTP. @@ -664,8 +840,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_bindings.ListTagBindingsResponse: @@ -675,6 +853,7 @@ def __call__( http_options = ( _BaseTagBindingsRestTransport._BaseListTagBindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_tag_bindings( request, metadata ) @@ -687,6 +866,33 @@ def __call__( 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.resourcemanager_v3.TagBindingsClient.ListTagBindings", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "ListTagBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagBindingsRestTransport._ListTagBindings._get_response( self._host, @@ -707,7 +913,31 @@ def __call__( pb_resp = tag_bindings.ListTagBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tag_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_bindings.ListTagBindingsResponse.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.resourcemanager_v3.TagBindingsClient.list_tag_bindings", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "ListTagBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -784,7 +1014,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -794,8 +1024,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -804,6 +1036,7 @@ def __call__( http_options = ( _BaseTagBindingsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTagBindingsRestTransport._BaseGetOperation._get_transcoded_request( @@ -818,6 +1051,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagBindingsClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagBindingsRestTransport._GetOperation._get_response( self._host, @@ -837,6 +1097,27 @@ def __call__( 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.resourcemanager_v3.TagBindingsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagBindings", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/async_client.py index ddb2a1c02940..374370569ffa 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TagHoldsTransport from .transports.grpc_asyncio import TagHoldsGrpcAsyncIOTransport +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 TagHoldsAsyncClient: """Allow users to create and manage TagHolds for TagValues. @@ -257,6 +267,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.TagHoldsAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "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.resourcemanager.v3.TagHolds", + "credentialsType": None, + }, + ) + async def create_tag_hold( self, request: Optional[Union[tag_holds.CreateTagHoldRequest, dict]] = None, @@ -265,7 +297,7 @@ async def create_tag_hold( tag_hold: Optional[tag_holds.TagHold] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue. @@ -324,8 +356,10 @@ async def sample_create_tag_hold(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -400,7 +434,7 @@ async def delete_tag_hold( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a TagHold. @@ -449,8 +483,10 @@ async def sample_delete_tag_hold(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -529,7 +565,7 @@ async def list_tag_holds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagHoldsAsyncPager: r"""Lists TagHolds under a TagValue. @@ -574,8 +610,10 @@ async def sample_list_tag_holds(): 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, 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: google.cloud.resourcemanager_v3.services.tag_holds.pagers.ListTagHoldsAsyncPager: @@ -649,7 +687,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -660,8 +698,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/client.py index 6b52e231be0f..1b12b6948881 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.longrunning import operations_pb2 # type: ignore @@ -582,6 +592,10 @@ def __init__( # 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( @@ -644,6 +658,29 @@ def __init__( 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.resourcemanager_v3.TagHoldsClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "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.resourcemanager.v3.TagHolds", + "credentialsType": None, + }, + ) + def create_tag_hold( self, request: Optional[Union[tag_holds.CreateTagHoldRequest, dict]] = None, @@ -652,7 +689,7 @@ def create_tag_hold( tag_hold: Optional[tag_holds.TagHold] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue. @@ -711,8 +748,10 @@ def sample_create_tag_hold(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -784,7 +823,7 @@ def delete_tag_hold( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a TagHold. @@ -833,8 +872,10 @@ def sample_delete_tag_hold(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -910,7 +951,7 @@ def list_tag_holds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagHoldsPager: r"""Lists TagHolds under a TagValue. @@ -955,8 +996,10 @@ def sample_list_tag_holds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.tag_holds.pagers.ListTagHoldsPager: @@ -1040,7 +1083,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1051,8 +1094,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/pagers.py index 69eaf61b1e05..3a4cbb01bb15 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tag_holds.ListTagHoldsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tag_holds.ListTagHoldsRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc.py index 74eabf02c23b..d039d464e746 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_holds from .base import DEFAULT_CLIENT_INFO, TagHoldsTransport +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.resourcemanager.v3.TagHolds", + "rpcName": 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.resourcemanager.v3.TagHolds", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagHoldsGrpcTransport(TagHoldsTransport): """gRPC backend transport for TagHolds. @@ -186,7 +267,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def create_tag_hold( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_hold" not in self._stubs: - self._stubs["create_tag_hold"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_hold"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/CreateTagHold", request_serializer=tag_holds.CreateTagHoldRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -301,7 +389,7 @@ def delete_tag_hold( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_hold" not in self._stubs: - self._stubs["delete_tag_hold"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_hold"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/DeleteTagHold", request_serializer=tag_holds.DeleteTagHoldRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -327,7 +415,7 @@ def list_tag_holds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_holds" not in self._stubs: - self._stubs["list_tag_holds"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_holds"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/ListTagHolds", request_serializer=tag_holds.ListTagHoldsRequest.serialize, response_deserializer=tag_holds.ListTagHoldsResponse.deserialize, @@ -335,7 +423,7 @@ def list_tag_holds( return self._stubs["list_tag_holds"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -347,7 +435,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc_asyncio.py index 2e441f976475..fbe4072486ac 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_holds from .base import DEFAULT_CLIENT_INFO, TagHoldsTransport from .grpc import TagHoldsGrpcTransport +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.resourcemanager.v3.TagHolds", + "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.resourcemanager.v3.TagHolds", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagHoldsGrpcAsyncIOTransport(TagHoldsTransport): """gRPC AsyncIO backend transport for TagHolds. @@ -233,10 +315,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_tag_hold( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_hold" not in self._stubs: - self._stubs["create_tag_hold"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_hold"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/CreateTagHold", request_serializer=tag_holds.CreateTagHoldRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -315,7 +400,7 @@ def delete_tag_hold( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_hold" not in self._stubs: - self._stubs["delete_tag_hold"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_hold"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/DeleteTagHold", request_serializer=tag_holds.DeleteTagHoldRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -343,7 +428,7 @@ def list_tag_holds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_holds" not in self._stubs: - self._stubs["list_tag_holds"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_holds"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagHolds/ListTagHolds", request_serializer=tag_holds.ListTagHoldsRequest.serialize, response_deserializer=tag_holds.ListTagHoldsResponse.deserialize, @@ -381,7 +466,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -397,7 +482,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/rest.py index dd468ff985f1..483d926d7b84 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_holds/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ 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, @@ -94,8 +102,8 @@ def post_list_tag_holds(self, response): def pre_create_tag_hold( self, request: tag_holds.CreateTagHoldRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_holds.CreateTagHoldRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_holds.CreateTagHoldRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_tag_hold Override in a subclass to manipulate the request or metadata @@ -117,8 +125,8 @@ def post_create_tag_hold( def pre_delete_tag_hold( self, request: tag_holds.DeleteTagHoldRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_holds.DeleteTagHoldRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_holds.DeleteTagHoldRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_tag_hold Override in a subclass to manipulate the request or metadata @@ -140,8 +148,8 @@ def post_delete_tag_hold( def pre_list_tag_holds( self, request: tag_holds.ListTagHoldsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_holds.ListTagHoldsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_holds.ListTagHoldsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tag_holds Override in a subclass to manipulate the request or metadata @@ -163,8 +171,10 @@ def post_list_tag_holds( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -345,7 +355,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create tag hold method over HTTP. @@ -356,8 +366,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -370,6 +382,7 @@ def __call__( http_options = ( _BaseTagHoldsRestTransport._BaseCreateTagHold._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag_hold(request, metadata) transcoded_request = ( _BaseTagHoldsRestTransport._BaseCreateTagHold._get_transcoded_request( @@ -388,6 +401,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagHoldsClient.CreateTagHold", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "CreateTagHold", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagHoldsRestTransport._CreateTagHold._get_response( self._host, @@ -407,7 +447,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag_hold(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.resourcemanager_v3.TagHoldsClient.create_tag_hold", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "CreateTagHold", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTagHold( @@ -444,7 +506,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete tag hold method over HTTP. @@ -455,8 +517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -469,6 +533,7 @@ def __call__( http_options = ( _BaseTagHoldsRestTransport._BaseDeleteTagHold._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag_hold(request, metadata) transcoded_request = ( _BaseTagHoldsRestTransport._BaseDeleteTagHold._get_transcoded_request( @@ -483,6 +548,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagHoldsClient.DeleteTagHold", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "DeleteTagHold", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagHoldsRestTransport._DeleteTagHold._get_response( self._host, @@ -501,7 +593,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_tag_hold(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.resourcemanager_v3.TagHoldsClient.delete_tag_hold", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "DeleteTagHold", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTagHolds(_BaseTagHoldsRestTransport._BaseListTagHolds, TagHoldsRestStub): @@ -536,7 +650,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_holds.ListTagHoldsResponse: r"""Call the list tag holds method over HTTP. @@ -547,8 +661,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_holds.ListTagHoldsResponse: @@ -558,6 +674,7 @@ def __call__( http_options = ( _BaseTagHoldsRestTransport._BaseListTagHolds._get_http_options() ) + request, metadata = self._interceptor.pre_list_tag_holds(request, metadata) transcoded_request = ( _BaseTagHoldsRestTransport._BaseListTagHolds._get_transcoded_request( @@ -572,6 +689,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagHoldsClient.ListTagHolds", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "ListTagHolds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagHoldsRestTransport._ListTagHolds._get_response( self._host, @@ -592,7 +736,29 @@ def __call__( pb_resp = tag_holds.ListTagHoldsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tag_holds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_holds.ListTagHoldsResponse.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.resourcemanager_v3.TagHoldsClient.list_tag_holds", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "ListTagHolds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -655,7 +821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -665,8 +831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -675,6 +843,7 @@ def __call__( http_options = ( _BaseTagHoldsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTagHoldsRestTransport._BaseGetOperation._get_transcoded_request( @@ -689,6 +858,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagHoldsClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagHoldsRestTransport._GetOperation._get_response( self._host, @@ -708,6 +904,27 @@ def __call__( 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.resourcemanager_v3.TagHoldsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagHolds", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/async_client.py index 1da8f0c88af8..1a675d69572f 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TagKeysTransport from .transports.grpc_asyncio import TagKeysGrpcAsyncIOTransport +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 TagKeysAsyncClient: """Allow users to create and manage tag keys.""" @@ -254,6 +264,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.TagKeysAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "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.resourcemanager.v3.TagKeys", + "credentialsType": None, + }, + ) + async def list_tag_keys( self, request: Optional[Union[tag_keys.ListTagKeysRequest, dict]] = None, @@ -261,7 +293,7 @@ async def list_tag_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagKeysAsyncPager: r"""Lists all TagKeys for a parent resource. @@ -308,8 +340,10 @@ async def sample_list_tag_keys(): 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, 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: google.cloud.resourcemanager_v3.services.tag_keys.pagers.ListTagKeysAsyncPager: @@ -378,7 +412,7 @@ async def get_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Retrieves a TagKey. This method will return ``PERMISSION_DENIED`` if the key does not exist or the user does @@ -424,8 +458,10 @@ async def sample_get_tag_key(): 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, 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: google.cloud.resourcemanager_v3.types.TagKey: @@ -486,7 +522,7 @@ async def get_namespaced_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Retrieves a TagKey by its namespaced name. This method will return ``PERMISSION_DENIED`` if the key does not exist or the @@ -535,8 +571,10 @@ async def sample_get_namespaced_tag_key(): 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, 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: google.cloud.resourcemanager_v3.types.TagKey: @@ -591,7 +629,7 @@ async def create_tag_key( tag_key: Optional[tag_keys.TagKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new TagKey. If another request with the same parameters is sent while the original request is in @@ -647,8 +685,10 @@ async def sample_create_tag_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -715,7 +755,7 @@ async def update_tag_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the attributes of the TagKey resource. @@ -778,8 +818,10 @@ async def sample_update_tag_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -855,7 +897,7 @@ async def delete_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues. @@ -906,8 +948,10 @@ async def sample_delete_tag_key(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -979,7 +1023,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The @@ -1030,8 +1074,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1117,7 +1163,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a TagKey, replacing any existing policy. The ``resource`` field should be the TagKey's @@ -1167,8 +1213,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1255,7 +1303,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified TagKey. The ``resource`` field should be the TagKey's resource name. For @@ -1315,8 +1363,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1373,7 +1423,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1384,8 +1434,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/client.py index 5db9b3313e51..0a5bcb8828d7 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -577,6 +587,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.resourcemanager_v3.TagKeysClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "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.resourcemanager.v3.TagKeys", + "credentialsType": None, + }, + ) + def list_tag_keys( self, request: Optional[Union[tag_keys.ListTagKeysRequest, dict]] = None, @@ -646,7 +683,7 @@ def list_tag_keys( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagKeysPager: r"""Lists all TagKeys for a parent resource. @@ -693,8 +730,10 @@ def sample_list_tag_keys(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.tag_keys.pagers.ListTagKeysPager: @@ -760,7 +799,7 @@ def get_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Retrieves a TagKey. This method will return ``PERMISSION_DENIED`` if the key does not exist or the user does @@ -806,8 +845,10 @@ def sample_get_tag_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.TagKey: @@ -865,7 +906,7 @@ def get_namespaced_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Retrieves a TagKey by its namespaced name. This method will return ``PERMISSION_DENIED`` if the key does not exist or the @@ -914,8 +955,10 @@ def sample_get_namespaced_tag_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.TagKey: @@ -967,7 +1010,7 @@ def create_tag_key( tag_key: Optional[tag_keys.TagKey] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new TagKey. If another request with the same parameters is sent while the original request is in @@ -1023,8 +1066,10 @@ def sample_create_tag_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1088,7 +1133,7 @@ def update_tag_key( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the attributes of the TagKey resource. @@ -1151,8 +1196,10 @@ def sample_update_tag_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1225,7 +1272,7 @@ def delete_tag_key( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues. @@ -1276,8 +1323,10 @@ def sample_delete_tag_key(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1346,7 +1395,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The @@ -1397,8 +1446,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1485,7 +1536,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a TagKey, replacing any existing policy. The ``resource`` field should be the TagKey's @@ -1535,8 +1586,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1624,7 +1677,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified TagKey. The ``resource`` field should be the TagKey's resource name. For @@ -1684,8 +1737,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1756,7 +1811,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1767,8 +1822,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/pagers.py index 15bf354cca28..326ac1dd650c 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tag_keys.ListTagKeysRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tag_keys.ListTagKeysRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc.py index be4a3b5b99b9..a37a98f0f888 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_keys from .base import DEFAULT_CLIENT_INFO, TagKeysTransport +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.resourcemanager.v3.TagKeys", + "rpcName": 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.resourcemanager.v3.TagKeys", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagKeysGrpcTransport(TagKeysTransport): """gRPC backend transport for TagKeys. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def list_tag_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_keys" not in self._stubs: - self._stubs["list_tag_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_keys"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/ListTagKeys", request_serializer=tag_keys.ListTagKeysRequest.serialize, response_deserializer=tag_keys.ListTagKeysResponse.deserialize, @@ -297,7 +385,7 @@ def get_tag_key(self) -> Callable[[tag_keys.GetTagKeyRequest], tag_keys.TagKey]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag_key" not in self._stubs: - self._stubs["get_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["get_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetTagKey", request_serializer=tag_keys.GetTagKeyRequest.serialize, response_deserializer=tag_keys.TagKey.deserialize, @@ -325,7 +413,7 @@ def get_namespaced_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespaced_tag_key" not in self._stubs: - self._stubs["get_namespaced_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["get_namespaced_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetNamespacedTagKey", request_serializer=tag_keys.GetNamespacedTagKeyRequest.serialize, response_deserializer=tag_keys.TagKey.deserialize, @@ -355,7 +443,7 @@ def create_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_key" not in self._stubs: - self._stubs["create_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/CreateTagKey", request_serializer=tag_keys.CreateTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -381,7 +469,7 @@ def update_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag_key" not in self._stubs: - self._stubs["update_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["update_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/UpdateTagKey", request_serializer=tag_keys.UpdateTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def delete_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_key" not in self._stubs: - self._stubs["delete_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/DeleteTagKey", request_serializer=tag_keys.DeleteTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -439,7 +527,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -469,7 +557,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -502,7 +590,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -510,7 +598,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -522,7 +610,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc_asyncio.py index 86b19103dbb0..bd4e001c3f74 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_keys from .base import DEFAULT_CLIENT_INFO, TagKeysTransport from .grpc import TagKeysGrpcTransport +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.resourcemanager.v3.TagKeys", + "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.resourcemanager.v3.TagKeys", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagKeysGrpcAsyncIOTransport(TagKeysTransport): """gRPC AsyncIO backend transport for TagKeys. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def list_tag_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_keys" not in self._stubs: - self._stubs["list_tag_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_keys"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/ListTagKeys", request_serializer=tag_keys.ListTagKeysRequest.serialize, response_deserializer=tag_keys.ListTagKeysResponse.deserialize, @@ -311,7 +396,7 @@ def get_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag_key" not in self._stubs: - self._stubs["get_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["get_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetTagKey", request_serializer=tag_keys.GetTagKeyRequest.serialize, response_deserializer=tag_keys.TagKey.deserialize, @@ -339,7 +424,7 @@ def get_namespaced_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespaced_tag_key" not in self._stubs: - self._stubs["get_namespaced_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["get_namespaced_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetNamespacedTagKey", request_serializer=tag_keys.GetNamespacedTagKeyRequest.serialize, response_deserializer=tag_keys.TagKey.deserialize, @@ -369,7 +454,7 @@ def create_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_key" not in self._stubs: - self._stubs["create_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/CreateTagKey", request_serializer=tag_keys.CreateTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def update_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag_key" not in self._stubs: - self._stubs["update_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["update_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/UpdateTagKey", request_serializer=tag_keys.UpdateTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -422,7 +507,7 @@ def delete_tag_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_key" not in self._stubs: - self._stubs["delete_tag_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_key"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/DeleteTagKey", request_serializer=tag_keys.DeleteTagKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -453,7 +538,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -483,7 +568,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -516,7 +601,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagKeys/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -611,7 +696,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -627,7 +712,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/rest.py index 71f15619d2c5..33d03a329e50 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_keys/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -142,8 +150,10 @@ def post_update_tag_key(self, response): """ def pre_create_tag_key( - self, request: tag_keys.CreateTagKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag_keys.CreateTagKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: tag_keys.CreateTagKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_keys.CreateTagKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_tag_key Override in a subclass to manipulate the request or metadata @@ -163,8 +173,10 @@ def post_create_tag_key( return response def pre_delete_tag_key( - self, request: tag_keys.DeleteTagKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag_keys.DeleteTagKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: tag_keys.DeleteTagKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_keys.DeleteTagKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_tag_key Override in a subclass to manipulate the request or metadata @@ -186,8 +198,10 @@ def post_delete_tag_key( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -207,8 +221,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_namespaced_tag_key( self, request: tag_keys.GetNamespacedTagKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_keys.GetNamespacedTagKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_keys.GetNamespacedTagKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_namespaced_tag_key Override in a subclass to manipulate the request or metadata @@ -226,8 +242,10 @@ def post_get_namespaced_tag_key(self, response: tag_keys.TagKey) -> tag_keys.Tag return response def pre_get_tag_key( - self, request: tag_keys.GetTagKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag_keys.GetTagKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: tag_keys.GetTagKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_keys.GetTagKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_tag_key Override in a subclass to manipulate the request or metadata @@ -245,8 +263,10 @@ def post_get_tag_key(self, response: tag_keys.TagKey) -> tag_keys.TagKey: return response def pre_list_tag_keys( - self, request: tag_keys.ListTagKeysRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag_keys.ListTagKeysRequest, Sequence[Tuple[str, str]]]: + self, + request: tag_keys.ListTagKeysRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_keys.ListTagKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tag_keys Override in a subclass to manipulate the request or metadata @@ -268,8 +288,10 @@ def post_list_tag_keys( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -289,8 +311,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -310,8 +335,10 @@ def post_test_iam_permissions( return response def pre_update_tag_key( - self, request: tag_keys.UpdateTagKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag_keys.UpdateTagKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: tag_keys.UpdateTagKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_keys.UpdateTagKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_tag_key Override in a subclass to manipulate the request or metadata @@ -333,8 +360,10 @@ def post_update_tag_key( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -508,7 +537,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create tag key method over HTTP. @@ -519,8 +548,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -533,6 +564,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseCreateTagKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag_key(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseCreateTagKey._get_transcoded_request( @@ -551,6 +583,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.CreateTagKey", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "CreateTagKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._CreateTagKey._get_response( self._host, @@ -570,7 +629,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag_key(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.resourcemanager_v3.TagKeysClient.create_tag_key", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "CreateTagKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTagKey(_BaseTagKeysRestTransport._BaseDeleteTagKey, TagKeysRestStub): @@ -605,7 +686,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete tag key method over HTTP. @@ -616,8 +697,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -630,6 +713,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseDeleteTagKey._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag_key(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseDeleteTagKey._get_transcoded_request( @@ -644,6 +728,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.DeleteTagKey", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "DeleteTagKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._DeleteTagKey._get_response( self._host, @@ -662,7 +773,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_tag_key(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.resourcemanager_v3.TagKeysClient.delete_tag_key", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "DeleteTagKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseTagKeysRestTransport._BaseGetIamPolicy, TagKeysRestStub): @@ -698,7 +831,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -708,8 +841,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -794,6 +929,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -812,6 +948,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._GetIamPolicy._get_response( self._host, @@ -833,7 +996,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.resourcemanager_v3.TagKeysClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNamespacedTagKey( @@ -870,7 +1055,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Call the get namespaced tag key method over HTTP. @@ -881,8 +1066,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_keys.TagKey: @@ -894,6 +1081,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseGetNamespacedTagKey._get_http_options() ) + request, metadata = self._interceptor.pre_get_namespaced_tag_key( request, metadata ) @@ -906,6 +1094,33 @@ def __call__( 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.resourcemanager_v3.TagKeysClient.GetNamespacedTagKey", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetNamespacedTagKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._GetNamespacedTagKey._get_response( self._host, @@ -926,7 +1141,29 @@ def __call__( pb_resp = tag_keys.TagKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_namespaced_tag_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_keys.TagKey.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.resourcemanager_v3.TagKeysClient.get_namespaced_tag_key", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetNamespacedTagKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTagKey(_BaseTagKeysRestTransport._BaseGetTagKey, TagKeysRestStub): @@ -961,7 +1198,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.TagKey: r"""Call the get tag key method over HTTP. @@ -972,8 +1209,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_keys.TagKey: @@ -983,6 +1222,7 @@ def __call__( """ http_options = _BaseTagKeysRestTransport._BaseGetTagKey._get_http_options() + request, metadata = self._interceptor.pre_get_tag_key(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseGetTagKey._get_transcoded_request( @@ -997,6 +1237,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.GetTagKey", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetTagKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._GetTagKey._get_response( self._host, @@ -1017,7 +1284,29 @@ def __call__( pb_resp = tag_keys.TagKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tag_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_keys.TagKey.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.resourcemanager_v3.TagKeysClient.get_tag_key", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetTagKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTagKeys(_BaseTagKeysRestTransport._BaseListTagKeys, TagKeysRestStub): @@ -1052,7 +1341,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_keys.ListTagKeysResponse: r"""Call the list tag keys method over HTTP. @@ -1063,8 +1352,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_keys.ListTagKeysResponse: @@ -1074,6 +1365,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseListTagKeys._get_http_options() ) + request, metadata = self._interceptor.pre_list_tag_keys(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseListTagKeys._get_transcoded_request( @@ -1088,6 +1380,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.ListTagKeys", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "ListTagKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._ListTagKeys._get_response( self._host, @@ -1108,7 +1427,29 @@ def __call__( pb_resp = tag_keys.ListTagKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tag_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_keys.ListTagKeysResponse.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.resourcemanager_v3.TagKeysClient.list_tag_keys", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "ListTagKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseTagKeysRestTransport._BaseSetIamPolicy, TagKeysRestStub): @@ -1144,7 +1485,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1154,8 +1495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1240,6 +1583,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1258,6 +1602,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._SetIamPolicy._get_response( self._host, @@ -1279,7 +1650,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.resourcemanager_v3.TagKeysClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1317,7 +1710,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1327,8 +1720,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1338,6 +1733,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1354,6 +1750,33 @@ def __call__( 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.resourcemanager_v3.TagKeysClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._TestIamPermissions._get_response( self._host, @@ -1375,7 +1798,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.resourcemanager_v3.TagKeysClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTagKey(_BaseTagKeysRestTransport._BaseUpdateTagKey, TagKeysRestStub): @@ -1411,7 +1856,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update tag key method over HTTP. @@ -1422,8 +1867,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1436,6 +1883,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseUpdateTagKey._get_http_options() ) + request, metadata = self._interceptor.pre_update_tag_key(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseUpdateTagKey._get_transcoded_request( @@ -1454,6 +1902,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.UpdateTagKey", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "UpdateTagKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._UpdateTagKey._get_response( self._host, @@ -1473,7 +1948,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tag_key(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.resourcemanager_v3.TagKeysClient.update_tag_key", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "UpdateTagKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1585,7 +2082,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1595,8 +2092,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1605,6 +2104,7 @@ def __call__( http_options = ( _BaseTagKeysRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTagKeysRestTransport._BaseGetOperation._get_transcoded_request( @@ -1619,6 +2119,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagKeysClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagKeysRestTransport._GetOperation._get_response( self._host, @@ -1638,6 +2165,27 @@ def __call__( 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.resourcemanager_v3.TagKeysAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagKeys", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/async_client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/async_client.py index a281aee5c2a0..3d5c6486a4c3 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/async_client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TagValuesTransport from .transports.grpc_asyncio import TagValuesGrpcAsyncIOTransport +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 TagValuesAsyncClient: """Allow users to create and manage tag values.""" @@ -256,6 +266,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcemanager_v3.TagValuesAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "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.resourcemanager.v3.TagValues", + "credentialsType": None, + }, + ) + async def list_tag_values( self, request: Optional[Union[tag_values.ListTagValuesRequest, dict]] = None, @@ -263,7 +295,7 @@ async def list_tag_values( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagValuesAsyncPager: r"""Lists all TagValues for a specific TagKey. @@ -308,8 +340,10 @@ async def sample_list_tag_values(): 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, 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: google.cloud.resourcemanager_v3.services.tag_values.pagers.ListTagValuesAsyncPager: @@ -378,7 +412,7 @@ async def get_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Retrieves a TagValue. This method will return ``PERMISSION_DENIED`` if the value does not exist or the user @@ -424,8 +458,10 @@ async def sample_get_tag_value(): 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, 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: google.cloud.resourcemanager_v3.types.TagValue: @@ -488,7 +524,7 @@ async def get_namespaced_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Retrieves a TagValue by its namespaced name. This method will return ``PERMISSION_DENIED`` if the value does not exist or the @@ -545,8 +581,10 @@ async def sample_get_namespaced_tag_value(): 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, 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: google.cloud.resourcemanager_v3.types.TagValue: @@ -603,7 +641,7 @@ async def create_tag_value( tag_value: Optional[tag_values.TagValue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is @@ -659,8 +697,10 @@ async def sample_create_tag_value(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -727,7 +767,7 @@ async def update_tag_value( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the attributes of the TagValue resource. @@ -787,8 +827,10 @@ async def sample_update_tag_value(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -864,7 +906,7 @@ async def delete_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a TagValue. The TagValue cannot have any bindings when it is deleted. @@ -914,8 +956,10 @@ async def sample_delete_tag_value(): 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, 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: google.api_core.operation_async.AsyncOperation: @@ -987,7 +1031,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The @@ -1039,8 +1083,10 @@ async def sample_get_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1126,7 +1172,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a TagValue, replacing any existing policy. The ``resource`` field should be the TagValue's @@ -1176,8 +1222,10 @@ async def sample_set_iam_policy(): 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, 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: google.iam.v1.policy_pb2.Policy: @@ -1264,7 +1312,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified TagValue. The ``resource`` field should be the TagValue's resource name. @@ -1324,8 +1372,10 @@ async def sample_test_iam_permissions(): 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, 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1382,7 +1432,7 @@ async def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1393,8 +1443,10 @@ async def get_operation( 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, 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/client.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/client.py index 6110fc9e8f2a..fd081c6cd176 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/client.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.iam.v1 import iam_policy_pb2 # type: ignore @@ -577,6 +587,10 @@ def __init__( # 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( @@ -639,6 +653,29 @@ def __init__( 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.resourcemanager_v3.TagValuesClient`.", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "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.resourcemanager.v3.TagValues", + "credentialsType": None, + }, + ) + def list_tag_values( self, request: Optional[Union[tag_values.ListTagValuesRequest, dict]] = None, @@ -646,7 +683,7 @@ def list_tag_values( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagValuesPager: r"""Lists all TagValues for a specific TagKey. @@ -691,8 +728,10 @@ def sample_list_tag_values(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.services.tag_values.pagers.ListTagValuesPager: @@ -758,7 +797,7 @@ def get_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Retrieves a TagValue. This method will return ``PERMISSION_DENIED`` if the value does not exist or the user @@ -804,8 +843,10 @@ def sample_get_tag_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.TagValue: @@ -865,7 +906,7 @@ def get_namespaced_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Retrieves a TagValue by its namespaced name. This method will return ``PERMISSION_DENIED`` if the value does not exist or the @@ -922,8 +963,10 @@ def sample_get_namespaced_tag_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcemanager_v3.types.TagValue: @@ -977,7 +1020,7 @@ def create_tag_value( tag_value: Optional[tag_values.TagValue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is @@ -1033,8 +1076,10 @@ def sample_create_tag_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1098,7 +1143,7 @@ def update_tag_value( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the attributes of the TagValue resource. @@ -1158,8 +1203,10 @@ def sample_update_tag_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1232,7 +1279,7 @@ def delete_tag_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a TagValue. The TagValue cannot have any bindings when it is deleted. @@ -1282,8 +1329,10 @@ def sample_delete_tag_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.api_core.operation.Operation: @@ -1352,7 +1401,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The @@ -1404,8 +1453,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1492,7 +1543,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on a TagValue, replacing any existing policy. The ``resource`` field should be the TagValue's @@ -1542,8 +1593,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.policy_pb2.Policy: @@ -1631,7 +1684,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified TagValue. The ``resource`` field should be the TagValue's resource name. @@ -1691,8 +1744,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1763,7 +1818,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1774,8 +1829,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/pagers.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/pagers.py index 0952df8d17d4..e0e5fec82f1b 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/pagers.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = tag_values.ListTagValuesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = tag_values.ListTagValuesRequest(request) diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc.py index 917b4f073736..acf988ad41c1 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_values from .base import DEFAULT_CLIENT_INFO, TagValuesTransport +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.resourcemanager.v3.TagValues", + "rpcName": 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.resourcemanager.v3.TagValues", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagValuesGrpcTransport(TagValuesTransport): """gRPC backend transport for TagValues. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -247,7 +333,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def list_tag_values( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_values" not in self._stubs: - self._stubs["list_tag_values"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_values"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/ListTagValues", request_serializer=tag_values.ListTagValuesRequest.serialize, response_deserializer=tag_values.ListTagValuesResponse.deserialize, @@ -299,7 +387,7 @@ def get_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag_value" not in self._stubs: - self._stubs["get_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["get_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetTagValue", request_serializer=tag_values.GetTagValueRequest.serialize, response_deserializer=tag_values.TagValue.deserialize, @@ -327,7 +415,7 @@ def get_namespaced_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespaced_tag_value" not in self._stubs: - self._stubs["get_namespaced_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["get_namespaced_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetNamespacedTagValue", request_serializer=tag_values.GetNamespacedTagValueRequest.serialize, response_deserializer=tag_values.TagValue.deserialize, @@ -357,7 +445,7 @@ def create_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_value" not in self._stubs: - self._stubs["create_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/CreateTagValue", request_serializer=tag_values.CreateTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -383,7 +471,7 @@ def update_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag_value" not in self._stubs: - self._stubs["update_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["update_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/UpdateTagValue", request_serializer=tag_values.UpdateTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -410,7 +498,7 @@ def delete_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_value" not in self._stubs: - self._stubs["delete_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/DeleteTagValue", request_serializer=tag_values.DeleteTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -442,7 +530,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -472,7 +560,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -505,7 +593,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -513,7 +601,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -525,7 +613,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc_asyncio.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc_asyncio.py index 77154bab434a..cebc687dacbf 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcemanager_v3.types import tag_values from .base import DEFAULT_CLIENT_INFO, TagValuesTransport from .grpc import TagValuesGrpcTransport +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.resourcemanager.v3.TagValues", + "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.resourcemanager.v3.TagValues", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TagValuesGrpcAsyncIOTransport(TagValuesTransport): """gRPC AsyncIO backend transport for TagValues. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -256,7 +341,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def list_tag_values( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tag_values" not in self._stubs: - self._stubs["list_tag_values"] = self.grpc_channel.unary_unary( + self._stubs["list_tag_values"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/ListTagValues", request_serializer=tag_values.ListTagValuesRequest.serialize, response_deserializer=tag_values.ListTagValuesResponse.deserialize, @@ -311,7 +396,7 @@ def get_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag_value" not in self._stubs: - self._stubs["get_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["get_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetTagValue", request_serializer=tag_values.GetTagValueRequest.serialize, response_deserializer=tag_values.TagValue.deserialize, @@ -341,7 +426,7 @@ def get_namespaced_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_namespaced_tag_value" not in self._stubs: - self._stubs["get_namespaced_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["get_namespaced_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetNamespacedTagValue", request_serializer=tag_values.GetNamespacedTagValueRequest.serialize, response_deserializer=tag_values.TagValue.deserialize, @@ -373,7 +458,7 @@ def create_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag_value" not in self._stubs: - self._stubs["create_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["create_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/CreateTagValue", request_serializer=tag_values.CreateTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +486,7 @@ def update_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag_value" not in self._stubs: - self._stubs["update_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["update_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/UpdateTagValue", request_serializer=tag_values.UpdateTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -430,7 +515,7 @@ def delete_tag_value( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag_value" not in self._stubs: - self._stubs["delete_tag_value"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag_value"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/DeleteTagValue", request_serializer=tag_values.DeleteTagValueRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -462,7 +547,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -492,7 +577,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -525,7 +610,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.resourcemanager.v3.TagValues/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -620,7 +705,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -636,7 +721,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + 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, diff --git a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/rest.py b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/rest.py index 543d523f73e4..bad4838b1c73 100644 --- a/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/rest.py +++ b/packages/google-cloud-resource-manager/google/cloud/resourcemanager_v3/services/tag_values/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -40,6 +40,14 @@ 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, @@ -144,8 +152,10 @@ def post_update_tag_value(self, response): def pre_create_tag_value( self, request: tag_values.CreateTagValueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.CreateTagValueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_values.CreateTagValueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tag_value Override in a subclass to manipulate the request or metadata @@ -167,8 +177,10 @@ def post_create_tag_value( def pre_delete_tag_value( self, request: tag_values.DeleteTagValueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.DeleteTagValueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_values.DeleteTagValueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tag_value Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_delete_tag_value( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -211,8 +225,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_namespaced_tag_value( self, request: tag_values.GetNamespacedTagValueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.GetNamespacedTagValueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_values.GetNamespacedTagValueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_namespaced_tag_value Override in a subclass to manipulate the request or metadata @@ -234,8 +250,8 @@ def post_get_namespaced_tag_value( def pre_get_tag_value( self, request: tag_values.GetTagValueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.GetTagValueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag_values.GetTagValueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_tag_value Override in a subclass to manipulate the request or metadata @@ -255,8 +271,10 @@ def post_get_tag_value(self, response: tag_values.TagValue) -> tag_values.TagVal def pre_list_tag_values( self, request: tag_values.ListTagValuesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.ListTagValuesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_values.ListTagValuesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tag_values Override in a subclass to manipulate the request or metadata @@ -278,8 +296,10 @@ def post_list_tag_values( def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -299,8 +319,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -322,8 +345,10 @@ def post_test_iam_permissions( def pre_update_tag_value( self, request: tag_values.UpdateTagValueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tag_values.UpdateTagValueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + tag_values.UpdateTagValueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_tag_value Override in a subclass to manipulate the request or metadata @@ -345,8 +370,10 @@ def post_update_tag_value( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + 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 @@ -522,7 +549,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create tag value method over HTTP. @@ -533,8 +560,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -547,6 +576,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseCreateTagValue._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag_value( request, metadata ) @@ -569,6 +599,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.CreateTagValue", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "CreateTagValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._CreateTagValue._get_response( self._host, @@ -588,7 +645,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag_value(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.resourcemanager_v3.TagValuesClient.create_tag_value", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "CreateTagValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTagValue( @@ -625,7 +704,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete tag value method over HTTP. @@ -636,8 +715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -650,6 +731,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseDeleteTagValue._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag_value( request, metadata ) @@ -666,6 +748,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.DeleteTagValue", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "DeleteTagValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._DeleteTagValue._get_response( self._host, @@ -684,7 +793,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_tag_value(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.resourcemanager_v3.TagValuesClient.delete_tag_value", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "DeleteTagValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -722,7 +853,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -732,8 +863,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -818,6 +951,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseTagValuesRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -836,6 +970,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._GetIamPolicy._get_response( self._host, @@ -857,7 +1018,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(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.resourcemanager_v3.TagValuesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNamespacedTagValue( @@ -894,7 +1077,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Call the get namespaced tag value method over HTTP. @@ -905,8 +1088,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_values.TagValue: @@ -920,6 +1105,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseGetNamespacedTagValue._get_http_options() ) + request, metadata = self._interceptor.pre_get_namespaced_tag_value( request, metadata ) @@ -932,6 +1118,33 @@ def __call__( 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.resourcemanager_v3.TagValuesClient.GetNamespacedTagValue", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetNamespacedTagValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._GetNamespacedTagValue._get_response( self._host, @@ -952,7 +1165,29 @@ def __call__( pb_resp = tag_values.TagValue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_namespaced_tag_value(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_values.TagValue.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.resourcemanager_v3.TagValuesClient.get_namespaced_tag_value", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetNamespacedTagValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTagValue(_BaseTagValuesRestTransport._BaseGetTagValue, TagValuesRestStub): @@ -987,7 +1222,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.TagValue: r"""Call the get tag value method over HTTP. @@ -998,8 +1233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_values.TagValue: @@ -1013,6 +1250,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseGetTagValue._get_http_options() ) + request, metadata = self._interceptor.pre_get_tag_value(request, metadata) transcoded_request = ( _BaseTagValuesRestTransport._BaseGetTagValue._get_transcoded_request( @@ -1027,6 +1265,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.GetTagValue", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetTagValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._GetTagValue._get_response( self._host, @@ -1047,7 +1312,29 @@ def __call__( pb_resp = tag_values.TagValue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tag_value(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_values.TagValue.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.resourcemanager_v3.TagValuesClient.get_tag_value", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetTagValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTagValues( @@ -1084,7 +1371,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag_values.ListTagValuesResponse: r"""Call the list tag values method over HTTP. @@ -1097,8 +1384,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.tag_values.ListTagValuesResponse: @@ -1108,6 +1397,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseListTagValues._get_http_options() ) + request, metadata = self._interceptor.pre_list_tag_values(request, metadata) transcoded_request = ( _BaseTagValuesRestTransport._BaseListTagValues._get_transcoded_request( @@ -1122,6 +1412,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.ListTagValues", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "ListTagValues", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._ListTagValues._get_response( self._host, @@ -1142,7 +1459,31 @@ def __call__( pb_resp = tag_values.ListTagValuesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tag_values(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag_values.ListTagValuesResponse.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.resourcemanager_v3.TagValuesClient.list_tag_values", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "ListTagValues", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1180,7 +1521,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1190,8 +1531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.policy_pb2.Policy: @@ -1276,6 +1619,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseTagValuesRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1294,6 +1638,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._SetIamPolicy._get_response( self._host, @@ -1315,7 +1686,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(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.resourcemanager_v3.TagValuesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1353,7 +1746,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1363,8 +1756,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1374,6 +1769,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1390,6 +1786,33 @@ def __call__( 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.resourcemanager_v3.TagValuesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._TestIamPermissions._get_response( self._host, @@ -1411,7 +1834,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(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.resourcemanager_v3.TagValuesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTagValue( @@ -1449,7 +1894,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update tag value method over HTTP. @@ -1460,8 +1905,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.operations_pb2.Operation: @@ -1474,6 +1921,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseUpdateTagValue._get_http_options() ) + request, metadata = self._interceptor.pre_update_tag_value( request, metadata ) @@ -1496,6 +1944,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.UpdateTagValue", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "UpdateTagValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._UpdateTagValue._get_response( self._host, @@ -1515,7 +1990,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tag_value(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.resourcemanager_v3.TagValuesClient.update_tag_value", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "UpdateTagValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1631,7 +2128,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1641,8 +2138,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: operations_pb2.Operation: Response from GetOperation method. @@ -1651,6 +2150,7 @@ def __call__( http_options = ( _BaseTagValuesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTagValuesRestTransport._BaseGetOperation._get_transcoded_request( @@ -1665,6 +2165,33 @@ def __call__( ) ) + 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.resourcemanager_v3.TagValuesClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TagValuesRestTransport._GetOperation._get_response( self._host, @@ -1684,6 +2211,27 @@ def __call__( 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.resourcemanager_v3.TagValuesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.resourcemanager.v3.TagValues", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-resource-manager/samples/generated_samples/snippet_metadata_google.cloud.resourcemanager.v3.json b/packages/google-cloud-resource-manager/samples/generated_samples/snippet_metadata_google.cloud.resourcemanager.v3.json index 2516b2643b20..18bac0c91496 100644 --- a/packages/google-cloud-resource-manager/samples/generated_samples/snippet_metadata_google.cloud.resourcemanager.v3.json +++ b/packages/google-cloud-resource-manager/samples/generated_samples/snippet_metadata_google.cloud.resourcemanager.v3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-resource-manager", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Folder", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Folder", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.folders.pagers.ListFoldersAsyncPager", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.folders.pagers.ListFoldersPager", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1021,7 +1021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.folders.pagers.SearchFoldersAsyncPager", @@ -1101,7 +1101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.folders.pagers.SearchFoldersPager", @@ -1182,7 +1182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1347,7 +1347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1677,7 +1677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1761,7 +1761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1842,7 +1842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1922,7 +1922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2003,7 +2003,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Organization", @@ -2083,7 +2083,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Organization", @@ -2164,7 +2164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.organizations.pagers.SearchOrganizationsAsyncPager", @@ -2244,7 +2244,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.organizations.pagers.SearchOrganizationsPager", @@ -2325,7 +2325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2405,7 +2405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2490,7 +2490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2574,7 +2574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2655,7 +2655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2735,7 +2735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2816,7 +2816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2896,7 +2896,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2977,7 +2977,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3057,7 +3057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3138,7 +3138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Project", @@ -3218,7 +3218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.Project", @@ -3299,7 +3299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.projects.pagers.ListProjectsAsyncPager", @@ -3379,7 +3379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.projects.pagers.ListProjectsPager", @@ -3464,7 +3464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3548,7 +3548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3629,7 +3629,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.projects.pagers.SearchProjectsAsyncPager", @@ -3709,7 +3709,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.projects.pagers.SearchProjectsPager", @@ -3790,7 +3790,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3870,7 +3870,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3955,7 +3955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -4039,7 +4039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -4120,7 +4120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4200,7 +4200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4285,7 +4285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4369,7 +4369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4450,7 +4450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4530,7 +4530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4611,7 +4611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4691,7 +4691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4772,7 +4772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListEffectiveTagsAsyncPager", @@ -4852,7 +4852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListEffectiveTagsPager", @@ -4933,7 +4933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListTagBindingsAsyncPager", @@ -5013,7 +5013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_bindings.pagers.ListTagBindingsPager", @@ -5098,7 +5098,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5182,7 +5182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5263,7 +5263,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5343,7 +5343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5424,7 +5424,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_holds.pagers.ListTagHoldsAsyncPager", @@ -5504,7 +5504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_holds.pagers.ListTagHoldsPager", @@ -5585,7 +5585,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5665,7 +5665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5746,7 +5746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5826,7 +5826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5907,7 +5907,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -5987,7 +5987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -6068,7 +6068,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagKey", @@ -6148,7 +6148,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagKey", @@ -6229,7 +6229,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagKey", @@ -6309,7 +6309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagKey", @@ -6390,7 +6390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_keys.pagers.ListTagKeysAsyncPager", @@ -6470,7 +6470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_keys.pagers.ListTagKeysPager", @@ -6551,7 +6551,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -6631,7 +6631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -6716,7 +6716,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -6800,7 +6800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -6885,7 +6885,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6969,7 +6969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7050,7 +7050,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7130,7 +7130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7211,7 +7211,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7291,7 +7291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7372,7 +7372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -7452,7 +7452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -7533,7 +7533,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagValue", @@ -7613,7 +7613,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagValue", @@ -7694,7 +7694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagValue", @@ -7774,7 +7774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.types.TagValue", @@ -7855,7 +7855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_values.pagers.ListTagValuesAsyncPager", @@ -7935,7 +7935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcemanager_v3.services.tag_values.pagers.ListTagValuesPager", @@ -8016,7 +8016,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -8096,7 +8096,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -8181,7 +8181,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -8265,7 +8265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -8350,7 +8350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8434,7 +8434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_folders.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_folders.py index 5561ddb777e7..5142b5a5fa6c 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_folders.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_folders.py @@ -4995,6 +4995,7 @@ def test_get_folder_rest_required_fields(request_type=folders.GetFolderRequest): response_value._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_folder(request) @@ -5040,6 +5041,7 @@ def test_get_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_folder(**mock_args) @@ -5179,6 +5181,7 @@ def test_list_folders_rest_required_fields(request_type=folders.ListFoldersReque response_value._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_folders(request) @@ -5240,6 +5243,7 @@ def test_list_folders_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_folders(**mock_args) @@ -5390,6 +5394,7 @@ def test_search_folders_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_folders(**mock_args) @@ -5575,6 +5580,7 @@ def test_create_folder_rest_required_fields(request_type=folders.CreateFolderReq response_value._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_folder(request) @@ -5618,6 +5624,7 @@ def test_create_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_folder(**mock_args) @@ -5742,6 +5749,7 @@ def test_update_folder_rest_required_fields(request_type=folders.UpdateFolderReq response_value._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_folder(request) @@ -5794,6 +5802,7 @@ def test_update_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_folder(**mock_args) @@ -5928,6 +5937,7 @@ def test_move_folder_rest_required_fields(request_type=folders.MoveFolderRequest response_value._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.move_folder(request) @@ -5980,6 +5990,7 @@ def test_move_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.move_folder(**mock_args) @@ -6109,6 +6120,7 @@ def test_delete_folder_rest_required_fields(request_type=folders.DeleteFolderReq response_value._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_folder(request) @@ -6152,6 +6164,7 @@ def test_delete_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_folder(**mock_args) @@ -6283,6 +6296,7 @@ def test_undelete_folder_rest_required_fields( response_value._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.undelete_folder(request) @@ -6326,6 +6340,7 @@ def test_undelete_folder_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_folder(**mock_args) @@ -6454,6 +6469,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -6497,6 +6513,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -6625,6 +6642,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -6676,6 +6694,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -6812,6 +6831,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -6864,6 +6884,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -7567,6 +7588,7 @@ def test_get_folder_rest_bad_request(request_type=folders.GetFolderRequest): 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_folder(request) @@ -7606,6 +7628,7 @@ def test_get_folder_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_folder(request) # Establish that the response is the type that we expect. @@ -7646,6 +7669,7 @@ def test_get_folder_rest_interceptors(null_interceptor): 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 = folders.Folder.to_json(folders.Folder()) req.return_value.content = return_value @@ -7688,6 +7712,7 @@ def test_list_folders_rest_bad_request(request_type=folders.ListFoldersRequest): 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_folders(request) @@ -7723,6 +7748,7 @@ def test_list_folders_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_folders(request) # Establish that the response is the type that we expect. @@ -7759,6 +7785,7 @@ def test_list_folders_rest_interceptors(null_interceptor): 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 = folders.ListFoldersResponse.to_json( folders.ListFoldersResponse() ) @@ -7803,6 +7830,7 @@ def test_search_folders_rest_bad_request(request_type=folders.SearchFoldersReque 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.search_folders(request) @@ -7838,6 +7866,7 @@ def test_search_folders_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_folders(request) # Establish that the response is the type that we expect. @@ -7874,6 +7903,7 @@ def test_search_folders_rest_interceptors(null_interceptor): 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 = folders.SearchFoldersResponse.to_json( folders.SearchFoldersResponse() ) @@ -7918,6 +7948,7 @@ def test_create_folder_rest_bad_request(request_type=folders.CreateFolderRequest 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_folder(request) @@ -8025,6 +8056,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_folder(request) # Establish that the response is the type that we expect. @@ -8062,6 +8094,7 @@ def test_create_folder_rest_interceptors(null_interceptor): 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 @@ -8104,6 +8137,7 @@ def test_update_folder_rest_bad_request(request_type=folders.UpdateFolderRequest 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_folder(request) @@ -8211,6 +8245,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_folder(request) # Establish that the response is the type that we expect. @@ -8248,6 +8283,7 @@ def test_update_folder_rest_interceptors(null_interceptor): 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 @@ -8290,6 +8326,7 @@ def test_move_folder_rest_bad_request(request_type=folders.MoveFolderRequest): 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.move_folder(request) @@ -8320,6 +8357,7 @@ def test_move_folder_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.move_folder(request) # Establish that the response is the type that we expect. @@ -8357,6 +8395,7 @@ def test_move_folder_rest_interceptors(null_interceptor): 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 @@ -8399,6 +8438,7 @@ def test_delete_folder_rest_bad_request(request_type=folders.DeleteFolderRequest 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_folder(request) @@ -8429,6 +8469,7 @@ def test_delete_folder_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_folder(request) # Establish that the response is the type that we expect. @@ -8466,6 +8507,7 @@ def test_delete_folder_rest_interceptors(null_interceptor): 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 @@ -8508,6 +8550,7 @@ def test_undelete_folder_rest_bad_request(request_type=folders.UndeleteFolderReq 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.undelete_folder(request) @@ -8538,6 +8581,7 @@ def test_undelete_folder_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_folder(request) # Establish that the response is the type that we expect. @@ -8575,6 +8619,7 @@ def test_undelete_folder_rest_interceptors(null_interceptor): 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 @@ -8619,6 +8664,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -8652,6 +8698,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -8689,6 +8736,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -8733,6 +8781,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -8766,6 +8815,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -8803,6 +8853,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -8847,6 +8898,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -8879,6 +8931,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -8915,6 +8968,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -8961,6 +9015,7 @@ def test_get_operation_rest_bad_request( 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) @@ -8991,6 +9046,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_organizations.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_organizations.py index e4f013a13d5c..18afea0f64d2 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_organizations.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_organizations.py @@ -3038,6 +3038,7 @@ def test_get_organization_rest_required_fields( response_value._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_organization(request) @@ -3083,6 +3084,7 @@ def test_get_organization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_organization(**mock_args) @@ -3178,6 +3180,7 @@ def test_search_organizations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_organizations(**mock_args) @@ -3369,6 +3372,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -3412,6 +3416,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -3541,6 +3546,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -3592,6 +3598,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -3729,6 +3736,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -3781,6 +3789,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -4212,6 +4221,7 @@ def test_get_organization_rest_bad_request( 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_organization(request) @@ -4251,6 +4261,7 @@ def test_get_organization_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_organization(request) # Establish that the response is the type that we expect. @@ -4294,6 +4305,7 @@ def test_get_organization_rest_interceptors(null_interceptor): 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 = organizations.Organization.to_json(organizations.Organization()) req.return_value.content = return_value @@ -4338,6 +4350,7 @@ def test_search_organizations_rest_bad_request( 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.search_organizations(request) @@ -4373,6 +4386,7 @@ def test_search_organizations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_organizations(request) # Establish that the response is the type that we expect. @@ -4413,6 +4427,7 @@ def test_search_organizations_rest_interceptors(null_interceptor): 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 = organizations.SearchOrganizationsResponse.to_json( organizations.SearchOrganizationsResponse() ) @@ -4459,6 +4474,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -4492,6 +4508,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -4531,6 +4548,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -4575,6 +4593,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -4608,6 +4627,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4647,6 +4667,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -4691,6 +4712,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -4723,6 +4745,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4761,6 +4784,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -4807,6 +4831,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4837,6 +4862,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_projects.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_projects.py index dd9b17dda71a..ce0a5344f899 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_projects.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_projects.py @@ -5014,6 +5014,7 @@ def test_get_project_rest_required_fields(request_type=projects.GetProjectReques response_value._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_project(request) @@ -5059,6 +5060,7 @@ def test_get_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_project(**mock_args) @@ -5198,6 +5200,7 @@ def test_list_projects_rest_required_fields(request_type=projects.ListProjectsRe response_value._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_projects(request) @@ -5259,6 +5262,7 @@ def test_list_projects_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_projects(**mock_args) @@ -5411,6 +5415,7 @@ def test_search_projects_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.search_projects(**mock_args) @@ -5598,6 +5603,7 @@ def test_create_project_rest_required_fields( response_value._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_project(request) @@ -5641,6 +5647,7 @@ def test_create_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_project(**mock_args) @@ -5769,6 +5776,7 @@ def test_update_project_rest_required_fields( response_value._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_project(request) @@ -5813,6 +5821,7 @@ def test_update_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_project(**mock_args) @@ -5947,6 +5956,7 @@ def test_move_project_rest_required_fields(request_type=projects.MoveProjectRequ response_value._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.move_project(request) @@ -5999,6 +6009,7 @@ def test_move_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.move_project(**mock_args) @@ -6130,6 +6141,7 @@ def test_delete_project_rest_required_fields( response_value._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_project(request) @@ -6173,6 +6185,7 @@ def test_delete_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_project(**mock_args) @@ -6306,6 +6319,7 @@ def test_undelete_project_rest_required_fields( response_value._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.undelete_project(request) @@ -6349,6 +6363,7 @@ def test_undelete_project_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.undelete_project(**mock_args) @@ -6477,6 +6492,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -6520,6 +6536,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -6648,6 +6665,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -6699,6 +6717,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -6835,6 +6854,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -6887,6 +6907,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -7591,6 +7612,7 @@ def test_get_project_rest_bad_request(request_type=projects.GetProjectRequest): 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_project(request) @@ -7631,6 +7653,7 @@ def test_get_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_project(request) # Establish that the response is the type that we expect. @@ -7672,6 +7695,7 @@ def test_get_project_rest_interceptors(null_interceptor): 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 = projects.Project.to_json(projects.Project()) req.return_value.content = return_value @@ -7714,6 +7738,7 @@ def test_list_projects_rest_bad_request(request_type=projects.ListProjectsReques 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_projects(request) @@ -7749,6 +7774,7 @@ def test_list_projects_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_projects(request) # Establish that the response is the type that we expect. @@ -7785,6 +7811,7 @@ def test_list_projects_rest_interceptors(null_interceptor): 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 = projects.ListProjectsResponse.to_json( projects.ListProjectsResponse() ) @@ -7829,6 +7856,7 @@ def test_search_projects_rest_bad_request(request_type=projects.SearchProjectsRe 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.search_projects(request) @@ -7864,6 +7892,7 @@ def test_search_projects_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.search_projects(request) # Establish that the response is the type that we expect. @@ -7900,6 +7929,7 @@ def test_search_projects_rest_interceptors(null_interceptor): 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 = projects.SearchProjectsResponse.to_json( projects.SearchProjectsResponse() ) @@ -7944,6 +7974,7 @@ def test_create_project_rest_bad_request(request_type=projects.CreateProjectRequ 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_project(request) @@ -8053,6 +8084,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_project(request) # Establish that the response is the type that we expect. @@ -8090,6 +8122,7 @@ def test_create_project_rest_interceptors(null_interceptor): 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 @@ -8132,6 +8165,7 @@ def test_update_project_rest_bad_request(request_type=projects.UpdateProjectRequ 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_project(request) @@ -8241,6 +8275,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_project(request) # Establish that the response is the type that we expect. @@ -8278,6 +8313,7 @@ def test_update_project_rest_interceptors(null_interceptor): 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 @@ -8320,6 +8356,7 @@ def test_move_project_rest_bad_request(request_type=projects.MoveProjectRequest) 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.move_project(request) @@ -8350,6 +8387,7 @@ def test_move_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.move_project(request) # Establish that the response is the type that we expect. @@ -8387,6 +8425,7 @@ def test_move_project_rest_interceptors(null_interceptor): 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 @@ -8429,6 +8468,7 @@ def test_delete_project_rest_bad_request(request_type=projects.DeleteProjectRequ 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_project(request) @@ -8459,6 +8499,7 @@ def test_delete_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_project(request) # Establish that the response is the type that we expect. @@ -8496,6 +8537,7 @@ def test_delete_project_rest_interceptors(null_interceptor): 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 @@ -8540,6 +8582,7 @@ def test_undelete_project_rest_bad_request( 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.undelete_project(request) @@ -8570,6 +8613,7 @@ def test_undelete_project_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.undelete_project(request) # Establish that the response is the type that we expect. @@ -8609,6 +8653,7 @@ def test_undelete_project_rest_interceptors(null_interceptor): 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 @@ -8653,6 +8698,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -8686,6 +8732,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -8723,6 +8770,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -8767,6 +8815,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -8800,6 +8849,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -8837,6 +8887,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -8881,6 +8932,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -8913,6 +8965,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -8949,6 +9002,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -8995,6 +9049,7 @@ def test_get_operation_rest_bad_request( 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) @@ -9025,6 +9080,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_bindings.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_bindings.py index 567ccae5563b..ebdb04a2be99 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_bindings.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_bindings.py @@ -2725,6 +2725,7 @@ def test_list_tag_bindings_rest_required_fields( response_value._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_tag_bindings(request) @@ -2785,6 +2786,7 @@ def test_list_tag_bindings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_bindings(**mock_args) @@ -2980,6 +2982,7 @@ def test_create_tag_binding_rest_required_fields( response_value._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_tag_binding(request) @@ -3023,6 +3026,7 @@ def test_create_tag_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_binding(**mock_args) @@ -3157,6 +3161,7 @@ def test_delete_tag_binding_rest_required_fields( response_value._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_tag_binding(request) @@ -3200,6 +3205,7 @@ def test_delete_tag_binding_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_binding(**mock_args) @@ -3344,6 +3350,7 @@ def test_list_effective_tags_rest_required_fields( response_value._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_effective_tags(request) @@ -3404,6 +3411,7 @@ def test_list_effective_tags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_effective_tags(**mock_args) @@ -3846,6 +3854,7 @@ def test_list_tag_bindings_rest_bad_request( 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_tag_bindings(request) @@ -3881,6 +3890,7 @@ def test_list_tag_bindings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_bindings(request) # Establish that the response is the type that we expect. @@ -3921,6 +3931,7 @@ def test_list_tag_bindings_rest_interceptors(null_interceptor): 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 = tag_bindings.ListTagBindingsResponse.to_json( tag_bindings.ListTagBindingsResponse() ) @@ -3967,6 +3978,7 @@ def test_create_tag_binding_rest_bad_request( 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_tag_binding(request) @@ -4070,6 +4082,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_binding(request) # Establish that the response is the type that we expect. @@ -4111,6 +4124,7 @@ def test_create_tag_binding_rest_interceptors(null_interceptor): 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 @@ -4155,6 +4169,7 @@ def test_delete_tag_binding_rest_bad_request( 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_tag_binding(request) @@ -4185,6 +4200,7 @@ def test_delete_tag_binding_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_binding(request) # Establish that the response is the type that we expect. @@ -4226,6 +4242,7 @@ def test_delete_tag_binding_rest_interceptors(null_interceptor): 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 @@ -4270,6 +4287,7 @@ def test_list_effective_tags_rest_bad_request( 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_effective_tags(request) @@ -4305,6 +4323,7 @@ def test_list_effective_tags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_effective_tags(request) # Establish that the response is the type that we expect. @@ -4345,6 +4364,7 @@ def test_list_effective_tags_rest_interceptors(null_interceptor): 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 = tag_bindings.ListEffectiveTagsResponse.to_json( tag_bindings.ListEffectiveTagsResponse() ) @@ -4391,6 +4411,7 @@ def test_get_operation_rest_bad_request( 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) @@ -4421,6 +4442,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_holds.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_holds.py index 2456c0e8e62e..fb079f4babac 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_holds.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_holds.py @@ -2310,6 +2310,7 @@ def test_create_tag_hold_rest_required_fields( response_value._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_tag_hold(request) @@ -2362,6 +2363,7 @@ def test_create_tag_hold_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_hold(**mock_args) @@ -2495,6 +2497,7 @@ def test_delete_tag_hold_rest_required_fields( response_value._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_tag_hold(request) @@ -2538,6 +2541,7 @@ def test_delete_tag_hold_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_hold(**mock_args) @@ -2675,6 +2679,7 @@ def test_list_tag_holds_rest_required_fields( response_value._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_tag_holds(request) @@ -2729,6 +2734,7 @@ def test_list_tag_holds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_holds(**mock_args) @@ -3103,6 +3109,7 @@ def test_create_tag_hold_rest_bad_request(request_type=tag_holds.CreateTagHoldRe 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_tag_hold(request) @@ -3207,6 +3214,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_hold(request) # Establish that the response is the type that we expect. @@ -3244,6 +3252,7 @@ def test_create_tag_hold_rest_interceptors(null_interceptor): 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 @@ -3286,6 +3295,7 @@ def test_delete_tag_hold_rest_bad_request(request_type=tag_holds.DeleteTagHoldRe 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_tag_hold(request) @@ -3316,6 +3326,7 @@ def test_delete_tag_hold_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_hold(request) # Establish that the response is the type that we expect. @@ -3353,6 +3364,7 @@ def test_delete_tag_hold_rest_interceptors(null_interceptor): 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 @@ -3395,6 +3407,7 @@ def test_list_tag_holds_rest_bad_request(request_type=tag_holds.ListTagHoldsRequ 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_tag_holds(request) @@ -3430,6 +3443,7 @@ def test_list_tag_holds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_holds(request) # Establish that the response is the type that we expect. @@ -3466,6 +3480,7 @@ def test_list_tag_holds_rest_interceptors(null_interceptor): 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 = tag_holds.ListTagHoldsResponse.to_json( tag_holds.ListTagHoldsResponse() ) @@ -3512,6 +3527,7 @@ def test_get_operation_rest_bad_request( 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) @@ -3542,6 +3558,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_keys.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_keys.py index ca914a37d2f7..a80ef3dd50af 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_keys.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_keys.py @@ -4198,6 +4198,7 @@ def test_list_tag_keys_rest_required_fields(request_type=tag_keys.ListTagKeysReq response_value._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_tag_keys(request) @@ -4258,6 +4259,7 @@ def test_list_tag_keys_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_keys(**mock_args) @@ -4444,6 +4446,7 @@ def test_get_tag_key_rest_required_fields(request_type=tag_keys.GetTagKeyRequest response_value._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_tag_key(request) @@ -4489,6 +4492,7 @@ def test_get_tag_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_key(**mock_args) @@ -4628,6 +4632,7 @@ def test_get_namespaced_tag_key_rest_required_fields( response_value._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_namespaced_tag_key(request) @@ -4679,6 +4684,7 @@ def test_get_namespaced_tag_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespaced_tag_key(**mock_args) @@ -4805,6 +4811,7 @@ def test_create_tag_key_rest_required_fields(request_type=tag_keys.CreateTagKeyR response_value._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_tag_key(request) @@ -4848,6 +4855,7 @@ def test_create_tag_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_key(**mock_args) @@ -4977,6 +4985,7 @@ def test_update_tag_key_rest_required_fields(request_type=tag_keys.UpdateTagKeyR response_value._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_tag_key(request) @@ -5029,6 +5038,7 @@ def test_update_tag_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_key(**mock_args) @@ -5165,6 +5175,7 @@ def test_delete_tag_key_rest_required_fields(request_type=tag_keys.DeleteTagKeyR response_value._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_tag_key(request) @@ -5216,6 +5227,7 @@ def test_delete_tag_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_key(**mock_args) @@ -5344,6 +5356,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -5387,6 +5400,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -5515,6 +5529,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -5566,6 +5581,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -5702,6 +5718,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -5754,6 +5771,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -6377,6 +6395,7 @@ def test_list_tag_keys_rest_bad_request(request_type=tag_keys.ListTagKeysRequest 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_tag_keys(request) @@ -6412,6 +6431,7 @@ def test_list_tag_keys_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_keys(request) # Establish that the response is the type that we expect. @@ -6448,6 +6468,7 @@ def test_list_tag_keys_rest_interceptors(null_interceptor): 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 = tag_keys.ListTagKeysResponse.to_json( tag_keys.ListTagKeysResponse() ) @@ -6492,6 +6513,7 @@ def test_get_tag_key_rest_bad_request(request_type=tag_keys.GetTagKeyRequest): 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_tag_key(request) @@ -6533,6 +6555,7 @@ def test_get_tag_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_key(request) # Establish that the response is the type that we expect. @@ -6575,6 +6598,7 @@ def test_get_tag_key_rest_interceptors(null_interceptor): 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 = tag_keys.TagKey.to_json(tag_keys.TagKey()) req.return_value.content = return_value @@ -6619,6 +6643,7 @@ def test_get_namespaced_tag_key_rest_bad_request( 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_namespaced_tag_key(request) @@ -6660,6 +6685,7 @@ def test_get_namespaced_tag_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespaced_tag_key(request) # Establish that the response is the type that we expect. @@ -6704,6 +6730,7 @@ def test_get_namespaced_tag_key_rest_interceptors(null_interceptor): 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 = tag_keys.TagKey.to_json(tag_keys.TagKey()) req.return_value.content = return_value @@ -6746,6 +6773,7 @@ def test_create_tag_key_rest_bad_request(request_type=tag_keys.CreateTagKeyReque 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_tag_key(request) @@ -6855,6 +6883,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_key(request) # Establish that the response is the type that we expect. @@ -6892,6 +6921,7 @@ def test_create_tag_key_rest_interceptors(null_interceptor): 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 @@ -6934,6 +6964,7 @@ def test_update_tag_key_rest_bad_request(request_type=tag_keys.UpdateTagKeyReque 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_tag_key(request) @@ -7043,6 +7074,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_key(request) # Establish that the response is the type that we expect. @@ -7080,6 +7112,7 @@ def test_update_tag_key_rest_interceptors(null_interceptor): 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 @@ -7122,6 +7155,7 @@ def test_delete_tag_key_rest_bad_request(request_type=tag_keys.DeleteTagKeyReque 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_tag_key(request) @@ -7152,6 +7186,7 @@ def test_delete_tag_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_key(request) # Establish that the response is the type that we expect. @@ -7189,6 +7224,7 @@ def test_delete_tag_key_rest_interceptors(null_interceptor): 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 @@ -7233,6 +7269,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -7266,6 +7303,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -7303,6 +7341,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7347,6 +7386,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -7380,6 +7420,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -7417,6 +7458,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7461,6 +7503,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -7493,6 +7536,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7529,6 +7573,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -7575,6 +7620,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7605,6 +7651,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_values.py b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_values.py index 25f14069de0b..bc47dde37a98 100644 --- a/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_values.py +++ b/packages/google-cloud-resource-manager/tests/unit/gapic/resourcemanager_v3/test_tag_values.py @@ -4221,6 +4221,7 @@ def test_list_tag_values_rest_required_fields( response_value._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_tag_values(request) @@ -4281,6 +4282,7 @@ def test_list_tag_values_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_values(**mock_args) @@ -4469,6 +4471,7 @@ def test_get_tag_value_rest_required_fields(request_type=tag_values.GetTagValueR response_value._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_tag_value(request) @@ -4514,6 +4517,7 @@ def test_get_tag_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_value(**mock_args) @@ -4653,6 +4657,7 @@ def test_get_namespaced_tag_value_rest_required_fields( response_value._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_namespaced_tag_value(request) @@ -4704,6 +4709,7 @@ def test_get_namespaced_tag_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_namespaced_tag_value(**mock_args) @@ -4834,6 +4840,7 @@ def test_create_tag_value_rest_required_fields( response_value._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_tag_value(request) @@ -4877,6 +4884,7 @@ def test_create_tag_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_value(**mock_args) @@ -5012,6 +5020,7 @@ def test_update_tag_value_rest_required_fields( response_value._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_tag_value(request) @@ -5064,6 +5073,7 @@ def test_update_tag_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_value(**mock_args) @@ -5204,6 +5214,7 @@ def test_delete_tag_value_rest_required_fields( response_value._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_tag_value(request) @@ -5255,6 +5266,7 @@ def test_delete_tag_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_tag_value(**mock_args) @@ -5383,6 +5395,7 @@ def test_get_iam_policy_rest_required_fields( response_value._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_iam_policy(request) @@ -5426,6 +5439,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_iam_policy(**mock_args) @@ -5555,6 +5569,7 @@ def test_set_iam_policy_rest_required_fields( response_value._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.set_iam_policy(request) @@ -5606,6 +5621,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.set_iam_policy(**mock_args) @@ -5743,6 +5759,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._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.test_iam_permissions(request) @@ -5795,6 +5812,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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.test_iam_permissions(**mock_args) @@ -6416,6 +6434,7 @@ def test_list_tag_values_rest_bad_request(request_type=tag_values.ListTagValuesR 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_tag_values(request) @@ -6451,6 +6470,7 @@ def test_list_tag_values_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_values(request) # Establish that the response is the type that we expect. @@ -6489,6 +6509,7 @@ def test_list_tag_values_rest_interceptors(null_interceptor): 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 = tag_values.ListTagValuesResponse.to_json( tag_values.ListTagValuesResponse() ) @@ -6533,6 +6554,7 @@ def test_get_tag_value_rest_bad_request(request_type=tag_values.GetTagValueReque 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_tag_value(request) @@ -6573,6 +6595,7 @@ def test_get_tag_value_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_value(request) # Establish that the response is the type that we expect. @@ -6614,6 +6637,7 @@ def test_get_tag_value_rest_interceptors(null_interceptor): 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 = tag_values.TagValue.to_json(tag_values.TagValue()) req.return_value.content = return_value @@ -6658,6 +6682,7 @@ def test_get_namespaced_tag_value_rest_bad_request( 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_namespaced_tag_value(request) @@ -6698,6 +6723,7 @@ def test_get_namespaced_tag_value_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_namespaced_tag_value(request) # Establish that the response is the type that we expect. @@ -6741,6 +6767,7 @@ def test_get_namespaced_tag_value_rest_interceptors(null_interceptor): 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 = tag_values.TagValue.to_json(tag_values.TagValue()) req.return_value.content = return_value @@ -6785,6 +6812,7 @@ def test_create_tag_value_rest_bad_request( 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_tag_value(request) @@ -6892,6 +6920,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_value(request) # Establish that the response is the type that we expect. @@ -6931,6 +6960,7 @@ def test_create_tag_value_rest_interceptors(null_interceptor): 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 @@ -6975,6 +7005,7 @@ def test_update_tag_value_rest_bad_request( 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_tag_value(request) @@ -7082,6 +7113,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_value(request) # Establish that the response is the type that we expect. @@ -7121,6 +7153,7 @@ def test_update_tag_value_rest_interceptors(null_interceptor): 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 @@ -7165,6 +7198,7 @@ def test_delete_tag_value_rest_bad_request( 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_tag_value(request) @@ -7195,6 +7229,7 @@ def test_delete_tag_value_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_tag_value(request) # Establish that the response is the type that we expect. @@ -7234,6 +7269,7 @@ def test_delete_tag_value_rest_interceptors(null_interceptor): 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 @@ -7278,6 +7314,7 @@ def test_get_iam_policy_rest_bad_request( 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_iam_policy(request) @@ -7311,6 +7348,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_iam_policy(request) # Establish that the response is the type that we expect. @@ -7348,6 +7386,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7392,6 +7431,7 @@ def test_set_iam_policy_rest_bad_request( 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.set_iam_policy(request) @@ -7425,6 +7465,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -7462,6 +7503,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): 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(policy_pb2.Policy()) req.return_value.content = return_value @@ -7506,6 +7548,7 @@ def test_test_iam_permissions_rest_bad_request( 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.test_iam_permissions(request) @@ -7538,6 +7581,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7574,6 +7618,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): 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( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -7620,6 +7665,7 @@ def test_get_operation_rest_bad_request( 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) @@ -7650,6 +7696,7 @@ def test_get_operation_rest(request_type): response_value.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) diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings/gapic_version.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings/gapic_version.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/gapic_version.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/gapic_version.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/async_client.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/async_client.py index 9d55d4cf1b46..5f2680c48a8e 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/async_client.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ResourceSettingsServiceTransport from .transports.grpc_asyncio import ResourceSettingsServiceGrpcAsyncIOTransport +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 ResourceSettingsServiceAsyncClient: """An interface to interact with resource settings and setting values @@ -281,6 +291,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.resourcesettings_v1.ResourceSettingsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "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.resourcesettings.v1.ResourceSettingsService", + "credentialsType": None, + }, + ) + async def list_settings( self, request: Optional[Union[resource_settings.ListSettingsRequest, dict]] = None, @@ -288,7 +320,7 @@ async def list_settings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSettingsAsyncPager: r"""Lists all the settings that are available on the Cloud resource ``parent``. @@ -338,8 +370,10 @@ async def sample_list_settings(): 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, 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: google.cloud.resourcesettings_v1.services.resource_settings_service.pagers.ListSettingsAsyncPager: @@ -414,7 +448,7 @@ async def get_setting( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Gets a setting. @@ -461,8 +495,10 @@ async def sample_get_setting(): 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, 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: google.cloud.resourcesettings_v1.types.Setting: @@ -520,7 +556,7 @@ async def update_setting( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Updates a setting. @@ -570,8 +606,10 @@ async def sample_update_setting(): 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, 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: google.cloud.resourcesettings_v1.types.Setting: diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/client.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/client.py index 3987d9d7f3ce..58b17256d332 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/client.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ 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.cloud.resourcesettings_v1.services.resource_settings_service import pagers from google.cloud.resourcesettings_v1.types import resource_settings @@ -600,6 +610,10 @@ def __init__( # 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( @@ -666,6 +680,29 @@ def __init__( 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.resourcesettings_v1.ResourceSettingsServiceClient`.", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "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.resourcesettings.v1.ResourceSettingsService", + "credentialsType": None, + }, + ) + def list_settings( self, request: Optional[Union[resource_settings.ListSettingsRequest, dict]] = None, @@ -673,7 +710,7 @@ def list_settings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSettingsPager: r"""Lists all the settings that are available on the Cloud resource ``parent``. @@ -723,8 +760,10 @@ def sample_list_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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.resourcesettings_v1.services.resource_settings_service.pagers.ListSettingsPager: @@ -796,7 +835,7 @@ def get_setting( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Gets a setting. @@ -843,8 +882,10 @@ def sample_get_setting(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcesettings_v1.types.Setting: @@ -899,7 +940,7 @@ def update_setting( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Updates a setting. @@ -949,8 +990,10 @@ def sample_update_setting(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: google.cloud.resourcesettings_v1.types.Setting: diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/pagers.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/pagers.py index 1d7bfb5de289..8dd526182e06 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/pagers.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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`. """ self._method = method self._request = resource_settings.ListSettingsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( 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, 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`. """ self._method = method self._request = resource_settings.ListSettingsRequest(request) diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc.py index e0c02320a362..a484c282e3bf 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ 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.resourcesettings_v1.types import resource_settings from .base import DEFAULT_CLIENT_INFO, ResourceSettingsServiceTransport +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.resourcesettings.v1.ResourceSettingsService", + "rpcName": 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.resourcesettings.v1.ResourceSettingsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ResourceSettingsServiceGrpcTransport(ResourceSettingsServiceTransport): """gRPC backend transport for ResourceSettingsService. @@ -195,7 +276,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -272,7 +358,7 @@ def list_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_settings" not in self._stubs: - self._stubs["list_settings"] = self.grpc_channel.unary_unary( + self._stubs["list_settings"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/ListSettings", request_serializer=resource_settings.ListSettingsRequest.serialize, response_deserializer=resource_settings.ListSettingsResponse.deserialize, @@ -301,7 +387,7 @@ def get_setting( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_setting" not in self._stubs: - self._stubs["get_setting"] = self.grpc_channel.unary_unary( + self._stubs["get_setting"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/GetSetting", request_serializer=resource_settings.GetSettingRequest.serialize, response_deserializer=resource_settings.Setting.deserialize, @@ -342,7 +428,7 @@ def update_setting( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_setting" not in self._stubs: - self._stubs["update_setting"] = self.grpc_channel.unary_unary( + self._stubs["update_setting"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/UpdateSetting", request_serializer=resource_settings.UpdateSettingRequest.serialize, response_deserializer=resource_settings.Setting.deserialize, @@ -350,7 +436,7 @@ def update_setting( return self._stubs["update_setting"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc_asyncio.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc_asyncio.py index ac5e0cc0276c..f42c7b43da18 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries 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 from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.resourcesettings_v1.types import resource_settings from .base import DEFAULT_CLIENT_INFO, ResourceSettingsServiceTransport from .grpc import ResourceSettingsServiceGrpcTransport +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.resourcesettings.v1.ResourceSettingsService", + "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.resourcesettings.v1.ResourceSettingsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ResourceSettingsServiceGrpcAsyncIOTransport(ResourceSettingsServiceTransport): """gRPC AsyncIO backend transport for ResourceSettingsService. @@ -242,10 +324,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + 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 @@ -281,7 +366,7 @@ def list_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_settings" not in self._stubs: - self._stubs["list_settings"] = self.grpc_channel.unary_unary( + self._stubs["list_settings"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/ListSettings", request_serializer=resource_settings.ListSettingsRequest.serialize, response_deserializer=resource_settings.ListSettingsResponse.deserialize, @@ -312,7 +397,7 @@ def get_setting( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_setting" not in self._stubs: - self._stubs["get_setting"] = self.grpc_channel.unary_unary( + self._stubs["get_setting"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/GetSetting", request_serializer=resource_settings.GetSettingRequest.serialize, response_deserializer=resource_settings.Setting.deserialize, @@ -355,7 +440,7 @@ def update_setting( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_setting" not in self._stubs: - self._stubs["update_setting"] = self.grpc_channel.unary_unary( + self._stubs["update_setting"] = self._logged_channel.unary_unary( "/google.cloud.resourcesettings.v1.ResourceSettingsService/UpdateSetting", request_serializer=resource_settings.UpdateSettingRequest.serialize, response_deserializer=resource_settings.Setting.deserialize, @@ -418,7 +503,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/rest.py b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/rest.py index f5faab470b13..2d86da54e90c 100644 --- a/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/rest.py +++ b/packages/google-cloud-resource-settings/google/cloud/resourcesettings_v1/services/resource_settings_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ 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, @@ -93,8 +101,10 @@ def post_update_setting(self, response): def pre_get_setting( self, request: resource_settings.GetSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[resource_settings.GetSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + resource_settings.GetSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_setting Override in a subclass to manipulate the request or metadata @@ -116,8 +126,10 @@ def post_get_setting( def pre_list_settings( self, request: resource_settings.ListSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[resource_settings.ListSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + resource_settings.ListSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_settings Override in a subclass to manipulate the request or metadata @@ -139,8 +151,10 @@ def post_list_settings( def pre_update_setting( self, request: resource_settings.UpdateSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[resource_settings.UpdateSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + resource_settings.UpdateSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_setting Override in a subclass to manipulate the request or metadata @@ -297,7 +311,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Call the get setting method over HTTP. @@ -307,8 +321,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource_settings.Setting: @@ -318,6 +334,7 @@ def __call__( http_options = ( _BaseResourceSettingsServiceRestTransport._BaseGetSetting._get_http_options() ) + request, metadata = self._interceptor.pre_get_setting(request, metadata) transcoded_request = _BaseResourceSettingsServiceRestTransport._BaseGetSetting._get_transcoded_request( http_options, request @@ -328,6 +345,33 @@ def __call__( 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.resourcesettings_v1.ResourceSettingsServiceClient.GetSetting", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "GetSetting", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourceSettingsServiceRestTransport._GetSetting._get_response( self._host, @@ -348,7 +392,29 @@ def __call__( pb_resp = resource_settings.Setting.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_setting(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource_settings.Setting.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.resourcesettings_v1.ResourceSettingsServiceClient.get_setting", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "GetSetting", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSettings( @@ -386,7 +452,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.ListSettingsResponse: r"""Call the list settings method over HTTP. @@ -396,8 +462,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource_settings.ListSettingsResponse: @@ -407,6 +475,7 @@ def __call__( http_options = ( _BaseResourceSettingsServiceRestTransport._BaseListSettings._get_http_options() ) + request, metadata = self._interceptor.pre_list_settings(request, metadata) transcoded_request = _BaseResourceSettingsServiceRestTransport._BaseListSettings._get_transcoded_request( http_options, request @@ -417,6 +486,33 @@ def __call__( 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.resourcesettings_v1.ResourceSettingsServiceClient.ListSettings", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "ListSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourceSettingsServiceRestTransport._ListSettings._get_response( self._host, @@ -437,7 +533,31 @@ def __call__( pb_resp = resource_settings.ListSettingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource_settings.ListSettingsResponse.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.resourcesettings_v1.ResourceSettingsServiceClient.list_settings", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "ListSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSetting( @@ -476,7 +596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource_settings.Setting: r"""Call the update setting method over HTTP. @@ -486,8 +606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be 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: ~.resource_settings.Setting: @@ -497,6 +619,7 @@ def __call__( http_options = ( _BaseResourceSettingsServiceRestTransport._BaseUpdateSetting._get_http_options() ) + request, metadata = self._interceptor.pre_update_setting(request, metadata) transcoded_request = _BaseResourceSettingsServiceRestTransport._BaseUpdateSetting._get_transcoded_request( http_options, request @@ -511,6 +634,33 @@ def __call__( 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.resourcesettings_v1.ResourceSettingsServiceClient.UpdateSetting", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "UpdateSetting", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ResourceSettingsServiceRestTransport._UpdateSetting._get_response( @@ -534,7 +684,29 @@ def __call__( pb_resp = resource_settings.Setting.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_setting(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource_settings.Setting.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.resourcesettings_v1.ResourceSettingsServiceClient.update_setting", + extra={ + "serviceName": "google.cloud.resourcesettings.v1.ResourceSettingsService", + "rpcName": "UpdateSetting", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-resource-settings/samples/generated_samples/snippet_metadata_google.cloud.resourcesettings.v1.json b/packages/google-cloud-resource-settings/samples/generated_samples/snippet_metadata_google.cloud.resourcesettings.v1.json index 58660108368f..61a2b1d93fba 100644 --- a/packages/google-cloud-resource-settings/samples/generated_samples/snippet_metadata_google.cloud.resourcesettings.v1.json +++ b/packages/google-cloud-resource-settings/samples/generated_samples/snippet_metadata_google.cloud.resourcesettings.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-resource-settings", - "version": "1.10.1" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.types.Setting", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.types.Setting", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.services.resource_settings_service.pagers.ListSettingsAsyncPager", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.services.resource_settings_service.pagers.ListSettingsPager", @@ -365,7 +365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.types.Setting", @@ -441,7 +441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.resourcesettings_v1.types.Setting", diff --git a/packages/google-cloud-resource-settings/tests/unit/gapic/resourcesettings_v1/test_resource_settings_service.py b/packages/google-cloud-resource-settings/tests/unit/gapic/resourcesettings_v1/test_resource_settings_service.py index 000034ea7c75..3b9ad3ebf0e9 100644 --- a/packages/google-cloud-resource-settings/tests/unit/gapic/resourcesettings_v1/test_resource_settings_service.py +++ b/packages/google-cloud-resource-settings/tests/unit/gapic/resourcesettings_v1/test_resource_settings_service.py @@ -2321,6 +2321,7 @@ def test_list_settings_rest_required_fields( response_value._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_settings(request) @@ -2375,6 +2376,7 @@ def test_list_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_settings(**mock_args) @@ -2569,6 +2571,7 @@ def test_get_setting_rest_required_fields( response_value._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_setting(request) @@ -2614,6 +2617,7 @@ def test_get_setting_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._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_setting(**mock_args) @@ -2739,6 +2743,7 @@ def test_update_setting_rest_required_fields( response_value._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_setting(request) @@ -3050,6 +3055,7 @@ def test_list_settings_rest_bad_request( 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_settings(request) @@ -3085,6 +3091,7 @@ def test_list_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_settings(request) # Establish that the response is the type that we expect. @@ -3125,6 +3132,7 @@ def test_list_settings_rest_interceptors(null_interceptor): 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 = resource_settings.ListSettingsResponse.to_json( resource_settings.ListSettingsResponse() ) @@ -3169,6 +3177,7 @@ def test_get_setting_rest_bad_request(request_type=resource_settings.GetSettingR 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_setting(request) @@ -3205,6 +3214,7 @@ def test_get_setting_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.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_setting(request) # Establish that the response is the type that we expect. @@ -3246,6 +3256,7 @@ def test_get_setting_rest_interceptors(null_interceptor): 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 = resource_settings.Setting.to_json(resource_settings.Setting()) req.return_value.content = return_value @@ -3290,6 +3301,7 @@ def test_update_setting_rest_bad_request( 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_setting(request) @@ -3411,6 +3423,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.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_setting(request) # Establish that the response is the type that we expect. @@ -3452,6 +3465,7 @@ def test_update_setting_rest_interceptors(null_interceptor): 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 = resource_settings.Setting.to_json(resource_settings.Setting()) req.return_value.content = return_value